# noureddin94/restauranthotelads architecture

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

- Interactive diagram: https://gitdiagram.com/noureddin94/restauranthotelads
- Repository: https://github.com/noureddin94/restauranthotelads

## Overview

##### Project Type and Purpose
- This is a full-stack, multi-portal advertising platform.
- Backend is built on ASP.NET Core with a Clean Architecture (Core → Infrastructure → Application → API).
- Frontend consists of three separate Angular apps:
- hotel-portal (for hotel admins)
- restaurant-portal (for restaurant owners)
- room-display (for in-room TV/kiosk display)
- Purpose: allow restaurants to create/manage ads, assign them to hotel rooms, and enable hotels to display those ads on internal dashboards or room TVs.

##### File Structure Analysis
- Backend/
- Core: domain entities and interface contracts only
- Infrastructure: EF Core DbContext, repository implementations, migrations, seeding
- Application: DTOs, mapping profiles, business-rule services, interfaces → sits between Core & Infrastructure
- API: ASP.NET Core Web API controllers, JWT authentication, Swagger, appsettings
- Frontend/
- hotel-portal, restaurant-portal, room-display: each is a standalone Angular project with its own src/, angular.json, environments, etc.
- Solution file (RestaurantHotelAds.sln) ties all backend projects together.

##### Key Architectural Insights from README
- Layered Dependency:
Core ← Infrastructure ← Application ← API ← Frontend
- Clean separation of concerns: no infra/framework dependencies in Core, Application coordinates business logic, API handles HTTP.
- Three distinct user-facing portals share the same API.

##### Main Components
a. Backend Layers
1. Core Layer (Domain)
– Entities (Hotel, Restaurant, Room, Advertisement, AdRequest, ApplicationUser)
– Interfaces for repositories & UoW
2. Infrastructure Layer (Persistence)
– ApplicationDbContext (EF Core)
– Repository implementations
– Migrations & Seeder
3. Application Layer (Business Logic)
– Service classes (AdRequestService, HotelService, etc.)
– DTOs & MappingProfile
4. API Layer (Presentation)
– Controllers (HotelController, etc.)
– Authentication (JWT)
– Swagger/OpenAPI
b. Database
– SQL Server (via EF Core)
c. Frontend Portals
– Hotel Portal (Angular)
– Restaurant Portal (Angular)
– Room-Display Portal (Angular)
d. External/Infrastructure Services
– Identity/JWT Auth provider (could be internal or Azure AD)
– Logging/Monitoring (if present)
– CDN/Static hosting for Angular apps (optional)

##### Relationships and Data Flow
- Authentication flow: Angular apps obtain JWT from API’s AuthController → include JWT in API calls
- (Optional) Data seeding at startup: API → Infrastructure Seeder → Database

##### Architectural Patterns & Principles
- Clean (Hexagonal) Architecture: clear dependency inversion, domain at core, outward layers depend inward, business rules isolated.
- Repository + Unit of Work pattern in Infrastructure.
- DTO/Mapping pattern in Application for decoupling domain from API contracts.
- Modular Angular applications for separation of concerns.

