# phonepe/drove-orchestrator architecture

> Architecture diagram of the GitHub repository phonepe/drove-orchestrator, 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/phonepe/drove-orchestrator
- Repository: https://github.com/phonepe/drove-orchestrator

## Overview

##### Project Type and Purpose
- This is a container orchestrator that manages containerized applications. It uses a set of microservices (e.g., controller, executor, gateway) coordinated via Zookeeper.
- The orchestration system also supports deployment, scaling, and management of apps (as seen from the commands to deploy an app via the CLI and scaling instructions).

##### Key Components
- External Clients:
- End Users accessing the UI through their browsers (pointing to drove.local:7000).
- The CLI tool (drove-cli and epoch-cli) that developers use to create, scale, or destroy applications.
- Core Services:
- Drove Controller – the central component (running on port 4000) that likely manages state and orchestrates tasks.
- Executor – responsible for carrying out task operations (running on port 3000).
- Drove Gateway (via nginx) – exposing the UI/API on port 7000.
- Zookeeper – used as a coordination backend (running on port 2181).
- Ancillary Services:
- coredns-drove – possibly the custom DNS service to help with service discovery inside the orchestrator.
- “compose” configuration used to spin up a demo cluster for quick deployment.
- Documentation/Support Directories:
- The docs folder provides detailed API and operations documentation. While not part of the live system architecture, it shows important endpoints and operational flows.
- Additional Modules:
- The various “drove”, “drove-cli”, “drove-gateway”, “epoch”, and “epoch-cli” directories indicate that there are distinct modules for CLI operations and gateway functionalities.

##### Representing Relationships and Interactions
- That the Drove Controller communicates with both the Executor (for task execution) and Zookeeper (for coordination).
- That the Gateway (backed by nginx) serves as the front door for the UI, and also routes API calls to the relevant services.
- You might also represent inter-module communication among the different components (for instance, the controller may send scaling commands to the executor, and status updates might flow back).

##### Architectural Patterns and Design Principles
- The separation between frontend (drove gateway and UI) and backend (controller, executor, and Zookeeper) is central.
- Microservices-based design can be illustrated – each of the core modules is in its own container.
- Use of configuration management and orchestration via Docker Compose indicates that container-based deployment is key.
- The presence of both CLI and gateway layers shows an emphasis on both programmatic and interactive management.

##### Final Elements
- All key components with proper names.
- Labels for ports or endpoints indicated in the README.
- Annotations for the configuration tools (Docker Compose) and any submodules that factor into the deployment architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Interface Layer
    subgraph "External Interface"
        EndUser["End User Browser (drove.local:7000)"]:::frontend
        DGateway["Drove Gateway (nginx, 7000)"]:::frontend
    end

    %% CLI Tools Layer
    subgraph "CLI Tools"
        CLI1["Drove CLI"]:::cli
        CLI2["Epoch CLI"]:::cli
        EpochService["Epoch Service"]:::cli
    end

    %% Control Plane Layer
    subgraph "Control Plane"
        DController["Drove Controller (4000)"]:::control
        ZK["Zookeeper (2181)"]:::control
    end

    %% Worker/Execution Layer
    subgraph "Worker/Execution"
        Executor["Executor (3000)"]:::worker
        CoreDNS["coredns-drove"]:::worker
    end

    %% Documentation
    Docs["Documentation & API/Operations"]:::doc

    %% Connections: External Interface to Control Plane
    EndUser -->|"accesses"| DGateway
    CLI1  -->|"sendsCommands"| DGateway
    CLI2  -->|"sendsCommands"| DGateway
    EpochService -->|"invokes"| DGateway

    DGateway -->|"routesAPI"| DController

    %% Control Plane interactions
    DController -->|"executesTask"| Executor
    DController -->|"orchestrates"| ZK
    Executor -->|"statusUpdate"| DController

    %% Optional connection for coordination feedback
    ZK -->|"coordination"| DController

    %% Documentation annotated separately (informational)
    Docs ---|"details"| DController

    %% Click Events
    click DController "https://github.com/phonepe/drove-orchestrator/tree/master/drove"
    click Executor "https://github.com/phonepe/drove-orchestrator/blob/master/compose/compose.yaml"
    click ZK "https://github.com/phonepe/drove-orchestrator/blob/master/compose/compose.yaml"
    click DGateway "https://github.com/phonepe/drove-orchestrator/tree/master/drove-gateway"
    click CoreDNS "https://github.com/phonepe/drove-orchestrator/tree/master/coredns-drove"
    click CLI1 "https://github.com/phonepe/drove-orchestrator/tree/master/drove-cli"
    click CLI2 "https://github.com/phonepe/drove-orchestrator/tree/master/epoch-cli"
    click EpochService "https://github.com/phonepe/drove-orchestrator/tree/master/epoch"
    click Docs "https://github.com/phonepe/drove-orchestrator/tree/master/docs"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef cli fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef control fill:#D5F5E3,stroke:#196F3D,stroke-width:2px;
    classDef worker fill:#F5CBA7,stroke:#AF601A,stroke-width:2px;
    classDef doc fill:#FADBD8,stroke:#CB4335,stroke-width:2px;
```
