# abhi1693/openclaw-mission-control architecture

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

- Interactive diagram: https://gitdiagram.com/abhi1693/openclaw-mission-control
- Repository: https://github.com/abhi1693/openclaw-mission-control

## Overview

1. **Overall shape**
   - This is a two-tier monorepo: a **FastAPI backend** in `backend/` and a **Next.js frontend** in `frontend/`.
   - The frontend is the primary operator UI; the backend is the system of record and API surface for orchestration, governance, and automation.

2. **Core domain boundary**
   - The repository is organized around a small set of first-class operational entities: **organizations, board groups, boards, tasks, agents, gateways, approvals, tags, custom fields, activity events, and users**.
   - `boards` are the main work units; `board_groups` aggregate boards and have their own memory/snapshot/heartbeat concepts.
   - `agents` and `gateways` are the runtime/control-plane side of the product, not just UI records.

3. **Backend API layer**
   - `backend/app/api/*` is split by domain, with one route module per resource area.
   - The API layer is thin: it handles request/response shaping, dependency injection, auth, pagination, and error translation, then delegates to services.
   - There are dedicated endpoints for operational streams and read models such as activity, approvals, board memory, gateway sessions, metrics, and onboarding.

4. **Service and orchestration layer**
   - `backend/app/services/*` contains the business logic that coordinates mutations across models.
   - Key service groups include:
     - **board lifecycle and snapshots**
     - **approvals and approval-task links**
     - **activity logging**
     - **mentions, tags, task dependencies**
     - **organizations and access control**
     - **webhook dispatch/queueing**
   - The `services/openclaw/` subtree is the highest-value orchestration boundary: it manages agent/gateway coordination, provisioning, lifecycle reconciliation, session handling, and compatibility logic.

5. **OpenClaw control-plane subsystem**
   - `services/openclaw/` is effectively a mini control plane for distributed agent execution.
   - It includes modules for:
     - **gateway RPC and dispatch**
     - **gateway resolution and compatibility**
     - **device identity and agent keys**
     - **session services and session keys**
     - **lifecycle queue/reconcile/orchestrator**
     - **provisioning and onboarding**
   - This is where remote execution environments and paired agent/gateway flows are coordinated.

6. **Persistence and data access**
   - Data is modeled with SQLAlchemy-style ORM models in `backend/app/models/*`.
   - `backend/app/db/*` provides session management, CRUD/query helpers, querysets, and pagination abstractions.
   - Alembic migrations in `backend/migrations/versions/` define the relational schema evolution, so the backend depends on a conventional SQL database as its durable store.

7. **Async/background work**
   - Background processing exists as a separate execution path, not just request-time logic.
   - `backend/app/services/queue.py`, `queue_worker.py`, and `services/webhooks/queue.py` indicate queued jobs for lifecycle and webhook-related work.
   - The deployment docs also reference a dedicated worker service, so the architecture includes at least one backend worker process alongside the API server.

8. **Auth, security, and policy boundaries**
   - Authentication supports two modes: **local shared-token auth** and **Clerk JWT auth**.
   - Security concerns are centralized in `backend/app/core/*`, including rate limiting, security headers, auth mode selection, client IP handling, and error handling.
   - There is also explicit policy logic around admin access, lead policy, and request authentication flows, which matters for who can mutate sensitive operational objects.

9. **Frontend architecture**
   - The frontend uses the **Next.js App Router** with route-based pages under `frontend/src/app/*`.
   - UI is organized by domain: boards, agents, approvals, gateways, organizations, tags, skills, custom fields, activity, onboarding, and settings.
   - Shared UI is componentized into tables, forms, shells/layouts, domain-specific panels, and auth providers.
   - The frontend is not just presentation; it contains meaningful client-side flow logic for onboarding, task board interactions, authentication redirects, and form behavior.

10. **Frontend-to-backend contract**
   - `frontend/src/api/generated/*` is auto-generated from the backend OpenAPI contract, so the backend schema is the source of truth for client types and API calls.
   - That means the architecture relies on a tight API contract between the FastAPI server and the Next.js client.
   - Generated models cover the same domain boundaries as the backend: boards, tasks, agents, approvals, gateways, metrics, skills, tags, and directory/search features.

11. **Operational data flows**
   - Primary user flow: browser UI → frontend pages/components → generated API client → backend routes → services → DB.
   - Control-plane flows: agent/gateway interactions → backend auth/session/lifecycle/gateway services → persistence and queued work.
   - Audit/visibility flows: mutations and system actions → activity events/logging services → activity feed and metrics endpoints.
   - Integration flows: webhook ingest/dispatch and gateway template sync are managed server-side and surfaced in the UI.

12. **Deployment and repo-level tooling**
   - The repo is built for containerized deployment with `compose.yml`, plus separate Dockerfiles for frontend and backend.
   - There are also systemd deployment docs, suggesting supported self-hosted/server deployments beyond local dev.
   - CI, migrations checks, OpenAPI export, and template sync scripts indicate the architecture is intentionally contract-driven and ops-heavy.

