# nimblepros/eshoponweb architecture

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

- Interactive diagram: https://gitdiagram.com/nimblepros/eshoponweb
- Repository: https://github.com/nimblepros/eshoponweb

## Overview

##### Project Type and Purpose
- This is Microsoft’s eShopOnWeb ASP.NET Core reference app—a full‐stack, “monolithic” (single‐repo but multi‐project) web application demonstrating Clean Architecture principles.
- It comprises:
- A REST API (PublicApi)
- A server‐rendered MVC/Razor Pages site (Web)
- A Blazor WebAssembly admin UI (BlazorAdmin)
- A shared domain project (ApplicationCore), infrastructure project (Infrastructure) for EF Core, Identity, logging, email, etc.
- IaC definitions under infra (Bicep for Azure SQL, App Service, Key Vault)
- Docker Compose and DevContainer configs for local/dev environments

##### File Structure Analysis & Architectural Layers
- Layer 1: Domain (src/ApplicationCore)
- Entities, value objects, interfaces, domain services, specifications, domain events
- Layer 2: Infrastructure (src/Infrastructure)
- EF Core DbContexts (catalog + identity), Repositories, Migrations, Identity setup, email sender, logging adapter
- Layer 3: Presentation
a. Web UI (src/Web) – ASP.NET Core MVC + Razor Pages + Identity; renders HTML to users, calls domain services directly via DI
b. Public API (src/PublicApi) – minimal API endpoints exposing catalog, order, auth, user/role management for clients
c. Blazor Admin (src/BlazorAdmin) – WebAssembly SPA, uses shared DTOs (src/BlazorShared) and calls PublicApi over HTTP
- Cross‐cutting:
- Shared client models (src/BlazorShared)
- Service defaults & hosting helpers (src/eShopWeb.AppHost, AspireServiceDefaults)
- Infrastructure as Code in infra: provisioning Azure SQL Databases, Key Vault, App Service plans

##### Key Architecture Patterns & Principles
- Clean (Onion) Architecture: inner domain layer, outer infrastructure & presentation
- Dependency Injection across layers
- Repository & Specification patterns for data access
- CQRS-style minimal APIs in PublicApi and MediatR-styled handlers in Web features
- Separation of concerns: Web UI vs. Public API vs. Admin UI
- Infrastructure as Code (Bicep) for cloud provisioning

