Semester project EAR/NSS β CTU FEL
Semester Project for Enterprise Applications (EAR) > Academic Year: 2025/2026
The goal of this semester project is to design and implement an enterprise information system for a bus transportation company (inspired by FlixBus). The project focuses on building a multi-layered enterprise-level application with emphasis on:
- backend system architecture design,
- use of modern technologies (Spring Boot 3, JWT, Testcontainers),
- security, data integrity, and testing.
| Technology | Version | Purpose |
|---|---|---|
| Java | 21 | Core language |
| Spring Boot | 3.5.6 | Application framework |
| Spring Security | 6.x | JWT authentication & authorization |
| JPA / Hibernate | 6.6 | ORM with native PostgreSQL enum support |
| PostgreSQL | 15 | Primary database |
| Flyway | 11.x | Database migrations (prepared) |
| Lombok | 1.18 | Boilerplate reduction |
| JUnit 5 + Mockito | 5.12 | Unit testing |
| Testcontainers | 1.21 | Integration tests with real PostgreSQL |
| Technology | Version | Purpose |
|---|---|---|
| React | 19.x | UI framework |
| TypeScript | 5.9 | Type safety |
| Vite | 7.x | Build tooling & dev server |
| React Router | 7.x | Client-side routing |
| Axios | β | HTTP client |
bus2holiday/
βββ src/main/java/cz/cvut/ear/bus2holiday/
β βββ config/ # Security, CORS, JWT filter configuration
β βββ controller/ # REST controllers
β βββ dao/ # JPA repositories (Spring Data)
β βββ dto/
β β βββ mapper/ # Entity β DTO mapping
β β βββ request/ # Inbound request DTOs
β β βββ response/ # Outbound response DTOs
β βββ exception/ # Global exception handling (GlobalExceptionHandler)
β βββ model/ # JPA entities
β β βββ enums/ # Enumerations (UserRole, TripStatus, BusStatus, ...)
β βββ security/ # JWT provider, SecurityUtils, UserDetailsService
β βββ service/ # Business logic layer
β βββ utils/ # Utility helpers
βββ src/main/resources/
β βββ application.properties # Main configuration
β βββ data.sql # Initial seed data (runs on startup)
βββ src/test/
β βββ java/.../
β β βββ TestContainerConfig.java # Shared Testcontainers base class
β β βββ controller/ # Controller integration tests
β β βββ dao/ # Repository (named query) tests
β β βββ service/ # Service integration tests
β βββ resources/
β βββ application.properties # Test-specific overrides (Testcontainers)
βββ frontend/ # React SPA
β βββ src/
β β βββ api/ # Axios API client
β β βββ components/ # Reusable UI components (Button, Card, Header, Footer)
β β βββ context/ # Auth context (React Context API)
β β βββ pages/ # Pages (Home, Search, Trip, Reservations, Login, Register)
β βββ vite.config.ts
βββ docker-compose.yml # PostgreSQL + app containerization
βββ Dockerfile
βββ pom.xml
- Java 21+
- Node.js 18+
- Docker (recommended) or a local PostgreSQL 15 instance
Starts PostgreSQL + the Spring Boot app in one command:
docker-compose up --build
# Backend: http://localhost:8080Create a local PostgreSQL database:
CREATE DATABASE bus2holiday;Configure src/main/resources/application.properties:
spring.datasource.url=jdbc:postgresql://localhost:5432/bus2holiday
spring.datasource.username=YOUR_USER
spring.datasource.password=YOUR_PASSWORD
jwt.secret=YOUR_SECRET_KEY_MIN_32_CHARSThen run:
./mvnw spring-boot:run
# Backend: http://localhost:8081On first startup, Hibernate auto-creates all tables and enum types, then data.sql seeds the initial data.
Default seed accounts (from data.sql):
| Password | Role | |
|---|---|---|
admin@bus2holiday.com |
password |
Admin |
john@example.com |
password |
User |
driver@example.com |
password |
Driver |
cd frontend
npm install
npm run dev
# Frontend: http://localhost:5173- Registration, login, JWT authentication (24h tokens)
- Role-based authorization: Admin / User / Driver
- User profile management (update name, phone)
- Vehicle fleet tracking with seat capacities and layouts
- Driver assignment to buses
- Route definition with stops (segment-based routes)
- Creation of individual trips (departure/arrival datetime, price, capacity)
- Trip modification, status management, cancellation
- Real-time seat availability via segment-based booking model
- Filtering by origin, destination, date, price, availability
- Public API endpoint β no authentication required
- Segment-based seat selection (
fromStopOrderβtoStopOrder) - Pessimistic locking prevents double-booking under concurrent load
- Online payment simulation
- Ticket cancellation (minimum 15 minutes before departure)
- Overview of assigned trips
- Availability management
- Full CRUD for users, routes, buses, trips, and drivers
- Role assignment and user management
- JWT tokens β stateless authentication, 24h expiration
- RBAC β
user,driver,adminroles via@PreAuthorize - Method-level security on all controllers
- CORS β configured for
http://localhost:* - Input validation β
@Valid+ Bean Validation on all request DTOs - Centralized exception handling β
GlobalExceptionHandlerwith consistent error responses
| Role | Description |
|---|---|
| Admin | Full access. Manages users, roles, routes, buses, drivers, and reservations. |
| User | Searches trips, creates and cancels reservations, pays for tickets. |
| Driver | Views assigned trips, manages own availability. |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/auth/login |
Login, returns JWT |
POST |
/api/auth/register |
New user registration |
GET |
/api/trips/search |
Search trips by criteria |
GET |
/api/trips/{id} |
Trip details |
GET |
/api/trips/{id}/available-seats |
Available seats for a trip |
GET |
/api/routes |
All routes |
GET |
/api/routes/{id} |
Route details with stops |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/users/me |
My profile |
PUT |
/api/users/{id} |
Update my profile |
GET |
/api/reservations |
My reservations |
POST |
/api/reservations |
Create a reservation |
DELETE |
/api/reservations/{id} |
Cancel a reservation |
POST |
/api/reservations/{id}/pay |
Pay for a reservation |
GET |
/api/drivers/me/trips |
My trips (driver only) |
| Method | Endpoint | Description |
|---|---|---|
GET/POST |
/api/buses |
List / create buses |
GET/PATCH/DELETE |
/api/buses/{id} |
Get / update status / delete bus |
GET/POST |
/api/routes |
List / create routes |
POST/DELETE |
/api/routes/{id}/stops |
Add / remove route stops |
POST/PUT/DELETE |
/api/trips |
Manage trips |
GET/POST/DELETE |
/api/drivers |
Manage drivers |
GET/DELETE |
/api/users |
List / delete users |
# Run all tests (requires Docker for Testcontainers)
./mvnw test- Testcontainers β each test suite spins up an isolated PostgreSQL 15 container
TestContainerConfigβ shared abstract base class with a single static container instanceddl-auto=create-dropin test profile β clean schema on every context loadpreparedStatementCacheQueries=0β prevents PostgreSQL cached plan errors across contexts@Transactionalon all test classes β automatic rollback after each test
| Type | Framework | Location |
|---|---|---|
| Unit tests | JUnit 5 + Mockito | service/ |
| Repository tests | @Transactional + EntityManager |
dao/ |
| Controller tests | MockMvc + Testcontainers | controller/ |
| Service integration | Full Spring context | service/ |
βββββββββββββββ βββββββββββββββββ βββββββββββββββ ββββββββββββββββ
β Frontend ββββββΆβ Controller ββββββΆβ Service ββββββΆβ Repository β
β (React) βββββββ (REST API) βββββββ (Business) βββββββ (JPA) β
βββββββββββββββ βββββββββββββββββ βββββββββββββββ ββββββββββββββββ
β β
ββββββββ΄βββββββ ββββββββ΄βββββββ
β DTO/Mapper β β PostgreSQL β
βββββββββββββββ βββββββββββββββ
- Controllers accept and return DTOs only β no JPA entities exposed to the API layer
- Mappers handle entity β DTO conversion (
UserMapper,BusMapper,TripMapper,ReservationMapper, etc.) - Services contain all business logic and enforce transactional boundaries
- Repositories use Spring Data JPA with custom JPQL queries where needed
See CONTRIBUTING.md for development guidelines.
CTU FEL β EAR/NSS Semester Project