# jorrit05/dynamos architecture

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

- Interactive diagram: https://gitdiagram.com/jorrit05/dynamos
- Repository: https://github.com/jorrit05/dynamos

## Overview

##### Main Components
- Clients/External Interfaces: Represent the web frontend (in the “web” directory) and any external API consumers that interact with the system.
- Ingress Layer: At the boundary, include the NGINX ingress (configured with Kubernetes) that routes external requests to the cluster.
- API Gateway: The dedicated microservice (found in go/cmd/api-gateway and its corresponding Helm chart) that accepts and fronts incoming requests.
- Core Orchestration Layer: Include the orchestrator service (go/cmd/orchestrator) that manages request flow and coordinates among services.
- Policy Enforcer: This service (in go/cmd/policy-enforcer) is responsible for validating or modifying requests based on system policies.
- Messaging Infrastructure: RabbitMQ is a central messaging bus that facilitates communication between the microservices (with configuration details, such as the secure password and PVC mounting as explained in the README).
- Shared Data and Configuration Store: Represent etcd as the repository for service configuration, service discovery, and job metadata.
- Observability and Monitoring Components: Include Prometheus (for metrics), Grafana (dashboards), Jaeger (distributed tracing installed via Linkerd), and the Linkerd service mesh layer.
- Supporting Build/Operational Tools: Note the Helm charts in the “charts” directory that package the deployment configuration, the Dockerfiles (in .devcontainer, go, python, etc.) that build images, and scripts/configuration files that automate deployment.

##### Relationships and Interactions
- External user requests flow through the Ingress, reaching the API Gateway.
- The API Gateway routes requests into the internal system where the Orchestrator processes them.
- The orchestrator then interacts with Agent services and possibly triggers operations in the Policy Enforcer or Sidecar components.
- All microservices communicate with each other via internal APIs (often using gRPC as the protocol) and utilize RabbitMQ for asynchronous messaging.
- Configuration, service registration, and state changes are reported and maintained in etcd.
- Observability tools tap into system metrics and traces across the microservices to form a feedback loop for monitoring.

##### Architectural Patterns & Design Principles
- Microservices Architecture: Emphasize the separation of concerns, with each service (agent, API gateway, orchestrator, policy enforcer, sidecar, etc.) being an independently deployable unit.
- Configuration as Code: Show that the cloud deployment is automated via Helm charts and Kubernetes manifests, and that deployments are configured dynamically (e.g., RabbitMQ credential generation, PVC filling for definitions).

