# varunda/honu architecture

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

- Interactive diagram: https://gitdiagram.com/varunda/honu
- Repository: https://github.com/varunda/honu

## Overview

##### Main Components (Top Level)

a) Frontend Layer:
- VueJS + TypeScript components (in /src directory)
- SignalR WebSocket clients for real-time updates
- Static assets (wwwroot)

b) Backend Layer:
- ASP.NET Core MVC application
- SignalR hubs for real-time communication
- Command processing system
- Event processing system

c) Data Layer:
- PostgreSQL database
- Census API integration (Daybreak Games)
- Caching system

##### Key Architectural Patterns to Highlight

a) Event-Driven Architecture:
- Event queues and processors
- Real-time event subscription system
- Background workers (Hosted Services)

b) Hub-and-Spoke Pattern for Real-time Updates:
- SignalR hubs as central communication points
- Multiple specialized hubs (AlertHub, MapHub, NetworkHub, etc.)

##### Detailed Component Breakdown

a) Services Layer:
- Census Services (API integration)
- Database Services
- Repository Services
- Hosted Background Services

b) Core Processing:
- Event Processing Pipeline
- Character Data Collection
- Statistics Aggregation
- Report Generation

a) External Data Flow:
- Census API → Event Processors
- Client Requests → API Controllers
- WebSocket Updates → Clients

b) Internal Data Flow:
- Event Processors → Database
- Database → Repositories → Services
- Services → Controllers/Hubs

##### Integration Points

- Census API integration
- Database connections
- WebSocket connections
- OpenTelemetry integration for tracing

##### The modularity of the different components

- All component types
- Special symbols used

Keep the abstraction level high enough to show the overall architecture while including enough detail to understand the system's key components and their interactions. Focus on showing how the real-time tracking and statistics generation work together with the background processing system.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Legend"
        L1[Frontend Component]:::frontend
        L2[Backend Service]:::backend
        L3[(Database)]:::database
        L4[External Service]:::external
        L5[Real-time Component]:::realtime
    end

    subgraph "Frontend Layer"
        VUE["Vue Components"]:::frontend
        SIGNAL_CLIENT["SignalR Clients"]:::frontend
        STATIC["Static Assets"]:::frontend
    end

    subgraph "Backend Layer"
        subgraph "API Layer"
            API_CTRL["API Controllers"]:::backend
            BASE_CTRL["Base Controllers"]:::backend
        end

        subgraph "Real-time Communication"
            HUBS["SignalR Hubs"]:::realtime
            HUB_IMPL["Hub Implementations"]:::realtime
        end

        subgraph "Core Processing"
            CMD_SYS["Command System"]:::backend
            CMD_PROC["Command Processing"]:::backend
            CHAR_STORE["Character Store"]:::backend
            ALERT_STORE["Alert Store"]:::backend
            ZONE_STORE["Zone State Store"]:::backend
        end

        subgraph "Background Processing"
            HOST_SVC["Hosted Services"]:::backend
            EVENT_PROC["Event Processing"]:::backend
        end
    end

    subgraph "Data Layer"
        DB[(PostgreSQL)]:::database
        REPOS["Repositories"]:::backend
        DB_SVC["Database Services"]:::backend
    end

    subgraph "External Services"
        CENSUS["Census API"]:::external
        CENSUS_SVC["Census Services"]:::backend
    end

    subgraph "Monitoring"
        HEALTH["Health Checks"]:::backend
        METRICS["Metrics"]:::backend
    end

    %% Relationships
    CENSUS --> CENSUS_SVC
    CENSUS_SVC --> EVENT_PROC
    EVENT_PROC --> DB
    DB <--> REPOS
    REPOS --> DB_SVC
    DB_SVC --> API_CTRL
    API_CTRL --> HUBS
    HUBS --> HUB_IMPL
    HUB_IMPL --> SIGNAL_CLIENT
    SIGNAL_CLIENT --> VUE
    CMD_SYS --> CMD_PROC
    CMD_PROC --> CHAR_STORE
    CMD_PROC --> ALERT_STORE
    CMD_PROC --> ZONE_STORE
    HOST_SVC --> EVENT_PROC
    HEALTH --> METRICS

    %% Click Events
    click VUE "https://github.com/Varunda/honu/tree/master/src/view/*"
    click SIGNAL_CLIENT "https://github.com/Varunda/honu/blob/master/src/view/realtimenetwork/RealtimeNetworkSocket.ts"
    click STATIC "https://github.com/Varunda/honu/tree/master/wwwroot/*"
    click API_CTRL "https://github.com/Varunda/honu/tree/master/Controllers/Api/*"
    click BASE_CTRL "https://github.com/Varunda/honu/blob/master/Controllers/ApiControllerBase.cs"
    click HUBS "https://github.com/Varunda/honu/tree/master/Code/Hubs/*"
    click HUB_IMPL "https://github.com/Varunda/honu/tree/master/Code/Hubs/Implementations/*"
    click CMD_SYS "https://github.com/Varunda/honu/tree/master/Code/Commands/*"
    click CMD_PROC "https://github.com/Varunda/honu/blob/master/Code/CommandBus.cs"
    click DB_SVC "https://github.com/Varunda/honu/tree/master/Services/Db/*"
    click CENSUS_SVC "https://github.com/Varunda/honu/tree/master/Services/Census/*"
    click REPOS "https://github.com/Varunda/honu/tree/master/Services/Repositories/*"
    click HOST_SVC "https://github.com/Varunda/honu/tree/master/Services/Hosted/*"
    click EVENT_PROC "https://github.com/Varunda/honu/blob/master/Services/Hosted/EventProcessService.cs"
    click CHAR_STORE "https://github.com/Varunda/honu/blob/master/Code/CharacterStore.cs"
    click ALERT_STORE "https://github.com/Varunda/honu/blob/master/Code/AlertStore.cs"
    click ZONE_STORE "https://github.com/Varunda/honu/blob/master/Code/ZoneStateStore.cs"
    click HEALTH "https://github.com/Varunda/honu/blob/master/Controllers/Api/HealthApiController.cs"
    click METRICS "https://github.com/Varunda/honu/tree/master/Services/Metrics/*"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#e74c3c,stroke:#c0392b,color:white
    classDef realtime fill:#9b59b6,stroke:#8e44ad,color:white
```
