# hieuanh87/api-phan-loai architecture

> Architecture diagram of the GitHub repository hieuanh87/api-phan-loai, 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/hieuanh87/api-phan-loai
- Repository: https://github.com/hieuanh87/api-phan-loai

## Overview

##### Main Components
- Data Sources:
- CSV files (123.csv, data.csv, dataset.csv)
- Data Ingestion and Preprocessing:
- data_loader.py (responsible for loading and preparing dataset)
- arguments.py (for configuring the run/training; likely capturing command-line parameters)
- utils.py (holds various helper functions)
- Model Training Component:
- train.py (script to train the text classification model)
- training_args.bin (stores training configuration or model state)
- Likely coupled with the Phobert model and its underlying dependencies (as indicated in the README)
- Application / Inference Component:
- app.py and app1.py (serve as application entry points – possibly for running predictions or demos)
- run.py (may orchestrate the execution flow for either training or inference)
- Data Persistence / External Integration:
- import db.py (manages interactions with a database or external store)
- Dependencies Management:
- requirements.txt (lists the Python packages and libraries used – such as those for machine learning or NLP)

##### Relationships and Interactions
- Once data is prepared, it is handed off to the Model Training component (train.py), which uses training_args.bin for any saved configurations or state.
- The Application/Inference components (app.py, app1.py, run.py) likely use the trained model for making predictions on new data.
- The utility modules (arguments.py, utils.py) support both the training and application components.
- The import db.py module, if used, can be placed as an external system or service interacting with the application, indicating data persistence or external logging.

##### Architectural Patterns or Design Principles
- Separation of Concerns: Each file is dedicated to a specific purpose (data loading, training, application interfacing, database interaction), which promotes modularity.
- Layered Architecture:
- Data Layer (CSV inputs, db module)
- Processing/Preprocessing Layer (data_loader, utils, arguments)
- Model Layer (train.py, training_args.bin, Phobert integration)
- Application Layer (app.py, app1.py, run.py)
- Reusability and Extensibility: Modular files allow isolated testing and independent development.

##### Relevant Technologies
- Python as the core language.
- Phobert (a Phonetics-adapted variation of BERT for text classification).
- Potential libraries for NLP and deep learning (as indicated in requirements.txt).
- If present, any database systems managed via import db.py.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Layer
    subgraph "Data Layer"
        CSV1["123.csv"]:::data
        CSV2["data.csv"]:::data
        CSV3["dataset.csv"]:::data
    end

    %% Data Ingestion and Preprocessing Layer
    subgraph "Data Ingestion and Preprocessing"
        DL["data_loader.py"]:::processing
        ARG["arguments.py"]:::processing
        UT["utils.py"]:::processing
    end

    %% Model Training Component
    subgraph "Model Training"
        TR["train.py"]:::model
        TA["training_args.bin"]:::model
        PB["Phobert Model"]:::model
    end

    %% Application / Inference Component
    subgraph "Application / Inference"
        AP["app.py"]:::app
        AP1["app1.py"]:::app
        RUN["run.py"]:::app
    end

    %% External Integration (Database)
    DB["db.py"]:::external

    %% Dependencies Management
    REQ["requirements.txt"]:::deps

    %% Connections from Data Layer to Preprocessing
    CSV1 --> DL
    CSV2 --> DL
    CSV3 --> DL

    %% Support modules connect to Data Loader and Training
    ARG --> DL
    UT --> DL
    ARG --> TR
    UT --> TR

    %% Preprocessing to Model Training
    DL --> TR
    TR --> TA
    TR --> PB

    %% Model output served to Application layer
    PB --> AP
    PB --> AP1
    PB --> RUN

    %% Application layer interacts with external DB for persistence
    AP --> DB
    AP1 --> DB
    RUN --> DB

    %% Dependencies support Model Training and Application
    REQ --> TR
    REQ --> AP

    %% Click Events
    click CSV1 "https://github.com/hieuanh87/api-phan-loai/blob/master/123.csv"
    click CSV2 "https://github.com/hieuanh87/api-phan-loai/blob/master/data.csv"
    click CSV3 "https://github.com/hieuanh87/api-phan-loai/blob/master/dataset.csv"
    click DL "https://github.com/hieuanh87/api-phan-loai/blob/master/data_loader.py"
    click ARG "https://github.com/hieuanh87/api-phan-loai/blob/master/arguments.py"
    click UT "https://github.com/hieuanh87/api-phan-loai/blob/master/utils.py"
    click TR "https://github.com/hieuanh87/api-phan-loai/blob/master/train.py"
    click TA "https://github.com/hieuanh87/api-phan-loai/blob/master/training_args.bin"
    click AP "https://github.com/hieuanh87/api-phan-loai/blob/master/app.py"
    click AP1 "https://github.com/hieuanh87/api-phan-loai/blob/master/app1.py"
    click RUN "https://github.com/hieuanh87/api-phan-loai/blob/master/run.py"
    click DB "https://github.com/hieuanh87/api-phan-loai/blob/master/db.py"
    click REQ "https://github.com/hieuanh87/api-phan-loai/blob/master/requirements.txt"

    %% Styles
    classDef data fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef processing fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef model fill:#FFFF99,stroke:#000,stroke-width:1px;
    classDef app fill:#F08080,stroke:#000,stroke-width:1px;
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px;
    classDef deps fill:#FFB6C1,stroke:#000,stroke-width:1px;
```
