# iamaden/flight-ticket-booking-system architecture

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

- Interactive diagram: https://gitdiagram.com/iamaden/flight-ticket-booking-system
- Repository: https://github.com/iamaden/flight-ticket-booking-system

## Overview

##### Project Type & Purpose
- This is a full-stack web application built using Java Spring Boot for the backend and HTML/JavaScript/CSS for the frontend.
- Its purpose is to allow users to register/login, search for flights, book tickets, view booking history, edit bookings, and cancel bookings.
- The README also highlights the use of custom data structures (MyLinkedList and MyQueue) to manage certain aspects of the booking system.

##### File Structure
- The top-level folder (com.ft.flight) shows a Maven-based Java project structure (pom.xml, mvnw scripts) and follows the typical Spring Boot hierarchy: src/main/java, src/main/resources, and src/test.
- Under src/main/java, the package structure (com.ft.flight) is divided into:
- Application.java – the main entry point.
- controller (e.g., MainController.java): handles HTTP requests.
- entity (includes Booking, Flight, User, and the custom MyLinkedList & MyQueue classes): defines the data models.
- repository (BookingRepository, FlightRepository, UserRepository): data access layer.
- service (BookingService, EmailService, FlightService, UserService): holds business logic.
- The resources folder contains application.properties for configuration, static files (CSS, JS, images), and templates (HTML pages for different views).
- Additional directories like node_modules, package.json, and screenshots indicate some frontend dependencies and documentation screenshots.

##### System Components and Their Relationships
- Frontend: Built with static HTML, CSS, and JavaScript stored under src/main/resources/static and templates. This layer provides user interfaces (e.g., login, registration, flight search, booking form, etc.).
- Backend (Spring Boot Application):
- Controller Layer: Exposes endpoints (e.g., /login, /booking) to handle user requests.
- Service Layer: Implements business logic including handling bookings, email processing, and user management.
- Repository Layer: Provides data access to the database (likely via JPA, connected to a MySQL database).
- Entity Layer: Defines domain objects and incorporates customized data structures for specialized operations.
- Database: A MySQL database is used (as noted from the README with the phpMyAdmin MySQL reference) for persisting flight, booking, and user data.
- Custom Data Structures: The MyLinkedList and MyQueue classes indicate that some parts of booking handling or flight listing might leverage custom implementations.

##### Architectural Patterns & Design Principles
- The application follows a layered (or N-tier) architecture: presentation (frontend), controller, service, repository, and database.
- It leverages the MVC (Model-View-Controller) pattern where the template engine renders views served by controllers.
- The structure shows separation of concerns; each layer has a distinct role.
- The use of Maven, Spring Boot conventions, and packaging into clear modules emphasizes modularity and scalability.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Subgraph
    subgraph "Frontend"
        B["Web Browser/Client"]:::frontend
        HT["HTML Templates"]:::frontend
        SA["Static Assets (CSS/JS)"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend"
        A["Application Entry Point"]:::entity
        subgraph "Controller Layer"
            C["MainController"]:::controller
        end
        subgraph "Service Layer"
            BS["BookingService"]:::service
            FS["FlightService"]:::service
            US["UserService"]:::service
            ES["EmailService"]:::service
        end
        subgraph "Repository Layer"
            BR["BookingRepository"]:::repository
            FR["FlightRepository"]:::repository
            UR["UserRepository"]:::repository
        end
        subgraph "Entity & Data Structures"
            E["Entities (Booking, Flight, User, MyLinkedList, MyQueue)"]:::entity
        end
        CP["Configuration (application.properties)"]:::entity
    end

    %% Database Node
    DB["MySQL Database (phpMyAdmin)"]:::database

    %% Data Flow Arrows
    B -->|"HTTP_Request"| C
    B -->|"renders"| HT
    B -->|"loads_assets"| SA

    A -->|"initializes"| C
    A -->|"reads_config"| CP

    C -->|"delegates"| BS
    C -->|"delegates"| FS
    C -->|"delegates"| US
    C -->|"delegates"| ES

    BS -->|"calls"| BR
    FS -->|"calls"| FR
    US -->|"calls"| UR

    BR -->|"maps_to"| E
    FR -->|"maps_to"| E
    UR -->|"maps_to"| E

    BR ---|"CRUD"| DB
    FR ---|"CRUD"| DB
    UR ---|"CRUD"| DB

    %% Click Events
    click HT "https://github.com/iamaden/flight-ticket-booking-system/tree/main/com.ft.flight/src/main/resources/templates"
    click SA "https://github.com/iamaden/flight-ticket-booking-system/tree/main/com.ft.flight/src/main/resources/static"
    click A "https://github.com/iamaden/flight-ticket-booking-system/blob/main/com.ft.flight/src/main/java/com/ft/flight/Application.java"
    click C "https://github.com/iamaden/flight-ticket-booking-system/blob/main/com.ft.flight/src/main/java/com/ft/flight/controller/MainController.java"
    click BS "https://github.com/iamaden/flight-ticket-booking-system/blob/main/com.ft.flight/src/main/java/com/ft/flight/service/BookingService.java"
    click FS "https://github.com/iamaden/flight-ticket-booking-system/blob/main/com.ft.flight/src/main/java/com/ft/flight/service/FlightService.java"
    click US "https://github.com/iamaden/flight-ticket-booking-system/blob/main/com.ft.flight/src/main/java/com/ft/flight/service/UserService.java"
    click ES "https://github.com/iamaden/flight-ticket-booking-system/blob/main/com.ft.flight/src/main/java/com/ft/flight/service/EmailService.java"
    click BR "https://github.com/iamaden/flight-ticket-booking-system/blob/main/com.ft.flight/src/main/java/com/ft/flight/repository/BookingRepository.java"
    click FR "https://github.com/iamaden/flight-ticket-booking-system/blob/main/com.ft.flight/src/main/java/com/ft/flight/repository/FlightRepository.java"
    click UR "https://github.com/iamaden/flight-ticket-booking-system/blob/main/com.ft.flight/src/main/java/com/ft/flight/repository/UserRepository.java"
    click E "https://github.com/iamaden/flight-ticket-booking-system/tree/main/com.ft.flight/src/main/java/com/ft/flight/entity"
    click CP "https://github.com/iamaden/flight-ticket-booking-system/blob/main/com.ft.flight/src/main/resources/application.properties"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef controller fill:#FADBD8,stroke:#873600,stroke-width:2px;
    classDef service fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef repository fill:#D6EAF8,stroke:#2874A6,stroke-width:2px;
    classDef entity fill:#F2D7D5,stroke:#C0392B,stroke-width:2px;
    classDef database fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
```
