# maleknoureddine/schoolprojectcleanarchitecture architecture

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

- Interactive diagram: https://gitdiagram.com/maleknoureddine/schoolprojectcleanarchitecture
- Repository: https://github.com/maleknoureddine/schoolprojectcleanarchitecture

## Overview

##### High-Level Architecture Components

**┌─ API Layer (Presentation)**
- Core Layer (Application)
- Service Layer (Business)
- Infrastructure Layer
- Data Layer

##### Detailed Component Breakdown

a) API Layer (Top):
- Middleware components (ErrorHandler)
- Base controller setup

b) Core Layer:
- Create sections for:
- Features (Commands/Queries)
- Behaviors (Validation)
- Mapping profiles
- Response handlers
- Shared resources

c) Service Layer:
- Service interfaces and implementations
- CurrentUserService
- Email service

d) Infrastructure Layer:
- DbContext
- Repositories
- Configurations
- Data seeders

e) Data Layer (Bottom):
- Entity models
- DTOs/Requests/Responses
- Enums
- Helper classes

##### Component Relationships

**→ Direct dependencies**
**⇢ Data flow**
**⇄ Two-way communication**

##### Special Elements

Create dedicated sections for:
**┌─ Authentication/Authorization Flow**
- CQRS Pattern Implementation
- MediatR Request Handling
- Entity Relationships

##### Implementation Details

**┌─ Technologies**
- .NET 7
- Entity Framework Core
- JWT Authentication
- MediatR
- Fluent Validation
- SQL Server

##### Key Patterns

Architectural patterns:
- CQRS separation
- Repository pattern
- Mediator pattern
- Unit of Work

##### Cross-Cutting Concerns

Horizontal layers for:
- Validation
- Authentication
- Authorization
- Error handling
- Localization

##### Data Flow

Typical request flow:
**Client → API → MediatR → Handler → Service → Repository → Database**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph API
        Controllers["Controllers"]:::api
        ErrorHandler["Error Handler"]:::middleware
        BaseController["Base Controller"]:::api
    end

    subgraph Core
        Features["Features"]:::core
        Behaviors["Behaviors"]:::core
        Mapping["Mapping Profiles"]:::core
        ResponseHandlers["Response Handlers"]:::core
        SharedRes["Shared Resources"]:::core
        
        subgraph CQRS
            Commands["Commands"]:::cqrs
            Queries["Queries"]:::cqrs
        end
        
        subgraph Auth
            Authentication["Authentication"]:::auth
            Authorization["Authorization"]:::auth
        end
    end

    subgraph Services
        ServiceInterfaces["Service Interfaces"]:::service
        ServiceImpl["Service Implementations"]:::service
        UserService["Current User Service"]:::service
        EmailService["Email Service"]:::service
    end

    subgraph Infrastructure
        DbContext["DbContext"]:::infra
        Repositories["Repositories"]:::infra
        Configs["Configurations"]:::infra
        Seeders["Data Seeders"]:::infra
    end

    subgraph Data
        Entities["Entity Models"]:::data
        DTOs["DTOs/Requests/Responses"]:::data
        Enums["Enums"]:::data
        Helpers["Helper Classes"]:::data
    end

    %% Relationships
    Controllers --> Features
    Features --> ServiceInterfaces
    ServiceInterfaces --> ServiceImpl
    ServiceImpl --> Repositories
    Repositories --> DbContext
    DbContext --> Entities
    Features --> Commands & Queries
    Controllers --> ErrorHandler
    Controllers --> Authentication
    Authentication --> Authorization
    EmailService --> ServiceImpl
    Behaviors --> Features
    Mapping --> Features

    %% Click Events
    click Controllers "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/tree/master/SchoolProjectCleanArchitecture.Api/Controllers"
    click Features "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/tree/master/CleanArchProject.Core/Featurs"
    click ServiceImpl "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/tree/master/CleanArchProject.Service/ServicesImplementation"
    click Infrastructure "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/blob/master/CleanArchProject.Infrastracture"
    click Entities "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/tree/master/CleanArchProject.Data/Entities"
    click Authentication "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/tree/master/CleanArchProject.Core/Featurs/Authentication"
    click Authorization "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/tree/master/CleanArchProject.Core/Featurs/Authorization"
    click ErrorHandler "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/blob/master/CleanArchProject.Core/MiddleWares/ErrorHandlerMiddleWare.cs"
    click EmailService "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/tree/master/CleanArchProject.Core/Featurs/Email"
    click Commands "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/tree/master/CleanArchProject.Core/Featurs/*/Commands"
    click Queries "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/tree/master/CleanArchProject.Core/Featurs/*/Queries"
    click Behaviors "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/blob/master/CleanArchProject.Core/Behavior/ValidationBehavior.cs"
    click Repositories "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/tree/master/CleanArchProject.Infrastracture/InfrastractureBases_(generics)"
    click DbContext "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/blob/master/CleanArchProject.Infrastracture/Data/AppDbContext.cs"
    click Mapping "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/tree/master/CleanArchProject.Core/Mapping"
    click SharedRes "https://github.com/MalekNoureddine/SchoolProjectCleanArchitecture/tree/master/CleanArchProject.Core/SharedResources"

    %% Styles
    classDef api fill:#2374ab
    classDef core fill:#48a9a6
    classDef service fill:#4ad66d
    classDef infra fill:#e4b363
    classDef data fill:#c1666b
    classDef auth fill:#9b4dca
    classDef middleware fill:#848fa5
    classDef cqrs fill:#4a90e2

    %% Legend
    subgraph Legend
        API_L["API Layer"]:::api
        Core_L["Core Layer"]:::core
        Service_L["Service Layer"]:::service
        Infra_L["Infrastructure Layer"]:::infra
        Data_L["Data Layer"]:::data
        Auth_L["Auth Components"]:::auth
        Mid_L["Middleware"]:::middleware
        CQRS_L["CQRS Components"]:::cqrs
    end
```
