RestoReserve API is a Spring Boot REST API for managing restaurant tables, reservations, and user access with JWT authentication.
The project started as an academic project and has since been refined with a focus on backend fundamentals: layered architecture, validation, security, persistence, testing, and business rules.
- Java 17
- Spring Boot 3.5.14
- Spring Web
- Spring Security
- Spring Data JPA
- H2 Database (default profile)
- PostgreSQL (
postgresprofile, optional) - JJWT
- Spring Validation
- Springdoc OpenAPI
- Lombok
- JUnit 5 + Mockito
- Spring Security Test
- Maven
- Docker Compose
- User registration and login with JWT-based authentication
- BCrypt password hashing
- Stateless authentication with Spring Security
- Role-based access control for
ADMINandUSER - Restaurant table management with filtering by status, location, and capacity
- Reservation management with business validations
- Reservation ownership and access control
- Penalization policy for late cancellations
- Automatic user banning after exceeding the penalization threshold
- Admin endpoint to reset penalization points and reactivate users
- Global exception handling
- Swagger / OpenAPI documentation
The application follows a layered architecture:
Controller
↓
Service
↓
Repository
↓
Database
Controllers handle HTTP requests and validation, services contain business rules, and repositories provide persistence through Spring Data JPA.
Security is handled separately through Spring Security and a custom JWT authentication filter.
The reservation service implements several domain rules:
- Reservations must be created for a future date and time.
- A reservation cannot exceed the maximum capacity of the selected table.
- A table cannot have overlapping confirmed reservations.
- Each confirmed reservation occupies a two-hour time window.
- Users with status
BANNEDcannot create new reservations. - Cancelling a reservation less than two hours before its scheduled time adds 2 penalty points.
- Users exceeding 6 penalty points are moved to
BANNED. - Administrators can reset a user's penalization and restore
ACTIVEstatus.
POST /api/v1/auth/register— register a new userPOST /api/v1/auth/login— authenticate and receive a JWT token
POST /api/v1/reservations— create a reservation for the authenticated user (USER,ADMIN)GET /api/v1/reservations— list reservations accessible to the current user (USER,ADMIN)GET /api/v1/reservations/{id}— get a reservation by ID (USER,ADMIN)GET /api/v1/reservations/status/{status}— filter reservations by status (USER,ADMIN)DELETE /api/v1/reservations/{id}— cancel a reservation (USER,ADMIN)
POST /api/v1/tables— create a table (ADMIN)GET /api/v1/tables— list all tables (ADMIN)GET /api/v1/tables/{id}— get a table by ID (ADMIN)PUT /api/v1/tables/{id}— update a table (ADMIN)DELETE /api/v1/tables/{id}— delete a table (ADMIN)GET /api/v1/tables/capacity/{pax}— filter by minimum capacity (ADMIN)GET /api/v1/tables/status/{status}— filter by status (ADMIN)GET /api/v1/tables/location/{location}— filter by location (ADMIN)GET /api/v1/tables/location-status?location=...&status=...— combined filter (ADMIN)GET /api/v1/tables/available?status=...&maxPax=...— filter by status and capacity (ADMIN)
PATCH /api/v1/users/{id}/reset-penalization— reset penalization points and restoreACTIVEstatus (ADMIN)
The API uses Bean Validation on request DTOs and a global exception handler to provide consistent error responses for:
- Validation errors
- Missing resources
- Business rule violations
- Banned users
- Other application-specific exceptions
Custom exceptions include:
ResourceNotFoundExceptionBusinessLogicExceptionBannedUserExceptionNotVipUserException
- Java 17
- Maven Wrapper included in the project
- Docker (only for the optional PostgreSQL profile)
The application signs its tokens with a key read from the JWT_SECRET environment
variable. Neither the key nor the database credentials are stored in the repository,
so the application will not start until you provide them.
Create a local .env file (already ignored by git) with freshly generated values:
printf 'JWT_SECRET=%s\nPOSTGRES_DB=restoreserve\nPOSTGRES_USER=restoreserve\nPOSTGRES_PASSWORD=%s\n' \
"$(openssl rand -base64 64)" "$(openssl rand -hex 16)" > .envThe command overwrites any existing .env. The required variables are documented in
.env.example. Never commit .env.
Linux / macOS:
./mvnw spring-boot:runWindows:
mvnw.cmd spring-boot:runStart the database and wait until it reports healthy:
docker compose up -d
docker compose psThen start the application:
./mvnw spring-boot:run -Dspring-boot.run.profiles=postgresStop the database when you are done:
docker compose downData lives in a named volume and survives container restarts. Use docker compose down -v
only if you want to delete it.
Once the application is running, open:
http://localhost:8080/swagger-ui/index.html
The OpenAPI documentation includes Bearer JWT authentication, allowing protected endpoints to be tested directly from Swagger UI.
- Register a user with
POST /api/v1/auth/registeror use the seeded users for local testing. - Login with
POST /api/v1/auth/login. - Copy the returned JWT token.
- In Swagger UI, click
Authorize. - Enter
Bearer <your-token>. - Call the protected endpoints.
The project includes seeded users for local development.
Username: armymoves
Password: 1234
Role: ROLE_USER
Username: admin
Password: Admin1234
Role: ROLE_ADMIN
These credentials are intended for local development and demonstration only.
src/main/java/com/pachedev/restoreserve
├── config
├── controller
├── dto
├── exception
├── model
│ ├── entity
│ └── enums
├── repository
├── security
└── service
The project uses:
- JUnit 5
- Mockito
- Spring Boot Test
- Spring Security Test
- MockMvc
Current tests cover three layers: the application context, reservation-service business rules (validation, banned users, reservation ownership, cancellation, penalization, and automatic banning), and the HTTP layer through MockMvc with real JWTs (login and registration responses, failed-login status codes, role-based access control, per-user data isolation, and validation errors).
Run the test suite with:
./mvnw test- The default profile runs on an in-memory H2 database; the optional
postgresprofile runs on PostgreSQL through Docker Compose. - Demo data is seeded on startup by
config/DataSeederand is skipped when users already exist, so restarting the application does not duplicate it. - JWT authentication is implemented with JJWT and Spring Security.
- The project is currently focused on local execution and portfolio presentation.
- Containerize the API with a Dockerfile and an
appservice in compose. - Replace
ddl-auto=updatewith Flyway migrations. - Add production-oriented configuration and observability.
This project goes beyond a basic CRUD application.
It demonstrates practical backend concepts including:
- REST API design
- Authentication and authorization
- JWT security
- Role-based access control
- DTO-based request and response handling
- Bean Validation
- JPA persistence
- Business-rule implementation
- Centralized exception handling
- Unit and integration testing
- API documentation with OpenAPI
It provides a foundation for demonstrating junior backend development skills with Java and Spring Boot while continuing to evolve toward a more production-oriented architecture.
Daniel Pacheco
GitHub: cloudxdam