{"id":19481169,"url":"https://github.com/nvzard/casino-royale","last_synced_at":"2025-10-29T11:45:03.468Z","repository":{"id":38386041,"uuid":"489605672","full_name":"nvzard/Casino-Royale","owner":"nvzard","description":"A production ready Go REST API with prometheus and grafana dashboards.","archived":false,"fork":false,"pushed_at":"2022-06-13T18:36:59.000Z","size":97,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-19T20:51:31.503Z","etag":null,"topics":["docker","gin-gonic","golang","grafana","prometheus","rest-api","zap"],"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/nvzard.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-05-07T07:42:45.000Z","updated_at":"2024-04-16T15:50:56.000Z","dependencies_parsed_at":"2022-08-18T19:10:58.549Z","dependency_job_id":null,"html_url":"https://github.com/nvzard/Casino-Royale","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/nvzard%2FCasino-Royale","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvzard%2FCasino-Royale/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvzard%2FCasino-Royale/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nvzard%2FCasino-Royale/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nvzard","download_url":"https://codeload.github.com/nvzard/Casino-Royale/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224008023,"owners_count":17240292,"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","gin-gonic","golang","grafana","prometheus","rest-api","zap"],"created_at":"2024-11-10T20:01:31.582Z","updated_at":"2025-10-29T11:44:58.446Z","avatar_url":"https://github.com/nvzard.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maintainability](https://api.codeclimate.com/v1/badges/f2b7b99e9c1d1c93ca47/maintainability)](https://codeclimate.com/github/nvzard/Casino-Royale/maintainability)\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=\"668\" alt=\"Screenshot 2022-05-17 at 1 08 21 PM\" src=\"https://user-images.githubusercontent.com/19310512/168756153-2892a485-d826-4e5d-bfc6-9e97c8110f31.png\"\u003e\n\u003c/p\u003e\n\n\u003c!-- An API to simulate a deck of cards --\u003e\n## Documentation\n\n- [Summary](#summary)\n- [Development Setup](#development)\n- [API Documentation](#api-documentation)\n- [Future Improvements](#api-documentation)\n- [Side Note](#side-note)\n\n---\n## Summary\n\nThis project exposes an API to simulate deck of cards which can be used for card games.\n\n## Tech Stack\n\nWritten in Go (Golang 1.18) using [gin](https://github.com/gin-gonic/gin) as web framework, [Postgres](https://github.com/postgres/postgres) as database, [zap](https://github.com/uber-go/zap) for logging, [prometheus](https://github.com/prometheus/prometheus) and [grafana](https://github.com/grafana/grafana) for monitoring.\n\n- Use `make build` to build the web server and `make start` to start the server. Server runs on `localhost:8080`.\n- Use `make test` runs the tests in a seperate docker container for isolation.\n- [Air](https://github.com/cosmtrek/air) and docker-sync are used for live reloading during development.\n- Grafana dashboard is avaialble on `localhost:3004`\n- Prometheus UI is accessible on `localhost:9090`\n\n## Development\n\n### Requirements\n\n```\ngit\ndocker\ndocker-compose\ndocker-sync (0.5.14) [Use `gem install docker-sync -v 0.5.14` for mac]\n```\n\n### Getting Started with Development\n\n1. Clone repository\n\n```\ngit clone https://github.com/nvzard/Casino-Royale.git\n```\n\n2. Change directory to the cloned repository\n\n```\ncd Casino-Royale\n```\n\n3. Build image\n\n```\nmake build\n```\n\n4. Run start command\n\n```\nmake start\n```\n\n### Run Tests\n\n```\nmake test\n```\n\n### Remove all artifacts and dependencies\n\n```\nmake clean\n```\n---\n\n## API Documentation\n\n```\nGET   /healthcheck          # ok\nPOST  /deck                 # create new deck (query parameters: shuffle, cards)\nGET   /deck/:deck_id        # open deck by id\nPOST  /deck/:deck_id/draw   # draw cards from the deck (query parameters: count)\n```\n\n### 1. Create a Deck\n\n```\nPOST /deck\n```\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `shuffle` | `bool`   | **Optional**. true or false |\n| `cards`   | `string` | **Optional**. Custom Cards Code: AS,1S,2S, etc |\n\n\n#### Example Request 1\n```\nPOST /deck\n```\n\n#### Response\n```\n{\n    \"deck_id\": \"a251071b-662f-44b6-ba11-e24863039c59\",\n    \"shuffled\": false,\n    \"remaining\": 52\n}\n```\n\n#### Example Request 2\n\n```\nPOST /deck?shuffle=true\u0026cards=AS,2S\n```\n\n#### Response\n```\n{\n    \"deck_id\": \"9bc9d90e-3056-40c7-94bc-241915cbee4d\",\n    \"shuffled\": true,\n    \"remaining\": 2\n}\n```\n\n### 2. Open a Deck\n\n```\nGET /deck/:deck_id\n```\n\n#### Example Request 1\n\n```\nGET /deck/a251071b-662f-44b6-ba11-e24863039c59\n```\n\n#### Response\n```\n{\n    \"deck_id\": \"a251071b-662f-44b6-ba11-e24863039c59\",\n    \"shuffled\": false,\n    \"remaining\": 3,\n    \"cards\": [\n        {\n            \"value\": \"ACE\",\n            \"suit\": \"SPADES\",\n            \"code\": \"AS\"\n        },\n\t    {\n            \"value\": \"KING\",\n            \"suit\": \"HEARTS\",\n            \"code\": \"KH\"\n        },\n        {\n            \"value\": \"8\",\n            \"suit\": \"CLUBS\",\n            \"code\": \"8C\"\n        }\n    ]\n}\n```\n\n### 3. Draw a Card\n\n```\nPOST /deck/:deck_id/draw\n```\n\n\n| Parameter | Type | Description |\n| :--- | :--- | :--- |\n| `count` | `string`   | **Optional**. Number of cards to draw [default=1]|\n\n\n#### Example Request 1\n\n```\nPOST /deck/a251071b-662f-44b6-ba11-e24863039c59/draw\n```\n\n#### Response\n```\n{\n    \"cards\": [\n        {\n            \"value\": \"QUEEN\",\n            \"suit\": \"HEARTS\",\n            \"code\": \"QH\"\n        }\n    ]\n}\n```\n#### Example Request 2\n\n```\nPOST /deck/:deck_id/draw?count=2\n```\n\n#### Response\n```\n{\n    \"cards\": [\n\t    {\n            \"value\": \"KING\",\n            \"suit\": \"HEARTS\",\n            \"code\": \"KH\"\n        },\n        {\n            \"value\": \"8\",\n            \"suit\": \"CLUBS\",\n            \"code\": \"8C\"\n        }\n    ]\n}\n```\n\n---\n## Future Improvements\n\nSome of the improvements that can be made but were skipped due to time constraints.\n\n- Refactor project structure to follow go guidelines. Currently it is similar to Rails/JS ecosystem.\n- Write more tests and improve code coverage.\n- Add error handling mechanism and single store for all strings.\n- Setup CI/CD pipeline for testing and deployment.\n- Add some kind of authentication mechanism. Basic Auth or JWT.\n\n---\n## Side Note\n\nPlease open an issue and let me know incase I messed something up. Some feedback would really help me up my go game.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnvzard%2Fcasino-royale","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnvzard%2Fcasino-royale","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnvzard%2Fcasino-royale/lists"}