# martincostello/dotnet-minimal-api-integration-testing architecture

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

- Interactive diagram: https://gitdiagram.com/martincostello/dotnet-minimal-api-integration-testing
- Repository: https://github.com/martincostello/dotnet-minimal-api-integration-testing

## Overview

##### Main Components

a. Frontend Layer:
- Razor Pages (Pages directory)
- TypeScript Client (scripts/ts directory)
- Static Assets (wwwroot directory)

b. Backend Layer:
- Minimal API Endpoints (ApiEndpoints.cs, AuthenticationEndpoints.cs)
- Services Layer (Services directory)
- Data Access Layer (Data directory)

c. External Services:
- GitHub OAuth Authentication
- SQLite Database

##### Component Relationships

- Client Browser → Frontend Layer
- Frontend Layer → Backend API Layer
- Backend API Layer → Services Layer
- Services Layer → Data Access Layer
- Backend → GitHub OAuth
- Data Access Layer → SQLite Database

##### Specific Implementation Details

Technical components:
- EF Core context (TodoContext)
- Repository Pattern (ITodoRepository, TodoRepository)
- TypeScript Models (TodoItem.ts, TodoList.ts)
- API Models (CreateTodoItemModel, TodoItemModel)

##### Architecture Pattern Representation

Following patterns:
- Clean Architecture layers
- Repository Pattern
- Dependency Injection flow
- OAuth authentication flow

**[Browser Client]**
- ↓
**[Frontend Layer]**
- Razor Pages
- TypeScript Client
- Static Assets
- ↓
**[Backend API Layer (Minimal APIs)]**
- API Endpoints
- Authentication Endpoints
- ↓
**[Services Layer]**
- TodoService
- ↓
**[Data Access Layer]**
- TodoContext (EF Core)
- Repository Interface
- Repository Implementation
- ↓
**[SQLite Database]**

**[GitHub OAuth]**
- ↑
- [Authentication Flow]

- Blue: Frontend components
- Green: API layer
- Yellow: Service layer
- Orange: Data access layer
- Gray: External services
- Purple: Authentication flow

Additional Visualization Guidelines:

##### Testing infrastructure
- WebApplicationFactory
- Playwright UI testing
- HttpClient interception points

##### A separate view for the testing architecture
- Integration test setup
- UI test configuration
- Mock points for external services

Remember to maintain a balance between detail and clarity, focusing on the architectural decisions that make this project unique, such as the minimal API approach and the integration testing strategy.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Browser Client"]
    end

    subgraph Frontend
        RazorPages["Razor Pages"]:::frontend
        TSClient["TypeScript Client"]:::frontend
        StaticAssets["Static Assets"]:::frontend
        TSModels["TypeScript Models"]:::frontend
        ViewComponents["Frontend Components"]:::frontend
    end

    subgraph API
        APIEndpoints["API Endpoints"]:::api
        AuthEndpoints["Authentication Endpoints"]:::api
        APIModels["API Models"]:::api
    end

    subgraph Services
        TodoService["Todo Service"]:::service
    end

    subgraph DataAccess
        TodoContext["Todo Context"]:::data
        RepoInterface["Repository Interface"]:::data
        RepoImpl["Repository Implementation"]:::data
        DB[(SQLite Database)]:::database
    end

    subgraph External
        GitHub["GitHub OAuth"]:::external
    end

    subgraph Testing
        TestInfra["Testing Infrastructure"]:::test
    end

    %% Relationships
    Browser --> RazorPages
    Browser --> TSClient
    Browser --> StaticAssets
    
    TSClient --> TSModels
    TSClient --> ViewComponents
    TSClient --> APIEndpoints
    
    RazorPages --> APIEndpoints
    RazorPages --> AuthEndpoints
    
    APIEndpoints --> TodoService
    AuthEndpoints --> GitHub
    
    TodoService --> RepoInterface
    RepoInterface --> RepoImpl
    RepoImpl --> TodoContext
    TodoContext --> DB

    TestInfra -.-> APIEndpoints
    TestInfra -.-> AuthEndpoints

    %% Click Events
    click RazorPages "https://github.com/martincostello/dotnet-minimal-api-integration-testing/tree/main/src/TodoApp/Pages"
    click TSClient "https://github.com/martincostello/dotnet-minimal-api-integration-testing/tree/main/src/TodoApp/scripts/ts"
    click StaticAssets "https://github.com/martincostello/dotnet-minimal-api-integration-testing/tree/main/src/TodoApp/wwwroot"
    click APIEndpoints "https://github.com/martincostello/dotnet-minimal-api-integration-testing/blob/main/src/TodoApp/ApiEndpoints.cs"
    click AuthEndpoints "https://github.com/martincostello/dotnet-minimal-api-integration-testing/blob/main/src/TodoApp/AuthenticationEndpoints.cs"
    click TodoService "https://github.com/martincostello/dotnet-minimal-api-integration-testing/tree/main/src/TodoApp/Services"
    click TodoContext "https://github.com/martincostello/dotnet-minimal-api-integration-testing/blob/main/src/TodoApp/Data/TodoContext.cs"
    click RepoInterface "https://github.com/martincostello/dotnet-minimal-api-integration-testing/blob/main/src/TodoApp/Data/ITodoRepository.cs"
    click RepoImpl "https://github.com/martincostello/dotnet-minimal-api-integration-testing/blob/main/src/TodoApp/Data/TodoRepository.cs"
    click TSModels "https://github.com/martincostello/dotnet-minimal-api-integration-testing/tree/main/src/TodoApp/scripts/ts/models"
    click APIModels "https://github.com/martincostello/dotnet-minimal-api-integration-testing/tree/main/src/TodoApp/Models"
    click ViewComponents "https://github.com/martincostello/dotnet-minimal-api-integration-testing/tree/main/src/TodoApp/scripts/ts/view"
    click TestInfra "https://github.com/martincostello/dotnet-minimal-api-integration-testing/blob/main/tests/TodoApp.Tests"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#f1c40f,stroke:#f39c12,color:black
    classDef data fill:#e67e22,stroke:#d35400,color:white
    classDef database fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef test fill:#e74c3c,stroke:#c0392b,color:white
```
