{"id":15921855,"url":"https://github.com/devforfu/gocoins","last_synced_at":"2025-06-10T09:35:37.048Z","repository":{"id":75401445,"uuid":"172934428","full_name":"devforfu/gocoins","owner":"devforfu","description":"A dummy transactions API ","archived":false,"fork":false,"pushed_at":"2019-03-03T09:15:37.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T12:23:52.339Z","etag":null,"topics":["docker","docker-compose","go","postgresql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devforfu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-27T14:52:03.000Z","updated_at":"2019-03-19T10:52:25.000Z","dependencies_parsed_at":"2023-06-06T09:31:05.035Z","dependency_job_id":null,"html_url":"https://github.com/devforfu/gocoins","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devforfu%2Fgocoins","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devforfu%2Fgocoins/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devforfu%2Fgocoins/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devforfu%2Fgocoins/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devforfu","download_url":"https://codeload.github.com/devforfu/gocoins/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devforfu%2Fgocoins/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259048809,"owners_count":22797803,"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":["docker","docker-compose","go","postgresql"],"created_at":"2024-10-06T20:02:32.367Z","updated_at":"2025-06-10T09:35:37.019Z","avatar_url":"https://github.com/devforfu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Coding Challenge\n\nA simple generic payment service implementation with a plain Go  and a couple of additional dependencies\nto deal with the database. The project uses Docker Compose to manage containers and deploy API. \n\n\n## Dependencies\n\n1. `go get github.com/lib/pq` - PostgreSQL driver written in Go. \n2. `go get github.com/jmoiron/sqlx` - A set of extensions for the standard `sql` package to make interactions \nwith the database more convenient.\n\n\n## Deployment\n\nThe `docker-compose.yml` file defines two containers:\n1. `api`- a container with the REST API application\n2. `db` - a container with the PostgreSQL database  \n\nTo deploy the app and make it ready to accept requests, it should be enough to install the Docker and run the\nfollowing commands:\n```\n$ docker-compose build\n$ docker-compose up\n``` \n\nThe database contains two tables only, `account` and `payment`. The amount of money on the account is stored\nas an integer number of \"cents\" to deal with possible rounding errors that can occur in case of floating-point numbers.\n\nNote that having a database withing a container is probably not a strict requirement in production setting. The\ndatabase can be (and probably should be) deployed on a dedicated high-performance host. Also, we use a single\n`docker-compose.yml` file while in general we should create separate configuration files for \n`test`, `stage`, `prod`, etc.\n\n## Endpoints\n\nAs soon as the containers are up, we can start making HTTP requests. \nAll examples use a handy [`httpie`](https://httpie.org) utility.\n\n### `/status`\n\nA testing endpoint to ping the API and check if the server is up.\n```\n$ http http://localhost:8080/status | jq .\n{\n  \"success\": true\n}\n```\n\n### `/accounts`\nRetrieves list of available accounts from the database.\n```\n$ http http://localhost:8080/accounts | jq .\n{\n  \"accounts\": [\n    {\n      \"name\": \"first\",\n      \"currency\": \"USD\",\n      \"amount\": \"10.00\"\n    },\n    {\n      \"name\": \"second\",\n      \"currency\": \"USD\",\n      \"amount\": \"0.00\"\n    },\n    {\n      \"name\": \"third\",\n      \"currency\": \"EUR\",\n      \"amount\": \"0.10\"\n    }\n  ]\n}\n``` \n\n\n### `/transfer`\n\nMoves funds from one account to the another, but only if they have the same currency, and there is a sufficient\namount of funds.\n```\nhttp http://localhost:8080/transfer fromId=first toId=second amount=100 | jq .\n{\n  \"payment\": {\n    \"id\": 0,\n    \"from\": \"first\",\n    \"to\": \"second\",\n    \"time_utc\": \"2019-03-03T08:30:53.039799678Z\",\n    \"amount\": 100,\n    \"currency\": \"USD\"\n  }\n}\n```\n\n### `/payments`\n\nReturns a list of transactions for the specific account.\n\n```\n$ http http://localhost:8080/payments accountId=first | jq .\n{\n  \"account\": \"first\",\n  \"payments\": {\n    \"received\": null,\n    \"sent\": [\n      {\n        \"account\": \"second\",\n        \"amount\": 1,\n        \"time\": \"2019-03-03T08:30:53.0398Z\"\n      }\n    ]\n  }\n}\n```\n\n## Tests\n\nThe endpoint tests are stored in the file `api/src/server/server_test.go`. The tests use mockery to replace\nPostgreSQL database queries with in-memory dataset. The tests don't provide the full coverage of the codebase \nbut verify that endpoints work as expected with valid and invalid parameters.\n\nTo run tests, use the code: \n```\n$ cd api \n$ go test -v ./src/server \n``` ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevforfu%2Fgocoins","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevforfu%2Fgocoins","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevforfu%2Fgocoins/lists"}