# dontnod/web-app-starter architecture

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

- Interactive diagram: https://gitdiagram.com/dontnod/web-app-starter
- Repository: https://github.com/dontnod/web-app-starter

## Overview

##### Project Type and Purpose
- This is a full-stack web application boilerplate combining a React SPA client and a .NET 8 backend.
- It demonstrates authentication and authorization via Azure AD and MSAL, exposes a To-Do API, and uses a Clean/CQRS architecture with EF Core for persistence.

##### File Structure
- Top-level “src” folder subdivided into:
- Api: ASP.NET Core Web API, controllers, middleware, security filters, configuration.
- Application: business logic layer with CQRS (Commands, Queries), cross-cutting behaviors (logging, validation, performance, exception handling).
- Domain: entities, value objects, domain events.
- Infrastructure: EF Core DbContext, migrations, interceptors, domain-event dispatching.
- Client: React/Vite SPA, MSAL authentication, API clients, components, hooks, routes.
- Tests folder for functional end-to-end tests against the API and database in memory.
- Dev-ops/config files (Dockerfile, docker-compose, GitHub workflows, devcontainer) for local/dev/prod environments.

##### README Insights
- React SPA obtains JWT ID Token via MSAL from Azure AD, calls the To-Do .NET API.
- Database migrations using EF CLI.
- Docker-compose orchestration of SPA, API, and DB.
- Dev Container support for consistent dev environment.

