A ticket allocation system that allows users to purchase tickets concurrently. The system ensures that tickets are allocated correctly and that no purchase exceeds more than the available tickets.
Built with Go Fiber, GORM, and PostgreSQL
- Docker
- Docker Compose
To build and start the application, use:
docker compose up --build
This command starts both the application and PostgreSQL database.
To execute the tests, use:
docker compose --profile test up test --build --force-recreate
Access the API documentation (Swagger) at:
- config/: Manages database connection & migrations. Also loads environment variables.
- dal/: Data Access Layer for database operations.
- docs/: OpenAPI (Swagger) documentation files.
- routes/: API route definitions.
- services/: Business logic for ticket and purchase operations.
- tests/: Unit tests with mocked database interactions.
- types/: Custom types for request/response validation.
- utils/: Helper functions for error handling and validation.
- Dockerfile: Docker configuration for building the application.
- docker-compose.yml: Docker Compose configuration for development and testing.
- main.go: Application entry point.
- Create Ticket: POST /tickets - Add a new ticket.
- Get Ticket: GET /tickets/{id} - Retrieve ticket details.
- Create Purchase: POST /tickets/{id}/purchases - Purchase tickets.