# subanesh-swe/chola architecture

> Architecture diagram of the GitHub repository subanesh-swe/chola, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/subanesh-swe/chola
- Repository: https://github.com/subanesh-swe/chola

## Overview

#### Purpose and deployable entry points
Chola CI is an on-premises distributed CI/CD orchestrator: a Rust controller schedules and tracks pipeline work, Rust workers execute build stages, and a React dashboard operates the system. Main binaries are `crates/ci-controller/src/main.rs`, `crates/ci-worker/src/main.rs`, and `crates/ci-job-runner/src/main.rs`; the browser entry is `frontend/src/main.tsx`.

#### Shared domain and protocol boundary
`ci-core` centralizes domain models for jobs, job groups, stages, workers, users, schedules, variables, and configuration. It also owns the protobuf contract used between controller and workers/clients: `crates/ci-core/proto/orchestrator.proto`, generated integration in `crates/ci-core/src/proto.rs`, and models under `crates/ci-core/src/models/`.
This is the primary compatibility boundary for distributed components.

#### Controller: orchestration and API plane
The controller exposes REST and gRPC servers through `crates/ci-controller/src/http_server.rs` and `crates/ci-controller/src/grpc_server.rs`. REST handlers provide dashboard, runner, webhook, artifact, log, worker, repository, and administrative operations under `crates/ci-controller/src/api/`.
Its runtime state coordinates registries, scheduling, DAG evaluation, reservations, and lifecycle cleanup: `crates/ci-controller/src/state.rs`, `crates/ci-controller/src/scheduler.rs`, `crates/ci-controller/src/dag.rs`, and `crates/ci-controller/src/reservation.rs`.

#### Pipeline scheduling and worker allocation
Jobs are grouped into multi-stage pipelines with dependency edges and resource requirements. The controller tracks available workers and job groups, selects capacity, reserves stages, and handles timeouts/recovery through `crates/ci-controller/src/worker_registry.rs`, `crates/ci-controller/src/job_registry.rs`, `crates/ci-controller/src/job_group_registry.rs`, and `crates/ci-controller/src/retention.rs`.
Workers register, heartbeat, reconnect, receive stage work, and report execution status over gRPC.

#### Worker execution and log path
A worker agent manages controller connectivity and liveness in `crates/ci-worker/src/agent.rs`, `crates/ci-worker/src/grpc_client.rs`, and `crates/ci-worker/src/heartbeat.rs`. Execution is isolated per stage/build and invokes build commands/scripts through `crates/ci-worker/src/stage_runner.rs` and `crates/ci-worker/src/executor.rs`.
Logs stream back to the controller via `crates/ci-worker/src/log_streamer.rs`; the controller aggregates/persists them and exposes live access, including SSE-facing APIs, via `crates/ci-controller/src/log_aggregator.rs` and `crates/ci-controller/src/api/log_handlers.rs`.

#### Persistence, security, and integrations
PostgreSQL is the durable system of record, evolved by `migrations/001_init_schema.sql` through `migrations/034_reserved_stages.sql`; controller storage is organized in `crates/ci-controller/src/storage.rs`. Redis supports transient/distributed state through `crates/ci-controller/src/redis_store.rs`.
Authentication combines JWT, passwords, API keys, middleware, and worker tokens: `crates/ci-controller/src/auth/`, `crates/ci-controller/src/api/api_key_handlers.rs`, and `crates/ci-controller/src/api/worker_token_handlers.rs`. Webhook ingestion and notifications are handled in `crates/ci-controller/src/api/webhook_handlers.rs` and `crates/ci-controller/src/notifier.rs`. Vector configuration supports external log shipping at `config/vector.toml`.

#### Operator and automation clients
The React SPA calls the REST API through `frontend/src/api/client.ts`, enforces authenticated/role-scoped routes in `frontend/src/router/ProtectedRoute.tsx` and `frontend/src/router/RoleGuard.tsx`, and visualizes builds/pipelines/logs with `frontend/src/pages/BuildDetailPage.tsx` and `frontend/src/components/pipeline/PipelineGraph.tsx`.
`ci-job-runner` is the automation-facing CLI for reserve, submit, run, status, cancellation, and logs commands: `crates/ci-job-runner/src/commands/` and `crates/ci-job-runner/src/main.rs`.

