# dotnet/eshopsupport architecture

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

- Interactive diagram: https://gitdiagram.com/dotnet/eshopsupport
- Repository: https://github.com/dotnet/eshopsupport

## Overview

##### Project type and purpose
- eShopSupport is a full-stack, microservices-style .NET Aspire solution demonstrating generative AI use cases (text classification, sentiment analysis, summarization, chat bots, synthetic data).
- It combines ASP.NET Core backends, Blazor WebUIs, a Python inference service, an identity provider, and data-generation/ingestion tools.

##### High-level file-structure analysis
- **root** (solution file, global props, docs, seeddata)
- `docs/Architecture.pptx` – existing slide deck
- `seeddata/` – C# DataGenerator project + sample JSON datasets
- `test/` – end-to-end and evaluation tests
- **src/** – main projects:
- **AppHost** – .NET Aspire host & API gateway, loads Python Uvicorn apps and local LLM plugins (Ollama)
- **Backend** – ASP.NET Core APIs (Catalog, Ticket, Assistant, TicketMessaging) and EF Core DbContext
- **IdentityServer** – OpenID Connect provider and sign-in UIs for authentication/authorization
- **CustomerWebUI** – Blazor client for customers
- **StaffWebUI** – Blazor client for staff with real-time ticket messaging
- **PythonInference** – Python/FastAPI service exposing embedding and classification endpoints
- **DataIngestor** – console app to ingest seed data into the DB
- **Evaluator** – .NET console to run evaluation tests on AI responses
- **ServiceDefaults** – shared HTTP/AI client defaults (ChatCompletion, PythonInference, Qdrant, Backend clients)

##### Key insights from README
- Architecture revolves around .NET Aspire’s AppHost, hosting multiple resource types (HTTP, Python, local models).
- Demonstrates integration of Python services and small local models via Ollama.
- Plans for cloud deployment, but current focus on local dev with Docker, Python, .NET tooling.

- **AppHost (API Gateway & Orchestrator)**
- **IdentityServer** (OAuth2/OIDC)
- **Backend Services**
- Catalog API
- Ticket API
- Assistant API
- TicketMessaging API (SignalR/Redis PubSub)
- **Databases & Caches**
- Relational DB (SQL Server/Postgres)
- Redis (real-time messaging cache)
- Vector store (Qdrant for semantic search)
- **PythonInference Service** (FastAPI via Uvicorn)
- **LLM Engine** (Ollama local model host)
- **Clients (Frontends)**
- CustomerWebUI (Blazor WASM/Server)
- StaffWebUI (Blazor)
- **Supporting Tools**
- DataIngestor
- Evaluator
- Tests (E2E, Evaluation)
- UIs → AppHost → appropriate API endpoints
- AppHost ↔ IdentityServer for authentication/authorization
- Backend Services ↔ AppHost (hosted as resources)
- Backend Services → Relational DB (CRUD via EF Core)
- TicketMessaging API ↔ Redis Pub/Sub ↔ StaffWebUI (SignalR)
- Assistant API → ChatCompletionService (OpenAI or Ollama plugin)
- Backend semantic-search services → PythonInference embeddings endpoint or Qdrant
- PythonInference ↔ AppHost (hosted under /python)
- DataIngestor → Relational DB (seed data)
- Evaluator → Assistant API + ChatCompletionCache (test folder)
c. Architectural patterns and principles:
- **API Gateway pattern** (AppHost centralizes hosting of .NET, Python, and LLM resources)
- **Microservices** (distinct projects for UI, API, inference, identity)
- **Separation of concerns** (UI vs API vs AI vs identity)
- **Event-driven messaging** (Redis/SignalR for real-time updates)
- **Extensibility** (PythonInference and Ollama are swappable)
d. Technologies & frameworks:
- .NET Aspire / ASP.NET Core / EF Core / Blazor
- IdentityServer (OpenID Connect)
- Python (FastAPI, Uvicorn)
- Ollama local LLM hosting
- Docker (local hosting), Redis, Qdrant
- OpenAI ChatCompletion client (via ServiceDefaults)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        CWUI["CustomerWebUI"]:::frontend
        SWUI["StaffWebUI"]:::frontend
    end

    %% API Gateway & Auth
    subgraph "API Layer"
        direction TB
        AH["AppHost (API Gateway & Orchestrator)"]:::api
        IS["IdentityServer"]:::auth
    end

    %% Backend Services
    subgraph "Backend Microservices"
        direction TB
        CAT["Catalog API"]:::api
        TIC["Ticket API"]:::api
        AST["Assistant API"]:::api
        TM["TicketMessaging API"]:::api
    end

    %% AI Services
    subgraph "AI & Inference Services"
        direction TB
        PI["PythonInference Service"]:::ai
        OL["Ollama LLM Engine"]:::ai
        OA["OpenAI ChatCompletion"]:::ai
    end

    %% Data & Storage
    subgraph "Data Stores"
        direction TB
        DB["Relational DB"]:::db
        RD["Redis Pub/Sub"]:::db
        VEC["Qdrant Vector Store"]:::db
    end

    %% Tools & Tests
    subgraph "Tools & Tests"
        direction TB
        DI["DataIngestor"]:::tool
        EV["Evaluator"]:::tool
        E2E["E2E Tests"]:::tool
        ET["Evaluation Tests"]:::tool
    end

    %% Presentation to API
    CWUI -->|"calls"| AH
    SWUI -->|"calls"| AH

    %% Authentication
    AH -->|"authN/authZ"| IS
    CWUI -->|"login flows"| IS
    SWUI -->|"login flows"| IS

    %% API Hosting
    AH -->|"hosts"| CAT
    AH -->|"hosts"| TIC
    AH -->|"hosts"| AST
    AH -->|"hosts"| TM
    AH -->|"hosts Python"| PI
    AH -->|"hosts Ollama"| OL

    %% Backend to Data
    CAT -->|"CRUD"| DB
    TIC -->|"CRUD"| DB
    AST -->|"semantic search"| VEC
    AST -->|"calls embedding"| PI
    TM -->|"pub/sub"| RD
    SWUI -->|"SignalR via"| TM

    %% AI Integrations
    AST -->|"ChatCompletion"| OA
    PI -->|"embedding/classify"| VEC

    %% Tools interactions
    DI -->|"seed data into"| DB
    EV -->|"tests"| AST
    E2E -->|"E2E flows via"| AH
    ET -->|"evaluates"| AST

    %% Click events
    click AH "https://github.com/dotnet/eshopsupport/tree/main/src/AppHost"
    click CAT "https://github.com/dotnet/eshopsupport/blob/main/src/Backend/Api/CatalogApi.cs"
    click TIC "https://github.com/dotnet/eshopsupport/blob/main/src/Backend/Api/TicketApi.cs"
    click AST "https://github.com/dotnet/eshopsupport/blob/main/src/Backend/Api/AssistantApi.cs"
    click TM "https://github.com/dotnet/eshopsupport/blob/main/src/Backend/Api/TicketMessagingApi.cs"
    click IS "https://github.com/dotnet/eshopsupport/tree/main/src/IdentityServer"
    click CWUI "https://github.com/dotnet/eshopsupport/tree/main/src/CustomerWebUI"
    click SWUI "https://github.com/dotnet/eshopsupport/tree/main/src/StaffWebUI"
    click PI "https://github.com/dotnet/eshopsupport/tree/main/src/PythonInference"
    click OL "https://github.com/dotnet/eshopsupport/tree/main/src/AppHost/Ollama"
    click DI "https://github.com/dotnet/eshopsupport/tree/main/src/DataIngestor"
    click EV "https://github.com/dotnet/eshopsupport/tree/main/src/Evaluator"
    click DI "https://github.com/dotnet/eshopsupport/tree/main/src/DataIngestor"
    click EV "https://github.com/dotnet/eshopsupport/tree/main/src/Evaluator"
    click E2E "https://github.com/dotnet/eshopsupport/tree/main/test/E2ETest"
    click ET "https://github.com/dotnet/eshopsupport/tree/main/test/EvaluationTests"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#1E90FF,color:#000
    classDef api fill:#90EE90,stroke:#008000,color:#000
    classDef auth fill:#98FB98,stroke:#006400,color:#000
    classDef ai fill:#D8BFD8,stroke:#800080,color:#000
    classDef db fill:#FFA500,stroke:#FF8C00,color:#000
    classDef tool fill:#D3D3D3,stroke:#696969,color:#000
```
