REST API for a booking/reservation system, built as the integrator project for the Ada School backend course. Each course module adds a new layer on top of this base project.
Live deployment (Render): https://booking-system-api-tn5k.onrender.com — auto-deploys on every push to main.
Free-tier instance: it spins down after inactivity, so the first request after a quiet period can take ~50s to wake up.
- Java 17
- Spring Boot 4.1.0
- Spring Web (MVC)
- Spring Security
- JJWT (JSON Web Tokens)
- Maven
- JDK 17+
- Maven 3.9+ (or use the included
mvnw/mvnw.cmdwrapper)
Clone the repository and run the application:
git clone https://github.com/AnderssonProgramming/booking-system-api.git
cd booking-system-api
# using the Maven wrapper
./mvnw spring-boot:run
# or with a local Maven install
mvn spring-boot:runThe application starts on http://localhost:8080.
The API is secured with Spring Security and JWT. All endpoints require a valid
Authorization: Bearer <token> header except /health and /api/auth/**.
- Passwords are hashed with BCrypt before being stored.
- Tokens are signed with HS256 and expire after
jwt.expirationmilliseconds (default 24h). - The signing key comes from the
JWT_SECRETenv var (a Base64 string, 32+ bytes). If it's not set, a random key is generated at startup — fine for local development, but it means tokens won't survive an application restart, and every instance in a multi-instance deployment needs the sameJWT_SECRET.
| Method | Endpoint | Auth required | Description |
|---|---|---|---|
| GET | /health |
No | Health check — confirms the API is up |
| POST | /api/auth/register |
No | Create a user and return a JWT |
| POST | /api/auth/login |
No | Authenticate and return a JWT |
| GET | /api/users |
Yes | List all users |
| GET | /api/users/{id} |
Yes | Get a user by id |
| POST | /api/users |
Yes | Create a user |
| PUT | /api/users/{id} |
Yes | Update a user |
| DELETE | /api/users/{id} |
Yes | Delete a user |
Health check:
curl http://localhost:8080/healthResponse:
<h1>The API is working ok!</h1>Register and get a token:
curl -X POST http://localhost:8080/api/auth/register \
-H "Content-Type: application/json" \
-d '{"name":"Andersson Sanchez","email":"andersson@example.com","phone":"3001234567","password":"Secret123"}'Response:
{"token":"eyJhbGciOiJIUzUxMiJ9...","email":"andersson@example.com","type":"Bearer"}Log in with existing credentials:
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"andersson@example.com","password":"Secret123"}'User CRUD example (requires the Authorization header):
curl http://localhost:8080/api/users \
-H "Authorization: Bearer <token>"Response:
[{"id":1,"name":"Andersson Sanchez","email":"andersson@example.com","phone":"3001234567"}]Note: users are stored in-memory in a
HashMap, so the data resets every time the application restarts.
src/main/java/com/andersson/bookingsystemapi/
├── BookingSystemApiApplication.java # Spring Boot entry point
├── controller/
│ ├── health/
│ │ └── HealthController.java # GET /health
│ ├── user/
│ │ └── UserController.java # /api/users CRUD endpoints
│ └── auth/
│ ├── AuthenticationController.java # /api/auth/register, /api/auth/login
│ └── dto/
│ ├── RegisterRequest.java
│ ├── LoginRequest.java
│ └── AuthenticationResponse.java
├── security/
│ ├── SecurityConfiguration.java # HttpSecurity rules, filter chain
│ ├── PasswordEncoderConfig.java # BCryptPasswordEncoder bean
│ ├── JwtService.java # Token generation/validation (JJWT)
│ ├── JwtAuthenticationFilter.java # Reads the Bearer token on every request
│ └── CustomUserDetailsService.java # Loads a User as Spring Security UserDetails
├── service/
│ ├── UserService.java # User service interface
│ └── impl/
│ └── UserServiceImpl.java # HashMap-based implementation (@Service)
├── model/
│ └── User.java # User model
└── exception/
└── UserNotFoundException.java # 404 when a user id doesn't exist
./mvnw clean packageThe packaged jar is generated at target/booking-system-api-0.0.1-SNAPSHOT.jar and can be run with:
java -jar target/booking-system-api-0.0.1-SNAPSHOT.jarUnit tests for the service layer use JUnit 5 and Mockito:
./mvnw testUserServiceImplTest— the in-memory CRUD service, withPasswordEncodermocked.JwtServiceTest— token generation/validation, expiry, and the random-key fallback.CustomUserDetailsServiceTest— mapping aUserto Spring Security'sUserDetails.
JaCoCo runs on every test and writes an HTML report to target/site/jacoco/index.html; each of the
services above is covered at 100% (lines) / 83%+ (branches), above the 70% target.
The API deploys as a Docker container. render.yaml is a Render Blueprint that describes the
service, so Render can pick up the whole configuration in one step:
- Push this repo to GitHub (already done if you're reading this from there).
- On Render, go to New + → Blueprint, and connect this GitHub repository. Authorize Render's GitHub App if this is the first time.
- Render reads
render.yamland proposes one Web Service (booking-system-api, Docker runtime,mainbranch,/healthas the health check path). Click Apply. - Render builds the
Dockerfileand deploys.JWT_SECRETis generated automatically by the blueprint (generateValue: true) and stays stable across deploys, unlike the random-per-restart local default. - Auto-deploy is on by default: every push to
maintriggers a new build and rollout, so the Render URL always tracks the latest commit.
If you'd rather create the service by hand instead of using the Blueprint: New + → Web Service →
select this repo → Runtime: Docker → Branch: main → Health Check Path: /health → add the
same JWT_SECRET / JWT_EXPIRATION env vars → Create Web Service.
Test the deployed instance the same way as local:
curl https://booking-system-api-tn5k.onrender.com/healthNote: the free Render plan spins the instance down after inactivity, so the first request after a quiet period can take a few extra seconds while it wakes back up.