# hunterskg/bus_booking_system_bts2 architecture

> Architecture diagram of the GitHub repository hunterskg/bus_booking_system_bts2, 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/hunterskg/bus_booking_system_bts2
- Repository: https://github.com/hunterskg/bus_booking_system_bts2

## Overview

##### Project Type and Purpose
- Type: This is a Java-based application that appears to be a bus booking system.
- Purpose: The project manages bus bookings using text files (“Booking.txt”, “Buses.txt”, “Passengers.txt”) for data persistence. The application uses custom data structures (e.g., linked lists, binary search trees, queues) to manage and search bookings, bus details, and passenger information, while the control package coordinates business logic and validations.
- Build/Deployment: The presence of build.xml (Ant build file) and NetBeans project files (under nbproject) indicates that the project is built using standard Java tooling and IDE support.

##### Analysis of the File Structure
- Top-Level Components:
- src: Contains the main source code organized in packages (control, linkedlist, menu, object).
- build and nbproject: Indicate auto-generated and IDE-related files.
- Plain text files (e.g., Booking.txt, Buses.txt, Passengers.txt): Likely used for persisting application data.
- Packages:
- menu: Contains Main.java (entry point), which likely handles initial program execution and user invocation.
- control: Contains business logic components (Manager.java, UI.java, Validation.java) that manage user input and application flow.
- object: Contains model classes (Booking.java, Bus.java, Passenger.java) representing core entities.
- linkedlist: Contains custom data structures (BookingList.java, BusBST.java, BusNode.java, BusQueue.java, PassengerBST.java) used to manage collections of entities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        UI1["Main.java"]
        UI2["UI.java"]
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        BL1["Manager.java"]
        BL2["Validation.java"]
    end

    %% Domain Model Layer
    subgraph "Domain Model Layer"
        DM1["Booking.java"]
        DM2["Bus.java"]
        DM3["Passenger.java"]
    end

    %% Data Structures Layer
    subgraph "Data Structures Layer"
        DS1["BookingList.java"]
        DS2["BusBST.java"]
        DS3["BusQueue.java"]
        DS4["PassengerBST.java"]
    end

    %% Persistence/Data Storage Layer
    subgraph "Persistence Layer"
        P1["Booking.txt"]
        P2["Buses.txt"]
        P3["Passengers.txt"]
    end

    %% Build & Deployment Layer
    subgraph "Build & Deployment"
        BD1["build.xml"]
        BD2["nbproject"]
    end

    %% Connections between layers
    %% UI -> Business Logic
    UI1 -->|"triggers"| BL1
    UI2 -->|"displays"| BL2

    %% Business Logic interacts with Domain Models and Data Structures
    BL1 -->|"processes"| DM1
    BL1 -->|"manages"| DS1
    BL2 -->|"validates"| DM2
    BL2 -->|"updates"| DS2

    %% Domain Models and Data Structures inter-relationship
    DM1 -->|"stored_in"| DS1
    DM2 -->|"stored_in"| DS2
    DM3 -->|"stored_in"| DS3
    DS4 -->|"indexes"| DM3

    %% Persistence interactions
    DM1 -->|"persist"| P1
    DM2 -->|"persist"| P2
    DM3 -->|"persist"| P3
    DS1 -->|"cache_save"| P1
    DS2 -->|"cache_save"| P2
    DS3 -->|"cache_save"| P3
    DS4 -->|"cache_save"| P3

    %% Build & Deployment influences the system
    BD1 ---|"builds"| UI1
    BD1 ---|"builds"| BL1
    BD1 ---|"builds"| DS1
    BD1 ---|"builds"| DM1

    %% Additional coordination within Business Logic
    BL1 ---|"coordinates"| BL2
    BL1 -->|"orchestrates"| P1

    %% Style Classes
    classDef ui fill:#FCE4EC,stroke:#C2185B,stroke-width:2px;
    classDef business fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef domain fill:#E1F5FE,stroke:#0277BD,stroke-width:2px;
    classDef datastruct fill:#E8F5E9,stroke:#2E7D32,stroke-width:2px;
    classDef persistence fill:#F3E5F5,stroke:#8E24AA,stroke-width:2px;
    classDef build fill:#E0E0E0,stroke:#616161,stroke-width:2px;

    class UI1,UI2 ui;
    class BL1,BL2 business;
    class DM1,DM2,DM3 domain;
    class DS1,DS2,DS3,DS4 datastruct;
    class P1,P2,P3 persistence;
    class BD1,BD2 build;

    %% Click Events for User Interface Layer
    click UI1 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/src/menu/Main.java"
    click UI2 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/src/control/UI.java"

    %% Click Events for Business Logic Layer
    click BL1 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/src/control/Manager.java"
    click BL2 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/src/control/Validation.java"

    %% Click Events for Data Structures Layer
    click DS1 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/src/linkedlist/BookingList.java"
    click DS2 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/src/linkedlist/BusBST.java"
    click DS3 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/src/linkedlist/BusQueue.java"
    click DS4 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/src/linkedlist/PassengerBST.java"

    %% Click Events for Domain Model Layer
    click DM1 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/src/object/Booking.java"
    click DM2 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/src/object/Bus.java"
    click DM3 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/src/object/Passenger.java"

    %% Click Events for Persistence/Data Storage
    click P1 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/Booking.txt"
    click P2 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/Buses.txt"
    click P3 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/Passengers.txt"

    %% Click Events for Build & Deployment
    click BD1 "https://github.com/hunterskg/bus_booking_system_bts2/blob/main/Bus_Booking_System-master/build.xml"
    click BD2 "https://github.com/hunterskg/bus_booking_system_bts2/tree/main/Bus_Booking_System-master/nbproject"
```
