# nejlasahin/airline-reservation-system architecture

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

- Interactive diagram: https://gitdiagram.com/nejlasahin/airline-reservation-system
- Repository: https://github.com/nejlasahin/airline-reservation-system

## Overview

##### Project Type & Purpose
- This is a monolithic, full-stack Java web application implementing an Airline Reservation System.
- It follows the classic MVC pattern, uses JSP for views, Servlets for controllers, DAOs/POJOs for the model, MySQL for persistence, and integrates file storage (for logos) and SMTP (for email).

##### File‐Structure & Architectural Patterns
- **src/java/model**: POJO classes representing DB tables (User, Flight, Reservation, Message, etc.).
- **src/java/dao**: DAO classes encapsulating JDBC calls (mysql-connector) for CRUD operations on each entity.
- **src/java/servlet**: Controller layer. One Servlet per module (e.g. KullaniciServlet for users, RezervasyonServlet for bookings). They handle HTTP requests, invoke DAOs, manage sessions, choose JSP views.
- **web/\***:
- JSP pages for user UI and admin panel under `web/` and `web/admin/`
- Static assets: CSS/SCSS, JS, images under `web/assets/` and `web/admin/css/js/vendor/`
- `WEB-INF/web.xml` & `context.xml` configure servlets, data source
- **sql/hawkeye.sql** holds the DB schema.
- Uses Apache Commons FileUpload for multipart form handling and JavaMail API for outgoing email.

a. **Main Components**
- **Browser (Web Client)**: interacts via HTTP/HTTPS, displays JSP-generated HTML.
- **Web Server (Servlet Container)**: houses the application WAR.
- **View Layer**: JSP pages + static assets
- **Controller Layer**: Servlet classes grouped by functional area
- **Model/DAO Layer**: POJOs + DAO classes, business logic confined to controllers/DAOs
- **Database**: MySQL instance (tables: users, flights, reservations, messages, airports, etc.)
- **File System Storage**: directory under `web/assets/data/` for uploaded logos
- **SMTP Server**: external email service (smtp.gmail.com) for messaging

b. **Relationships & Data Flows**
1. Browser → HTTP Request → Servlet (Controller)
2. Servlet → calls DAO → executes SQL → returns POJOs
3. Servlet → places data in request/session → forwards to JSP
4. JSP → renders HTML/CSS/JS → Browser
5. For uploads: Servlet writes files to FS → DAO records filename in DB
6. For email: Servlet uses JavaMail to send via SMTP

c. **Architectural Patterns & Principles**
- MVC separation: keeps UI, control logic, and data access decoupled
- DAO Pattern: isolating JDBC code
- Layered three-tier architecture: Presentation / Application / Data
- Session management and role-based access (admin vs. user)

d. **Key Technologies & Frameworks**
- Java Servlet API & JSP + JSTL 1.2.2
- JDBC with mysql-connector-java 5.1.23
- Apache Commons FileUpload 1.4
- JavaMail API (javax.mail.jar)
- Ant build (build.xml and NetBeans project files)
- SCSS & sb-admin-2 Bootstrap theme for admin UI

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["Browser"]:::ui
        subgraph "JSP Views"
            direction TB
            JSPPublic["Public JSP Views"]:::ui
            JSPAdmin["Admin JSP Views"]:::ui
        end
        subgraph "Static Assets"
            direction TB
            StaticAssetsPub["Public Assets (CSS/JS/Images)"]:::ui
            StaticAssetsAdmin["Admin Assets (CSS/JS/SCSS/Vendor)"]:::ui
        end
        WebXml["web.xml"]:::config
        ContextXml["context.xml"]:::config
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        ControllerLayer["Servlet Controllers"]:::server
        DAOLayer["DAO Classes"]:::server
        ModelLayer["POJO Model Classes"]:::server
        FileUploadJar["Commons FileUpload"]:::lib
        JavaMailJar["JavaMail API"]:::lib
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DB["MySQL Database"]:::db
        FileStorage["File System Storage"]:::storage
        SMTP["SMTP Server"]:::external
        DBSchema["DB Schema Script"]:::script
    end

    %% Connections
    Browser -->|"HTTP Request"| ControllerLayer
    ControllerLayer -->|"calls DAO"| DAOLayer
    DAOLayer -->|"JDBC SQL ops"| DB
    DAOLayer -->|"returns POJOs"| ControllerLayer
    ControllerLayer -->|"forwards with data"| JSPPublic
    ControllerLayer -->|"forwards with data"| JSPAdmin
    JSPPublic -->|"renders HTML/CSS/JS"| Browser
    JSPAdmin -->|"renders HTML/CSS/JS"| Browser
    ControllerLayer -->|"writes files"| FileStorage
    ControllerLayer -->|"sends email via"| SMTP
    ControllerLayer -->|"uses libs"| FileUploadJar
    ControllerLayer -->|"uses libs"| JavaMailJar

    %% Click Events
    click ModelLayer "https://github.com/nejlasahin/airline-reservation-system/tree/master/src/java/model"
    click DAOLayer "https://github.com/nejlasahin/airline-reservation-system/tree/master/src/java/dao"
    click ControllerLayer "https://github.com/nejlasahin/airline-reservation-system/tree/master/src/java/servlet"
    click JSPPublic "https://github.com/nejlasahin/airline-reservation-system/blob/master/web/index.jsp"
    click JSPAdmin "https://github.com/nejlasahin/airline-reservation-system/blob/master/web/admin/index.jsp"
    click StaticAssetsPub "https://github.com/nejlasahin/airline-reservation-system/tree/master/web/assets/css"
    click StaticAssetsAdmin "https://github.com/nejlasahin/airline-reservation-system/tree/master/web/admin/css"
    click WebXml "https://github.com/nejlasahin/airline-reservation-system/blob/master/web/WEB-INF/web.xml"
    click ContextXml "https://github.com/nejlasahin/airline-reservation-system/blob/master/web/META-INF/context.xml"
    click FileUploadJar "https://github.com/nejlasahin/airline-reservation-system/blob/master/web/WEB-INF/lib/commons-fileupload-1.4.jar"
    click JavaMailJar "https://github.com/nejlasahin/airline-reservation-system/blob/master/web/WEB-INF/lib/javax.mail.jar"
    click DBSchema "https://github.com/nejlasahin/airline-reservation-system/blob/master/sql/hawkeye.sql"
    click BuildConfig "https://github.com/nejlasahin/airline-reservation-system/blob/master/build.xml"
    click NetBeans "https://github.com/nejlasahin/airline-reservation-system/tree/master/nbproject/"

    %% Styles
    classDef ui fill:#e3f2fd,stroke:#90caf9,color:#0d47a1,stroke-width:1px
    classDef server fill:#e8f5e9,stroke:#66bb6a,color:#1b5e20,stroke-width:1px
    classDef db fill:#eeeeee,stroke:#bdbdbd,color:#424242,stroke-width:1px
    classDef storage fill:#fff3e0,stroke:#ffb74d,color:#e65100,stroke-width:1px
    classDef external fill:#f3e5f5,stroke:#ba68c8,color:#4a148c,stroke-width:1px
    classDef config fill:#f0f4c3,stroke:#c0ca33,color:#827717,stroke-width:1px
    classDef lib fill:#ffebee,stroke:#e57373,color:#b71c1c,stroke-width:1px
    classDef script fill:#e0f7fa,stroke:#4dd0e1,color:#006064,stroke-width:1px
```
