# cryptonomikhan/dynamo architecture

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

- Interactive diagram: https://gitdiagram.com/cryptonomikhan/dynamo
- Repository: https://github.com/cryptonomikhan/dynamo

## Overview

The NVIDIA Dynamo project is a distributed, high-performance inference framework for generative AI and reasoning models. It is designed to operate in multi-node environments and supports multiple backend inference engines (such as TRT-LLM, vLLM, and SGLang). The project is built primarily in Rust (for performance-critical runtime components and engine integrations) and Python (to provide extensibility and SDK support). It is deployed using container technologies (Docker, Kubernetes via Helm charts), and the file tree reveals a rich assortment of components, including API servers, control operators, runtime libraries, and engine libraries.

##### Main components
- Frontend/API layer: This includes the OpenAI compatible HTTP server (see components/http and parts of lib/llm/src/http) which receives client requests.
- Request Routing & Load Balancing: The router (e.g. basic/KV-aware router as shown in examples/llm and in lib/llm/src/kv_router) that routes traffic and load balances among workers.
- Worker Components: The workers that run the inference engines. Dynamo supports multiple backends (TRT-LLM, vLLM, SGLang, etc.), and these are implemented within lib/llm (engines directories) and executed by worker nodes.
- Distributed Runtime: The core runtime system (under lib/runtime) implements distributed processing, pipelines (for both prefill and decode), dynamic GPU scheduling, and data transfer optimizations. It also manages pipeline nodes, network ingress/egress, and service communications.
- SDK & Bindings: Python bindings (in lib/bindings/python) and the provided SDK allow for easy integration of Dynamo’s capabilities with external applications.
- Supporting Components: Components for metrics (components/metrics) and HTTP utilities, as well as logging, KV cache management, and dependency libraries spread across multiple directories.

##### Relationships and interactions
- Client Interaction: Clients send inference or chat requests to the Frontend/API server.
- API Processing: The API server validates and forwards these requests to the router.
- Routing: The router (either the basic or KV-aware type) directs the requests to an available worker node based on scheduling decisions.
- Worker Execution: Worker nodes execute the chosen inference engine (leveraging specialized backends) and make use of distributed runtime capabilities like dynamic GPU scheduling and accelerated data transfer.
- Runtime Coordination: The distributed runtime manages inter-node communications, pipeline processing, and efficiently handles prefill and decode stages.
- Control and Orchestration: The operator (with its CRDs and K8s configurations) monitors and manages deployments, scaling, and updates across the cluster.
- Metrics and Logging: Dedicated components capture performance and operational metrics to continuously monitor system health.

##### Architectural patterns and design principles
- Modular Microservices Architecture: The system is clearly divided into independent yet communicating modules (API, router, workers, control plane, runtime, etc.).
- Decoupling of Frontend and Compute: The design separates client-facing API endpoints from backend inference engines and runtime logic.
- Layered Architecture: There is a visible separation between core engine processing, distributed runtime management, and orchestration (via Kubernetes/Helm charts).
- Extensibility and Abstraction: With support for multiple inference engines and well-defined Python bindings/SDK, the design anticipates future extensions.
- Containerized & Cloud-Native Deployment: The inclusion of Docker compose files and Kubernetes Helm charts emphasizes cloud-native deployment practices.

