{"id":23095224,"url":"https://github.com/pauluswi/alpine","last_synced_at":"2025-09-19T20:52:43.726Z","repository":{"id":65298814,"uuid":"446765366","full_name":"pauluswi/alpine","owner":"pauluswi","description":"Is a microservice which provides credential (pin) service. Credential are stored at hashed format with salt.","archived":false,"fork":false,"pushed_at":"2022-01-12T04:14:17.000Z","size":3572,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T19:34:02.944Z","etag":null,"topics":["cryptography","fintech","go","golang","jwt","microservice","payment","rest-api","salt"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pauluswi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-11T09:56:56.000Z","updated_at":"2022-02-17T06:21:03.000Z","dependencies_parsed_at":"2023-01-16T15:15:24.834Z","dependency_job_id":null,"html_url":"https://github.com/pauluswi/alpine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pauluswi/alpine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauluswi%2Falpine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauluswi%2Falpine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauluswi%2Falpine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauluswi%2Falpine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pauluswi","download_url":"https://codeload.github.com/pauluswi/alpine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauluswi%2Falpine/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265004071,"owners_count":23696348,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","fintech","go","golang","jwt","microservice","payment","rest-api","salt"],"created_at":"2024-12-16T22:20:05.490Z","updated_at":"2025-09-19T20:52:38.705Z","avatar_url":"https://github.com/pauluswi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Alpine\nIs a microservice which provides credential (pin) service.\nCredential are stored at hashed format with salt.\n\n![Build](https://github.com/pauluswi/alpine/actions/workflows/build.yml/badge.svg)\n[![codecov](https://codecov.io/gh/pauluswi/alpine/branch/master/graph/badge.svg)](https://codecov.io/gh/pauluswi/alpine)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n\n\n---\n\nHashed Pin = base64 encoded[sha512(pin+ salt)]\n\nExample:\n\nOrigin Pin = 123456\n\nHashed Pin = ddivu2QSb2hIk9uGpihW3v2KwkEoHeyIk7GiE96OfxeuXXIK9JazAeWmvbtQLCiZJVLz7qWZoQUN9vJ3WJHOHw==\n\n---\nA salt is added to the hashing process to force their uniqueness, increase their complexity without increasing user requirements, and to mitigate password attacks like hash tables\n\n\n## Project Layout\n\nAlpine uses the following project layout:\n \n```\n.\n├── cmd                  main applications of the project\n│   └── server           the API server application\n├── config               configuration files for different environments\n├── internal             private application and library code\n│   ├── pin              pin-related features\n│   ├── auth             authentication feature\n│   ├── config           configuration library\n│   ├── entity           entity definitions and domain logic\n│   ├── errors           error types and handling\n│   ├── healthcheck      healthcheck feature\n│   └── test             helpers for testing purpose\n├── migrations           database migrations\n├── pkg                  public library code\n│   ├── accesslog        access log middleware\n│   ├── graceful         graceful shutdown of HTTP server\n│   ├── log              structured and context-aware logger\n│   └── pagination       paginated list\n└── testdata             test data scripts\n```\n\nThe top level directories `cmd`, `internal`, `pkg` are commonly found in other popular Go projects, as explained in\n[Standard Go Project Layout](https://github.com/golang-standards/project-layout).\n\nWithin `internal` and `pkg`, packages are structured by features in order to achieve the so-called\n[screaming architecture](https://blog.cleancoder.com/uncle-bob/2011/09/30/Screaming-Architecture.html). For example, \nthe `pin` directory contains the application logic related with the payment token feature. \n\nWithin each feature package, code are organized in layers (API, service, repository), following the dependency guidelines\nas described in the [clean architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html).\n\n# Getting Started\n\n```shell\n# download the repo\ngit clone https://github.com/pauluswi/alpine.git\n\ncd alpine\n\n# start a PostgreSQL database server in a Docker container\nmake db-start\n\n# seed the database with some test data\nmake testdata\n\n# run the RESTful API server\nmake run\n```\n\nAt this time, you have a RESTful API server running at `http://127.0.0.1:8080`. \nIt provides the following endpoints:\n\n* `GET /healthcheck`: a healthcheck service provided for health checking purpose (needed when implementing a server cluster)\n* `POST /v1/login`: authenticates a user and generates a JWT\n* `POST /v1/create`: create a pin\n* `POST /v1/change`: change a pin\n* `POST /v1/validate`: validate the pin is valid or not\n* `GET /v1/get/:customer_id`:return pin information belongs to a customer\n\nTry the URL `http://localhost:8080/healthcheck` in a browser, and you should see something like `\"OK v1.0.0\"` displayed.\n\nIf you have `cURL` or some API client tools (e.g. [Postman](https://www.getpostman.com/)), you may try the following \nmore complex scenarios:\n\n```shell\n# authenticate the user via: POST /v1/login\ncurl -X POST -H \"Content-Type: application/json\" -d '{\"username\": \"demo\", \"password\": \"pass\"}' http://localhost:8080/v1/login\n# should return a JWT token like: {\"token\":\"...JWT token here...\"}\n\n# with the above JWT token, access the album resources, such as: GET /v1/xxx\n# start example\ncurl -X GET -H \"Authorization: Bearer ...JWT token here...\" http://localhost:8080/v1/xxx\n# end example \n\n```\n\n## Updating Database Schema\n\nThe starter kit uses [database migration](https://en.wikipedia.org/wiki/Schema_migration) to manage the changes of the \ndatabase schema over the whole project development phase. The following commands are commonly used with regard to database\nschema changes:\n\n```shell\n# Execute new migrations made by you or other team members.\n# Usually you should run this command each time after you pull new code from the code repo. \nmake migrate\n\n# Create a new database migration.\n# In the generated `migrations/*.up.sql` file, write the SQL statements that implement the schema changes.\n# In the `*.down.sql` file, write the SQL statements that revert the schema changes.\nmake migrate-new\n\n# Revert the last database migration.\n# This is often used when a migration has some issues and needs to be reverted.\nmake migrate-down\n\n# Clean up the database and rerun the migrations from the very beginning.\n# Note that this command will first erase all data and tables in the database, and then\n# run all migrations. \nmake migrate-reset\n```\n\n\n### Managing Configurations\n\nThe application configuration is represented in `internal/config/config.go`. When the application starts,\nit loads the configuration from a configuration file as well as environment variables. The path to the configuration \nfile is specified via the `-config` command line argument which defaults to `./config/local.yml`. Configurations\nspecified in environment variables should be named with the `APP_` prefix and in upper case. When a configuration\nis specified in both a configuration file and an environment variable, the latter takes precedence. \n\nThe `config` directory contains the configuration files named after different environments. For example,\n`config/local.yml` corresponds to the local development environment and is used when running the application \nvia `make run`.\n\nDo not keep secrets in the configuration files. Provide them via environment variables instead. For example,\nyou should provide `Config.DSN` using the `APP_DSN` environment variable. Secrets can be populated from a secret\nstorage (e.g. HashiCorp Vault) into environment variables in a bootstrap script (e.g. `cmd/server/entryscript.sh`)\n\n## Unit Testing and Its Coverage\n\nFor testability purpose, unit testings are provided.\nWe can use golang test package.\n\n```shell\n$ go test -v internal/pin/*.go -race -coverprofile=coverage.out\n\n```\n\n## Deployment\n\nThe application can be run as a docker container. You can use `make build-docker` to build the application \ninto a docker image. The docker container starts with the `cmd/server/entryscript.sh` script which reads \nthe `APP_ENV` environment variable to determine which configuration file to use. For example,\nif `APP_ENV` is `qa`, the application will be started with the `config/qa.yml` configuration file.\n\nYou can also run `make build` to build an executable binary named `server`. Then start the API server using the following\ncommand,\n\n```shell\n./server -config=./config/prod.yml\n```\n\n## Reference\n\nGo RESTful API Starter Kit (Boilerplate)\nhttps://github.com/qiangxue/go-rest-api\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauluswi%2Falpine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpauluswi%2Falpine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauluswi%2Falpine/lists"}