# dnsportcapstone/dnsport-be architecture

> Architecture diagram of the GitHub repository dnsportcapstone/dnsport-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/dnsportcapstone/dnsport-be
- Repository: https://github.com/dnsportcapstone/dnsport-be

## Overview

##### Main Components
- Presentation Layer: Represented by the “Presentation” directory. It contains controllers (e.g., AdminController, BookingController, AuthenticationController, etc.) and configuration files (Program.cs, appsettings.json). This layer acts as the API gateway of your system.
- Business Object Layer: Found in the “BusinessObject” folder, this part encapsulates domain models (like User, Payment, Booking, Field, etc.) that represent core business entities.
- Data Access Layer: Split across sub-components:
- Data Access Logic & Helpers: The “DataAccess” directory contains Common components (Helper), DAOs (BookingDAO, StadiumDAO, etc.), and Mappers (ApplicationMapper).
- DTOs: Both Request and Response DTOs are included, ensuring a clear separation between the internal models and the exposed API contracts.
- Repositories: You have both interfaces and implementations (for Booking, User, etc.) showing a repository pattern to manage persistence.
- Services: This part abstracts and implements business processes such as AuthService, BookingService, CloudinaryService, GoMapsService, among others. These services contain the logic to interact with the repositories and handle domain-specific operations.
- External Services and Utilities: Though not explicitly separated, note that services like CloudinaryService, GoMapsService, and SendMailService indicate integration with third-party services.

##### Relationships and Interactions
- The Presentation Layer (controllers) acts as the entry point. Controllers receive client requests and then interact with the business logic.
- The DAO and Mapper components assist with the translations between business objects (BusinessObject) and data representations (DTOs/Models).

##### Architectural Patterns and Design Principles
- Repository Pattern: Emphasize the repository interfaces and their implementations, showing dependency inversion where controllers call services which in turn call repositories.
- DTOs and Mappers: Show how data is transferred between layers using DTOs (Request and Response objects) and converted by Mappers.
- Service Abstraction: The presence of service interfaces and their corresponding implementations strengthens modular design.
- Use of Domain-Driven Design: The “BusinessObject” folder with rich domain models indicates that the domain is core to the system's design.

##### Final Touches
- Multiple controllers and API endpoints,
- All repositories and services,
- Domain models that capture business logic,
- Supporting third-party integrations/services.
- Avoid oversimplification; be as detailed as possible to capture every significant component shown in the file tree.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Presentation Layer
    subgraph "Presentation Layer"
        P1["Controllers"]:::presentation
        P2["Program.cs"]:::presentation
        P3["appsettings.json"]:::presentation
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DA1["DAO"]:::dataaccess
        DA2["DTOs"]:::dataaccess
        DA3["Repository Interfaces"]:::dataaccess
        DA4["Repository Implementations"]:::dataaccess
        DA5["Application Mapper"]:::dataaccess
        DA6["Services Interfaces"]:::dataaccess
        DA7["Services Implementations"]:::dataaccess
    end

    %% Business Layer
    subgraph "Business Layer"
        B1["Domain Models"]:::business
    end

    %% External Integrations
    subgraph "External Integrations"
        EX1["Cloudinary"]:::external
        EX2["GoMaps"]:::external
        EX3["SendMail"]:::external
        EX4["Vnpay"]:::external
    end

    %% Connections between layers
    P1 -->|"calls"| DA7
    DA7 -->|"calls_DAO"| DA1
    DA7 -->|"calls_Repository"| DA3
    DA7 -->|"calls_Repository"| DA4
    DA7 -->|"maps"| DA5
    DA7 -->|"transforms"| DA2
    DA7 -->|"calls"| EX1
    DA7 -->|"calls"| EX2
    DA7 -->|"calls"| EX3
    DA7 -->|"calls"| EX4

    DA1 -->|"manages"| B1
    DA3 -->|"queries"| B1
    DA4 -->|"persists"| B1

    %% Click Events for Presentation Layer
    click P1 "https://github.com/dnsportcapstone/dnsport-be/tree/main/Presentation/Controllers"
    click P2 "https://github.com/dnsportcapstone/dnsport-be/blob/main/Presentation/Program.cs"
    click P3 "https://github.com/dnsportcapstone/dnsport-be/blob/main/Presentation/appsettings.json"

    %% Click Events for Data Access Layer
    click DA1 "https://github.com/dnsportcapstone/dnsport-be/tree/main/DataAccess/DAO"
    click DA2 "https://github.com/dnsportcapstone/dnsport-be/tree/main/DataAccess/DTOs"
    click DA3 "https://github.com/dnsportcapstone/dnsport-be/tree/main/DataAccess/Repositories/Interfaces"
    click DA4 "https://github.com/dnsportcapstone/dnsport-be/tree/main/DataAccess/Repositories/Implement"
    click DA5 "https://github.com/dnsportcapstone/dnsport-be/blob/main/DataAccess/Mapper/ApplicationMapper.cs"
    click DA6 "https://github.com/dnsportcapstone/dnsport-be/tree/main/DataAccess/Services/Interfaces"
    click DA7 "https://github.com/dnsportcapstone/dnsport-be/tree/main/DataAccess/Services/Implement"

    %% Click Event for Business Layer
    click B1 "https://github.com/dnsportcapstone/dnsport-be/tree/main/BusinessObject/Models"

    %% Click Events for External Integrations
    click EX1 "https://github.com/dnsportcapstone/dnsport-be/blob/main/DataAccess/Services/Implement/CloudinaryService.cs"
    click EX2 "https://github.com/dnsportcapstone/dnsport-be/blob/main/DataAccess/Services/Implement/GoMapsService.cs"
    click EX3 "https://github.com/dnsportcapstone/dnsport-be/blob/main/DataAccess/Services/Implement/SendMailService.cs"
    click EX4 "https://github.com/dnsportcapstone/dnsport-be/blob/main/DataAccess/Services/Implement/VnpayPayment.cs"

    %% Styles
    classDef presentation fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef business fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef dataaccess fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef external fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
```
