A backend system to manage book loans.
- Create, retrieve, and list users
- Retrieve books with filters
- Retrieve book details and book item details
- Lend and return book items
- Notify users via email when a loan is about to expire
- Go - Backend
- PostgreSQL - Database
- Docker - Containerization
- RabbitMQ - Message queuing
- Build API
- Build loan expiring job
- Build email handler
- Add database migrations
- Dockerfiles
- Docker Compose
- Swagger Docs
- Rename book_copies to book_copies (db, code, db diagram and NOTES.md)
- Integrate with Prometheus for metrics?
-
Create a
.env
file based on.env.example
. -
Build and start the infrastructure:
docker compose --env-file .env build --no-cache && docker compose --env-file .env up -d --force-recreate
Once the API is running, you can access the Swagger docs at:
http://localhost:8080/swagger/index.html
Alternatively, you can open the HTML documentation manually from the docs/
folder in a browser.
curl -X POST http://localhost:8080/users \
-H "Content-Type: application/json" \
-d '{
"name": "John",
"email": "john@example.com"
}' -v
curl "http://localhost:8080/users"
curl http://localhost:8080/users/{id}
curl -X POST http://localhost:8080/books \
-H "Content-Type: application/json" \
-d '{
"title": "Book Title",
"description": "A detailed description",
"isbn": "123456789",
"author": "Author Name",
"numberOfPages": 250
}' -v
curl "http://localhost:8080/books?title=example"
curl http://localhost:8080/books/{book_id}
curl -X POST http://localhost:8080/books/{book_id}/items \
-H "Content-Type: application/json" \
-d '{
"bookId": "book_uuid",
"status": "available",
"condition": "good",
"location": "Section B"
}' -v
curl http://localhost:8080/books/{book_id}/items
curl -X POST http://localhost:8080/loans \
-H "Content-Type: application/json" \
-d '{
"userId": "user_uuid",
"status": "active",
"bookCopyId": "book_item_uuid",
"loanDate": "2025-01-26T15:30:00Z",
"expiringDate": "2025-01-27T15:30:00Z"
}' -v
curl "http://localhost:8080/loans?userId={user_id}"