13. **What to show in an architecture diagram**
   - Draw the backend as the central hub, with separate boxes for **API routes**, **domain services**, **persistence**, **queue/worker**, and **OpenClaw orchestration**.
   - Show the frontend as a client consuming the backend OpenAPI contract.
   - Show external boundaries for **database**, **Clerk or local auth**, **agents/gateways**, and **webhook integrations**.
   - Highlight that approvals, lifecycle orchestration, and gateway/session management are core control-plane paths, not peripheral features.

Main entry points: [`backend/app/services`](https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/services) (Domain Services), [`backend/app/api`](https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/api) (Route Layer), [`backend/app/main.py`](https://github.com/abhi1693/openclaw-mission-control/blob/master/backend/app/main.py) (API Server), [`frontend/src/app`](https://github.com/abhi1693/openclaw-mission-control/tree/master/frontend/src/app) (App Router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_repo["Monorepo"]
end

subgraph group_backend["Backend"]
  node_backend_main["API Server<br/>FastAPI app<br/>[main.py]"]
  node_backend_api["Route Layer<br/>domain routes"]
  node_backend_core["Core Policy<br/>auth & security"]
  node_backend_services["Domain Services<br/>business logic"]
  node_backend_openclaw["OpenClaw CP<br/>control plane"]
  node_backend_queue["Queue Worker<br/>background jobs<br/>[queue_worker.py]"]
  node_backend_db["Data Access<br/>ORM & persistence"]
  node_backend_models["Domain Models<br/>ORM models"]
  node_backend_schemas["Schemas"]
  node_backend_migrations["Migrations<br/>alembic schema"]
end

subgraph group_frontend["Frontend"]
  node_frontend_app["App Router<br/>nextjs routes"]
  node_frontend_components["UI System<br/>shared components"]
  node_frontend_auth["Auth Client<br/>client auth"]
  node_frontend_api_generated["API Client"]
end

subgraph group_external["External"]
  node_db[("Database<br/>sql store")]
  node_auth_ext(("Auth Provider<br/>Clerk or local token"))
  node_agents_gws(("Agents & Gateways<br/>remote runtimes"))
  node_webhooks_ext(("Webhooks<br/>integration boundary"))
end

node_frontend_app -->|"renders"| node_frontend_components
node_frontend_app -->|"auth flow"| node_frontend_auth
node_frontend_app -->|"calls"| node_frontend_api_generated
node_frontend_api_generated -->|"contract"| node_backend_api
node_backend_main -->|"mounts"| node_backend_api
node_backend_api -->|"depends on"| node_backend_core
node_backend_api -->|"delegates"| node_backend_services
node_backend_services -->|"orchestrates"| node_backend_openclaw
node_backend_services -->|"reads/writes"| node_backend_db
node_backend_db -->|"maps"| node_backend_models
node_backend_db -->|"persists"| node_db
node_backend_migrations -->|"evolves"| node_db
node_backend_api -->|"serializes"| node_backend_schemas
node_backend_services -->|"returns"| node_backend_schemas
node_backend_core -->|"validates"| node_auth_ext
node_backend_openclaw -->|"coordinates"| node_agents_gws
node_backend_services -->|"dispatches"| node_webhooks_ext
node_backend_queue -->|"runs jobs"| node_backend_services
node_backend_queue -->|"delivers"| node_webhooks_ext
node_frontend_auth -->|"signs in"| node_auth_ext
node_backend_main -->|"spawns"| node_backend_queue
node_backend_main -->|"uses"| node_backend_core

click node_frontend_app "https://github.com/abhi1693/openclaw-mission-control/tree/master/frontend/src/app"
click node_frontend_components "https://github.com/abhi1693/openclaw-mission-control/tree/master/frontend/src/components"
click node_frontend_auth "https://github.com/abhi1693/openclaw-mission-control/tree/master/frontend/src/auth"
click node_frontend_api_generated "https://github.com/abhi1693/openclaw-mission-control/tree/master/frontend/src/api/generated"
click node_backend_main "https://github.com/abhi1693/openclaw-mission-control/blob/master/backend/app/main.py"
click node_backend_api "https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/api"
click node_backend_core "https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/core"
click node_backend_services "https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/services"
click node_backend_openclaw "https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/services/openclaw"
click node_backend_queue "https://github.com/abhi1693/openclaw-mission-control/blob/master/backend/app/services/queue_worker.py"
click node_backend_db "https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/db"
click node_backend_models "https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/models"
click node_backend_schemas "https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/schemas"
click node_backend_migrations "https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/migrations/versions"

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_backend_main,node_backend_api,node_backend_core,node_backend_services,node_backend_openclaw,node_backend_queue,node_backend_db,node_backend_models,node_backend_schemas,node_backend_migrations toneAmber
class node_frontend_app,node_frontend_components,node_frontend_auth,node_frontend_api_generated toneMint
class node_db,node_auth_ext,node_agents_gws,node_webhooks_ext toneRose
```

## Components

### Backend

FastAPI API, services, persistence, and worker processes.

- [API Server](https://github.com/abhi1693/openclaw-mission-control/blob/master/backend/app/main.py): FastAPI app · Application entrypoint wiring middleware, routing, auth, and dependency injection. · `backend/app/main.py`
- [Route Layer](https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/api): domain routes · Thin resource-oriented API modules for boards, tasks, agents, gateways, approvals, activity, metrics, and organizations. · `backend/app/api`
- [Core Policy](https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/core): auth & security · Shared auth mode selection, token handling, rate limiting, security headers, client IP, and error handling. · `backend/app/core`
- [Domain Services](https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/services): business logic · Board lifecycle, snapshots, approvals, activity, mentions, tags, task dependencies, organization access, and webhook coordination. · `backend/app/services`
- [OpenClaw CP](https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/services/openclaw): control plane · Agent/gateway orchestration, provisioning, lifecycle reconciliation, sessions, compatibility, and device identity. · `backend/app/services/openclaw`
- [Queue Worker](https://github.com/abhi1693/openclaw-mission-control/blob/master/backend/app/services/queue_worker.py): background jobs · Queued work for lifecycle and webhook dispatch, plus dedicated worker execution. · `backend/app/services/queue_worker.py`
- [Data Access](https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/db): ORM & persistence · SQLAlchemy-style CRUD, query helpers, pagination, and session management. · `backend/app/db`
- [Domain Models](https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/models): ORM models · Core entities for boards, board groups, tasks, agents, gateways, approvals, tags, custom fields, organizations, users, and activity events. · `backend/app/models`
- [Schemas](https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/app/schemas): API schemas · Request/response models for the public API and gateway coordination contracts. · `backend/app/schemas`
- [Migrations](https://github.com/abhi1693/openclaw-mission-control/tree/master/backend/migrations/versions): alembic schema · Database schema evolution and relational history. · `backend/migrations/versions`

### Frontend

Next.js operator UI and generated API client.

- [App Router](https://github.com/abhi1693/openclaw-mission-control/tree/master/frontend/src/app): nextjs routes · Route-based operator UI for boards, agents, approvals, gateways, organizations, skills, tags, onboarding, and settings. · `frontend/src/app`
- [UI System](https://github.com/abhi1693/openclaw-mission-control/tree/master/frontend/src/components): shared components · Reusable shells, tables, forms, panels, and domain widgets used across the app. · `frontend/src/components`
- [Auth Client](https://github.com/abhi1693/openclaw-mission-control/tree/master/frontend/src/auth): client auth · Clerk/local auth mode handling, redirects, and sign-in flow logic. · `frontend/src/auth`
- [API Client](https://github.com/abhi1693/openclaw-mission-control/tree/master/frontend/src/api/generated): generated OpenAPI client · Auto-generated client and models derived from the backend contract. · `frontend/src/api/generated`

### External

Runtime and integration boundaries outside the repo.

- **Database**: sql store · Primary durable relational database backing the backend.
- **Auth Provider**: Clerk or local token · External or local authentication boundary used by the system.
- **Agents & Gateways**: remote runtimes · Distributed execution environments that pair with the backend control plane.
- **Webhooks**: integration boundary · Outbound and inbound webhook consumers and dispatch targets.

## Connections

- App Router → UI System: renders · Pages assemble shared UI and domain panels.
- App Router → Auth Client: auth flow · Routes react to auth state and redirects.
- App Router → API Client: calls · UI uses generated API client and models.
- API Client → Route Layer: contract · Client is generated from backend OpenAPI.
- API Server → Route Layer: mounts · Application wires route modules into the server.
- Route Layer → Core Policy: depends on · Routes use shared auth, rate limiting, and error handling.
- Route Layer → Domain Services: delegates · Routes translate requests then call domain services.
- Domain Services → OpenClaw CP: orchestrates · Business services hand off control-plane concerns to OpenClaw.
- Domain Services → Data Access: reads/writes · Services persist and query domain state.
- Data Access → Domain Models: maps · CRUD and queryset layers operate on ORM models.
- Data Access → Database: persists · Database sessions store durable state.
- Migrations → Database: evolves · Alembic migrations define schema changes.
- Route Layer → Schemas: serializes · Routes use typed request and response schemas.
- Domain Services → Schemas: returns · Service results are shaped into API-facing models.
- Core Policy → Auth Provider: validates · Auth mode is selected between local token and Clerk JWT paths.
- OpenClaw CP → Agents & Gateways: coordinates · Gateway dispatch, sessions, provisioning, and lifecycle reconciliation target remote agents and gateways.
- Domain Services → Webhooks: dispatches · Webhook queue/dispatch reaches external consumers.
- Queue Worker → Domain Services: runs jobs · Worker executes queued lifecycle and webhook-related work.
- Queue Worker → Webhooks: delivers · Queued webhook jobs send outbound integration events.
- Auth Client → Auth Provider: signs in · Frontend login and redirect flows depend on the selected auth mode.
- API Server → Queue Worker: spawns · Deployment includes a dedicated worker process alongside the API server.
- API Server → Core Policy: uses · Server entrypoint applies security and request policy middleware.
