How abhi1693/openclaw-mission-control works
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: services Domain Services · api Route Layer · main.py API Server · app App Router
Components 18
Backend
FastAPI API, services, persistence, and worker processes.
- API Server · Application entrypoint wiring middleware, routing, auth, and dependency injection.
backend/app/main.py - Route Layer · Thin resource-oriented API modules for boards, tasks, agents, gateways, approvals, activity, metrics, and organizations.
backend/app/api - Core Policy · Shared auth mode selection, token handling, rate limiting, security headers, client IP, and error handling.
backend/app/core - Domain Services · Board lifecycle, snapshots, approvals, activity, mentions, tags, task dependencies, organization access, and webhook coordination.
backend/app/services - OpenClaw CP · Agent/gateway orchestration, provisioning, lifecycle reconciliation, sessions, compatibility, and device identity.
backend/app/services/openclaw - Queue Worker · Queued work for lifecycle and webhook dispatch, plus dedicated worker execution.
backend/app/services/queue_worker.py - Data Access · SQLAlchemy-style CRUD, query helpers, pagination, and session management.
backend/app/db - Domain Models · Core entities for boards, board groups, tasks, agents, gateways, approvals, tags, custom fields, organizations, users, and activity events.
backend/app/models - Schemas · Request/response models for the public API and gateway coordination contracts.
backend/app/schemas - Migrations · Database schema evolution and relational history.
backend/migrations/versions
Frontend
Next.js operator UI and generated API client.
- App Router · Route-based operator UI for boards, agents, approvals, gateways, organizations, skills, tags, onboarding, and settings.
frontend/src/app - UI System · Reusable shells, tables, forms, panels, and domain widgets used across the app.
frontend/src/components - Auth Client · Clerk/local auth mode handling, redirects, and sign-in flow logic.
frontend/src/auth - API Client · Auto-generated client and models derived from the backend contract.
frontend/src/api/generated
External
Runtime and integration boundaries outside the repo.
- Database · Primary durable relational database backing the backend.
- Auth Provider · External or local authentication boundary used by the system.
- Agents & Gateways · Distributed execution environments that pair with the backend control plane.
- Webhooks · Outbound and inbound webhook consumers and dispatch targets.
Connections 22
- 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.