# hiennguyen278610/metro architecture

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

- Interactive diagram: https://gitdiagram.com/hiennguyen278610/metro
- Repository: https://github.com/hiennguyen278610/metro

## Overview

The “metro” project is a Java-based desktop (or standalone) management system that appears to handle various aspects of metro (train) management such as customer handling, train scheduling, maintenance, and more. Based on the file tree and setup instructions in the README, the project follows a layered MVC-like architecture with clear separations between data access, business logic, and presentation.

##### Main Components
- Database Layer: The MySQL database (as referenced in the README with details for configuration). Also include the MetroManagement.sql script in the resources.
- Data Access Layer: The DAO package containing classes like DangkyDao, KhachHangDAO, TauDAO, TramDAO, etc., and the IBaseDAO interface, which abstract the database interactions.
- Business/Service Layer: Classes in the service package (for example, KhachHangService, TaiKhoanService, VeTauService, etc.) which encapsulate domain logic and interact with the DAOs.
- Presentation Layer: The view package (including components, dialogs, panels, frames) that manages the UI using various custom components (e.g., ButtonEdit, ContentPanel, InputField, etc.). This layer also incorporates the controller package (such as KhachHangController, LoginController, MainController, etc.) that mediates between the UI and the backend logic.
- Utility Layer: Utility classes like DatabaseUtils and SessionManager, which support common functions such as database connectivity and session management.
- Application Entry Point: The Main.java class which likely initializes the system, configures the GUI, and orchestrates the starting flows.

##### Representing Relationships and Interactions
- Database interaction from the DAO layer to the MySQL Database.
- Auxiliary relationships like configuration management through the properties file (config.properties) loaded via the utility classes.
- That controllers serve as intermediaries between UI components and service methods, enforcing the MVC pattern.

##### Architectural Patterns
- MVC Pattern: Emphasize the role of controllers in handling user input while updating views, and the separation of model classes in the model package representing domain data.
- Utility/Configuration Pattern: Display supporting components (DatabaseUtils, SessionManager) that provide cross-cutting concerns like DB connectivity and session management.

##### Relevant Technologies and Frameworks
- Java as the primary programming language.
- Maven as the build and dependency management tool (as indicated by the presence of pom.xml).
- MySQL as the database technology (with connection configuration detailed in the README and config.example.properties used for setup).
- Integrated development environments like IntelliJ or VSCode as mentioned in the README (although these are more for setup, they can be noted as part of the development environment).

##### Essential Elements
- Clear labels for each layer/component (Presentation, Business, Data Access, Database, and Utility).
- Notation of significant packages and classes (for instance, a note on DAO package classes, key controllers, and view modules such as dialogs and panels).
- Visual separation that highlights MVC: include “User Interface” elements (views and dialogs) separately from “Controllers” that manage events, and then “Services/Business logic” and “Data Access” below them.
- A separate, clearly marked component for configuration and utility functions (including DatabaseUtils and SessionManager).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UIC["UI Components"]:::presentation
        DIA["Dialogs"]:::presentation
        PAN["Panels & Frames"]:::presentation
        CONT["Controllers"]:::presentation
    end

    %% Business/Service Layer
    subgraph "Business Layer"
        SERV["Service Package"]:::business
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DAO["DAO Package"]:::dao
        IBASE["IBaseDAO Interface"]:::dao
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["MySQL Database"]:::database
        SQL["MetroManagement.sql"]:::database
        CONF["config.properties"]:::database
    end

    %% Utility Layer
    subgraph "Utility Layer"
        UTIL["Utility Classes"]:::utility
    end

    %% Application Entry Point
    subgraph "Application Entry Point"
        MAIN["Main.java"]:::entrypoint
    end

    %% Connections - Presentation Flow
    UIC -->|"triggers"| CONT
    DIA -->|"triggers"| CONT
    PAN -->|"triggers"| CONT

    %% Connections - MVC Flow
    CONT -->|"calls"| SERV
    SERV -->|"invokes"| DAO
    DAO -->|"queries"| DB

    %% Utility and Configuration Connections
    UTIL -->|"loads"| CONF

    %% Application Startup
    MAIN -->|"initializes"| CONT
    MAIN -->|"initializes"| UTIL

    %% Click Events
    click SQL "https://github.com/hiennguyen278610/metro/blob/main/src/main/resources/MetroManagement.sql"
    click CONF "https://github.com/hiennguyen278610/metro/blob/main/src/main/resources/config.example.properties"
    click DAO "https://github.com/hiennguyen278610/metro/tree/main/src/main/java/org/metro/DAO"
    click IBASE "https://github.com/hiennguyen278610/metro/blob/main/src/main/java/org/metro/DAO/IBaseDAO.java"
    click SERV "https://github.com/hiennguyen278610/metro/tree/main/src/main/java/org/metro/service"
    click CONT "https://github.com/hiennguyen278610/metro/tree/main/src/main/java/org/metro/controller"
    click UIC "https://github.com/hiennguyen278610/metro/tree/main/src/main/java/org/metro/view/Component"
    click DIA "https://github.com/hiennguyen278610/metro/tree/main/src/main/java/org/metro/view/Dialog"
    click PAN "https://github.com/hiennguyen278610/metro/tree/main/src/main/java/org/metro/view/Panel"
    click UTIL "https://github.com/hiennguyen278610/metro/tree/main/src/main/java/org/metro/util"
    click MAIN "https://github.com/hiennguyen278610/metro/blob/main/src/main/java/org/metro/Main.java"

    %% Styles
    classDef presentation fill:#AED6F1,stroke:#000,stroke-width:2px;
    classDef business fill:#A9DFBF,stroke:#000,stroke-width:2px;
    classDef dao fill:#F9E79F,stroke:#000,stroke-width:2px;
    classDef database fill:#F5B7B1,stroke:#000,stroke-width:2px;
    classDef utility fill:#D2B4DE,stroke:#000,stroke-width:2px;
    classDef entrypoint fill:#FAD7A0,stroke:#000,stroke-width:2px;
```