##### Relevant technologies and frameworks
- Languages and Build Systems: Rust for high-performance components (with Cargo.toml and build scripts), and Python for SDK and binding layers.
- Containerization: Docker (see container/Dockerfile.* and docker-compose artifacts) and Kubernetes deployments (Helm charts in deploy/Kubernetes).
- CI/CD & Quality Assurance: GitHub workflows and other configuration files demonstrate a robust development pipeline.
- Communication & Scheduling: Use of messaging systems (NATS, as seen in container/deps/requirements.nats.txt) along with dynamic scheduling algorithms for GPU and resource management.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Layer
    subgraph "Client Layer"
        A["Client/CLI"]:::client
    end

    %% API Frontend Layer
    subgraph "API Frontend Layer"
        API1["HTTP API Server (Rust)"]:::api
        API2["API Server (Go)"]:::api
    end

    %% Request Routing & Load Balancing Layer
    subgraph "Request Routing Layer"
        R["Router (Disagg/KV)"]:::routing
    end

    %% Worker Components Layer
    subgraph "Worker/Engine Layer"
        W1["Worker: TRT-LLM"]:::worker
        W2["Worker: vLLM"]:::worker
        W3["Worker: SGLang"]:::worker
        W4["Worker: Prefill"]:::worker
    end

    %% Distributed Runtime & Pipeline Layer
    subgraph "Distributed Runtime & Pipeline"
        D["Distributed Runtime"]:::runtime
    end

    %% Control Plane & Orchestration Layer
    subgraph "Control Plane & Orchestration"
        CP["Operator/Control Plane"]:::control
    end

    %% SDK & Bindings Layer
    subgraph "SDK & Bindings Layer"
        SDK["Python SDK & Bindings"]:::sdk
    end

    %% Support & Monitoring Layer
    subgraph "Support & Monitoring"
        M["Metrics & Logging"]:::support
    end

    %% Connections
    A -->|"sendsRequest"| API1
    A -->|"sendsRequest"| API2

    API1 -->|"forwards"| R
    API2 -->|"forwards"| R

    R -->|"routesTo"| W1
    R -->|"routesTo"| W2
    R -->|"routesTo"| W3
    R -->|"routesTo"| W4

    W1 -->|"executesInference"| D
    W2 -->|"executesInference"| D
    W3 -->|"executesInference"| D
    W4 -->|"executesInference"| D

    D -->|"coordinates"| CP
    CP -->|"manages"| API1
    CP -->|"monitors"| W1
    CP -->|"monitors"| W2
    CP -->|"monitors"| W3
    CP -->|"monitors"| W4

    SDK -->|"integratesWith"| API1
    SDK -->|"integratesWith"| D

    M -->|"monitors"| API1
    M -->|"monitors"| D
    M -->|"monitors"| CP

    %% Click Events for Component Mapping
    click API1 "https://github.com/cryptonomikhan/dynamo/blob/main/components/http/src/main.rs"
    click API2 "https://github.com/cryptonomikhan/dynamo/blob/main/deploy/dynamo/api-server/api/main.go"
    click R "https://github.com/cryptonomikhan/dynamo/blob/main/lib/llm/src/kv_router/indexer.rs"
    click W1 "https://github.com/cryptonomikhan/dynamo/tree/main/lib/llm/src/engines/trtllm"
    click W2 "https://github.com/cryptonomikhan/dynamo/tree/main/lib/llm/src/engines/vllm"
    click W3 "https://github.com/cryptonomikhan/dynamo/tree/main/lib/llm/src/engines/sglang"
    click W4 "https://github.com/cryptonomikhan/dynamo/blob/main/examples/llm/components/prefill_worker.py"
    click D "https://github.com/cryptonomikhan/dynamo/blob/main/lib/runtime/src/runtime.rs"
    click CP "https://github.com/cryptonomikhan/dynamo/tree/main/deploy/dynamo/operator"
    click SDK "https://github.com/cryptonomikhan/dynamo/tree/main/lib/bindings/python"
    click M "https://github.com/cryptonomikhan/dynamo/tree/main/components/metrics/src"

    %% Styles
    classDef client fill:#F5DEB3,stroke:#333,stroke-width:2px;
    classDef api fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef routing fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef worker fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef runtime fill:#FFC0CB,stroke:#333,stroke-width:2px;
    classDef control fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef sdk fill:#DDA0DD,stroke:#333,stroke-width:2px;
    classDef support fill:#E0FFFF,stroke:#333,stroke-width:2px;
```
