# drekhai123/demo-capstone-project architecture

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

- Interactive diagram: https://gitdiagram.com/drekhai123/demo-capstone-project
- Repository: https://github.com/drekhai123/demo-capstone-project

## Overview

##### Project’s Purpose and Type
- EduSource_BE serves as the backend for an application that seems to manage accounts, authentications, orders, products, carts, and even book-related operations.
- It is a modern, containerized ASP.NET Core-based application (as evidenced by docker-compose files, Dockerfiles, and the .sln file) that follows clean or onion architecture principles.

- API Layer (Gateway):
- EduSource.API: This is the entry point and host for the web API.
- Middleware (such as ExceptionHandlingMiddleware) and configurations (e.g., SwaggerExtensions) should be shown as part of the API layer.
- Application Layer:
- EduSource.Application: Contains use case handlers, command and query processing (e.g., Commands for Accounts, Authentications, Orders, etc.).
- Pipeline behaviors like TransactionBehavior and ValidationPipelineBehavior indicate a layered request processing flow.
- Domain Layer:
- EduSource.Domain: Incorporates the business entities (Account, Book, Order, etc.), domain exceptions, and domain-specific logic.
- Contract Layer:
- EduSource.Contract: Provides abstractions (interfaces, DTOs, enumerations) that define the boundaries and contracts between the layers. Represent it as a shared component used by both the Application and Domain layers.
- Data Access / Persistence Layers:
- EduSource.Infrastructure.Dapper: Implements repository patterns using Dapper for data access.
- EduSource.Persistance: Implements data access using Entity Framework Core (with migrations, seed data, and a proper DbContext).
- Both repositories and UnitOfWork patterns (DPUnitOfWork, EFUnitOfWork) should be clearly indicated.
- Infrastructure Services:
- EduSource.Infrastructure provides concrete implementations for external concerns such as EmailService, GoogleOAuthService, MediaService, PaymentService, ResponseCacheService, and TokenGeneratorService.
- These implementations are consumed by the Application layer via abstractions defined in the Contract layer.
- Presentation Layer:
- EduSource.Presentation houses the API controllers (e.g., AccountController, AuthenticationController, etc.). Even though controllers often reside in the API project, here they are separated, which is an architectural decision worth noting.
- Testing:
- There is also an EduSource.Architecture.Tests project to handle architecture and unit tests, indicating an emphasis on verifying correct layering and dependencies.

- In the Application layer, illustrate that use case handlers interact with:
- The Domain layer for business logic.
- The Contract layer to communicate standardized messages (DTOs, commands, queries).
- That the Application layer then depends on persistence and infrastructure:
- The Contract layer should be shown in the center as a shared interface boundary, linking Application, Domain, and Infrastructure.

