How hossam-hosny/restaurantssystem works
Project Type & Purpose
• Full-stack backend Web API built with ASP.NET Core 8, following Clean Architecture.
• Exposes CRUD operations for Restaurants and Dishes, secured with JWT-based ASP.NET Identity.
• Uses CQRS via MediatR, EF Core for persistence, Serilog for logging, FluentValidation for input validation, and Swagger for documentation.
• Deployed to Azure App Service with Azure SQL, CI/CD via GitHub Actions.
High-Level Architectural Layers
• Presentation/API Layer (“RestaurantSystem” project)
• Application Layer (src/Restaurants.Application)
• Domain Layer (src/Restaurants.Domain)
• Infrastructure Layer (src/Restaurants.Infrastructure)
• External Systems (Azure SQL, Azure App Service, GitHub Actions, Postman/Swagger UI)
Main Components & Their Responsibilities
a. API Layer
• Controllers (RestaurantsController, DishesController, IdentityController)
• Custom Middleware (ErrorHandlingMiddleware, RequestTimeLoggingMiddleware)
• JWT Authentication & Authorization Policies
• Serilog configuration (in Program.cs & extensions)
b. Application Layer
• CQRS Commands & Queries (Create/Update/Delete/Read handlers)
• DTOs & AutoMapper Profiles
• Validators (FluentValidation)
• IUserContext for current user info
c. Domain Layer
• Entities (Restaurant, Dish, User, Address)
• Domain Exceptions & Constants
• Repository Interfaces & Authorization Service Interface
d. Infrastructure Layer
• EF Core DbContext & Migrations
• Repository Implementations (IDishRepository, IRestaurantRepository)
• ASP.NET Identity Stores & Claims Principal Factory
• Seeders for initial data (roles, restaurants)
• ServiceCollectionExtensions for DI registration
e. Testing
• Unit Tests for Application & Infrastructure logic
• Integration Tests for Controllers & Middleware
(These are separate test projects and can be shown as “Offline QA”)
Component Interactions & Data Flow
1. Client (Swagger/UI/Postman) → HTTP Request → API Controller
2. Controller → MediatR.Send(Command/Query)
3. MediatR → Application Handler
4. Handler → Domain Entities & Validation → Repository Interface
5. Repository Implementation (Infrastructure) → EF Core → Azure SQL
6. Results flow back up: Infrastructure → Handler → Controller → Client
7. Middleware logs request timing & handles exceptions via Serilog
8. Authentication: JWT token issued by IdentityController, validated by ASP.NET Identity services
Architectural Patterns & Principles
• Clean Architecture: strict layer separations, no direct DB calls in API
• CQRS: separate read (Queries) & write (Commands) flows
• Dependency Inversion: API & Application depend on Domain interfaces
• Single Responsibility: each handler, controller, middleware has one purpose
• Cross-cutting Concerns: Logging, Exception Handling, Validation are centralized in middleware or pipelines