A RESTful API built with Go (Gin) for managing books, featuring Swagger documentation, Kafka event streaming, and Redis caching. This project was originally requested as part of a job application coding task, which I've kept as a showcase of my Go development skills and understanding of modern backend technologies.
For detailed project requirements and specifications that were provided as part of the original task, see REQUIREMENTS.md
- Go (Gin Framework)
- PostgreSQL for persistent storage
- Redis for caching
- Kafka for event streaming
- Swagger for API documentation
- Docker & Docker Compose for containerization
- GORM as ORM
- Air for live reload during development
- RESTful API endpoints for CRUD operations on books
- Event streaming via Kafka for book events (create/update/delete)
- Redis caching to optimize read performance
- Database persistence with PostgreSQL
- API documentation with Swagger UI
- Docker support for both development and production
- Request ID tracking and logging
- CORS support
- Error handling and validation
- Resource limits for production containers
- Docker and Docker Compose installed
- Go 1.22 or later (for local development)
- Make (optional, but recommended)
- Clone the repository:
git clone https://github.com/username/books-api-go
cd books-api-go
- Start the development environment:
make docker-dev
This will start:
- API server on port 8080
- PostgreSQL on port 5432
- Redis on port 6379
- Kafka broker on port 9092
- Set required environment variables:
export DB_PASSWORD=your_db_password
export REDIS_PASSWORD=your_redis_password
- Start the production environment:
make docker-prod
GET /api/v1/books
- List all books (paginated)GET /api/v1/books/{id}
- Get a specific bookPOST /api/v1/books
- Create a new bookPUT /api/v1/books/{id}
- Update a bookDELETE /api/v1/books/{id}
- Delete a book
Swagger documentation is available at /swagger
make build
- Build the applicationmake run
- Run the built binarymake dev
- Run with live reload using Airmake test
- Run testsmake swagger
- Generate Swagger documentationmake docker-dev
- Start development environmentmake docker-prod
- Start production environmentmake docker-down
- Stop all containers
This project is licensed under the MIT License.