##### Architectural Patterns and Technologies
- Clean Architecture/Onion Architecture:
- The API/Presentation layer depends on the Application layer, which in turn depends on the Domain layer, with Infrastructure and Persistence implementations remaining external.
- Use of Dependency Injection across layers (evidenced by the extension methods in various DependencyInjection directories).
- Containerization with Docker (docker-compose.yml, Dockerfile), suggesting the application is designed for deployment in containerized environments.
- Technologies include ASP.NET Core, Entity Framework Core, Dapper, and external services for email, caching (Redis), payment processing, and third-party authentication.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% API Layer
    subgraph "API Layer"
        API["EduSource.API"]:::api
        MW["ExceptionHandlingMiddleware"]:::api_mw
        SW["SwaggerExtensions"]:::api_mw
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        PRES["EduSource.Presentation"]:::presentation
        CTRL["API Controllers (V1)"]:::presentation
    end

    %% Application Layer
    subgraph "Application Layer"
        APP["EduSource.Application"]:::app
        BEH["Pipeline Behaviors"]:::app
        UC["Use Cases"]:::app
    end

    %% Domain Layer
    subgraph "Domain Layer"
        DOM["EduSource.Domain"]:::domain
        ENT["Domain Entities"]:::domain
        DEX["Domain Exceptions"]:::domain
    end

    %% Contract Layer
    subgraph "Contract Layer"
        CTR["EduSource.Contract"]:::contract
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        DAP["Dapper Repositories & UOW"]:::persistence
        EF["EF Core Persistence"]:::persistence
    end

    %% Infrastructure Services
    subgraph "Infrastructure Services"
        INF["EduSource.Infrastructure"]:::infra
        DI["Dependency Injection"]:::infra
    end

    %% Configuration & Testing
    subgraph "Configuration & Testing"
        CONF["Configuration & Deployment"]:::config
        TESTS["Architecture & Unit Tests"]:::tests
    end

    %% Connections: API & Presentation
    API -->|"routesTo"| CTRL
    MW --- API
    SW --- API

    %% Presentation to Application
    CTRL -->|"calls"| UC

    %% Application Internal Connections
    APP --> BEH
    BEH --> UC

    %% Application to Domain & Contract
    UC -->|"businessLogic"| DOM
    UC -->|"uses"| CTR

    %% Domain Internal
    DOM --> ENT
    DOM --> DEX

    %% Application to Persistence
    UC -->|"dataAccess"| DAP
    UC -->|"dataAccess"| EF

    %% Application to Infrastructure
    UC -->|"externalServices"| INF

    %% Shared Contract Relations
    CTR --- DOM
    INF --- CTR

    %% Configuration influences API Layer
    CONF --> API
    CONF --> APP
    CONF --> INF

    %% Testing Sample Relations
    TESTS --> APP
    TESTS --> DOM

    %% Click Events
    click API "https://github.com/drekhai123/demo-capstone-project/blob/main/EduSource/src/EduSource.API"
    click MW "https://github.com/drekhai123/demo-capstone-project/blob/main/EduSource/src/EduSource.API/Middleware/ExceptionHandlingMiddleware.cs"
    click SW "https://github.com/drekhai123/demo-capstone-project/blob/main/EduSource/src/EduSource.API/DepedencyInjection/Extensions/SwaggerExtensions.cs"
    click APP "https://github.com/drekhai123/demo-capstone-project/blob/main/EduSource/src/EduSource.Application"
    click BEH "https://github.com/drekhai123/demo-capstone-project/tree/main/EduSource/src/EduSource.Application/Behaviors"
    click UC "https://github.com/drekhai123/demo-capstone-project/tree/main/EduSource/src/EduSource.Application/UseCases"
    click DOM "https://github.com/drekhai123/demo-capstone-project/blob/main/EduSource/src/EduSource.Domain"
    click ENT "https://github.com/drekhai123/demo-capstone-project/tree/main/EduSource/src/EduSource.Domain/Entities"
    click DEX "https://github.com/drekhai123/demo-capstone-project/tree/main/EduSource/src/EduSource.Domain/Exceptions"
    click CTR "https://github.com/drekhai123/demo-capstone-project/blob/main/EduSource/src/EduSource.Contract"
    click DAP "https://github.com/drekhai123/demo-capstone-project/blob/main/EduSource/src/EduSource.Infrastructure.Dapper"
    click EF "https://github.com/drekhai123/demo-capstone-project/blob/main/EduSource/src/EduSource.Persistance"
    click INF "https://github.com/drekhai123/demo-capstone-project/blob/main/EduSource/src/EduSource.Infrastructure"
    click DI "https://github.com/drekhai123/demo-capstone-project/tree/main/EduSource/src/EduSource.Infrastructure/DependencyInjection"
    click PRES "https://github.com/drekhai123/demo-capstone-project/blob/main/EduSource/src/EduSource.Presentation"
    click CTRL "https://github.com/drekhai123/demo-capstone-project/tree/main/EduSource/src/EduSource.Presentation/Controller/V1"
    click TESTS "https://github.com/drekhai123/demo-capstone-project/blob/main/EduSource/test/EduSource.Architecture.Tests"

    %% Styles
    classDef api fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef api_mw fill:#b0e0e6,stroke:#000,stroke-width:2px;
    classDef presentation fill:#dda0dd,stroke:#000,stroke-width:2px;
    classDef app fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef domain fill:#ffdab9,stroke:#000,stroke-width:2px;
    classDef contract fill:#d3d3d3,stroke:#000,stroke-width:2px;
    classDef persistence fill:#ffcccb,stroke:#000,stroke-width:2px;
    classDef infra fill:#f0e68c,stroke:#000,stroke-width:2px;
    classDef config fill:#ffffe0,stroke:#000,stroke-width:2px;
    classDef tests fill:#ffc0cb,stroke:#000,stroke-width:2px;
```
