# mahammadpiriyev/school-management architecture

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

- Interactive diagram: https://gitdiagram.com/mahammadpiriyev/school-management
- Repository: https://github.com/mahammadpiriyev/school-management

## Overview

##### Project Type and Purpose
- This is a full-stack ASP.NET Core MVC web application (School Management System) with a layered architecture:
- Presentation layer (“School” project) using Razor Views, Controllers, and static assets.
- Business logic layer (“School.Business”) with service interfaces and implementations.
- Data access layer (“School.DataAccess”) using Entity Framework Core, Repository and Unit of Work patterns.
- Domain model layer (“School.Entities”) describing core entities and ViewModels.
- Utility layer (“School.Utility”) for cross-cutting concerns (e.g., email sending).

##### Main Architectural Components
a. Client/browser (Web UI)
b. ASP.NET Core MVC Web App
- Controllers (Areas: Admin, Customer, Identity)
- Views & Razor Pages
- Static assets (wwwroot: CSS, JS, images)
c. Business Layer (“School.Business”)
- IStudentService, ITeacherService interfaces
- StudentService, TeacherService implementations
d. Data Access Layer (“School.DataAccess”)
- ApplicationDbContext (EF Core)
- Repository abstractions (IBaseRepository<T>, IUnitOfWork) and concrete repositories
- EF Migrations
e. Domain Models & ViewModels (“School.Entities”)
- Entities (Student, Teacher, Class, Department, Exam, Mark, ApplicationUser)
- ViewModels for dashboard and CRUD UIs
f. Database (MS SQL Server)
g. External services (e.g., SMTP via EmailSender in School.Utility)

##### Relationships & Data Flows
1. User → Browser → HTTP Request → MVC Controller
2. Controller calls Business Service (IStudentService, ITeacherService, etc.)
3. Business Service orchestrates domain logic, then calls Data Access layer (UnitOfWork, Repositories)
4. Repository uses Entity Framework DbContext to query/update the SQL Server database
5. Results bubble back: Repository → Service → Controller → View → User’s browser
6. Utility EmailSender invoked by Services for notifications

##### Architectural Patterns & Design Principles
- Layered Architecture (Presentation → Business → Data Access → Persistence)
- Dependency Injection (services and repositories injected into controllers)
- Repository + Unit of Work patterns abstracting EF Core
- Separation of Concerns: distinct projects for domain models, business logic, data access, utilities, and presentation
- ASP.NET Identity for authentication/authorization (in Areas/Identity)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    client["Browser"]:::ui
    subgraph "Presentation Layer (School)"
        controllers["Controllers\n(Admin, Customer, Identity)"]:::ui
        views["Views & Razor Pages"]:::ui
        static["Static Assets (wwwroot)"]:::ui
    end

    %% Business Layer
    subgraph "Business Layer (School.Business)"
        SvcInt1["IStudentService"]:::biz
        SvcInt2["ITeacherService"]:::biz
        SvcImpl1["StudentService"]:::biz
        SvcImpl2["TeacherService"]:::biz
    end

    %% Domain Model Layer
    subgraph "Domain Model (School.Entities)"
        entities["Entities & ViewModels"]:::domain
    end

    %% Data Access Layer
    subgraph "Data Access Layer (School.DataAccess)"
        uow["IUnitOfWork"]:::data
        repo["Repositories\n(IBaseRepository & Entity Repos)"]:::data
        dbcontext["ApplicationDbContext\n(EF Core)"]:::data
        migrations["EF Migrations"]:::data
    end

    %% Persistence & External
    db[(SQL Server)]:::db
    smtp[(SMTP Email Service)]:::external

    %% Data Flows
    client -->|"HTTP Request"| controllers
    controllers -->|"calls via DI"| SvcImpl1
    controllers -->|"calls via DI"| SvcImpl2
    SvcImpl1 -->|"implements"| SvcInt1
    SvcImpl2 -->|"implements"| SvcInt2
    SvcImpl1 -->|"uses"| uow
    SvcImpl2 -->|"uses"| uow
    uow -->|"manages"| repo
    repo -->|"queries/updates"| dbcontext
    dbcontext -->|"connects to"| db
    SvcImpl1 -->|"sends notifications"| smtp
    SvcImpl2 -->|"sends notifications"| smtp

    %% Response Flows
    db --> dbcontext
    dbcontext --> repo
    repo --> uow
    uow --> SvcImpl1
    SvcImpl1 --> controllers
    controllers --> client

    %% Click Events
    click controllers "https://github.com/mahammadpiriyev/school-management/tree/master/School/Areas/Admin/Controllers/"
    click views "https://github.com/mahammadpiriyev/school-management/tree/master/School/Areas/Admin/Views/"
    click static "https://github.com/mahammadpiriyev/school-management/tree/master/School/wwwroot/"
    click SvcInt1 "https://github.com/mahammadpiriyev/school-management/blob/master/School.Business/Abstract/IStudentService.cs"
    click SvcInt2 "https://github.com/mahammadpiriyev/school-management/blob/master/School.Business/Abstract/ITeacherService.cs"
    click SvcImpl1 "https://github.com/mahammadpiriyev/school-management/blob/master/School.Business/Concrete/StudentService.cs"
    click SvcImpl2 "https://github.com/mahammadpiriyev/school-management/blob/master/School.Business/Concrete/TeacherService.cs"
    click uow "https://github.com/mahammadpiriyev/school-management/blob/master/School.DataAccess/Repository/IRepository/IUnitOfWork.cs"
    click repo "https://github.com/mahammadpiriyev/school-management/tree/master/School.DataAccess/Repository/"
    click dbcontext "https://github.com/mahammadpiriyev/school-management/blob/master/School.DataAccess/Data/ApplicationDbContext.cs"
    click migrations "https://github.com/mahammadpiriyev/school-management/tree/master/School.DataAccess/Migrations/"
    click entities "https://github.com/mahammadpiriyev/school-management/blob/master/School.Entities/School.Entities.csproj"
    click smtp "https://github.com/mahammadpiriyev/school-management/blob/master/School.Utility/EmailSender.cs"

    %% Styles
    classDef ui fill:#e3f2fd,stroke:#2196f3
    classDef biz fill:#e8f5e9,stroke:#4caf50
    classDef data fill:#fff3e0,stroke:#fb8c00
    classDef domain fill:#f3e5f5,stroke:#8e24aa
    classDef db fill:#fff9c4,stroke:#fbc02d
    classDef external fill:#eceff1,stroke:#607d8b
```