##### Main Components & Interactions
- Web Browser
- Renders Web UI (MVC/Razor) served by Web app
- Hosts BlazorAdmin SPA under /admin, served by Web app or separate static site pointing to PublicApi
- Web App (ASP.NET Core)
- Hosts MVC/Razor Pages, Identity UI, server‐side controllers/features
- Directly calls ApplicationCore services & Infrastructure repositories
- Connects to two SQL DBs: CatalogContext and AppIdentityDbContext
- PublicApi App (ASP.NET Core minimal API)
- Exposes JSON endpoints for catalog, orders, users, roles, auth
- Calls same ApplicationCore & Infrastructure layers via DI
- BlazorAdmin (WebAssembly)
- Hosted in browser, calls PublicApi over HTTPS for data & auth
- Uses shared DTOs (BlazorShared)
- Domain & Infrastructure
- ApplicationCore defines domain model, interfaces
- Infrastructure implements data persistence, identity, email, logging
- Azure Resources (via infra/*.bicep)
- Azure SQL Servers & Databases
- App Service plans & Web Apps for Web & PublicApi
- Key Vault for connection string secrets
- Local Dev
- Docker Compose spins up Web, PublicApi, SQL containers
- DevContainers for code and docs

##### Checklist
- Labels on every component (e.g., “src/Web: ASP.NET Core MVC”)
- “Shared Domain + Infra” central to both Web & API
- External services: Azure Key Vault, Azure SQL, App Service

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation in Browser
    subgraph "Browser"
        BrowserUI["Web Browser"]:::presentation
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        WebApp["src/Web: ASP.NET Core MVC + Razor Pages"]:::presentation
        PublicApi["src/PublicApi: REST API"]:::presentation
        BlazorClient["src/BlazorAdmin: Blazor WebAssembly SPA"]:::presentation
        BlazorShared["src/BlazorShared: Shared DTOs"]:::presentation
    end

    %% Domain Layer
    subgraph "Domain Layer"
        ApplicationCore["src/ApplicationCore: Domain"]:::domain
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        Infrastructure["src/Infrastructure: EF Core, Identity, Logging, Email"]:::infra
        AppHost["src/eShopWeb.AppHost: Service Hosting Helpers"]:::infra
        AspireDefaults["src/eShopWeb.AspireServiceDefaults"]:::infra
    end

    %% Databases and Cloud Resources
    subgraph "Azure Resources"
        KeyVault["Azure Key Vault"]:::cloud
        AppServiceWeb["App Service (Web)"]:::cloud
        AppServiceAPI["App Service (API)"]:::cloud
        CatalogDB["Azure SQL: Catalog DB"]:::cloud
        IdentityDB["Azure SQL: Identity DB"]:::cloud
    end

    %% IaC
    IaC["infra: Bicep IaC"]:::cloud

    %% Local Development
    subgraph "Local Development"
        DockerCompose["docker-compose.yml"]:::local
        DevContainer[".devcontainer"]:::local
    end

    %% Connections
    BrowserUI -->|"HTTP"| WebApp
    BrowserUI -->|"HTTP to /admin"| BlazorClient
    BlazorClient -->|"HTTP calls"| PublicApi

    WebApp -->|"DI calls"| ApplicationCore
    PublicApi -->|"DI calls"| ApplicationCore

    ApplicationCore -->|"implements"| Infrastructure
    Infrastructure -->|"EF Core queries"| CatalogDB
    Infrastructure -->|"EF Core queries"| IdentityDB
    Infrastructure -->|"fetch secrets"| KeyVault

    IaC -->|"provisions"| AppServiceWeb
    IaC -->|"provisions"| AppServiceAPI
    IaC -->|"provisions"| CatalogDB
    IaC -->|"provisions"| IdentityDB
    IaC -->|"provisions"| KeyVault

    DockerCompose -->|"spins up"| WebApp
    DockerCompose -->|"spins up"| PublicApi
    DockerCompose -->|"spins up"| CatalogDB
    DockerCompose -->|"spins up"| IdentityDB

    DevContainer -->|"configures env"| WebApp
    DevContainer -->|"configures env"| PublicApi

    %% Click Events
    click WebApp "https://github.com/nimblepros/eshoponweb/tree/main/src/Web"
    click PublicApi "https://github.com/nimblepros/eshoponweb/tree/main/src/PublicApi"
    click BlazorClient "https://github.com/nimblepros/eshoponweb/tree/main/src/BlazorAdmin"
    click BlazorShared "https://github.com/nimblepros/eshoponweb/tree/main/src/BlazorShared"
    click ApplicationCore "https://github.com/nimblepros/eshoponweb/tree/main/src/ApplicationCore"
    click Infrastructure "https://github.com/nimblepros/eshoponweb/tree/main/src/Infrastructure"
    click AppHost "https://github.com/nimblepros/eshoponweb/blob/main/src/eShopWeb.AppHost"
    click AspireDefaults "https://github.com/nimblepros/eshoponweb/blob/main/src/eShopWeb.AspireServiceDefaults"
    click IaC "https://github.com/nimblepros/eshoponweb/tree/main/infra"
    click DockerCompose "https://github.com/nimblepros/eshoponweb/blob/main/docker-compose.yml"
    click DevContainer "https://github.com/nimblepros/eshoponweb/blob/main/.devcontainer/devcontainer.json"

    %% Styles
    classDef presentation fill:#ffa500,stroke:#333,stroke-width:1px
    classDef domain fill:#90ee90,stroke:#333,stroke-width:1px
    classDef infra fill:#add8e6,stroke:#333,stroke-width:1px
    classDef cloud fill:#dda0dd,stroke:#333,stroke-width:1px
    classDef local fill:#d3d3d3,stroke:#333,stroke-width:1px
```
