# uitxmic/-nt208.p23.antt-group-3 architecture

> Architecture diagram of the GitHub repository uitxmic/-nt208.p23.antt-group-3, 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/uitxmic/-nt208.p23.antt-group-3
- Repository: https://github.com/uitxmic/-nt208.p23.antt-group-3

## Overview

##### Main Components Identification
- Frontend: The FrontEnd folder highlights a React.js application (note files such as index.html, main.jsx, and App.jsx), utilizing Tailwind CSS for UI/UX.
- Backend: The BackEnd folder comprises files for a Node.js (Express.js) API server. It includes controllers (NotificationController, PostingController, TradeController, UsersController, VoucherController), routes, middleware (authMiddleware), configuration (viewEngine), and an environment file (.env).
- Database: The README indicates MySQL is used for data storage. The existence of various SQL procedure files (found in BackEnd/PROD.SQL.PROCEDURES) illustrates the use of stored procedures for key functionalities like voucher creation, user creation, and transaction handling.
- External/Supporting Components: Consider including external services (such as potential blockchain-based security features mentioned under “Tính năng mở rộng”) as future expansion elements.

##### Relationships and Interactions
- Backend Workflows: Within the Backend, illustrate how the route layer directs API requests to the appropriate controller, which in turn invokes business logic. Middleware (e.g., authMiddleware) should be shown as intercepting requests to secure endpoints.
- Database Integration: Show that the backend communicates with the MySQL database to execute SQL procedures for creating and updating voucher/user records. This should also include error-handling and transaction commit/rollback flows.
- Optional Future Components: Add a note or component that hints at future enhancements like blockchain integration for securing transactions or AI modules for voucher recommendations.

##### Architectural Patterns and Design Principles
- MVC Pattern: Highlight that the backend is designed along an MVC-like pattern. Controllers manage HTTP request processing, routes define endpoints, and SQL procedures encapsulate the core database logic.
- Separation of Concerns: Emphasize the clear split between the frontend (presentation layer), backend (API and business logic layer), and data layer (MySQL database).
- Modular Layout: The directory structure reflects a modular design (distinct directories for controllers, routes, middlewares, and views), making it easier to map out the system.

##### Relevant Technologies and Frameworks
- Backend: Node.js, Express.js, and MySQL, along with stored procedures for efficient database operations.
- Frontend: React.js with Tailwind CSS for a modern and responsive UI, leveraging Vite as the build tool.
- Others: Environment configuration (.env), ESLint for code quality, and package management via npm.

## Diagram (Mermaid)

```mermaid
graph TD

    %% Client Layer
    subgraph "Client Layer (Frontend)"
        FE["React Application (VoucherHub UI)"]:::frontend
    end

    %% Server Layer
    subgraph "Server Layer (Backend)"
        API["API Server (Express.js)"]:::backend

        subgraph "Routes"
            ROUTES["HTTP Endpoints (notification, posting, trade, users, voucher)"]:::backend
        end

        subgraph "Controllers"
            CTLS["Controllers (Notification, Posting, Trade, Users, Voucher)"]:::backend
        end

        subgraph "Middlewares"
            MW["Auth Middleware"]:::middleware
        end

        subgraph "Configuration"
            CONFIG["View Engine Config"]:::configuration
            ENV["Environment (.env)"]:::configuration
        end
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["MySQL Database"]:::database
        SQL["SQL Procedures"]:::database
    end

    %% Data Flow Connections
    FE -->|"HTTP_Request_Response"| API
    API -->|"Routes_Forwarding"| ROUTES
    API -->|"Invokes"| CTLS
    API -->|"Applies"| MW
    API -->|"Uses_Config"| CONFIG
    API -->|"Uses_Env"| ENV
    CTLS -->|"DB_Operations"| SQL
    SQL -->|"Commits/Queries"| DB
    API -.->|"Future:Blockchain/AI"| DB

    %% Click Events
    click FE "https://github.com/uitxmic/-nt208.p23.antt-group-3/tree/main/FrontEnd/"
    click API "https://github.com/uitxmic/-nt208.p23.antt-group-3/blob/main/BackEnd/server.js"
    click CTLS "https://github.com/uitxmic/-nt208.p23.antt-group-3/tree/main/BackEnd/controllers/"
    click ROUTES "https://github.com/uitxmic/-nt208.p23.antt-group-3/tree/main/BackEnd/routes/"
    click MW "https://github.com/uitxmic/-nt208.p23.antt-group-3/blob/main/BackEnd/middlewares/authMiddleware.js"
    click SQL "https://github.com/uitxmic/-nt208.p23.antt-group-3/tree/main/BackEnd/PROD.SQL.PROCEDURES/"
    click CONFIG "https://github.com/uitxmic/-nt208.p23.antt-group-3/blob/main/BackEnd/config/viewEngine.js"
    click ENV "https://github.com/uitxmic/-nt208.p23.antt-group-3/blob/main/BackEnd/.env"

    %% Style Classes
    classDef frontend fill:#8ecae6,stroke:#023047,stroke-width:2px;
    classDef backend fill:#219ebc,stroke:#023047,stroke-width:2px;
    classDef middleware fill:#ffb703,stroke:#d90429,stroke-width:2px;
    classDef configuration fill:#fff3b0,stroke:#ffb703,stroke-width:2px;
    classDef database fill:#ffddd2,stroke:#d90429,stroke-width:2px;
```
