# miguelamelom/drip architecture

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

## Overview

A. Project Type and Purpose
##### Type
- A command‐line tool and long‐running service written in Go.
- Acts as a “model serving framework” (control plane + data plane) for deploying AI/ML models.
##### Purpose
- Expose AI models over HTTP.
- Provide advanced release strategies (A/B testing, Canary, Shadow).
- Integrate Prometheus metrics.
- Support auto‐scaling and warm‐up.
- Declarative config via YAML/JSON.

B. File Structure Analysis
##### cmd/ – CLI entrypoints
- Remove, update, changeAlias, stageAlias, serve, etc.
##### engine/ – Business logic invoked by CLI and server
- AddModel, RemoveModel, Update, auth, raise events, stageAlias.
##### core/ – Runtime components for the served service
- core/modelsManager.go – registry of loaded models.
- core/serverRaiser/ – injects model servers (in‐house or MLflow).
- core/modelProxy/ – routing strategies (stable, A/B, Canary, shadow, load‐balancer).
- core/proxyStats/ – gather and expose metrics for Prometheus.
- core/warming/ – pre‐warm model endpoints.
##### go.mod/go.sum – dependency management.

C. README Insights
- HTTP endpoints expose models.
- Prometheus metrics baked in.
- Advanced release strategies noted.
- Configurable auto‐scaling.
- Uses declarative configs.

##### Control Plane (CLI/Config)
- CLI commands (cmd/) that mutate the desired state (add/remove/update models, aliases, config files).
- Config files (YAML/JSON).
##### Data Plane (Server)
- HTTP Server (main.go → core/server).
- Models Manager – keeps track of active model instances.
- Server Raiser – spins up model servers (inHouse or MLflow backends).
- Model Proxy – routes incoming requests per chosen strategy (stable, AB testing, Canary, shadow).
- Warming Service – pre‐loads models before routing traffic.
- Proxy Stats – collects and exposes metrics for Prometheus.
##### External Services
- MLflow (optional remote model store/serving).
- Prometheus (metrics ingestion).
- HTTP Clients (downstream applications invoking model endpoints).

E. Relationships & Interactions
- CLI → Engine APIs → updates config/desired state.
- Serve Command → initializes HTTP Server → Core components.
- HTTP Request → Model Proxy → forwards to one or more Model Servers (via Server Raiser).
- Warming Service → triggers Server Raiser to pre‐spin instances.
- Proxy Stats → taps into Model Proxy and Server Raiser for metrics → Prometheus.
- Server Raiser (MLflow) → calls MLflow REST API to spin up or register models.

F. Architectural Patterns & Design Principles
- Separation of Concerns:
- CLI vs. long‐running service.
- Control Plane vs Data Plane.
- Plugin/Strategy Pattern:
- serverRaiser/backends and modelProxy/strategies are extensible.
- Declarative Configuration:
- entire deployment defined in YAML/JSON.
- Observability Built-In:
- proxyStats exports Prometheus metrics.
- Modular Go Packages:
- clear package boundaries under core and engine.

G. Diagramming Guidelines
- CLI → Config files and Engine APIs.
- Serve → Core modules initialization.
- HTTP Clients → HTTP Server → Model Proxy → Model Servers.
- Model Proxy/Warming → Server Raiser.
- Core modules → Proxy Stats → Prometheus.
##### Detail Level
- Component with its Go package path (e.g., core/modelProxy).
- Strategy plugins under Model Proxy.
- Backend options under Server Raiser.
- Metric pull vs. push for Prometheus.

H. Tailoring to This Project
- Two operating modes:
1. CLI – mutates model state (add/update/remove/alias).
2. Serve – spins up HTTP service with core modules.
- Warming Service as a sidecar to pre‐load models.
- Both inHouse and mlflow server raisers as selectable backends.

- Configuration flow (CLI → Service).
- Data flow (Client → Proxy → Model Instances).
- Metrics flow (ProxyStats → Prometheus).
- Control plane (CLI/config) – Blue.
- Data plane (HTTP server & modules) – Green.
- External services – Gray.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Control Plane (Blue)
    subgraph "Control Plane"
        direction TB
        CLI["CLI Commands"]:::control
        Config["Config Files\n(YAML/JSON)"]:::control
        EngineAPI["Engine APIs"]:::control
    end

    %% Data Plane (Green)
    subgraph "Data Plane"
        direction TB
        HTTPServer["HTTP Server\n(main.go)"]:::data
        ModelsMgr["Models Manager\n(core/modelsManager.go)"]:::data
        ServerRaiser["Server Raiser\n(core/serverRaiser/)"]:::data
        ModelProxy["Model Proxy\n(core/modelProxy/)"]:::data
        Warming["Warming Service\n(core/warming/warmer.go)"]:::data
        ProxyStats["Proxy Stats\n(core/proxyStats/monitoring.go)"]:::data
    end

    %% External Services (Gray)
    subgraph "External Services"
        direction TB
        HTTPClients["HTTP Clients"]:::external
        MLflow["MLflow"]:::external
        Prometheus["Prometheus"]:::external
    end

    %% Connections
    CLI -->|"mutates state"| EngineAPI
    CLI -->|"reads/writes"| Config
    CLI -->|"serve command"| HTTPServer

    HTTPClients -->|"requests"| HTTPServer
    HTTPServer -->|"route requests"| ModelProxy
    ModelProxy -->|"invoke backend"| ServerRaiser
    ServerRaiser -->|"spin up instances"| ModelsMgr
    Warming -->|"pre-warm models"| ServerRaiser

    ModelProxy -->|"metrics"| ProxyStats
    ServerRaiser -->|"metrics"| ProxyStats
    ProxyStats -->|"metrics pull"| Prometheus

    ServerRaiser -->|uses REST API| MLflow

    %% Click Events
    click CLI "https://github.com/miguelamelom/drip/tree/main/cmd/"
    click EngineAPI "https://github.com/miguelamelom/drip/tree/main/engine/"
    click HTTPServer "https://github.com/miguelamelom/drip/blob/main/main.go"
    click ModelsMgr "https://github.com/miguelamelom/drip/blob/main/core/modelsManager.go"
    click ServerRaiser "https://github.com/miguelamelom/drip/tree/main/core/serverRaiser/"
    click ModelProxy "https://github.com/miguelamelom/drip/tree/main/core/modelProxy/"
    click Warming "https://github.com/miguelamelom/drip/blob/main/core/warming/warmer.go"
    click ProxyStats "https://github.com/miguelamelom/drip/blob/main/core/proxyStats/monitoring.go"

    %% Styles
    classDef control fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef data fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px

    %% Legend
    subgraph Legend
        direction TB
        C1["Control Plane"]:::control
        C2["Data Plane"]:::data
        C3["External Services"]:::external
    end
```
