# 2thuancr/fashionshopmanagement architecture

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

- Interactive diagram: https://gitdiagram.com/2thuancr/fashionshopmanagement
- Repository: https://github.com/2thuancr/fashionshopmanagement

## Overview

##### Main Components
- API Layer: In the “API” folder, you have an ASP.NET (or similar) web service exposing endpoints via controllers (AccountController, AuthController, etc.) for RESTful interactions.
- GUI (Presentation Layer): Under the “GUI” folder, there is a Windows Forms desktop application with multiple forms (fLogin, fHome, fDonHang, etc.) that serves as the main user interface.
- Business Layer: The “ServiceBUS” folder contains business logic classes (AccountBUS, BillBUS, etc.) that encapsulate the core rules and processes.
- Data Access Layer: The “RepositoryDAO” folder implements data access objects (DAO) that communicate directly with the database.
- DTO Layer: The “DTO” folder holds data transfer objects used to communicate data across layers.
- Shared Utilities: Under the “Shared” folder, there are common helper classes (Logger, MailHelper, Converter, etc.) that provide cross-cutting functions.
- Database: The “Database” folder includes the database backup files, SQL scripts, ERD image, stored procedures, triggers, and functions that define the persistence layer.

##### Relationships Between Components
- The GUI and API layers act as the two frontends. The GUI will interact with the ServiceBUS (business layer) via the RepositoryDAO (data access layer) or may consume data through DTO objects.
- The API layer provides services (likely RESTful) that encapsulate business logic operations. It too will interact with the ServiceBUS and then the RepositoryDAO.
- Both the ServiceBUS and RepositoryDAO layers work together: the ServiceBUS processes business rules and uses the RepositoryDAO to perform data operations.
- DTOs facilitate communication between these layers, ensuring that data models are consistent and decoupled from underlying database schemas.
- The Shared library supports all these layers with common functionality such as logging, email operations, and data conversions.
- The Database is the persistent storage component, and its structure is detailed by the ERD provided in the README.

##### Key Architectural Patterns & Principles
- Layered Architecture: The clear separation into Presentation (GUI/API), Business, Data Access, and Model (DTO) layers.
- MVC-like Pattern in API: Controllers in API indicate an MVC pattern, where command routing and handling are clearly defined.
- Separation of Concerns: Each layer focuses on a distinct responsibility, making the system modular and maintainable.
- Utilization of shared utilities to avoid redundancy and foster reuse.

##### Additional Elements
- Optionally, you may add annotations near the database part to call out the existence of triggers, stored procedures, and functions that enforce business rules at the persistence level.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        GUI["GUI (Windows Forms Client)"]:::frontend
        API["API (RESTful Service)"]:::frontend
    end

    %% Application Layer (Business and Data Access)
    subgraph "Application Layer"
        BUS["Business Layer (ServiceBUS)"]:::business
        DAO["Data Access (RepositoryDAO)"]:::dataaccess
        DTO["Data Transfer Objects (DTO)"]:::dto
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        DB["Database (SQL Server)"]:::database
        Shared["Shared Utilities"]:::shared
    end

    %% Data Flow Connections
    GUI -->|"calls"| BUS
    API -->|"calls"| BUS
    BUS -->|"invokes"| DAO
    BUS -->|"transfersDataVia"| DTO
    DAO -->|"performsCRUDOn"| DB

    %% Shared Utilities Integration (dashed lines)
    GUI -.->|"uses"| Shared
    API -.->|"uses"| Shared
    BUS -.->|"uses"| Shared
    DAO -.->|"uses"| Shared
    DTO -.->|"uses"| Shared

    %% Click Events
    click API "https://github.com/2thuancr/fashionshopmanagement/tree/main/API/Controllers"
    click GUI "https://github.com/2thuancr/fashionshopmanagement/tree/main/GUI"
    click BUS "https://github.com/2thuancr/fashionshopmanagement/tree/main/ServiceBUS"
    click DAO "https://github.com/2thuancr/fashionshopmanagement/tree/main/RepositoryDAO"
    click DTO "https://github.com/2thuancr/fashionshopmanagement/tree/main/DTO"
    click Shared "https://github.com/2thuancr/fashionshopmanagement/tree/main/Shared"
    click DB "https://github.com/2thuancr/fashionshopmanagement/tree/main/Database"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef business fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef dataaccess fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef dto fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef shared fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