##### Final Checklist
- [ ] Components labeled with project folder names and purposes
- [ ] Group boundaries for Backend vs Frontend
- [ ] Authentication/JWT flow path
- [ ] Database shown as a central persistence component

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Applications"
        direction TB
        HotelPortal["Hotel Portal (Angular)"]:::frontend
        RestaurantPortal["Restaurant Portal (Angular)"]:::frontend
        RoomDisplay["Room-Display Portal (Angular)"]:::frontend
    end

    %% Backend Solution Layers
    subgraph "Backend Solution"
        direction TB

        subgraph "Core Layer (Domain)"
            direction TB
            CoreEntities["Entities"]:::core
            CoreInterfaces["Interfaces (Repositories & UoW)"]:::core
        end

        subgraph "Infrastructure Layer (Persistence)"
            direction TB
            InfrastructureDb["ApplicationDbContext"]:::infra
            DatabaseSeeder["DatabaseSeeder"]:::infra
            DesignFactory["DesignTimeDbContextFactory"]:::infra
            UnitOfWorkImpl["UnitOfWork Implementation"]:::infra
            Migrations["EF Migrations"]:::infra
            Repositories["Repository Implementations"]:::infra
        end

        subgraph "Application Layer (Business Logic)"
            direction TB
            DTOs["DTO Definitions"]:::app
            Mappings["MappingProfile"]:::app
            Services["Service Classes"]:::app
        end

        subgraph "API Layer (Presentation)"
            direction TB
            Controllers["Controllers"]:::api
            AuthController["AuthController (JWT)"]:::api
            APIDocs["Swagger/OpenAPI"]:::api
            APIConfig["Program & Startup Config"]:::api
        end
    end

    %% Database
    SQLServer["SQL Server Database"]:::database

    %% Relationships
    HotelPortal -->|REST API Calls| Controllers
    RestaurantPortal -->|REST API Calls| Controllers
    RoomDisplay -->|REST API Calls| Controllers

    Controllers -->|Invoke| Services
    AuthController -->|Issues JWT| Controllers
    Services -->|Calls| Repositories
    Repositories -->|Uses| InfrastructureDb
    InfrastructureDb -->|Queries| SQLServer
    DatabaseSeeder -->|Seeds| SQLServer
    Services -->|Uses| DTOs
    Services -->|Uses| Mappings

    %% Click Events
    click CoreEntities "https://github.com/noureddin94/restauranthotelads/tree/main/Backend/RestaurantHotelAds.Core/Entities"
    click CoreInterfaces "https://github.com/noureddin94/restauranthotelads/tree/main/Backend/RestaurantHotelAds.Core/Interfaces"
    click InfrastructureDb "https://github.com/noureddin94/restauranthotelads/blob/main/Backend/RestaurantHotelAds.Infrastructure/Data/ApplicationDbContext.cs"
    click DatabaseSeeder "https://github.com/noureddin94/restauranthotelads/blob/main/Backend/RestaurantHotelAds.Infrastructure/Data/DatabaseSeeder.cs"
    click DesignFactory "https://github.com/noureddin94/restauranthotelads/blob/main/Backend/RestaurantHotelAds.Infrastructure/Data/DesignTimeDbContextFactory.cs"
    click UnitOfWorkImpl "https://github.com/noureddin94/restauranthotelads/blob/main/Backend/RestaurantHotelAds.Infrastructure/Data/UnitOfWork .cs"
    click Migrations "https://github.com/noureddin94/restauranthotelads/tree/main/Backend/RestaurantHotelAds.Infrastructure/Migrations"
    click Repositories "https://github.com/noureddin94/restauranthotelads/tree/main/Backend/RestaurantHotelAds.Infrastructure/Repositories"
    click DTOs "https://github.com/noureddin94/restauranthotelads/tree/main/Backend/RestaurantHotelAds.Application/DTOs"
    click Mappings "https://github.com/noureddin94/restauranthotelads/blob/main/Backend/RestaurantHotelAds.Application/Mappings/MappingProfile.cs"
    click Services "https://github.com/noureddin94/restauranthotelads/tree/main/Backend/RestaurantHotelAds.Application/Services"
    click Controllers "https://github.com/noureddin94/restauranthotelads/tree/main/Backend/RestaurantHotelAds.API/Controllers"
    click APIConfig "https://github.com/noureddin94/restauranthotelads/blob/main/Backend/RestaurantHotelAds.API/Program.cs"
    click APIConfig "https://github.com/noureddin94/restauranthotelads/blob/main/Backend/RestaurantHotelAds.API/appsettings.json"
    click APIConfig "https://github.com/noureddin94/restauranthotelads/blob/main/Backend/RestaurantHotelAds.API/Properties/launchSettings.json"
    click HotelPortal "https://github.com/noureddin94/restauranthotelads/tree/main/Frontend/hotel-portal"
    click RestaurantPortal "https://github.com/noureddin94/restauranthotelads/tree/main/Frontend/restaurant-portal"
    click RoomDisplay "https://github.com/noureddin94/restauranthotelads/tree/main/Frontend/room-display"
    click SQLServer "https://github.com/noureddin94/restauranthotelads/blob/main/Backend/RestaurantHotelAds.Infrastructure/Data/ApplicationDbContext.cs"

    %% Styles
    classDef core fill:#D6E9FE,stroke:#6395F5,color:#08306B
    classDef infra fill:#E6F8E0,stroke:#47A347,color:#154406
    classDef app fill:#FFE7C6,stroke:#FB9F31,color:#663C00
    classDef api fill:#F0DAFF,stroke:#A45EC0,color:#4B0071
    classDef frontend fill:#CDF0EA,stroke:#34A79C,color:#093F3E
    classDef database fill:#F2F2F2,stroke:#8A8A8A,color:#333333
```
