# cerebellum-network/cluster-apps architecture

> Architecture diagram of the GitHub repository cerebellum-network/cluster-apps, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cerebellum-network/cluster-apps
- Repository: https://github.com/cerebellum-network/cluster-apps

## Overview

##### Main Components Identification
- Applications Layer: Represent the three primary web apps:
- Developer Console – with multiple sub-modules (e.g., ActivityCapture, ContentDelivery, ContentStorage).
- Node Provider Console – which includes modules like Network Topology, Node Configuration Steps, Payouts, etc.
- Global Registry – another web app focusing on registry and access management.
- Shared Packages: Illustrate the repositories under “packages” which include:
- API package – handling all the backend communication with endpoints such as AccessRegistryApi, ClusterManagementApi, FaucetApi, IndexerApi, and StatsApi.
- Analytics and Reporting packages – which are used across the UIs to monitor and report on system metrics.
- Infrastructure & Configuration: Note the environment configuration files (e.g., .env files for dev, prod and stage) and the GitHub workflows (CI/CD pipelines) that automate testing and deployment.
- Build and Tooling: Incorporate nodes for tools like ESLint, Prettier, Vite configuration, and the standard Node Version Manager (.nvmrc) for setting the runtime environment.

##### Relationships and Interactions
- Each app in “apps” draws from the shared “packages” (such as the UI and API libraries) to maintain consistent component design and API integrations.
- GitHub Actions (found in the .github/workflows directory) are crucial for automating deployments and tests; thus, include these as an external CI/CD pipeline that triggers builds and deployments.

##### Highlighting Architectural Patterns and Design Principles
- Monorepo Architecture: Show that multiple independent web app projects and shared libraries coexist within a single repository. This is beneficial for synchronization of changes and consistent dependency management.
- Component-Based UI: Each web app is structured using UI components (as evidenced by the many component directories) and adheres to a clear separation of concerns – for example, by having dedicated folders for routes, stores, hooks, and components.
- Modular and Reusable Code: The “packages” directory embodies this principle. Emphasize how the UI and API packages are designed for reusability across different apps.
- Frontend Routing and State Management: With robust routing (files in routes/) and state management (stores/), these aspects should be visually represented, for instance, by grouping routes and store modules within each app.

##### Detailed Layers
- Top Layer: CI/CD and Environment Management – show GitHub workflows and .env files linking to deployment pipelines.
- Middle Layer: The three main web apps (each as a separate module with submodules inside for their routes, stores, and components).
- Bottom Layer: Shared packages/libraries – represent the analytics, API, reporting, and UI libraries, and their utility across the apps.

## Diagram (Mermaid)

