# duchai46/repo_nha_hang_com_ga_be architecture

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

- Interactive diagram: https://gitdiagram.com/duchai46/repo_nha_hang_com_ga_be
- Repository: https://github.com/duchai46/repo_nha_hang_com_ga_be

## Overview

##### Main Components
- Client/Consumer: Represent any client (web/mobile app, Postman, etc.) sending HTTP requests.
- API Gateway / Entry Point: This is represented by Program.cs which sets up the web host and initializes the middleware.
- Mapping/Service Layer: Although there isn’t a distinct “Service” folder, you have files like MappingProfile.cs and MongoDbServiceExtensions.cs in the Models/Common/Services folder. Represent these as light service utilities that translate between incoming requests and business models.
- Repository Layer: Show the interface definitions (e.g., IBanRepository, IComboRepository) along with their implementations (under Repository/Imp). This abstract layer encapsulates all data access logic.

##### Relationships and Interactions
- Optionally, show a connection between the Mapping/Service components and the Controllers and/or Repositories, reflecting object transformation (e.g., DTO mapping).
- Configuration dependencies (from docker-compose, appsettings.json) to both the application server and the MongoDB component.

##### Architectural Patterns and Design Principles
- Layered architecture – MVC-like separation with Controllers (Presentation), Repositories (Data Access), and Models (Domain Objects).
- Repository Pattern which decouples the business logic from direct database interaction.
- Point out the use of Dependency Injection, which is common in .NET projects, and is facilitated by MappingProfile and Service Extensions.
- That Docker integration indicates a containerized deployment approach.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client/Consumer"]:::external
    APIGateway["API Gateway/Entry Point"]:::api
    Controllers["Controllers Layer"]:::controllers
    MappingService["Mapping/Service Utilities"]:::service
    RepoInterface["Repository Interfaces"]:::repo
    RepoImpl["Repository Implementations"]:::repo
    MongoModels["MongoDB Models"]:::db
    MongoSettings["MongoDB Settings"]:::db
    Dockerfile["Dockerfile"]:::deployment
    DockerCompose["Docker Compose Configuration"]:::deployment

    Client -->|"HTTP_Request"| APIGateway
    APIGateway -->|"Routes_Request"| Controllers
    Controllers -->|"Calls_Repository"| RepoInterface
    Controllers -->|"DTO_Mapping"| MappingService
    MappingService -->|"Transforms_Data"| RepoInterface
    RepoInterface -->|"Implemented_by"| RepoImpl
    RepoImpl -->|"CRUD_Operations"| MongoModels
    RepoImpl -->|"Uses_Settings"| MongoSettings
    DockerCompose -->|"Configures"| APIGateway
    DockerCompose -->|"Configures"| MongoModels
    Dockerfile -->|"Builds_Deploys"| APIGateway

    classDef external fill:#c2f0c2,stroke:#333,stroke-width:2px;
    classDef api fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef controllers fill:#aed6f1,stroke:#333,stroke-width:2px;
    classDef service fill:#d7bde2,stroke:#333,stroke-width:2px;
    classDef repo fill:#f5cba7,stroke:#333,stroke-width:2px;
    classDef db fill:#d5f5e3,stroke:#333,stroke-width:2px;
    classDef deployment fill:#f9ebea,stroke:#333,stroke-width:2px;

    click APIGateway "https://github.com/duchai46/repo_nha_hang_com_ga_be/blob/main/repo_nha_hang_com_ga_BE/Program.cs"
    click Controllers "https://github.com/duchai46/repo_nha_hang_com_ga_be/tree/main/repo_nha_hang_com_ga_BE/Controllers"
    click MappingService "https://github.com/duchai46/repo_nha_hang_com_ga_be/tree/main/repo_nha_hang_com_ga_BE/Models/Common/Services"
    click RepoInterface "https://github.com/duchai46/repo_nha_hang_com_ga_be/tree/main/repo_nha_hang_com_ga_BE/Repository"
    click RepoImpl "https://github.com/duchai46/repo_nha_hang_com_ga_be/tree/main/repo_nha_hang_com_ga_BE/Repository/Imp"
    click MongoModels "https://github.com/duchai46/repo_nha_hang_com_ga_be/tree/main/repo_nha_hang_com_ga_BE/Models/MongoDB"
    click MongoSettings "https://github.com/duchai46/repo_nha_hang_com_ga_be/blob/main/repo_nha_hang_com_ga_BE/Models/Common/Models/MongoDbSettings.cs"
    click Dockerfile "https://github.com/duchai46/repo_nha_hang_com_ga_be/tree/main/Dockerfile"
    click DockerCompose "https://github.com/duchai46/repo_nha_hang_com_ga_be/blob/main/docker-compose.yml"
```
