Skip to content

Architecture Overview

Composia uses a control plane-agent (Controller-Agent) architecture that supports distributed multi-node service management.

System Architecture

┌─────────────────────────────────────────────────────────────┐
│                      Control Plane                          │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────────────┐  │
│  │   Web UI    │  │  API Server │  │     Task Queue      │  │
│  │  (SvelteKit)│  │ (ConnectRPC)│  │     (SQLite)        │  │
│  └─────────────┘  └─────────────┘  └─────────────────────┘  │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────────────┐  │
│  │  Git Repo   │  │   Service   │  │    Node Manager     │  │
│  │  (Config)   │  │   Registry  │  │                     │  │
│  └─────────────┘  └─────────────┘  └─────────────────────┘  │
└─────────────────────────────────────────────────────────────┘

              ┌───────────────┼───────────────┐
              │               │               │
       ┌──────▼──────┐ ┌──────▼──────┐ ┌──────▼──────┐
       │   Agent 1   │ │   Agent 2   │ │   Agent N   │
       │  (Node A)   │ │  (Node B)   │ │  (Node C)   │
       │ ┌─────────┐ │ │ ┌─────────┐ │ │ ┌─────────┐ │
       │ │ Docker  │ │ │ │ Docker  │ │ │ │ Docker  │ │
       │ │ Compose │ │ │ │ Compose │ │ │ │ Compose │ │
       │ └─────────┘ │ │ └─────────┘ │ │ └─────────┘ │
       └─────────────┘ └─────────────┘ └─────────────┘

Core Components

Control Plane (Controller)

The control plane is the central hub of the system, running in its own container:

FunctionDescription
Configuration ManagementLoading and maintaining service definitions from Git repositories
State AggregationCollecting status information from all agents
Task SchedulingAssigning deployment tasks to appropriate agents
API ServicesProviding Web UI and external integration interfaces
Data PersistenceUsing SQLite for tasks and state storage

Execution Agents

Agents run on target Docker hosts:

FunctionDescription
Heartbeat CommunicationRegularly reporting status to the control plane (default: 5 seconds)
Task ExecutionExecuting deployment, stop, restart, and other operations
Log CollectionCollecting and forwarding container logs
Resource MonitoringMonitoring host and container resource usage
Docker OperationsDirectly managing local Docker containers

Web Interface

A modern management interface built with SvelteKit:

  • Service Management: Create, edit, and deploy services
  • Node Monitoring: View status of all agent nodes
  • Container Operations: View logs, execute commands
  • Task Tracking: Monitor task execution progress in real-time

Communication

ConnectRPC

Composia uses ConnectRPC for inter-service communication:

  • Bidirectional streaming based on HTTP/2
  • Protobuf serialization
  • Compatible with gRPC and REST clients
  • Supports browser direct calls

Authentication

ComponentAuthentication Method
Web UI → ControllerCLI Token (Bearer)
Agent → ControllerNode Token
Controller → AgentmTLS (optional)

Data Flow

Deployment Flow

User Request → Controller Validation → Create Task → Agent Pull → Execute Deploy → Report Result
  1. User initiates a deployment request via Web UI or API
  2. Controller validates service definition and permissions
  3. Creates deployment tasks for each target node
  4. Agent retrieves tasks via long-polling
  5. Agent downloads service bundle and executes Docker Compose deployment
  6. Agent reports execution result and container status

Status Synchronization

Agent Collect → Heartbeat Report → Controller Aggregate → Web UI Display
  • Agents send heartbeats every 5 seconds
  • Heartbeats include node status, container list, and resource usage
  • Controller aggregates status from all agents into SQLite
  • Web UI displays real-time status updates

Core Object Model

Service (Service Definition)

    ├── ServiceInstance (Node Instance) ── Container (Docker Container)

    └── ServiceInstance (Node Instance) ── Container (Docker Container)
ObjectDescriptionStorage
ServiceLogical service definition from Git repositoryGit Repo
ServiceInstanceDeployment instance of a service on a specific nodeSQLite
ContainerActual Docker containerDocker Daemon
NodeDocker host where an Agent runsController Config

Security

LayerMeasures
AuthenticationToken-based authentication
TransportTLS encryption supported (recommended for production)
AuthorizationPrinciple of least privilege; agents only access assigned services
SecretsEncrypted storage using age

Scalability

  • Horizontal Scaling: Add more Agent nodes to manage more Docker hosts
  • Service Scaling: Deploy the same service to multiple nodes
  • Load Balancing: Multi-instance load balancing through Caddy configuration

Deployment Patterns

Single-Node Mode

┌─────────────────────────────────────┐
│           Single Server             │
│  ┌──────────┐    ┌───────────────┐  │
│  │Controller│◄──►│     Agent     │  │
│  └──────────┘    └───────┬───────┘  │
│                          │          │
│                   ┌──────▼──────┐   │
│                   │   Docker    │   │
│                   └─────────────┘   │
└─────────────────────────────────────┘

Multi-Node Mode

┌─────────────────┐
│    Controller   │
└────────┬────────┘

    ┌────┴────┬────────┬────────┐
    ▼         ▼        ▼        ▼
┌───────┐ ┌───────┐ ┌───────┐ ┌───────┐
│Agent 1│ │Agent 2│ │Agent 3│ │Agent N│
└───┬───┘ └───┬───┘ └───┬───┘ └───┬───┘
    │         │         │         │
┌───▼───┐ ┌───▼───┐ ┌───▼───┐ ┌───▼───┐
│Docker │ │Docker │ │Docker │ │Docker │
│Node 1 │ │Node 2 │ │Node 3 │ │Node N │
└───────┘ └───────┘ └───────┘ └───────┘

Released under the AGPL-3.0 License.