# oising/aspireprojectcommander architecture

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

- Interactive diagram: https://gitdiagram.com/oising/aspireprojectcommander
- Repository: https://github.com/oising/aspireprojectcommander

## Overview

##### Main Components

a) Core Components:
- Aspire Dashboard (existing component)
- Project Commander Hub (SignalR Hub)
- Project Commander Client
- Target Projects (Consumer Applications)

b) Integration Components:
- Hosting Package (Nivot.Aspire.Hosting.ProjectCommander)
- Integration Package (Nivot.Aspire.ProjectCommander)

**[Aspire Dashboard] <---> [Project Commander Hub]**

- v
**[Target Projects] <---> [Project Commander Client]**

##### Specific Implementation Details

a) Communication Flow:
- Command flow from Dashboard → Hub → Client → Target Projects
- Configuration flow from AppHost to Projects

b) Component Relationships:
- How the Hosting package (ProjectCommanderHub) integrates with Aspire Dashboard
- How the Integration package (ProjectCommanderClient) connects to target projects
- Demonstrate the registration of commands and their handlers

##### Important Elements to Highlight

- Command Registration Flow
- SignalR Hub Connection
- Command Handling Pipeline
- Integration Points with Aspire
- Background Service Workers

##### Technical Details

Specific implementations:
- ProjectCommanderHub implementation
- IAspireProjectCommanderClient interface
- Command registration mechanism
- Background service workers
- Resource builder extensions

##### Architectural Patterns

Patterns:
- Publisher/Subscriber pattern for commands
- Dependency Injection
- Resource Builder pattern
- Background Service pattern

**[Dashboard Layer]**
- Aspire Dashboard
- Command UI Interface

**[Hub Layer]**
- ProjectCommanderHub
- SignalR Infrastructure
- Command Registration

**[Client Layer]**
- ProjectCommanderClient
- Command Handlers
- Background Services

**[Application Layer]**
- Target Projects
- Command Implementations

Annotations for:
- Configuration points
- Extension methods
- Service registration
- Command flow
- Resource dependencies

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef dashboard fill:#4287f5,color:white
    classDef hub fill:#2ecc71,color:white
    classDef client fill:#27ae60,color:white
    classDef target fill:#e67e22,color:white
    classDef config fill:#9b59b6,color:white
    classDef service fill:#95a5a6,color:white
    classDef integration fill:#3498db,color:white

    %% Dashboard Layer
    subgraph DashboardLayer["Dashboard Layer"]
        Dashboard["Aspire Dashboard"]:::dashboard
    end

    %% Hub Layer
    subgraph HubLayer["Hub Layer"]
        PCHub["Project Commander Hub"]:::hub
        HubOptions["Hub Options"]:::config
        HubResource["Hub Resource"]:::config
        HubLifecycle["Hub Lifecycle Hook"]:::config
    end

    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        PCClient["Project Commander Client"]:::client
        ClientWorker["Client Worker Service"]:::service
        ClientInterface["Commander Client Interface"]:::integration
    end

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        AppHost["AppHost"]:::target
        Consumer["Consumer App"]:::target
        DataGen["Data Generator"]:::target
        ServiceDefaults["Service Defaults"]:::config
    end

    %% Integration Components
    subgraph Integration["Integration Components"]
        DistBuilderExt["Distributed Builder Extensions"]:::integration
        ResBuilderExt["Resource Builder Extensions"]:::integration
        ServiceCollExt["Service Collection Extensions"]:::integration
    end

    %% Relationships
    Dashboard <--> |SignalR| PCHub
    PCHub --> ClientInterface
    PCHub --- HubOptions
    PCHub --- HubResource
    PCHub --- HubLifecycle
    
    ClientInterface --> PCClient
    PCClient --- ClientWorker
    
    PCClient --> Consumer
    PCClient --> DataGen
    
    AppHost --> ServiceDefaults
    ServiceDefaults --> Consumer
    ServiceDefaults --> DataGen
    
    DistBuilderExt --> PCHub
    ResBuilderExt --> PCHub
    ServiceCollExt --> PCClient

    %% Click Events
    click PCHub "https://github.com/oising/AspireProjectCommander/blob/main/Src/Nivot.Aspire.Hosting.ProjectCommander/ProjectCommanderHub.cs"
    click HubOptions "https://github.com/oising/AspireProjectCommander/blob/main/Src/Nivot.Aspire.Hosting.ProjectCommander/ProjectCommanderHubOptions.cs"
    click HubResource "https://github.com/oising/AspireProjectCommander/blob/main/Src/Nivot.Aspire.Hosting.ProjectCommander/ProjectCommanderHubResource.cs"
    click HubLifecycle "https://github.com/oising/AspireProjectCommander/blob/main/Src/Nivot.Aspire.Hosting.ProjectCommander/ProjectCommanderHubLifecycleHook.cs"
    click ClientInterface "https://github.com/oising/AspireProjectCommander/blob/main/Src/Nivot.Aspire.ProjectCommander/IAspireProjectCommanderClient.cs"
    click ClientWorker "https://github.com/oising/AspireProjectCommander/blob/main/Src/Nivot.Aspire.ProjectCommander/AspireProjectCommanderClientWorker.cs"
    click DistBuilderExt "https://github.com/oising/AspireProjectCommander/blob/main/Src/Nivot.Aspire.Hosting.ProjectCommander/DistributedApplicationBuilderExtensions.cs"
    click ResBuilderExt "https://github.com/oising/AspireProjectCommander/blob/main/Src/Nivot.Aspire.Hosting.ProjectCommander/ResourceBuilderProjectCommanderExtensions.cs"
    click ServiceCollExt "https://github.com/oising/AspireProjectCommander/blob/main/Src/Nivot.Aspire.ProjectCommander/ServiceCollectionAspireProjectCommanderExtensions.cs"
    click AppHost "https://github.com/oising/AspireProjectCommander/blob/main/Sample/ProjectCommander.AppHost/Program.cs"
    click Consumer "https://github.com/oising/AspireProjectCommander/blob/main/Sample/Consumer/Program.cs"
    click DataGen "https://github.com/oising/AspireProjectCommander/blob/main/Sample/DataGenerator/Program.cs"
    click ServiceDefaults "https://github.com/oising/AspireProjectCommander/blob/main/Sample/ProjectCommander.ServiceDefaults/Extensions.cs"

    %% Legend
    subgraph Legend["Legend"]
        L1["Aspire Component"]:::dashboard
        L2["Project Commander Component"]:::hub
        L3["Target Application"]:::target
        L4["Configuration"]:::config
        L5["Service"]:::service
        L6["Integration"]:::integration
    end
```