##### Including Relevant Technologies and Frameworks
- Languages: Go (for core microservices), Python (for client library), and Vue (for web interface).
- Containerization: Docker images (with Dockerfiles in various directories) and deployment via Kubernetes.
- CI/CD Tools: GitHub Actions (as seen with .github files) and Helm/Makefiles.
- Observability: Prometheus, Grafana, Jaeger integrated via Linkerd.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Layer
    subgraph "External Layer"
        A["Web Frontend"]:::external
    end

    %% Ingress and API Layer
    subgraph "Ingress & API Layer"
        I["NGINX Ingress"]:::ingress
        API["API Gateway"]:::service
    end

    %% Core Microservices Layer
    subgraph "Core Microservices"
        ORCH["Orchestrator"]:::service
        AGENT["Agent Services"]:::service
        SID["Sidecar Components"]:::service
        POL["Policy Enforcer"]:::service
    end

    %% Messaging and Configuration
    subgraph "Messaging & Configuration"
        RAB["RabbitMQ"]:::infra
        ETCD["etcd"]:::infra
    end

    %% Observability & Monitoring
    subgraph "Observability & Monitoring"
        PRO["Prometheus"]:::observ
        GRAF["Grafana"]:::observ
        JAE["Jaeger"]:::observ
        LINK["Linkerd"]:::observ
    end

    %% DevOps & Build Tools
    subgraph "DevOps & Build Tools"
        HELM["Helm Charts"]:::support
        DOCKER["Dockerfiles & Scripts"]:::support
    end

    %% Data Flow Connections
    A --> I
    I --> API
    API --> ORCH
    ORCH --> AGENT
    ORCH --> SID
    ORCH --> POL

    %% Microservices communicating with Messaging & Configuration
    API -->|"msg"| RAB
    ORCH -->|"msg"| RAB
    AGENT -->|"msg"| RAB
    SID -->|"msg"| RAB
    POL -->|"msg"| RAB

    API -->|"config"| ETCD
    ORCH -->|"config"| ETCD
    AGENT -->|"config"| ETCD
    SID -->|"config"| ETCD
    POL -->|"config"| ETCD

    %% Observability connections from API Gateway as representative
    API -->|"metrics"| PRO
    API -->|"metrics"| GRAF
    API -->|"traces"| JAE
    API -->|"service-mesh"| LINK

    %% DevOps influencing deployment of core components
    HELM -->|"deploys"| I
    HELM -->|"deploys"| API
    HELM -->|"deploys"| ORCH
    DOCKER -->|"builds"| API
    DOCKER -->|"builds"| ORCH

    %% Style Definitions
    classDef external fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef ingress fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef service fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef infra fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef observ fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef support fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;

    %% Click Events
    click A "https://github.com/jorrit05/dynamos/tree/main/web/"
    click I "https://github.com/jorrit05/dynamos/blob/main/charts/core/templates/gateway.yaml"
    click I "https://github.com/jorrit05/dynamos/blob/main/charts/core/ingress-values.yaml"
    click API "https://github.com/jorrit05/dynamos/tree/main/go/cmd/api-gateway"
    click API "https://github.com/jorrit05/dynamos/tree/main/charts/api-gateway/"
    click ORCH "https://github.com/jorrit05/dynamos/tree/main/go/cmd/orchestrator"
    click ORCH "https://github.com/jorrit05/dynamos/tree/main/charts/orchestrator/"
    click AGENT "https://github.com/jorrit05/dynamos/tree/main/go/cmd/agent"
    click AGENT "https://github.com/jorrit05/dynamos/tree/main/charts/agents/"
    click SID "https://github.com/jorrit05/dynamos/tree/main/go/cmd/sidecar"
    click POL "https://github.com/jorrit05/dynamos/tree/main/go/cmd/policy-enforcer"
    click POL "https://github.com/jorrit05/dynamos/blob/main/charts/orchestrator/templates/policyEnforcer.yaml"
    click RAB "https://github.com/jorrit05/dynamos/blob/main/charts/core/templates/rabbitmq.yaml"
    click RAB "https://github.com/jorrit05/dynamos/blob/main/charts/core/templates/rabbitmq-services.yaml"
    click RAB "https://github.com/jorrit05/dynamos/blob/main/configuration/k8s_service_files/rabbitmq.conf"
    click ETCD "https://github.com/jorrit05/dynamos/blob/main/charts/core/templates/etcd.yaml"
    click ETCD "https://github.com/jorrit05/dynamos/tree/main/configuration/etcd*"
    click PRO "https://github.com/jorrit05/dynamos/blob/main/charts/core/templates/prometheus-values.yaml"
    click GRAF "https://github.com/jorrit05/dynamos/blob/main/charts/core/templates/grafana.yaml"
    click JAE "https://github.com/jorrit05/dynamos/blob/main/charts/core/templates/jaeger-nodeport.yaml"
    click HELM "https://github.com/jorrit05/dynamos/tree/main/charts/"
    click DOCKER "https://github.com/jorrit05/dynamos/tree/main/.devcontainer/Dockerfile"
    click DOCKER "https://github.com/jorrit05/dynamos/tree/main/go/Dockerfile"
    click DOCKER "https://github.com/jorrit05/dynamos/tree/main/python/Dockerfile"
    click DOCKER "https://github.com/jorrit05/dynamos/tree/main/scripts/"
```