##### Detail
- Mediator pipeline behaviors (logging, validation, performance).
- Interceptors for domain-event dispatch before/after saving entities.
- Environment configurations (appsettings, .env) feeding into Docker compose.
- Dev Container boundary if illustrating developer workflows.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        direction TB
        React["React SPA"]:::frontend
        MSAL["MSAL Auth Config"]:::frontend
        HTTPClient["HTTP Client"]:::frontend
        TodoList["TodoList Component"]:::frontend
        TodoForm["TodoForm Component"]:::frontend
    end

    AzureAD["Azure AD Identity Platform"]:::external
    User["User"]:::external

    User -->|uses| React
    React -->|configured by| MSAL
    React -->|calls| HTTPClient
    React -->|renders| TodoList
    React -->|renders| TodoForm
    MSAL -->|authenticates with| AzureAD
    HTTPClient -->|HTTP calls| API

    subgraph "Server Layer"
        direction TB

        subgraph "API Layer"
            direction TB
            Controllers["TodoListController"]:::backend
            PermissionFilter["PermissionFilter.cs"]:::backend
            ReadPermission["ReadTodoPermission.cs"]:::backend
            WritePermission["WriteTodoPermission.cs"]:::backend
            ClaimSettings["ClaimSettings.cs"]:::backend
            ExceptionHandler["CustomExceptionHandler.cs"]:::backend
            ResponseConvention["GlobalProducesResponseTypeConvention.cs"]:::backend
        end

        subgraph "Application Layer"
            direction TB
            Behaviours["MediatR Behaviours"]:::business
            CreateCommand["CreateTodoItemCommand.cs"]:::business
            CreateHandler["CreateTodoItemCommandHandler.cs"]:::business
            Query["GetUserTodoItemsQuery.cs"]:::business
            QueryHandler["GetUserTodoItemsQueryHandler.cs"]:::business
            InterfacesDb["IApplicationDbContext.cs"]:::business
            InterfacesUser["ICurrentUser.cs"]:::business
        end

        subgraph "Domain Layer"
            direction TB
            Entity["TodoItem.cs"]:::domain
            Event["TodoItemCreatedEvent.cs"]:::domain
        end

        subgraph "Infrastructure Layer"
            direction TB
            DbContext["ApplicationDbContext.cs"]:::infra
            Migration["20240517132224_InitialCreate.cs"]:::infra
            Interceptor["DispatchDomainEventsInterceptor.cs"]:::infra
        end

        Database["SQL Database"]:::db
    end

    API -->|filters| PermissionFilter
    API -->|filters| ReadPermission
    API -->|filters| WritePermission
    API -->|uses config| ClaimSettings
    API -->|uses middleware| ExceptionHandler
    API -->|uses conventions| ResponseConvention
    API -->|handles requests| Controllers
    Controllers -->|sends to| Behaviours
    Behaviours -->|executes| CreateCommand
    Behaviours -->|executes| Query
    CreateCommand -->|handled by| CreateHandler
    Query -->|handled by| QueryHandler
    CreateHandler -->|calls| InterfacesDb
    QueryHandler -->|calls| InterfacesDb
    InterfacesDb -->|implements| DbContext
    InterfacesDb -->|provides user| InterfacesUser
    DbContext -->|runs migrations| Migration
    DbContext -->|uses| Interceptor
    DbContext -->|connects to| Database

    subgraph "Test Harness"
        direction TB
        Tests["CreateTodoItemTests.cs"]:::test
    end
    Tests -->|calls| API

    click React "https://github.com/dontnod/web-app-starter/tree/main/src/Client"
    click MSAL "https://github.com/dontnod/web-app-starter/blob/main/src/Client/src/config/auth-config.ts"
    click HTTPClient "https://github.com/dontnod/web-app-starter/blob/main/src/Client/src/api/http-client.ts"
    click TodoList "https://github.com/dontnod/web-app-starter/blob/main/src/Client/src/components/TodoList/TodoList.tsx"
    click TodoForm "https://github.com/dontnod/web-app-starter/blob/main/src/Client/src/components/TodoForm/TodoForm.tsx"
    click API "https://github.com/dontnod/web-app-starter/tree/main/src/Api"
    click Controllers "https://github.com/dontnod/web-app-starter/blob/main/src/Api/Controllers/TodoListController.cs"
    click PermissionFilter "https://github.com/dontnod/web-app-starter/blob/main/src/Api/Security/PermissionFilter.cs"
    click ReadPermission "https://github.com/dontnod/web-app-starter/blob/main/src/Api/Security/ReadTodoPermission.cs"
    click WritePermission "https://github.com/dontnod/web-app-starter/blob/main/src/Api/Security/WriteTodoPermission.cs"
    click ClaimSettings "https://github.com/dontnod/web-app-starter/blob/main/src/Api/Configuration/ClaimSettings.cs"
    click ExceptionHandler "https://github.com/dontnod/web-app-starter/blob/main/src/Api/Infrastructure/CustomExceptionHandler.cs"
    click ResponseConvention "https://github.com/dontnod/web-app-starter/blob/main/src/Api/Infrastructure/GlobalProducesResponseTypeConvention.cs"
    click Behaviours "https://github.com/dontnod/web-app-starter/tree/main/src/Application/Common/Behaviours"
    click CreateCommand "https://github.com/dontnod/web-app-starter/blob/main/src/Application/TodoItems/Commands/CreateTodoItem/CreateTodoItemCommand.cs"
    click CreateHandler "https://github.com/dontnod/web-app-starter/blob/main/src/Application/TodoItems/Commands/CreateTodoItem/CreateTodoItemCommandHandler.cs"
    click Query "https://github.com/dontnod/web-app-starter/blob/main/src/Application/TodoItems/Queries/GetUserTodoItems/GetUserTodoItemsQuery.cs"
    click QueryHandler "https://github.com/dontnod/web-app-starter/blob/main/src/Application/TodoItems/Queries/GetUserTodoItems/GetUserTodoItemsQueryHandler.cs"
    click InterfacesDb "https://github.com/dontnod/web-app-starter/blob/main/src/Application/Common/Interfaces/IApplicationDbContext.cs"
    click InterfacesUser "https://github.com/dontnod/web-app-starter/blob/main/src/Application/Common/Interfaces/ICurrentUser.cs"
    click Entity "https://github.com/dontnod/web-app-starter/blob/main/src/Domain/Entities/TodoItem.cs"
    click Event "https://github.com/dontnod/web-app-starter/blob/main/src/Domain/Events/TodoItemCreatedEvent.cs"
    click DbContext "https://github.com/dontnod/web-app-starter/blob/main/src/Infrastructure/Data/ApplicationDbContext.cs"
    click Migration "https://github.com/dontnod/web-app-starter/blob/main/src/Infrastructure/Data/Migrations/20240517132224_InitialCreate.cs"
    click Interceptor "https://github.com/dontnod/web-app-starter/blob/main/src/Infrastructure/Data/Interceptors/DispatchDomainEventsInterceptor.cs"
    click Tests "https://github.com/dontnod/web-app-starter/blob/main/tests/Application.FunctionalTests/Commands/CreateTodoItemTests.cs"

    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef business fill:#FFD700,stroke:#333,stroke-width:1px
    classDef domain fill:#F0E68C,stroke:#333,stroke-width:1px
    classDef infra fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef db fill:#A9A9A9,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef test fill:#FFB6C1,stroke:#333,stroke-width:1px
```