Main entry points: [`crates/ci-controller/src/main.rs`](https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/main.rs) (CI controller), [`crates/ci-controller/src/http_server.rs`](https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/http_server.rs) (REST API), [`crates/ci-controller/src/log_aggregator.rs`](https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/log_aggregator.rs) (Log aggregation), [`crates/ci-worker/src/main.rs`](https://github.com/subanesh-swe/chola/blob/master/crates/ci-worker/src/main.rs) (CI worker agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Operators &amp; Automation"]
  node_dashboard["React dashboard<br/>SPA<br/>[main.tsx]"]
  node_runner_cli["Job runner CLI<br/>automation CLI<br/>[main.rs]"]
end

subgraph group_shared["Shared Contract"]
  node_core_models["CI domain models<br/>shared Rust crate"]
  node_orchestrator_proto["Orchestrator protocol<br/>protobuf contract<br/>[orchestrator.proto]"]
end

subgraph group_controller["Controller Plane"]
  node_controller{{"CI controller<br/>Rust service<br/>[main.rs]"}}
  node_rest_api["REST API<br/>HTTP server<br/>[http_server.rs]"]
  node_grpc_server["Worker gRPC service<br/>gRPC server<br/>[grpc_server.rs]"]
  node_scheduler["Pipeline scheduler<br/>orchestration runtime<br/>[scheduler.rs]"]
  node_registries["Worker &amp; job registries<br/>runtime state<br/>[worker_registry.rs]"]
  node_log_service["Log aggregation<br/>log service<br/>[log_aggregator.rs]"]
  node_auth["Authentication<br/>security layer"]
end

subgraph group_execution["Worker Execution"]
  node_worker{{"CI worker agent<br/>Rust agent<br/>[main.rs]"}}
  node_stage_execution["Isolated stage execution<br/>build executor<br/>[stage_runner.rs]"]
  node_log_streamer["Worker log streamer<br/>log client<br/>[log_streamer.rs]"]
end

subgraph group_data["State &amp; Integrations"]
  node_postgres[("PostgreSQL<br/>durable system of record")]
  node_redis[("Redis<br/>transient distributed state<br/>[redis_store.rs]")]
  node_webhooks_notifications["Webhooks &amp; notifications<br/>integration plane"]
  node_external_log_shipping["External log shipping<br/>Vector integration<br/>[vector.toml]"]
end

node_dashboard -->|"REST API and SSE logs"| node_rest_api
node_runner_cli -->|"reserve, submit, control"| node_rest_api
node_dashboard -->|"authenticated access"| node_auth
node_rest_api -->|"operations"| node_controller
node_rest_api -->|"authenticates requests"| node_auth
node_rest_api -->|"live and historical logs"| node_log_service
node_grpc_server -->|"worker control plane"| node_controller
node_controller -->|"schedules pipelines"| node_scheduler
node_scheduler -->|"selects and reserves capacity"| node_registries
node_scheduler -->|"durable job state"| node_postgres
node_controller -->|"transient distributed state"| node_redis
node_controller -->|"event ingestion and delivery"| node_webhooks_notifications
node_grpc_server -->|"register, heartbeat, dispatch, status"| node_worker
node_worker -->|"executes assigned stage"| node_stage_execution
node_stage_execution -->|"execution output"| node_log_streamer
node_log_streamer -->|"stream logs"| node_log_service
node_log_service -->|"persist logs"| node_postgres
node_log_service -->|"ship external logs"| node_external_log_shipping
node_orchestrator_proto -.->|"server contract"| node_grpc_server
node_orchestrator_proto -.->|"client contract"| node_worker
node_core_models -.->|"shared domain"| node_controller
node_core_models -.->|"shared domain"| node_worker

click node_dashboard "https://github.com/subanesh-swe/chola/blob/master/frontend/src/main.tsx"
click node_runner_cli "https://github.com/subanesh-swe/chola/blob/master/crates/ci-job-runner/src/main.rs"
click node_orchestrator_proto "https://github.com/subanesh-swe/chola/blob/master/crates/ci-core/proto/orchestrator.proto"
click node_controller "https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/main.rs"
click node_rest_api "https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/http_server.rs"
click node_grpc_server "https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/grpc_server.rs"
click node_scheduler "https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/scheduler.rs"
click node_registries "https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/worker_registry.rs"
click node_log_service "https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/log_aggregator.rs"
click node_worker "https://github.com/subanesh-swe/chola/blob/master/crates/ci-worker/src/main.rs"
click node_stage_execution "https://github.com/subanesh-swe/chola/blob/master/crates/ci-worker/src/stage_runner.rs"
click node_log_streamer "https://github.com/subanesh-swe/chola/blob/master/crates/ci-worker/src/log_streamer.rs"
click node_postgres "https://github.com/subanesh-swe/chola/blob/master/migrations/001_init_schema.sql"
click node_redis "https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/redis_store.rs"
click node_webhooks_notifications "https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/api/webhook_handlers.rs"
click node_external_log_shipping "https://github.com/subanesh-swe/chola/blob/master/config/vector.toml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_runner_cli toneBlue
class node_core_models,node_orchestrator_proto toneAmber
class node_controller,node_rest_api,node_grpc_server,node_scheduler,node_registries,node_log_service,node_auth toneMint
class node_worker,node_stage_execution,node_log_streamer toneRose
class node_postgres,node_redis,node_webhooks_notifications,node_external_log_shipping toneIndigo
```

## Components

### Operators & Automation

- [React dashboard](https://github.com/subanesh-swe/chola/blob/master/frontend/src/main.tsx): SPA · Operates builds, pipelines, and live logs. · `frontend/src/main.tsx`
- [Job runner CLI](https://github.com/subanesh-swe/chola/blob/master/crates/ci-job-runner/src/main.rs): automation CLI · Submits and controls automation jobs. · `crates/ci-job-runner/src/main.rs`

### Shared Contract

- **CI domain models**: shared Rust crate · Jobs, pipelines, stages, workers, users, and configuration.
- [Orchestrator protocol](https://github.com/subanesh-swe/chola/blob/master/crates/ci-core/proto/orchestrator.proto): protobuf contract · Compatibility boundary for distributed components. · `crates/ci-core/proto/orchestrator.proto`

### Controller Plane

- [CI controller](https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/main.rs): Rust service · Schedules, tracks, and recovers pipeline work. · `crates/ci-controller/src/main.rs`
- [REST API](https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/http_server.rs): HTTP server · Dashboard, runner, webhook, artifact, log, and administration operations. · `crates/ci-controller/src/http_server.rs`
- [Worker gRPC service](https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/grpc_server.rs): gRPC server · Registration, heartbeats, work delivery, and status reporting. · `crates/ci-controller/src/grpc_server.rs`
- [Pipeline scheduler](https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/scheduler.rs): orchestration runtime · Evaluates DAGs, capacity, reservations, and lifecycle recovery. · `crates/ci-controller/src/scheduler.rs`
- [Worker & job registries](https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/worker_registry.rs): runtime state · Tracks workers, jobs, job groups, and reservations. · `crates/ci-controller/src/worker_registry.rs`
- [Log aggregation](https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/log_aggregator.rs): log service · Persists worker logs and serves live log access. · `crates/ci-controller/src/log_aggregator.rs`
- **Authentication**: security layer · JWT, passwords, API keys, middleware, and worker tokens.

### Worker Execution

- [CI worker agent](https://github.com/subanesh-swe/chola/blob/master/crates/ci-worker/src/main.rs): Rust agent · Maintains controller connectivity and liveness. · `crates/ci-worker/src/main.rs`
- [Isolated stage execution](https://github.com/subanesh-swe/chola/blob/master/crates/ci-worker/src/stage_runner.rs): build executor · Runs stage commands and scripts per build. · `crates/ci-worker/src/stage_runner.rs`
- [Worker log streamer](https://github.com/subanesh-swe/chola/blob/master/crates/ci-worker/src/log_streamer.rs): log client · `crates/ci-worker/src/log_streamer.rs`

### State & Integrations

- [PostgreSQL](https://github.com/subanesh-swe/chola/blob/master/migrations/001_init_schema.sql): durable system of record · Stores CI state and history. · `migrations/001_init_schema.sql`
- [Redis](https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/redis_store.rs): transient distributed state · `crates/ci-controller/src/redis_store.rs`
- [Webhooks & notifications](https://github.com/subanesh-swe/chola/blob/master/crates/ci-controller/src/api/webhook_handlers.rs): integration plane · Ingests repository events and emits notifications. · `crates/ci-controller/src/api/webhook_handlers.rs`
- [External log shipping](https://github.com/subanesh-swe/chola/blob/master/config/vector.toml): Vector integration · `config/vector.toml`

## Connections

- React dashboard → REST API: REST API and SSE logs
- Job runner CLI → REST API: reserve, submit, control
- React dashboard → Authentication: authenticated access
- REST API → CI controller: operations
- REST API → Authentication: authenticates requests
- REST API → Log aggregation: live and historical logs
- Worker gRPC service → CI controller: worker control plane
- CI controller → Pipeline scheduler: schedules pipelines
- Pipeline scheduler → Worker & job registries: selects and reserves capacity
- Pipeline scheduler → PostgreSQL: durable job state
- CI controller → Redis: transient distributed state
- CI controller → Webhooks & notifications: event ingestion and delivery
- Worker gRPC service → CI worker agent: register, heartbeat, dispatch, status
- CI worker agent → Isolated stage execution: executes assigned stage
- Isolated stage execution → Worker log streamer: execution output
- Worker log streamer → Log aggregation: stream logs
- Log aggregation → PostgreSQL: persist logs
- Log aggregation → External log shipping: ship external logs
- Orchestrator protocol → Worker gRPC service: server contract
- Orchestrator protocol → CI worker agent: client contract
- CI domain models → CI controller: shared domain
- CI domain models → CI worker agent: shared domain
