# loinguyenvan274/pbl_2 architecture

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

## Overview

##### Project Type & Purpose
- This is a C++ application built for managing dormitory (ký túc xá) operations.
- It is a standalone desktop application that includes both core business logic (dormitory, room, student management) and a graphical user interface.

##### File Structure
- Top-Level Files:
– Files like .gitignore, Makefile, README.md indicate version control and a build process via Makefile.
– Executable files (e.g., index.exe) and assets demonstrate that the build output is a desktop application.
- Data Directory:
– Contains several CSV and text files (e.g., sinhVien.csv, phong.csv) alongside C++ source files in a subfolder (“data”). These likely serve as data stores for dormitory, room, and student records.
- & Lib Directories:
– "include" has headers like raylib.h, and "lib" contains raylib libraries, suggesting the usage of Raylib as a graphical library.
- src Directory:
– Divided into two major subdirectories:
- app – Contains core logic such as dormitory management (QuanLyKTX), room management (Phong), student management (sinhVien), file I/O (docGhiFile), and utility classes like Vector and BangBam.
- gui – Contains all UI aspects such as various windows (giaoDien, cuaSoCon), dialogs (hop, hopChu), and other GUI components that manage the display and interaction (e.g., giaoDienChinh, quanLyGiaoDien).
- Build & Doc Directories:
– The build directory holds generated executables, and the doc directory contains notes, which might include design documentation or reminders.

##### Key Architectural Components
a. Frontend / GUI Components:
- “src/gui” folder which includes the user interface modules, windows, and dialogs.
- That these modules are responsible for interacting with the user and rendering graphical elements using Raylib.
b. Business Logic / Application Layer:
- “src/app” folder which encapsulates business operations like dormitory management (QuanLyKTX), room (Phong) administration, student (sinhVien) processing, file operations (docGhiFile), and other utility classes.
c. Data Layer:
- Components for reading/writing files to persist application state.
d. External Libraries & Build Tools:
- Acknowledge the use of Raylib (include and lib folders) for the graphic interface.
- A note about the Makefile that manages the build process.

##### Relationships and Interactions
- Business Logic interacting with the Data Layer for reading from CSVs and writing changes.
- Build process (Makefile) as a separate element that feeds into the creation of the executable which bundles together these components.

##### Detailed Architectural Patterns and Design Principles
- Separation of concerns is fundamental: distinct layers for GUI and application logic.
- Modular design: Each source component (e.g., SinhVien handling, Phong management) is designed as an independent module.
- Data abstraction: Although data is stored in files (CSV and txt), encapsulated file I/O modules provide abstraction.
- Reusable external libraries: Raylib is isolated as the rendering layer, keeping UI code separate from business operations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface (GUI)"
        GUI["User Interface (GUI)"]:::gui
    end

    subgraph "External Graphics Library"
        Raylib["Graphics Library (Raylib)"]:::raylib
    end

    subgraph "Application Layer"
        BusinessLogic["Business Logic / Application Core"]:::business
    end

    subgraph "Data Layer"
        DataManagement["Data Management"]:::data
    end

    subgraph "Build & Deployment"
        BuildSystem["Build System (Makefile)"]:::build
        Executable["Executable (index.exe)"]:::buildExe
    end

    %% Relationships
    GUI -->|"triggers"| BusinessLogic
    BusinessLogic -->|"persists"| DataManagement
    GUI -->|"rendersUsing"| Raylib
    BuildSystem -->|"builds"| Executable

    %% Click Events
    click GUI "https://github.com/loinguyenvan274/pbl_2/tree/main/src/gui/"
    click BusinessLogic "https://github.com/loinguyenvan274/pbl_2/tree/main/src/app/"
    click DataManagement "https://github.com/loinguyenvan274/pbl_2/tree/main/data/"
    click Raylib "https://github.com/loinguyenvan274/pbl_2/tree/main/include/"
    click BuildSystem "https://github.com/loinguyenvan274/pbl_2/tree/main/Makefile"
    click Executable "https://github.com/loinguyenvan274/pbl_2/tree/main/build/"

    %% Styles
    classDef gui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px,rx:10,ry:10;
    classDef business fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#B7950B,stroke-width:2px,stroke-dasharray: 5, 5;
    classDef raylib fill:#FAD7A0,stroke:#B9770E,stroke-width:2px,rx:5,ry:5;
    classDef build fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef buildExe fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
