# mattrathburn/gymhub architecture

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

- Interactive diagram: https://gitdiagram.com/mattrathburn/gymhub
- Repository: https://github.com/mattrathburn/gymhub

## Overview

##### Project type and purpose
- This is a full-stack, cloud-native microservices application (“Gym Hub”) for fitness-program subscription, built on .NET 8 with Clean Architecture and Vertical-Slice principles.
- It comprises multiple back-end services (APIs, event bus, DB manager), two client UIs (Blazor Admin and two WebApp flavors—Angular & React/Vite), plus infrastructure libraries.

##### File-structure highlights & architectural patterns
- src/EventBus + src/EventBusRabbitMQ: a shared abstraction layer and RabbitMQ/MassTransit integration for async, event-driven communication.
- GymHub.ServiceDefaults: common startup, swagger, authn/authz extensions used by all services.
- GymHub.AppHost: the host project orchestrating service registration (APIs, event bus, defaults).
- GH.Plan.API, Todo.API: vertical-slice microservices exposing REST endpoints, using EF Core migrations to PostgreSQL (and optionally SQL Server).
- GH.Plan.DbManager: a console or background service bootstrapping DB schemas/data.
- GH.Infrastructure & GH.Plan.Db: data models, DbContexts, repository implementations.
- GH.Admin (Blazor) and GH.WebApp (Angular + React/Vite): front-end clients consuming the APIs.
- Identity Server (implied by README): an authN/authZ microservice or external provider.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        BlazorAdmin["Blazor Admin UI"]:::frontend
        AngularWebApp["Angular WebApp"]:::frontend
        ReactViteWebApp["React/Vite WebApp"]:::frontend
    end

    %% Orchestration Layer
    subgraph "Orchestration Layer"
        direction TB
        AppHost["GymHub.AppHost"]:::service
    end

    %% Microservices Layer
    subgraph "Microservices Layer"
        direction TB
        PlanAPI["GH.Plan.API - Plans Service"]:::service
        TodoAPI["Todo.API - Task Service"]:::service
        DbManager["GH.Plan.DbManager"]:::service
    end

    %% Shared Libraries
    subgraph "Shared Libraries"
        direction TB
        ServiceDefaults["GymHub.ServiceDefaults"]:::lib
        EventBusAbs["EventBus Abstractions"]:::lib
        EventBusCore["EventBus Core Library"]:::lib
        RabbitMQIntegration["RabbitMQ Integration (MassTransit)"]:::lib
        InfrastructureModels["GH.Infrastructure"]:::lib
        PlanDb["GH.Plan.Db"]:::lib
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        direction TB
        RabbitMQBroker["RabbitMQ Broker"]:::broker
        PostgreSQL["PostgreSQL DB"]:::infra
        SQLServer["SQL Server DB"]:::infra
    end

    %% Connections
    BlazorAdmin -->|HTTP/HTTPS| AppHost
    AngularWebApp -->|HTTP/HTTPS| AppHost
    ReactViteWebApp -->|HTTP/HTTPS| AppHost

    AppHost -->|In-Process DI / HTTP| PlanAPI
    AppHost -->|In-Process DI / HTTP| TodoAPI

    PlanAPI -->|EF Core| PostgreSQL
    PlanAPI -->|EF Core| SQLServer
    TodoAPI -->|EF Core| PostgreSQL
    TodoAPI -->|EF Core| SQLServer

    PlanAPI -->|Publish PlanCreatedEvent| RabbitMQBroker
    TodoAPI -->|Publish TodoEvent| RabbitMQBroker
    PlanAPI <-->|Subscribe Events| RabbitMQBroker
    TodoAPI <-->|Subscribe Events| RabbitMQBroker

    DbManager -->|DB Migrations/Seeding| PostgreSQL
    DbManager -->|DB Migrations/Seeding| SQLServer

    AppHost -->|uses| ServiceDefaults
    AppHost -->|uses| EventBusAbs
    AppHost -->|uses| EventBusCore
    AppHost -->|uses| RabbitMQIntegration

    PlanAPI -->|references| ServiceDefaults
    PlanAPI -->|references| EventBusAbs
    PlanAPI -->|references| EventBusCore
    PlanAPI -->|references| RabbitMQIntegration
    PlanAPI -->|references| InfrastructureModels
    PlanAPI -->|references| PlanDb

    TodoAPI -->|references| ServiceDefaults
    TodoAPI -->|references| EventBusAbs
    TodoAPI -->|references| EventBusCore
    TodoAPI -->|references| RabbitMQIntegration

    %% Click Events
    click EventBusAbs "https://github.com/mattrathburn/gymhub/tree/main/src/EventBus/Abstractions"
    click EventBusCore "https://github.com/mattrathburn/gymhub/blob/main/src/EventBus/EventBus.csproj"
    click RabbitMQIntegration "https://github.com/mattrathburn/gymhub/tree/main/src/EventBusRabbitMQ"
    click ServiceDefaults "https://github.com/mattrathburn/gymhub/blob/main/src/GymHub.ServiceDefaults"
    click AppHost "https://github.com/mattrathburn/gymhub/blob/main/src/GymHub.AppHost"
    click PlanAPI "https://github.com/mattrathburn/gymhub/blob/main/src/GH.Plan.API"
    click TodoAPI "https://github.com/mattrathburn/gymhub/blob/main/src/Todo.API"
    click DbManager "https://github.com/mattrathburn/gymhub/blob/main/src/GH.Plan.DbManager"
    click InfrastructureModels "https://github.com/mattrathburn/gymhub/blob/main/src/GH.Infrastructure"
    click PlanDb "https://github.com/mattrathburn/gymhub/blob/main/src/GH.Plan.Db"
    click BlazorAdmin "https://github.com/mattrathburn/gymhub/blob/main/src/GH.Admin/GH.Admin.Client"
    click AngularWebApp "https://github.com/mattrathburn/gymhub/blob/main/src/GH.WebApp/gh.webapp.ng"
    click ReactViteWebApp "https://github.com/mattrathburn/gymhub/blob/main/src/GH.WebApp/gh.webapp.vite"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000
    classDef service fill:#90EE90,stroke:#000
    classDef lib fill:#D3D3D3,stroke:#000
    classDef infra fill:#FFA500,stroke:#000
    classDef broker fill:#9370DB,stroke:#000
```
