# fullstackproltd/aspnetcorespa architecture

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

- Interactive diagram: https://gitdiagram.com/fullstackproltd/aspnetcorespa
- Repository: https://github.com/fullstackproltd/aspnetcorespa

## Overview

##### Project Type & Purpose
- This is a full‐stack web application built on ASP.NET Core 7.0 using a Clean Architecture style.
- It exposes two backend services:
- “Web” – an ASP.NET Core Web API hosting an Angular 15 Single Page Application (SPA) under /ClientApp, SignalR hubs, and controllers for business data.
- “STS” – an ASP.NET Core IdentityServer4 application that handles authentication/authorization (OpenID-Connect/OAuth2).
- Core domain/business logic is in the Core projects (Domain, Application, Common). Infrastructure implements persistence, identity, email, file builders.

##### High‐Level File Structure & Architectural Patterns
- src/Core
- Domain: Entities and aggregates.
- Application: Mediator (CQRS) handlers, abstractions (IApplicationDbContext, IEmailService, etc.), cross‐cutting behaviors (logging, validation).
- Common: shared constants, mappings, result models.
- src/Infrastructure
- Persistence: EF Core DbContexts (ApplicationDbContext, LocalizationDbContext, IdentityServerDbContext), migrations, configurations.
- Identity: IdentityServer4 store entities.
- Email, Files (CsvFileBuilder), Certificate services (KeyVault).
- Custom middlewares & extensions.
- src/Presentation
- STS: IdentityServer host with Razor Pages UI for account management, custom profile service, security headers, Dockerfiles.
- Web: API controllers, SignalR hubs, Angular SPA (under ClientApp), middlewares, Dockerfiles.
- tests: Integration tests for Web API and unit tests for controllers.

a. Main Components
1. Angular SPA (ClientApp)
2. Web API service (Presentation/Web)
3. IdentityServer (Presentation/STS)
4. Core (Domain + Application layers)
5. Infrastructure services
– ApplicationDbContext (SQL Server/SQLite)
– LocalizationDbContext
– IdentityServerDbContext
– EmailService (SMTP or external provider)
– KeyVaultCertificateService
6. External dependencies (Databases, Key Vault, SMTP, Azure/Heroku, Docker)

b. Relationships & Data Flows
- User browser → Angular SPA
- SPA → Web API endpoints (HTTP/REST)
- SPA → STS for login (OIDC redirect)
- Web API ↔ IdentityServer (token validation via introspection or JWKS)
- Web API → ApplicationDbContext & LocalizationDbContext (EF Core)
- STS → IdentityServerDbContext (EF Core)
- Backend services → EmailService & CertificateService
- All services optionally containerized via Docker Compose or deployed to Azure/Heroku

c. Architectural Patterns & Principles
- Clean Architecture / Onion Architecture:
- Outer layers (Presentation) depend inward only on Application layer abstractions.
- Infrastructure sits at the perimeter implementing Application interfaces.
- CQRS with Mediator for commands & queries
- Domain Entities in Core.Domain
- Dependency Injection throughout
- Cross‐cutting concerns (logging, validation) via pipeline behaviors and middlewares
- Micro‐frontends / multiple hosts separated for security (STS vs Web)