```mermaid
graph TD
  %% Top Layer: Deployment & Configuration
  subgraph "Deployment & Configuration"
    CICD["CI/CD Pipelines"]:::external
    Env["Environment Config (.env.dev, .env.prod, .env.stage)"]:::external
    subgraph "Build & Tooling"
      ESLint["ESLint (.eslintrc.json)"]:::tooling
      Prettier["Prettier (.prettierrc.json)"]:::tooling
      Vite["Vite (vite.config.ts)"]:::tooling
      NVM["Node Version (.nvmrc)"]:::tooling
    end
  end

  %% Middle Layer: Web Applications
  subgraph "Web Applications"
    %% Developer Console Subgraph
    subgraph "Developer Console"
      DevConsole["Developer Console"]:::app
      ActCap["ActivityCapture"]:::module
      ContentDel["ContentDelivery"]:::module
      ContentStor["ContentStorage"]:::module
      DevConsole --> ActCap
      DevConsole --> ContentDel
      DevConsole --> ContentStor
    end

    %% Node Provider Console Subgraph
    subgraph "Node Provider Console"
      NodeProv["Node Provider Console"]:::app
      NetTopo["Network Topology"]:::module
      NodeConf["Node Configuration Steps"]:::module
      Payouts["Payouts"]:::module
      NodeProv --> NetTopo
      NodeProv --> NodeConf
      NodeProv --> Payouts
    end

    %% Global Registry Subgraph
    subgraph "Global Registry"
      GlobalReg["Global Registry"]:::app
      AccessReg["Access & Registry Management"]:::module
      GlobalReg --> AccessReg
    end
  end

  %% Bottom Layer: Shared Packages
  subgraph "Shared Packages"
    SharedAPI["Shared API Package"]:::package
    SharedUI["Shared UI Package"]:::package
    SharedAnalytics["Shared Analytics Package"]:::package
    SharedReporting["Shared Reporting Package"]:::package
  end

  %% Relationships between Deployment & Configuration and Web Applications
  CICD -->|"triggers"| DevConsole
  CICD -->|"triggers"| NodeProv
  CICD -->|"triggers"| GlobalReg
  Env -->|"configures"| DevConsole
  Env -->|"configures"| NodeProv
  Env -->|"configures"| GlobalReg
  ESLint -->|"lints"| DevConsole
  ESLint -->|"lints"| NodeProv
  ESLint -->|"lints"| GlobalReg

  %% Relationships between Web Applications and Shared Packages
  DevConsole -->|"uses"| SharedAPI
  DevConsole -->|"uses"| SharedUI
  DevConsole -->|"monitors"| SharedAnalytics

  NodeProv -->|"uses"| SharedAPI
  NodeProv -->|"uses"| SharedUI
  NodeProv -->|"monitors"| SharedReporting

  GlobalReg -->|"calls"| SharedAPI
  GlobalReg -->|"renders"| SharedUI

  %% Styles for clarity
  classDef app fill:#AED6F1,stroke:#1f78b4,stroke-width:2px;
  classDef module fill:#D5F5E3,stroke:#27ae60,stroke-width:2px;
  classDef package fill:#FCF3CF,stroke:#f39c12,stroke-width:2px;
  classDef external fill:#F9E79F,stroke:#d35400,stroke-width:2px;
  classDef tooling fill:#E8DAEF,stroke:#8e44ad,stroke-width:2px;

  %% Click Events
  click DevConsole "https://github.com/cerebellum-network/cluster-apps/tree/dev/apps/developer-console"
  click ActCap "https://github.com/cerebellum-network/cluster-apps/tree/dev/apps/developer-console/src/applications/ActivityCapture"
  click ContentDel "https://github.com/cerebellum-network/cluster-apps/tree/dev/apps/developer-console/src/applications/ContentDelivery"
  click ContentStor "https://github.com/cerebellum-network/cluster-apps/tree/dev/apps/developer-console/src/applications/ContentStorage"

  click NodeProv "https://github.com/cerebellum-network/cluster-apps/tree/dev/apps/node-provider"
  click NetTopo "https://github.com/cerebellum-network/cluster-apps/tree/dev/apps/node-provider/src/applications/NetworkTopology"
  click NodeConf "https://github.com/cerebellum-network/cluster-apps/tree/dev/apps/node-provider/src/applications/NodeConfigurationSteps"
  click Payouts "https://github.com/cerebellum-network/cluster-apps/tree/dev/apps/node-provider/src/applications/Payouts"

  click GlobalReg "https://github.com/cerebellum-network/cluster-apps/tree/dev/apps/global-registry"
  click AccessReg "https://github.com/cerebellum-network/cluster-apps/tree/dev/apps/global-registry/src/routes/AccessList"

  click SharedAPI "https://github.com/cerebellum-network/cluster-apps/tree/dev/packages/api"
  click SharedUI "https://github.com/cerebellum-network/cluster-apps/tree/dev/packages/ui"
  click SharedAnalytics "https://github.com/cerebellum-network/cluster-apps/tree/dev/packages/analytics"
  click SharedReporting "https://github.com/cerebellum-network/cluster-apps/tree/dev/packages/reporting"

  click CICD "https://github.com/cerebellum-network/cluster-apps/tree/dev/.github/workflows"
  click Env "https://github.com/cerebellum-network/cluster-apps/blob/dev/.env.dev"
  click ESLint "https://github.com/cerebellum-network/cluster-apps/blob/dev/.eslintrc.json"
  click Prettier "https://github.com/cerebellum-network/cluster-apps/blob/dev/.prettierrc.json"
  click Vite "https://github.com/cerebellum-network/cluster-apps/blob/dev/vite.config.ts"
  click NVM "https://github.com/cerebellum-network/cluster-apps/blob/dev/.nvmrc"
```
