# odumpling/olivebranch architecture

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

- Interactive diagram: https://gitdiagram.com/odumpling/olivebranch
- Repository: https://github.com/odumpling/olivebranch

## Overview

##### High-Level Architecture Overview

a. Client Layer (Frontend)
- Vue.js SPA components
- Inertia.js as the bridge between frontend and backend
- Frontend technologies (Tailwind CSS, Vite)

b. Web Layer (Presentation)
- ASP.NET Core Controllers
- Inertia.js Adapter
- Middleware components

c. Application Layer
- CQRS pattern (Commands and Queries)
- MediatR handlers
- Behaviors (Validation, Authorization, Logging)

d. Domain Layer
- Entities
- Value Objects
- Domain Events

e. Infrastructure Layer
- Entity Framework Core
- Database context
- External services

##### Component Relationships

a. Data Flow
- Frontend → Inertia.js → Controllers → Application Layer
- Application Layer → Domain Layer
- Infrastructure Layer providing implementation details

b. Cross-Cutting Concerns
- Authentication/Authorization flow
- Validation pipeline
- Logging and exception handling

##### Specific Implementation Details

a. Frontend Structure
- Vue Components hierarchy
- Auth pages
- Shared layouts
- CSS/JS assets

b. Backend Structure
- Todo Items/Lists feature modules
- Weather Forecasts module
- Auth module
- Common behaviors and interfaces

##### Key Elements to Highlight

a. Authentication Flow
- Login/Register commands
- Authorization behavior
- Current user service

b. CQRS Implementation
- Command handlers (CreateTodoList, UpdateTodoItem, etc.)
- Query handlers (GetTodos, GetWeatherForecasts)
- Event handlers (TodoItemCompletedEventHandler)

c. Data Access
- AppDbContext
- Entity configurations
- Migrations

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef frontend fill:#3498db,color:white
    classDef api fill:#2ecc71,color:white
    classDef application fill:#f1c40f,color:black
    classDef domain fill:#e74c3c,color:white
    classDef infrastructure fill:#9b59b6,color:white
    classDef external fill:#95a5a6,color:white

    %% Frontend Layer
    subgraph Frontend
        VueComponents["Vue Components"]:::frontend
        AuthPages["Auth Pages"]:::frontend
        SharedLayouts["Shared Layouts"]:::frontend
        Assets["CSS/JS Assets"]:::frontend
    end
    click VueComponents "https://github.com/ODumpling/OliveBranch/tree/main/src/WebApp/Frontend/js/Components/"
    click AuthPages "https://github.com/ODumpling/OliveBranch/tree/main/src/WebApp/Frontend/js/Pages/Auth/"
    click SharedLayouts "https://github.com/ODumpling/OliveBranch/tree/main/src/WebApp/Frontend/js/Shared/"

    %% Web Layer
    subgraph Web
        Controllers["Controllers"]:::api
        InertiaAdapter["Inertia.js Adapter"]:::api
        Middleware["Middleware"]:::api
        CurrentUserSvc["Current User Service"]:::api
    end
    click Controllers "https://github.com/ODumpling/OliveBranch/tree/main/src/WebApp/Controllers/"
    click Middleware "https://github.com/ODumpling/OliveBranch/tree/main/src/WebApp/Middleware/"
    click CurrentUserSvc "https://github.com/ODumpling/OliveBranch/blob/main/src/WebApp/Services/CurrentUserService.cs"

    %% Application Layer
    subgraph Application
        Commands["Commands"]:::application
        Queries["Queries"]:::application
        EventHandlers["Event Handlers"]:::application
        Behaviors["Behaviors"]:::application
    end
    click Commands "https://github.com/ODumpling/OliveBranch/tree/main/src/Application/TodoItems/Commands/"
    click Queries "https://github.com/ODumpling/OliveBranch/tree/main/src/Application/TodoItems/Queries/"
    click EventHandlers "https://github.com/ODumpling/OliveBranch/tree/main/src/Application/TodoItems/EventHandlers/"
    click Behaviors "https://github.com/ODumpling/OliveBranch/tree/main/src/Application/Common/Behaviours/"

    %% Domain Layer
    subgraph Domain
        Entities["Entities"]:::domain
        ValueObjects["Value Objects"]:::domain
        DomainEvents["Domain Events"]:::domain
        CommonBase["Common Base Classes"]:::domain
    end
    click Entities "https://github.com/ODumpling/OliveBranch/tree/main/src/Domain/Entities/"
    click ValueObjects "https://github.com/ODumpling/OliveBranch/tree/main/src/Domain/ValueObjects/"
    click DomainEvents "https://github.com/ODumpling/OliveBranch/tree/main/src/Domain/Events/"
    click CommonBase "https://github.com/ODumpling/OliveBranch/tree/main/src/Domain/Common/"

    %% Infrastructure Layer
    subgraph Infrastructure
        DbContext["AppDbContext"]:::infrastructure
        EntityConfig["Entity Configurations"]:::infrastructure
        Migrations["Database Migrations"]:::infrastructure
        DateTimeService["DateTime Service"]:::infrastructure
    end
    click DbContext "https://github.com/ODumpling/OliveBranch/blob/main/src/Infrastructure/Data/AppDbContext.cs"
    click EntityConfig "https://github.com/ODumpling/OliveBranch/tree/main/src/Infrastructure/Data/Configurations/"
    click Migrations "https://github.com/ODumpling/OliveBranch/tree/main/src/Infrastructure/Data/Migrations/"
    click DateTimeService "https://github.com/ODumpling/OliveBranch/blob/main/src/Infrastructure/Common/DateTimeService.cs"

    %% Cross-Cutting Concerns
    subgraph CrossCutting
        Auth["Authorization"]:::application
        Validation["Validation"]:::application
        ExceptionHandling["Exception Handling"]:::application
        Logging["Logging"]:::application
    end
    click Auth "https://github.com/ODumpling/OliveBranch/blob/main/src/Application/Common/Security/AuthorizeAttribute.cs"
    click Validation "https://github.com/ODumpling/OliveBranch/blob/main/src/Application/Common/Behaviours/ValidationBehaviour.cs"
    click ExceptionHandling "https://github.com/ODumpling/OliveBranch/blob/main/src/Application/Common/Behaviours/UnhandledExceptionBehaviour.cs"
    click Logging "https://github.com/ODumpling/OliveBranch/blob/main/src/Application/Common/Behaviours/LoggingBehaviour.cs"

    %% Relationships
    VueComponents --> InertiaAdapter
    AuthPages --> InertiaAdapter
    SharedLayouts --> InertiaAdapter
    InertiaAdapter --> Controllers
    Controllers --> Commands
    Controllers --> Queries
    Commands --> Entities
    Queries --> Entities
    EventHandlers --> DomainEvents
    Entities --> DomainEvents
    DbContext --> Entities
    EntityConfig --> DbContext
    Migrations --> DbContext
    CrossCutting --> Application
    Application --> Domain
    Infrastructure --> Domain

    %% Legend
    subgraph Legend
        Frontend_["Frontend"]:::frontend
        API_["API/Web"]:::api
        App_["Application"]:::application
        Domain_["Domain"]:::domain
        Infra_["Infrastructure"]:::infrastructure
    end
```
