# riiichan04/flightticketmanagement architecture

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

- Interactive diagram: https://gitdiagram.com/riiichan04/flightticketmanagement
- Repository: https://github.com/riiichan04/flightticketmanagement

## Overview

##### Main Components
- Model Layer – Contains business logic and data representations. This includes classes for flights, accounts, tickets, filtering (e.g., AmountFilter, BrandFilter, DateFilter), and strategies (FlightStrategy). All these are under the “src/model” directory.
- View Layer – Manages the user interface. It’s composed of panels and frames (e.g., AccountPanel, FlightPanel, SignInFrame) in “src/view”. This layer is responsible for displaying flight lists, account information and allowing user interactions.
- Controller Layer – Found in “src/controller”. The Controller.java (and the IController.java interface) acts as a central dispatcher that connects UI actions (from the View) to business operations (in the Model).
- Data Storage – The “src/data” directory contains text files representing persistent storage for accounts and flight details. The flight details are segmented in text files with a defined format.
- Utilities – A supporting library of helper classes such as FileLoader, FileConverter, FontLoader, and JDialogCreator in “src/utilities”, used by various parts of the application.
- Assets – UI resources including fonts, images, and screenshots (helpful for UI design reference) in “src/asset.”

##### Relationships and Interactions
- The View interacts with the Controller through event handling. For example, user actions on a SignInPanel trigger events that the Controller processes.
- The Controller, acting as the middleman, calls methods on the Model to, for example, add, update, or retrieve flight and account information.
- The Model includes communication with the Data layer, reading and writing from txt files to maintain persistent state.
- Utility classes are used by both the Model (for tasks such as file conversion or loading) and the View (for generating dialog windows or custom labels).
- Some design patterns are evidenced: the Observer pattern (with the Observable class in the model and Observer interface in the view), and a Decorator pattern (as indicated by TicketDecorator).

##### Important Architectural Patterns
- MVC Architecture – Clear separation of concerns between UI (view), business logic (model), and request handling (controller).
- Observer Pattern – Ensures that views updating can be synchronized with changes in the model.
- Possibly a Decorator Pattern – Used to modify or extend the behavior of ticket processing.
- Layered Interaction – Data (files) connect to Model, then flow to Controller and out to the UI in the View layer.

