Bingo
Deploy
docker-compose up --build
Test cases
docker-compose -f docker-compose.test.yml up --build --abort-on-container-exit
Code structure
This project uses go-kit framework for microservices and MongoDB as data store.
- Package
config
and config.yaml
, holds data store credentials.
- Package
bingo
,
service.go
holds all the buisiness logic.
endpoint.go
holds request and response schema for each endpoint.
transport.go
holds details how each request is decoded and corresponding response is encoded.
- Package
game
holds domain model and repository interface for games.
- Package
ticket
holds domain model and repository interface for tickets.
- Package
mongo
holds implementation of game
and ticket
repository with mongo store.
Models
Game
has,
- Unique string ID.
- List of IDs of tickets generated.
- List of Numbers drawn
Ticket
has,
- Unique string ID.
- Username for which this ticket was generated.
- Cell values represented as semicolon(;) seperated integer values.
-1
signifies empty cell.
APIs
For manual testing: Postman collection
1. POST /api/game/create
Success HTTP 200
{
"game_id": "5efbbb5c0880edb67dd9fd33"
}
2. POST /api/game/{game_id}/ticket/{username}/generate
Success HTTP 200
{
"ticket_id": "5efbbf88abaf8fdbd4aae78d"
}
3. GET /api/game/{game_id}/number/random
Success HTTP 200
{
"number": 79
}
4. GET /api/game/{game_id}/numbers
Success HTTP 200
{
"numbers": [
36,
79
]
}
5. GET /api/game/{game_id}/stats
Success HTTP 200
{
"numbers_drawn": 2,
"tickets_generated": 1
}
6. GET /ticket/{ticket_id}
Success HTTP 200