# nitin27may/clean-architecture-docker-dotnet-angular architecture

> Architecture diagram of the GitHub repository nitin27may/clean-architecture-docker-dotnet-angular, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nitin27may/clean-architecture-docker-dotnet-angular
- Repository: https://github.com/nitin27may/clean-architecture-docker-dotnet-angular

## Overview

##### Project Type and Purpose
- The project is a full-stack application following Clean Architecture. Its purpose is to serve as a boilerplate for rapid application development featuring user registration, JWT-based authentication and role-based access control, as well as CRUD operations for contacts.
- The README highlights that the application is designed with modularity, scalability, and maintainability in mind using a layered approach.

##### & List Main Components
a. Frontend:
- Built with Angular 19.
- Supports Server Side Rendering (SSR) via Node (as suggested by the NodeJS-based Dockerfile used for angular production).
- Contains UI components, HTTP interceptors (e.g., JWT and error handling), guards, and services that interact with the backend API.
b. Backend API:
- Developed in .NET 9 with Clean Architecture principles.
- Contains distinct layers: API Controllers, Application Services (business logic, mappings, use cases), Domain Entities/Interfaces (core business models and exceptions), and Infrastructure (persistence using Dapper, repositories, external service integrations like SMTP).
- Implements essential functionalities such as authentication, role-based API access, middleware for exceptions and activity logging.
c. Database:
- MS SQL Server container (with a Dockerfile provided in the mssql folder).
- Contains seeded data (as per the seed-data.sql script) for users with different roles.
d. Load Balancer:
- Implemented using NGINX (configured under the loadbalancer directory) which likely routes and distributes requests across the containers.
e. Docker & CI/CD Infrastructure:
- Docker Compose orchestration using multiple Dockerfiles (for development and production in both frontend and backend).
- GitHub Actions workflows for building the Angular app, .NET API, and load balancer container.

##### Architectural Patterns & Technologies
- Use of Dapper for lightweight ORM and AutoMapper for DTO mapping in the Application layer.
- Technologies per component:
- Angular 19, Bootstrap, SSR via NodeJS for Frontend.
- .NET 9 for APIs, JWT-based Authentication, FluentValidation.
- MS SQL for persistence.
- Docker (Docker Compose orchestration), NGINX for load balancing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Load Balancer Cluster
    A["Load Balancer (NGINX Container)"]:::container

    %% Frontend Cluster
    subgraph "Frontend Cluster"
        B["Angular Frontend (SSR via Node)\n(HTTP Interceptors, Guards, JWT)"]:::frontend
    end

    %% Backend API Cluster with Clean Architecture Layers
    subgraph "Backend API"
        subgraph "Clean Architecture Layers"
            C1["API Layer\n(Controllers, Program.cs)"]:::backendLayer
            C2["Application Layer\n(Services, Use Cases, Mappings)"]:::backendLayer
            C3["Domain Layer\n(Entities, Exceptions)"]:::backendLayer
            C4["Infrastructure Layer\n(Persistence, Repositories, External Services)"]:::backendLayer
        end
    end

    %% Database Component
    D(("MS SQL Server")):::database

    %% Seed Data Script Node
    E["Seed Data Script"]:::cicd

    %% Docker & CI/CD Infrastructure Cluster
    subgraph "Docker & CI/CD Infrastructure"
        F["Docker Compose (docker-compose.yml)"]:::cicd
        G["GitHub Actions Workflows"]:::cicd
    end

    %% Connections for Data Flow
    A -->|"Routes"| B
    A -->|"Routes"| C1
    B -->|"API_Calls_with_JWT"| C1
    C1 -->|"calls"| C2
    C2 -->|"validates"| C3
    C3 -->|"supplies_to"| C4
    C4 -->|"DB_Query"| D
    E -->|"seeds"| D

    %% CI/CD Deployment Arrows
    F -->|"Deploys"| A
    G -->|"Deploys"| A

    %% Click Events
    click B "https://github.com/nitin27may/clean-architecture-docker-dotnet-angular/tree/main/frontend/"
    click C1 "https://github.com/nitin27may/clean-architecture-docker-dotnet-angular/tree/main/backend/src/Contact.Api/"
    click C2 "https://github.com/nitin27may/clean-architecture-docker-dotnet-angular/tree/main/backend/src/Contact.Application/"
    click C3 "https://github.com/nitin27may/clean-architecture-docker-dotnet-angular/tree/main/backend/src/Contact.Domain/"
    click C4 "https://github.com/nitin27may/clean-architecture-docker-dotnet-angular/tree/main/backend/src/Contact.Infrastructure/"
    click D "https://github.com/nitin27may/clean-architecture-docker-dotnet-angular/tree/main/mssql/"
    click A "https://github.com/nitin27may/clean-architecture-docker-dotnet-angular/tree/main/loadbalancer/"
    click F "https://github.com/nitin27may/clean-architecture-docker-dotnet-angular/blob/main/docker-compose.yml"
    click G "https://github.com/nitin27may/clean-architecture-docker-dotnet-angular/tree/main/.github/workflows/"
    click E "https://github.com/nitin27may/clean-architecture-docker-dotnet-angular/blob/main/backend/scripts/seed-data.sql"

    %% Styles
    classDef container fill:#F4A460,stroke:#333,stroke-width:2px;
    classDef frontend fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef backendLayer fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef database fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef cicd fill:#FFB6C1,stroke:#333,stroke-width:2px;
```
