# vinhthaitong/3345-assignment4 architecture

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

- Interactive diagram: https://gitdiagram.com/vinhthaitong/3345-assignment4
- Repository: https://github.com/vinhthaitong/3345-assignment4

## Overview

##### Project type and purpose
- This is a stand-alone, command-line Java application (“Flight Path Finder”) that models a flight network as a directed, weighted graph.
- It ingests two data files (FlightData.txt and Input.txt), builds an in-memory graph, performs a full DFS to enumerate all acyclic paths between two airports, sorts by cost or time, and prints human-readable results.

##### File structure
- Top-level Java classes:
- Main.java      – application entry point, coordinates I/O, graph construction, search, and output
- Graph.java     – holds adjacency-list representation; implements DFS logic for “all-paths” search
- Node.java      – data model for a graph vertex (airport) and outgoing edges
- Path.java      – data model for a candidate route, accumulates cost & time
- Data files:
- FlightData.txt – source data for graph edges (source|dest|cost|time)
- Input.txt      – list of trip requests (source|dest|C or T)
- No external frameworks; plain Java 11+ with recursive DFS.

##### Key insights from the README
- The core algorithm is depth-first search over a directed weighted graph.
- The project is extremely modular around these concerns:
- Data ingestion
- Graph construction
- Search & path storage
- Sorting / selection of optimal metrics
- Console rendering

##### Components
a. Data Sources Layer
- FlightData.txt (edge definitions)
- Input.txt (search requests)
b. I/O & Controller Layer
- Main.java
– Reads both files
– Instantiates Graph
– Parses requests & dispatches to search
– Receives results & forwards to output
c. Graph Model Layer
- Graph.java
- Node.java
- Path.java
d. Algorithm & Processing Layer
- DFS engine (recursive calls inside Graph.java)
- Path accumulator (Path.java instances)
- Sorter / comparator (cost vs time)
e. Output Layer
- Console renderer in Main.java (prints summary, all paths, best paths)

##### Relationships & data flow
- Controller → calls Graph.DFS → produces a collection of Path objects
- Collection → Sorter → picks cheapest/fastest
- Final results → Console Output

##### Architectural patterns & principles
- Single-process monolith with clear separation of concerns
- Layered structure: I/O → Domain model → Algorithm → Presentation
- Data models (Node, Path) are plain old Java objects (POJOs)
- Algorithm encapsulated inside Graph class

##### Technologies & libraries
- Java 11+ / OpenJDK 17
- No external dependencies
- Recursive DFS on adjacency lists

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources Layer
    subgraph "Data Sources Layer"
        FlightData(("FlightData.txt")):::io
        Input(("Input.txt")):::io
    end

    %% I/O & Controller Layer
    subgraph "I/O & Controller Layer"
        Main["Main.java"]:::io
    end

    %% Domain Model Layer
    subgraph "Domain Model Layer"
        Graph["Graph.java"]:::domain
        Node["Node.java"]:::domain
        Path["Path.java"]:::domain
    end

    %% Processing Layer
    subgraph "Processing Layer"
        DFS["DFS Engine"]:::processing
        Sorter["Sorter (Cost/Time Comparator)"]:::processing
    end

    %% Output Layer
    subgraph "Output Layer"
        Console[/Console Renderer/]:::output
    end

    %% Connections
    FlightData -->|"read edges"| Main
    Input -->|"read requests"| Main
    Main -->|"build graph"| Graph
    Graph -->|"uses vertex model"| Node
    Graph -->|"accumulates metrics"| Path
    Main -->|"invoke search"| DFS
    DFS -->|"traverse graph"| Graph
    DFS -->|"produce paths"| Path
    DFS -->|"send to sorter"| Sorter
    Sorter -->|"select optimal"| Path
    Sorter -->|"forward results"| Console

    %% Click Events
    click FlightData "https://github.com/vinhthaitong/3345-assignment4/blob/main/FlightData.txt"
    click Input "https://github.com/vinhthaitong/3345-assignment4/blob/main/Input.txt"
    click Main "https://github.com/vinhthaitong/3345-assignment4/blob/main/Main.java"
    click Graph "https://github.com/vinhthaitong/3345-assignment4/blob/main/Graph.java"
    click Node "https://github.com/vinhthaitong/3345-assignment4/blob/main/Node.java"
    click Path "https://github.com/vinhthaitong/3345-assignment4/blob/main/Path.java"

    %% Styles
    classDef io fill:#cfe2f3,stroke:#036,stroke-width:2px
    classDef domain fill:#e0e0e0,stroke:#888,stroke-width:2px
    classDef processing fill:#d9ead3,stroke:#090,stroke-width:2px
    classDef output fill:#fce5cd,stroke:#f60,stroke-width:2px

    %% Legend
    subgraph "Legend"
        direction TB
        A(("Cylinder: Data File")):::io
        B["Rectangle: Module/Class"]:::domain
        C["Parallelogram: Console I/O"]:::output
    end
```
