
Booking Platform API
Overview
Booking Platform API is a NestJS and TypeScript REST API for managing a service catalog and customer bookings. Customers can create bookings without an account, while authenticated users manage services and booking records through protected endpoints.
The API stores users, services, and bookings in PostgreSQL through Prisma. It validates booking dates, only accepts bookings for active services, and prevents duplicate service slots with a database-level unique constraint. Booking management includes pagination, customer search, status filtering, cancellation, and guarded status transitions.
The project also includes JWT authentication, request validation, consistent HTTP errors, Swagger OpenAPI documentation, Docker Compose for a local PostgreSQL database, and focused Jest tests.
Architecture
Challenges & Solutions
Two customers could request the same service slot at nearly the same time.
The API validates the booking rules and enforces a composite unique constraint on service, date, and time in PostgreSQL.
Customers need a low-friction booking flow, while service and booking records must stay protected.
Customer booking creation is public, while service management and booking administration require JWT authentication.
Removing a service should not erase the context of existing bookings.
Services are deactivated with a soft delete, preserving their records while preventing new bookings.
Features
- JWT registration and login for users who manage services and bookings
- Create, list, retrieve, update, and soft-delete services
- Public customer booking creation without requiring an account
- Booking rules reject past dates and prevent bookings for inactive services
- Database-level uniqueness prevents duplicate service, date, and time slots
- Authenticated booking management with status updates and cancellation
- Paginated booking search by customer name, email, or phone, with status filters
- Global request validation, consistent error responses, and Swagger API documentation
- PostgreSQL persistence through Prisma, with migrations, Docker Compose, and optional sample data