# deepanshululla/flight-reservation architecture

> Architecture diagram of the GitHub repository deepanshululla/flight-reservation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/deepanshululla/flight-reservation
- Repository: https://github.com/deepanshululla/flight-reservation

## Overview

##### Project Type and Purpose
- This is a full-stack airline e-commerce web application built with Java Spring Boot, Spring Data JPA (MySQL), Thymeleaf for server-side templates, and AngularJS for client-side form validation / two-way binding. It also exposes a REST integration layer for a separate flight-checkin microservice.

##### File-Structure Analysis
- src/main/java/com/flightreservation/flightreservation
- FlightreservationApplication.java (entry point)
- controllers/ – Spring MVC controllers for web pages and REST endpoints (FlightController, ReservationController, ReservationRestController, UserController)
- services/ – Business services (ReservationService, SecurityService, UserDetailsService)
- repositories/ – Spring Data JPA Repos for FLIGHT, RESERVATION, USER, PASSENGER, ROLE, USER_ROLE
- domains/ – JPA entity classes reflecting the database model
- dto/ – Request/response objects for creating/updating reservations
- security/config/ – WebSecurityConfig for authentication/authorization
- util/ – EmailUtil (SMTP), PdfGenerator
- src/main/resources
- application.properties, SQL scripts (schema & initial data), logback.xml
- static/ – CSS, JS, images, Bower-installed Angular, jQuery, Bootstrap libraries
- templates/ – Thymeleaf HTML templates for flights, reservations, login, registration
- pom.xml, bower.json, mvnw wrappers, .gitignore

##### Architectural Patterns & Key Technologies
- Layered (MVC) pattern:
- Presentation: Thymeleaf + AngularJS + Bootstrap (static assets)
- Controller: Spring + Spring MVC (web & REST controllers)
- Service: Business logic, security, integration
- Repository: Spring Data JPA (Hibernate) → MySQL
- Security: Spring Security with encoded passwords, role-based auth
- Integration: REST API to external flight-checkin microservice
- Utilities: Email (SMTP), PDF generation, externalized logging via Logback
- Database: MySQL, six tables (FLIGHT, RESERVATION, USER, PASSENGER, ROLE, USER_ROLE)

##### Main Components and Their Interactions
- Client Browser
→ Requests HTML pages (Thymeleaf templates) / REST calls (AngularJS)
- Web Server (Spring Boot)
- Web Controller Layer (Thymeleaf views)
- REST Controller Layer (JSON endpoints)
- Service Layer (business & security logic)
- Repository Layer (CRUD on MySQL)
- MySQL Database
- External Flight-Checkin Microservice (REST API)
← ReservationRestController calls it for check-in
- SMTP Mail Server (via EmailUtil)
- Logging Subsystem (Logback writes to external files)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        Browser["Client Browser"]:::ui
        Thymeleaf["Thymeleaf Templates"]:::ui
        AngularJS["AngularJS (app.js)"]:::ui
        StaticAssets["Static Assets (CSS/JS)"]:::ui
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        AppEntry["FlightreservationApplication"]:::backend
        subgraph Controllers
            direction TB
            FlightController["FlightController"]:::backend
            ReservationController["ReservationController"]:::backend
            ReservationRestController["ReservationRestController"]:::backend
            UserController["UserController"]:::backend
        end
        subgraph Services
            direction TB
            ReservationServiceImpl["ReservationServiceImpl"]:::backend
            SecurityServiceImpl["SecurityServiceImpl"]:::backend
            UserDetailsServiceImpl["UserDetailsServiceImpl"]:::backend
        end
        WebSecurityConfig["WebSecurityConfig"]:::backend
        subgraph Repositories
            direction TB
            FlightRepository["FlightRepository"]:::backend
            ReservationRepository["ReservationRepository"]:::backend
            PassengerRepository["PassengerRepository"]:::backend
            UserRepository["UserRepository"]:::backend
            RoleRepository["RoleRepository"]:::backend
        end
        subgraph Utilities
            direction TB
            EmailUtil["EmailUtil"]:::backend
            PdfGenerator["PdfGenerator"]:::backend
        end
    end

    %% Database
    MySQL["MySQL Database"]:::db

    %% External Services
    FlightCheckin["Flight-Checkin Microservice"]:::external
    SMTP["SMTP Mail Server"]:::external

    %% Connections
    Browser -->|"requests HTML"| Thymeleaf
    Browser -->|"AJAX/REST calls"| ReservationRestController
    Browser -->|"form bindings"| AngularJS
    Browser --> StaticAssets

    Thymeleaf --> FlightController
    Thymeleaf --> ReservationController
    Thymeleaf --> UserController

    FlightController --> ReservationServiceImpl
    ReservationController --> ReservationServiceImpl
    UserController --> SecurityServiceImpl

    ReservationRestController --> ReservationServiceImpl
    ReservationServiceImpl --> ReservationRepository
    ReservationServiceImpl --> FlightRepository
    ReservationServiceImpl --> PassengerRepository
    ReservationServiceImpl --> UserRepository
    ReservationServiceImpl --> RoleRepository

    ReservationServiceImpl -->|"call REST API"| FlightCheckin
    ReservationServiceImpl --> EmailUtil
    ReservationServiceImpl --> PdfGenerator

    SecurityServiceImpl --> UserDetailsServiceImpl
    SecurityServiceImpl --> UserRepository

    WebSecurityConfig --> FlightController
    WebSecurityConfig --> ReservationController
    WebSecurityConfig --> ReservationRestController
    WebSecurityConfig --> UserController

    FlightRepository --> MySQL
    ReservationRepository --> MySQL
    PassengerRepository --> MySQL
    UserRepository --> MySQL
    RoleRepository --> MySQL

    %% Click Events
    click AppEntry "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/FlightreservationApplication.java"
    click FlightController "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/controllers/FlightController.java"
    click ReservationController "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/controllers/ReservationController.java"
    click ReservationRestController "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/controllers/ReservationRestController.java"
    click UserController "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/controllers/UserController.java"
    click ReservationServiceImpl "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/services/ReservationServiceImpl.java"
    click ReservationService "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/services/ReservationService.java"
    click SecurityServiceImpl "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/services/SecurityServiceImpl.java"
    click SecurityService "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/services/SecurityService.java"
    click UserDetailsServiceImpl "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/services/UserDetailsServiceImpl.java"
    click FlightRepository "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/repositories/FlightRepository.java"
    click ReservationRepository "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/repositories/ReservationRepository.java"
    click PassengerRepository "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/repositories/PassengerRepository.java"
    click UserRepository "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/repositories/UserRepository.java"
    click RoleRepository "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/repositories/RoleRepository.java"
    click EmailUtil "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/util/EmailUtil.java"
    click PdfGenerator "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/java/com/flightreservation/flightreservation/util/PdfGenerator.java"
    click AngularJS "https://github.com/deepanshululla/flight-reservation/blob/master/src/main/resources/static/js/app.js"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#0066cc,color:#000
    classDef backend fill:#ccffcc,stroke:#339933,color:#000
    classDef db fill:#ffe0b3,stroke:#cc6600,color:#000
    classDef external fill:#e2d7ff,stroke:#663399,color:#000
```
