go-sales-api
is an API for ticket sales, where partners provide information and we sell their tickets. The application manages events, seats, and tickets.
- Go 1.16+
- Docker
- Docker Compose
- MySQL
-
Clone the repository:
git clone https://github.com/salmomascarenhas/go-sales-api.git cd go-sales-api
-
Configure the environment:
- Edit
docker-compose.yaml
as needed. - Check the database settings in
mysql-init/init.sql
.
- Edit
-
Start the Docker containers:
docker-compose up -d
You can use the Makefile to simplify running the application:
-
Initialize the database:
make init
-
Generate Swagger files:
make swag
-
Compile the code:
make build
-
Run the server:
make run
-
cmd/: Contains the main files to start the application.
- events/main.go: Application entry point.
-
docs/: Documentation and Swagger files.
-
internal/events/: Application code, including business logic and data handling.
- domain/: Contains domain definitions like
Event
,Spot
, andTicket
.- event.go: Structure and methods for events.
- spot.go: Structure and methods for seats.
- ticket.go: Structure and methods for tickets.
- infra/: Infrastructure, including
http
handlers and repositories.- http/: HTTP handlers for application routes.
- repository/: Repository implementations.
- service/: Auxiliary services and partner integration.
- usecase/: Application use cases.
- buy_tickets.go: Use case for ticket purchase.
- create_event.go: Use case for event creation.
- create_spots.go: Use case for seat creation.
- get_event.go: Use case for retrieving event details.
- list_events.go: Use case for listing events.
- list_spots.go: Use case for listing seats.
- domain/: Contains domain definitions like
-
mysql-init/: MySQL database initialization scripts.
- init.sql: SQL script for database initialization.
-
Makefile: File for automating common development tasks.
- GET /events: Lists all events.
- POST /events: Creates a new event.
- GET /events/{eventID}: Details of a specific event.
- GET /events/{eventID}/spots: Lists all seats for an event.
- POST /events/{eventID}/spots: Creates new seats for an event.
- POST /checkout: Purchases tickets for a specific event.
- Ensure all dependencies are installed before running the application.
- Refer to the official Go documentation for development environment queries.
For more details, you can visit the repository on GitHub.