{"id":27247296,"url":"https://github.com/matrix278/entain-test-task","last_synced_at":"2025-04-10T22:49:24.994Z","repository":{"id":102681387,"uuid":"605673356","full_name":"Matrix278/entain-test-task","owner":"Matrix278","description":"Entain test task","archived":false,"fork":false,"pushed_at":"2024-06-17T10:59:25.000Z","size":6422,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T22:49:20.789Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Matrix278.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":"2023-02-23T16:53:19.000Z","updated_at":"2024-06-17T10:59:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"64a2f54b-0d16-4776-821a-e31518de02c1","html_url":"https://github.com/Matrix278/entain-test-task","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matrix278%2Fentain-test-task","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matrix278%2Fentain-test-task/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matrix278%2Fentain-test-task/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matrix278%2Fentain-test-task/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Matrix278","download_url":"https://codeload.github.com/Matrix278/entain-test-task/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248312179,"owners_count":21082637,"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":[],"created_at":"2025-04-10T22:49:24.482Z","updated_at":"2025-04-10T22:49:24.968Z","avatar_url":"https://github.com/Matrix278.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Entain test task\n\n### Tools and technologies used:\n\n1. Go\n2. PostgreSQL\n3. Docker\n4. Makefile\n5. Postman\n\nAll database tables are in `migrations` folder. To run them, use `make` command.\n\n1. `make migrate-up` - to run up migrations\n2. `make migrate-down` - to run down migrations\n3. `make migrate-force` - to force run migrations if you have some errors like `error: Dirty database version -1. Fix and force version.`\n\n### Tables:\n\n1. `users` - contains users data\n2. `transaction` - contains transactions data\n\n### Endpoints to test:\n\n1. `GET /users` - to get all users\n2. `GET /users/{user_id}` - to get user by id, check his balance\n3. `GET /transactions/{user_id}` - to get all transactions by user id (check if user has any transactions)\n4. `POST /process-record/{user_id}` - to process record by user id\n\nProcess record request body example:\n\n```\n{\n    \"amount\": 10,\n    \"transaction_id\": \"64338a05-81e5-426b-b01e-927e447c9e33\",\n    \"state\": \"win\"\n}\n```\n\nTransaction id is unique, so you can't process the same transaction twice, provide UUID v4 format.\nState can be `win` or `lose`.\nAmount is a number should be positive but to have a negative balance you should provide a `lose` state.\n\n### Required header for all endpoints:\n\n1. `Source-Type: game` - available values: `game`, `server`, `payment`\n\nPostman collection is in `postman` folder to test endpoints.\n\n## To run the app locally:\n\n1. Create `.env` file in root folder and add all required variables from `.env.example` file\n2. To run migrations you should have migrate tool installed. You can install it with `brew install golang-migrate` (https://github.com/golang-migrate/migrate/tree/master/cmd/migrate)\n3. To run any `make` command you should have `make` tool installed. You can install it with `sudo apt install make` command (https://linuxhint.com/install-make-ubuntu/)\n4. Run `make migrate-up` command to run migrations and create all tables with test user (user_id: `63e83104-b9a7-4fec-929e-9d08cae3f9b9`)\n5. Run `make run` command to run application\n6. Take a look at `postman` folder to take collection for testing all endpoints\n\nTest user with id `63e83104-b9a7-4fec-929e-9d08cae3f9b9` will be created automatically when you run migrations.\nThis user has 50 amount of his balance for testing.\n\n## To run application in docker container:\n\n1. Create `.env` file in root folder and add all required variables from `.env.example` file\n2. To run docker container you should have `docker` and `docker-compose` tools installed (Tested on `Docker version 26.1.3, build b72abbb` and `Docker Compose version v2.27.1`)\n3. `docker-compose up` - to run application in docker container\n4. `docker-compose down` - to stop application in docker container\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrix278%2Fentain-test-task","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatrix278%2Fentain-test-task","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrix278%2Fentain-test-task/lists"}