How mohamedshawky70/education--management--system works
Project Type and Purpose
• This is a full-stack backend API (Education Management System) built as a layered .NET solution. It exposes RESTful endpoints for managing Students, Teachers, Departments, Subjects, Assignments, Enrollments, and User/Role administration, all secured via JWT.
File-Structure Analysis
• Four top-level projects represent distinct layers:
• School.Api – Web/API layer (Controllers, Program, DI, Templates).
• School.Application – Business-logic and service interfaces (DTOs, Validation, Mapping, Interfaces, Services, Error/Exception handling).
• School.Domain – Core entities and domain models.
• School.Infrastructure – Data access implementations (Entity Framework Core DbContext, Repository & UnitOf-Work, Migrations, Identity configs, external integrations).
README Insights
• Tech stack: .NET 9, Entity Framework Core, SQL Server, JWT Authentication, FluentValidation, Automapper/Mapster, Hangfire, Caching, Health Checks, Rate Limiting, CORS.
• Key workflows: Authentication (register, login, refresh/revoke tokens, email confirmation, password reset), Profile Management, Role-based access, CRUD flows for each entity, Enrollment linking.
Main Components
a. Client & Entry Points
• Web/Mobile client or Postman → HTTP(S) calls to School.Api (Controllers).
b. API Layer (School.Api)
• Controllers (AuthController, StudentController, etc.)
• Middleware: ExceptionHandler, CORS, RateLimiting, HealthChecks
• Templates/Email engine for confirmations & resets (via Hangfire)
c. Application Layer (School.Application)
• DTOs & Validators (FluentValidation)
• Service Interfaces (IAuthService, IStudentService, etc.)
• Automapper/Mapster mapping profiles
• Unit of Work & Result-pattern error handling
d. Domain Layer (School.Domain)
• Entities: ApplicationUser, Student, Teacher, Subject, Department, Assignment, Enrollment, RefreshToken
e. Infrastructure Layer (School.Infrastructure)
• EF Core DbContext → SQL Server
• Repository implementations (BaseRepo) & UnitOfWork
• Authentication: JwtProvider, AccountService, AuthService, RoleService, UserService
• Background Jobs: Hangfire (EmailSender)
• Caching (in-memory or distributed)
f. External Services
• SMTP/Email provider
• Hangfire dashboard & storage
• Optional Redis or in-memory cache
Relationships & Data Flow
1. Client → HTTP Request → API Layer Controllers
2. Controller injects Application-layer Service Interface
3. Service executes business logic, validation, mapping
4. Service calls Repository via UnitOfWork → Infrastructure
5. EF Core DbContext persists or queries SQL Server
6. Response bubbles back: Data → DTO → Controller → HTTP Response
7. For Auth: Controller → AuthService → JwtProvider → DB (RefreshToken) → return JWT + refresh token
8. Background tasks: Controller enqueues Hangfire job → EmailSender sends via SMTP
Architectural Patterns & Principles
• Layered (Presentation, Application, Domain, Infrastructure)
• Repository + Unit of Work
• Dependency Injection (centralized in Program.cs / DependencyInjection.cs)
• Result pattern for error handling
• FluentValidation for input validation
• Automapper/Mapster for object mapping
• JWT-based stateless authentication, Role-based authorization
• CQRS-style separation (read/write in services)
• API versioning via route templates
Final Recommendations
• Keep it hierarchical: top-level external clients & infra, mid-level API & services, bottom-level persistence & domain.
• Essential flows:
• Authentication sequence (Login → Token → Refresh → Revoke)
• CRUD flow for a sample entity (Student)
• Enrollment linking (StudentService → DepartmentSubjectService → EnrollmentService)
• Be exhaustive with components but avoid clutter: group similar services or controllers into packages.