d. Key Technologies & Frameworks
- ASP.NET Core 7.0, IdentityServer4, Entity Framework Core 7.0
- Angular 15 + CLI, SignalR, SASS, PWA support
- Docker & Docker Compose, Azure App Service, Heroku Container Registry
- Jest & Protractor for front-end tests, xUnit/MSTest for back-end tests
- Swagger (Swashbuckle) for API exploration

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Angular["Angular SPA"]:::client
    end

    %% Authentication Layer
    subgraph "Authentication Layer"
        subgraph "STS Service" 
            RazorUI["Razor Pages UI"]:::services
            CustomProfile["CustomProfileService"]:::services
            OIDCConfig["OIDC Configuration Controller"]:::services
            SecHeadersSTS["Security Headers Middleware"]:::services
            AdminSafe["Admin SafeList Middleware"]:::services
            BaseSTS["Base STS Controller"]:::services
            IdentityDB["IdentityServerDbContext"]:::database
            IdentityMigs["IdentityServerDbContext Migrations"]:::database
        end
    end

    %% API Layer
    subgraph "API Layer"
        subgraph "Web API Service"
            Controllers["Web API Controllers"]:::services
            SignalR["SignalR Hubs"]:::services
            CsvHub["ChatHub & ShapeHub"]:::services
            AppService["ApplicationService"]:::services
            SecHeadersWeb["Security Header Middleware"]:::services
            AppDB["ApplicationDbContext"]:::database
            AppMigs["ApplicationDbContext Migrations"]:::database
            LocDB["LocalizationDbContext"]:::database
            LocMigs["LocalizationDbContext Migrations"]:::database
        end
    end

    %% Core & Infrastructure shared
    subgraph "Core & Infrastructure"
        Domain["Domain Entities"]:::services
        Abstractions["Application Layer Abstractions"]:::services
        Behaviours["CQRS Handlers & Behaviours"]:::services
        Common["Shared Common Models & Mappings"]:::services
        EmailSvc["EmailService"]:::external
        CsvBuilder["CSV File Builder"]:::external
        KeyVault["KeyVaultCertificateService"]:::external
        ClientInfo["ClientInfoService"]:::external
        CurrentUser["CurrentUserService"]:::external
        UserMgr["UserManagerService"]:::external
        DeployEnv["DeploymentEnvironment"]:::external
        CustomEx["CustomExceptionHandler"]:::services
    end

    %% External Dependencies
    SMTP["SMTP / External Email"]:::external
    KeyVaultExt["Azure Key Vault"]:::external
    SQLDB["SQL Server / SQLite"]:::external
    Docker["Docker & Compose"]:::external

    %% Flows
    Browser-->Angular
    Angular-->WebAPI["Web API"] 
    Angular-->STS["STS"] 
    STS-->|"OIDC Redirect"|Angular
    WebAPI-->|"Token Validation"|STS
    WebAPI-->|"EF Core"|AppDB
    WebAPI-->|"EF Core"|LocDB
    STS-->|"EF Core"|IdentityDB
    WebAPI-->|"Email"|EmailSvc
    WebAPI-->|"Certificates"|KeyVault
    STS-->|"Email"|EmailSvc
    STS-->|"Certificates"|KeyVault
    EmailSvc-->SMTP
    KeyVault-->KeyVaultExt
    AppDB-->SQLDB
    LocDB-->SQLDB
    IdentityDB-->SQLDB
    WebAPI-->Docker
    STS-->Docker

    %% Click Events
    click Angular "https://github.com/fullstackproltd/aspnetcorespa/tree/master/src/Presentation/Web/ClientApp"
    click WebAPI "https://github.com/fullstackproltd/aspnetcorespa/tree/master/src/Presentation/Web"
    click CsvHub "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Presentation/Web/SignalR/ChatHub.cs"
    click CsvBuilder "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Infrastructure/Infrastructure/Files/CsvFileBuilder.cs"
    click KeyVault "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Infrastructure/Infrastructure/Services/Certificate/KeyVaultCertificateService.cs"
    click RazorUI "https://github.com/fullstackproltd/aspnetcorespa/tree/master/src/Presentation/STS/Areas/Identity/Pages/Account"
    click CustomProfile "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Presentation/STS/CustomProfileService.cs"
    click OIDCConfig "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Presentation/STS/Controllers/OidcConfigurationController.cs"
    click SecHeadersSTS "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Presentation/STS/Filters/SecurityHeadersAttribute.cs"
    click AdminSafe "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Presentation/STS/Middlewares/AdminSafeListMiddleware.cs"
    click BaseSTS "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Presentation/STS/Controllers/BaseController.cs"
    click Domain "https://github.com/fullstackproltd/aspnetcorespa/tree/master/src/Core/Domain/Entities"
    click Abstractions "https://github.com/fullstackproltd/aspnetcorespa/tree/master/src/Core/Application/Abstractions"
    click Behaviours "https://github.com/fullstackproltd/aspnetcorespa/tree/master/src/Core/Application/Behaviours"
    click Common "https://github.com/fullstackproltd/aspnetcorespa/tree/master/src/Core/Common"
    click AppDB "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Infrastructure/Infrastructure/Persistence/ApplicationDbContext.cs"
    click AppMigs "https://github.com/fullstackproltd/aspnetcorespa/tree/master/src/Infrastructure/Infrastructure/Persistence/Migrations"
    click LocDB "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Infrastructure/Infrastructure/Localization/LocalizationDbContext.cs"
    click LocMigs "https://github.com/fullstackproltd/aspnetcorespa/tree/master/src/Infrastructure/Infrastructure/Localization/Migrations"
    click IdentityDB "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Infrastructure/Infrastructure/Identity/IdentityServerDbContext.cs"
    click CustomEx "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Infrastructure/Infrastructure/Middlewares/CustomExceptionHandler.cs"
    click EmailSvc "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Infrastructure/Infrastructure/Email/EmailService.cs"
    click ClientInfo "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Infrastructure/Infrastructure/Services/ClientInfoService.cs"
    click CurrentUser "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Infrastructure/Infrastructure/Services/CurrentUserService.cs"
    click UserMgr "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Infrastructure/Infrastructure/Services/UserManagerService.cs"
    click DeployEnv "https://github.com/fullstackproltd/aspnetcorespa/blob/master/src/Infrastructure/Infrastructure/Environment/DeploymentEnvironment.cs"

    %% Styles
    classDef client fill:#add8e6,stroke:#000
    classDef services fill:#90ee90,stroke:#000
    classDef database fill:#ffa500,stroke:#000
    classDef external fill:#d3d3d3,stroke:#000
```
