# trycatchlearn/datingapp-dotnet8angular18 architecture

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

- Interactive diagram: https://gitdiagram.com/trycatchlearn/datingapp-dotnet8angular18
- Repository: https://github.com/trycatchlearn/datingapp-dotnet8angular18

## Overview

##### Project type and purpose
- This is a full-stack web application—a social/dating platform—built with an Angular 17 front end and a .NET 8.0 back end.
- Core features include user registration/login (JWT auth), member browsing, photo uploads (Cloudinary), real-time messaging (SignalR), likes, admin photo approval, pagination, and role-based access control.

##### File structure
- Top-level directories:
- API – ASP.NET Core Web API project, organized by layers (Controllers, DTOs, Data, Entities, Services, SignalR, Middleware, Extensions, Helpers, Interfaces).
- client – Angular SPA with modules for components (_services, _guards, _interceptors, _models, _resolvers, feature folders).
- docker-compose.yml – defines multi-container setup (API, database).
- Data access: EF Core DataContext, Repositories (LikesRepository, MessageRepository, PhotoRepository, UserRepository), UnitOfWork.
- Business logic: Services (TokenService, PhotoService), AutoMapper profiles.
- API surface: Controllers (Account, Users, Likes, Messages, Admin) expose REST endpoints.
- Real-time layer: SignalR hubs (MessageHub, PresenceHub).
- Client bootstraps via index.html, main.ts, app.routes.ts, and uses Bootstrap for styling.

##### README for additional insights
- Confirms the tech stack (.NET 8.0, Angular 17/18, Bootstrap 5).
- Mentions newer/older versions for reference—implies the architecture is stable across versions.

