# castvier/tresleches-airlines architecture

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

- Interactive diagram: https://gitdiagram.com/castvier/tresleches-airlines
- Repository: https://github.com/castvier/tresleches-airlines

## Overview

##### Main Components
a. User Interface (Presentation Layer):
- The UI layer consists of various Java classes in the airline/ui package (e.g., MainUI.java, AirplaneUI.java, FlightUI.java, and others).
- The CSS files under airline/ui (e.g., mainUIStyles.css, flightUIStyles.css) and associated resources under airline/resources indicate that there is styling support for the UI.
b. Business Logic / Management Layer:
- The airline/management directory contains classes like FlightManagement.java (and corresponding UI classes like FlightManagementUI.java) that encapsulate business rules for managing flights.
- Test files in the airline/models subfolder for various domain entities (FlightTest.java, AirplaneTest.java, ManagerTest.java) suggest that domain rules and validation logic are critical here.
c. Domain Models:
- The airline/models package holds key domain classes (e.g., Flight.java, Airplane.java, Airport.java, Reservation.java, etc.) and a DatabaseManager that likely abstracts data persistence.
d. Data Storage:
- The presence of a CSV file (airline/data/flights.csv) and a database file (tresLechesAirlines.db) indicates that flight and booking data is stored in file-based and/or database systems.

##### Relationships and Interactions
- The UI components interact with the management layer to trigger actions (search flights, book flights, update flight info) and update the display.
- The management layer uses domain models to represent the data and business entities and utilizes the DatabaseManager (inside models) to interact with the underlying database and CSV data.
- There is a clear directional flow: user input → UI → business logic → data access → response back up the chain.
- Testing components accompany models to ensure logic and business rules are functioning correctly.

##### Architectural Patterns
- Separation of Concerns: The structure separates UI (presentation), business logic (management), and data/domin models (models).
- MVC-influenced Design: Although not a strict MVC implementation, the directories reflect a split where UI components handle presentation, while the models and management areas cover data and business operations.
- Data Access Abstraction: Using a DatabaseManager hints at an abstraction layer that decouples data persistence from business logic.

##### Relevant Technologies / Frameworks
- Java is clearly the language used, potentially running as a desktop or applet-style web app.
- CSS styling is applied to the UI (likely within a Java UI framework that supports CSS styling, like JavaFX, if not a traditional web approach).
- CSV file handling and a SQLite (or similar) database file are being used for data storage.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Presentation Layer"
        UI["User Interface (MainUI, FlightUI, AirplaneUI, ManagerUI + CSS)"]:::presentation
    end

    subgraph "Business Logic Layer"
        BL["Flight Management (FlightManagement.java & FlightManagementUI.java)"]:::business
    end

    subgraph "Data Access Layer"
        DM["Domain Models (Flight.java, Airplane.java, Reservation.java, etc.)"]:::models
        DS1["CSV Data (flights.csv)"]:::database
        DS2["Database File (tresLechesAirlines.db)"]:::database
    end

    UI -->|"invokes"| BL
    BL -->|"uses"| DM
    DM -->|"reads/writes"| DS1
    DM -->|"reads/writes"| DS2

    click UI "https://github.com/castvier/tresleches-airlines/tree/main/airline/ui"
    click BL "https://github.com/castvier/tresleches-airlines/tree/main/airline/management"
    click DM "https://github.com/castvier/tresleches-airlines/tree/main/airline/models"
    click DS1 "https://github.com/castvier/tresleches-airlines/blob/main/airline/data/flights.csv"
    click DS2 "https://github.com/castvier/tresleches-airlines/blob/main/tresLechesAirlines.db"

    classDef presentation fill:#aeeceb,stroke:#036,stroke-width:2px;
    classDef business fill:#ffecb3,stroke:#ff9800,stroke-width:2px;
    classDef models fill:#f8bbd0,stroke:#d81b60,stroke-width:2px;
    classDef database fill:#dcedc8,stroke:#689f38,stroke-width:2px;
```