##### Technologies and Frameworks
- Java – Core language running the application.
- Standard Java Swing (implied by frame and panel classes) for the UI.
- Basic file I/O operations for data persistence.
- Custom utilities for common tasks such as converting file data and loading resources.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% View Layer
    subgraph "View Layer"
        V1["SignInFrame (View)"]:::view
        V2["SignInPanel (View)"]:::view
        V3["AccountPanel (View)"]:::view
        V4["FlightPanel (View)"]:::view
        V5["TicketPanel (View)"]:::view
        V6["UserPanel (View)"]:::view
        V7["WorkFrame (View)"]:::view
        V8["Observer (View)"]:::view
    end

    %% Controller Layer
    subgraph "Controller Layer"
        C1["Controller"]:::controller
        C2["IController"]:::controller
    end

    %% Model Layer
    subgraph "Model Layer"
        M1["Flight.java"]:::model
        M2["FlightSystem"]:::model
        M3["AddFlight"]:::model
        M4["RemoveFlight"]:::model
        M5["UpdateFlight"]:::model
        M6["Account.java"]:::model
        M7["AccountSystem"]:::model
        M8["CreateAccount"]:::model
        M9["DeleteAccount"]:::model
        M10["ListAccount"]:::model
        M11["ManagerAccount"]:::model
        M12["StaffAccount"]:::model
        M13["AmountFilter"]:::model
        M14["BrandFilter"]:::model
        M15["DateFilter"]:::model
        M16["NoFilter"]:::model
        M17["Filter"]:::model
        M18["FlightStrategy"]:::model
        M19["TicketSystem"]:::model
        M20["TicketDecorator"]:::model
        M21["Observable"]:::model
    end

    %% Data Storage
    subgraph "Data Storage"
        D1["account.txt"]:::data
        D2["SV207031.txt"]:::data
        D3["SV22130.txt"]:::data
        D4["SV22132.txt"]:::data
    end

    %% Utilities
    subgraph "Utilities"
        U1["FileLoader"]:::utilities
        U2["FileConverter"]:::utilities
        U3["FontLoader"]:::utilities
        U4["JDialogCreator"]:::utilities
        U5["CustomLabel"]:::utilities
    end

    %% Assets
    subgraph "Assets"
        A1["Fonts"]:::assets
        A2["Images"]:::assets
        A3["Screenshots"]:::assets
    end

    %% Connections from View to Controller
    V2 -->|"triggers"| C1
    V3 -->|"triggers"| C1
    V4 -->|"triggers"| C1
    V5 -->|"triggers"| C1
    V6 -->|"triggers"| C1
    V7 -->|"triggers"| C1

    %% Controller to Model interactions
    C1 -->|"calls"| M2
    C1 -->|"calls"| M7
    C1 -->|"calls"| M19

    %% Model interactions with Data Storage
    M2 -->|"reads/writes"| D2
    M2 -->|"reads/writes"| D3
    M2 -->|"reads/writes"| D4
    M7 -->|"reads/writes"| D1

    %% Decorator pattern in Ticket handling
    M20 -->|"wraps"| M19

    %% Observer pattern interaction
    M21 -->|"notifies"| V8

    %% Model usage of Utilities
    M2 -->|"uses"| U1
    M2 -->|"uses"| U2
    M7 -->|"uses"| U5

    %% Utilities interaction with Assets
    U3 -->|"loads"| A1
    U4 -->|"loads"| A2

    %% Styles
    classDef view fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef controller fill:#FFD580,stroke:#FF8C00,stroke-width:2px;
    classDef model fill:#C1FFC1,stroke:#008000,stroke-width:2px;
    classDef data fill:#F5F5F5,stroke:#696969,stroke-width:2px;
    classDef utilities fill:#E6E6FA,stroke:#9370DB,stroke-width:2px;
    classDef assets fill:#FFFACD,stroke:#DAA520,stroke-width:2px;

    %% Click Events for Model Layer
    click M1 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/Flight.java"
    click M2 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/FlightSystem.java"
    click M3 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/AddFlight.java"
    click M4 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/RemoveFlight.java"
    click M5 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/UpdateFlight.java"
    click M6 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/Account.java"
    click M7 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/AccountSystem.java"
    click M8 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/CreateAccount.java"
    click M9 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/DeleteAccount.java"
    click M10 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/ListAccount.java"
    click M11 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/ManagerAccount.java"
    click M12 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/StaffAccount.java"
    click M13 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/AmountFilter.java"
    click M14 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/BrandFilter.java"
    click M15 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/DateFilter.java"
    click M16 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/NoFilter.java"
    click M17 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/Filter.java"
    click M18 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/FlightStrategy.java"
    click M19 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/TicketSystem.java"
    click M20 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/TicketDecorator.java"
    click M21 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/model/Observable.java"

    %% Click Events for View Layer
    click V1 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/view/SignInFrame.java"
    click V2 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/view/SignInPanel.java"
    click V3 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/view/AccountPanel.java"
    click V4 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/view/FlightPanel.java"
    click V5 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/view/TicketPanel.java"
    click V6 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/view/UserPanel.java"
    click V7 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/view/WorkFrame.java"
    click V8 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/view/Observer.java"

    %% Click Events for Controller Layer
    click C1 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/controller/Controller.java"
    click C2 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/controller/IController.java"

    %% Click Events for Data Storage
    click D1 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/data/account.txt"
    click D2 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/data/SV207031.txt"
    click D3 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/data/SV22130.txt"
    click D4 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/data/SV22132.txt"

    %% Click Events for Utilities
    click U1 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/utilities/FileLoader.java"
    click U2 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/utilities/FileConverter.java"
    click U3 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/utilities/FontLoader.java"
    click U4 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/utilities/JDialogCreator.java"
    click U5 "https://github.com/riiichan04/flightticketmanagement/blob/master/src/utilities/CustomLabel.java"

    %% Click Events for Assets
    click A1 "https://github.com/riiichan04/flightticketmanagement/tree/master/src/asset/font"
    click A2 "https://github.com/riiichan04/flightticketmanagement/tree/master/src/asset/image"
    click A3 "https://github.com/riiichan04/flightticketmanagement/tree/master/src/asset/screenshot"
```