a. Main components:
- Angular SPA (Browser)
- ASP.NET Core API
- EF Core / SQL Database
- SignalR Hub (inside API)
- Cloudinary (external photo storage)
- Authentication/Authorization (JWT token service)
- Docker Compose orchestration
b. Relationships and interactions:
– Browser ↔ API: REST calls (HTTP/HTTPS) for CRUD operations, JWT in Authorization header.
– Browser ↔ API: WebSocket connection to SignalR for real-time chat/presence.
– API → Database: EF Core issues SQL queries to read/write Entities.
– API → Cloudinary: PhotoService uploads/downloads images.
– API Middleware pipeline: ExceptionHandling → Logging → Authentication/Authorization → Routing → Controllers.
c. Architectural patterns/design principles:
– Layered Architecture: Controllers → Services → Repositories → DataContext
– Repository & Unit of Work patterns for data access
– DTO mapping via AutoMapper for separation between domain and API models
– Middleware pipeline in ASP.NET Core for cross-cutting concerns
– SPA pattern in Angular with Services/Guards/Interceptors for auth and error handling
– Real-time communication via SignalR hubs
d. Key technologies/frameworks/libraries:
– Back end: ASP.NET Core 8.0, EF Core, AutoMapper, SignalR, Cloudinary SDK, JWT Bearer Auth
– Front end: Angular 17, RxJS, Angular Router, Bootstrap 5, Angular Guards/Interceptors
– DevOps: Docker, Docker Compose, SQL Server container

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    subgraph "Client (Angular SPA)" 
        direction TB
        A1["Index.html | main.ts"]:::frontend
        A2["App Routes"]:::frontend
        A3["Services"]:::frontend
        A4["Guards"]:::frontend
        A5["Interceptors"]:::frontend
        A6["Models"]:::frontend
        A7["Resolvers"]:::frontend
    end

    %% Server Side
    subgraph "Server (ASP.NET Core API)"
        direction TB
        subgraph "Middleware Pipeline" 
            direction TB
            M1["ExceptionMiddleware"]:::middleware
            M2["Logging"]:::middleware
            M3["Authentication/Authorization"]:::middleware
            M4["Routing"]:::middleware
        end
        subgraph "Controllers"
            direction TB
            C1["AccountController"]:::backend
            C2["UsersController"]:::backend
            C3["LikesController"]:::backend
            C4["MessagesController"]:::backend
            C5["AdminController"]:::backend
            C6["MessageHub (SignalR)"]:::backend
            C7["PresenceHub (SignalR)"]:::backend
        end
        subgraph "Services"
            direction TB
            S1["TokenService"]:::backend
            S2["PhotoService"]:::backend
        end
        subgraph "Data Access"
            direction TB
            R1["UserRepository"]:::backend
            R2["LikesRepository"]:::backend
            R3["MessageRepository"]:::backend
            R4["PhotoRepository"]:::backend
            R5["UnitOfWork"]:::backend
            D1["DataContext"]:::backend
        end
    end

    %% External Services
    subgraph "External"
        direction TB
        DB["SQL Server"]:::db
        CL["Cloudinary"]:::external
        DC["Docker Compose"]:::external
    end

    %% Flows
    Browser["Browser"]:::external
    Browser -->|"HTTP/HTTPS + JWT"| A2
    A2 --> A3
    A3 -->|"REST calls"| C1
    A3 -->|"REST calls"| C2
    A3 -->|"REST calls"| C3
    A3 -->|"REST calls"| C4
    A3 -->|"REST calls"| C5
    A3 -->|"WebSocket (SignalR)"| C6
    A3 -->|"WebSocket (SignalR)"| C7

    C1 --> M4
    C2 --> M4
    C3 --> M4
    C4 --> M4
    C5 --> M4
    C6 --> M4
    C7 --> M4

    M4 --> M3
    M3 --> M2
    M2 --> M1

    C1 --> S1
    C2 --> S1
    C3 --> S1
    C4 --> S1
    C5 --> S1
    C6 --> S1
    C7 --> S1

    S2 --> CL
    S1 --> R1
    S1 --> R2
    S1 --> R3
    S1 --> R4
    R1 --> D1
    R2 --> D1
    R3 --> D1
    R4 --> D1
    D1 --> DB

    DC --> Browser
    DC --> D1
    DC --> DB

    %% Click Events Client
    click A1 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/client/src/index.html"
    click A1 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/client/src/main.ts"
    click A2 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/client/src/app/app.routes.ts"
    click A3 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/tree/main/client/src/app/_services"
    click A4 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/tree/main/client/src/app/_guards"
    click A5 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/tree/main/client/src/app/_interceptors"
    click A6 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/tree/main/client/src/app/_models"
    click A7 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/tree/main/client/src/app/_resolvers"

    %% Click Events Server
    click M1 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Middleware/ExceptionMiddleware.cs"
    click C1 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Controllers/AccountController.cs"
    click C2 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Controllers/UsersController.cs"
    click C3 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Controllers/LikesController.cs"
    click C4 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Controllers/MessagesController.cs"
    click C5 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Controllers/AdminController.cs"
    click C6 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/SignalR/MessageHub.cs"
    click C7 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/SignalR/PresenceHub.cs"
    click S1 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Services/TokenService.cs"
    click S2 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Services/PhotoService.cs"
    click R1 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Data/UserRepository.cs"
    click R2 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Data/LikesRepository.cs"
    click R3 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Data/MessageRepository.cs"
    click R4 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Data/PhotoRepository.cs"
    click R5 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Data/UnitOfWork.cs"
    click D1 "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Data/DataContext.cs"
    click DB "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/docker-compose.yml"
    click CL "https://github.com/trycatchlearn/datingapp-dotnet8angular18/blob/main/API/Helpers/CloudinarySettings.cs"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#007bff,color:#004085
    classDef backend fill:#d4edda,stroke:#28a745,color:#155724
    classDef external fill:#f8d7da,stroke:#dc3545,color:#721c24
    classDef db fill:#fff3cd,stroke:#ffc107,color:#856404
    classDef middleware fill:#e2e3e5,stroke:#6c757d,color:#343a40
```
