How shuncoder/student-manager-webapi works
Project Type and Purpose
• This is a backend-only, RESTful ASP.NET Core Web API (.NET 8) for managing Students, Classes, and their relationships.
• It follows a layered architecture: Presentation (Controllers) → Business Logic (Services) → Data Store (InMemory).
File Structure
• Controllers/ – HTTP entrypoints (ClassesController, StudentsController).
• Services/
• Interfaces (IClassService, IStudentService) define business operations.
• Implementations (ClassService, StudentService) contain logic and call the Data layer.
• Data/ – InMemoryDataStore: holds Lists of Student, Class, and StudentClass.
• Models/ – Domain entities (Student, Class, StudentClass).
• DTOs/ – Request/response payloads and validation rules.
• Program.cs – Configures DI, adds services, and sets up Swagger.
Main Components
a. API Layer (Controllers)
• StudentsController
• ClassesController
• Swagger UI endpoint
b. Business Layer (Services)
• IStudentService → StudentService
• IClassService → ClassService
c. Data Layer
• InMemoryDataStore (holds three collections)
d. Domain Models & DTOs
• Models: Student, Class, StudentClass
• DTOs: Create/UpdateStudentDto, StudentDto, Create/UpdateClassDto, ClassDto, AddStudentsToClassDto
e. External/Infrastructure
• ASP.NET Core hosting environment
• appsettings.json (configuration)
• Dependency Injection container
Relationships & Data Flows
• Client → HTTP request → Controller
• Controller → calls Service Interface → concrete Service Implementation
• Service → reads/writes InMemoryDataStore → retrieves/updates Models
• Service → maps Models ↔ DTOs → returns to Controller
• Controller → HTTP response (JSON) → Client
• Swagger UI interacts directly with Controllers via HTTP.
Architectural Patterns & Principles
• Layered Architecture – clear separation of concerns.
• Dependency Injection – controllers depend on service interfaces, configured in Program.cs.
• DTO Pattern – isolates internal models from external API contracts.
• In-Memory Repository – Data store abstraction, easily replaceable by EF Core or another provider later.
• Exception Handling – try-catch in Controllers to translate errors into HTTP status codes.