# cft0808/edict architecture

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

- Interactive diagram: https://gitdiagram.com/cft0808/edict
- Repository: https://github.com/cft0808/edict

## Overview

Edict is an AI multi-agent task coordination platform with an observable, operator-controlled dashboard. Its documented workflow takes an edict through Taizi triage, Zhongshu planning, Menxia review (including rejection and rework), Shangshu dispatch, departmental execution, and a final report. The repository includes both a legacy dashboard server and a newer event-driven backend; the frontend API explicitly targets the dashboard server, so they are shown as distinct runtime paths rather than assumed to be one integrated stack. The backend excerpts establish task, event, and worker responsibilities; several dashboard capabilities are README-documented but their implementations were not sampled.

Main entry points: [`edict/frontend/src/App.tsx`](https://github.com/cft0808/edict/blob/main/edict/frontend/src/App.tsx) (Dashboard App), [`edict/backend/app/services/task_service.py`](https://github.com/cft0808/edict/blob/main/edict/backend/app/services/task_service.py) (Task Service), [`edict/backend/app/services/event_bus.py`](https://github.com/cft0808/edict/blob/main/edict/backend/app/services/event_bus.py) (Event Bus), [`edict/frontend/src/api.ts`](https://github.com/cft0808/edict/blob/main/edict/frontend/src/api.ts) (Frontend API Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Task Workflow"]
  node_taizi["Taizi Triage"]
  node_zhongshu["Zhongshu Planning"]
  node_menxia["Menxia Review"]
  node_shangshu["Shangshu Dispatch"]
  node_departments["Department Agents"]
end

subgraph group_backend["Event Backend"]
  node_task_api["Task API<br/>[tasks.py]"]
  node_task_service["Task Service<br/>[task_service.py]"]
  node_task_model["Task State Model<br/>[task.py]"]
  node_db[("Database Layer<br/>[db.py]")]
  node_outbox["Outbox Relay<br/>[outbox_relay.py]"]
  node_event_bus["Event Bus<br/>[event_bus.py]"]
  node_orchestrator["Orchestrator"]
  node_dispatch_worker["Dispatch Worker<br/>[dispatch_worker.py]"]
  node_redis["Redis Streams"]
end

subgraph group_dashboard["Operations Dashboard"]
  node_dashboard_server["Dashboard API<br/>[server.py]"]
  node_frontend_api["Frontend API Client<br/>[api.ts]"]
  node_store["Dashboard Store<br/>[store.ts]"]
  node_app["Dashboard App<br/>[App.tsx]"]
  node_kanban["Edict Kanban<br/>[EdictBoard.tsx]"]
  node_task_detail["Task Detail<br/>[TaskModal.tsx]"]
  node_monitor["Agent Monitor<br/>[MonitorPanel.tsx]"]
  node_memorials["Memorial Archive<br/>[MemorialPanel.tsx]"]
  node_court["Court Discussion"]
  node_court_service["Discussion Service<br/>[court_discuss.py]"]
  node_morning["News Briefing<br/>[MorningPanel.tsx]"]
  node_models["Model Settings<br/>[ModelConfig.tsx]"]
  node_skills["Skills Manager<br/>[SkillsConfig.tsx]"]
  node_sessions["Session Monitor<br/>[SessionsPanel.tsx]"]
  node_officials["Officials Overview<br/>[OfficialPanel.tsx]"]
  node_templates["Edict Templates<br/>[TemplatePanel.tsx]"]
  node_ceremony["Court Ceremony<br/>[CourtCeremony.tsx]"]
end

subgraph group_integrations["Agent Integrations"]
  node_channels["Messaging Channels"]
  node_openclaw["OpenClaw Gateway"]
end

node_operator(("Operator"))

node_operator -->|"issues edict"| node_channels
node_channels -.->|"delivers request"| node_taizi
node_taizi -->|"routes edict"| node_zhongshu
node_zhongshu -->|"submits plan"| node_menxia
node_menxia -->|"approves plan"| node_shangshu
node_menxia -->|"returns for rework"| node_zhongshu
node_shangshu -->|"dispatches tasks"| node_departments
node_departments -->|"reports result"| node_operator
node_operator -.->|"submits task"| node_task_api
node_task_api -->|"calls service"| node_task_service
node_task_service -->|"reads and updates"| node_task_model
node_task_service -->|"commits task"| node_db
node_task_service -->|"writes events"| node_outbox
node_outbox -.->|"relays events"| node_event_bus
node_event_bus -->|"publishes streams"| node_redis
node_orchestrator -->|"consumes and publishes"| node_event_bus
node_orchestrator -->|"requests dispatch"| node_dispatch_worker
node_dispatch_worker -.->|"dispatches agent work"| node_openclaw
node_operator -->|"uses dashboard"| node_app
node_app -->|"starts polling"| node_store
node_app -->|"renders panel"| node_kanban
node_app -->|"renders modal"| node_task_detail
node_app -->|"renders panel"| node_monitor
node_app -->|"renders panel"| node_memorials
node_app -->|"renders panel"| node_court
node_app -->|"renders panel"| node_morning
node_app -->|"renders panel"| node_models
node_app -->|"renders panel"| node_skills
node_app -->|"renders panel"| node_sessions
node_app -->|"renders panel"| node_officials
node_app -->|"renders panel"| node_templates
node_app -->|"renders overlay"| node_ceremony
node_store -->|"loads dashboard data"| node_frontend_api
node_frontend_api -->|"requests endpoints"| node_dashboard_server
node_dashboard_server -->|"invokes discussion"| node_court_service
node_court -->|"requests discussion data"| node_frontend_api

click node_channels "https://github.com/cft0808/edict/tree/main/edict/backend/app/channels"
click node_task_api "https://github.com/cft0808/edict/blob/main/edict/backend/app/api/tasks.py"
click node_task_service "https://github.com/cft0808/edict/blob/main/edict/backend/app/services/task_service.py"
click node_task_model "https://github.com/cft0808/edict/blob/main/edict/backend/app/models/task.py"
click node_db "https://github.com/cft0808/edict/blob/main/edict/backend/app/db.py"
click node_outbox "https://github.com/cft0808/edict/blob/main/edict/backend/app/workers/outbox_relay.py"
click node_event_bus "https://github.com/cft0808/edict/blob/main/edict/backend/app/services/event_bus.py"
click node_orchestrator "https://github.com/cft0808/edict/blob/main/edict/backend/app/workers/orchestrator_worker.py"
click node_dispatch_worker "https://github.com/cft0808/edict/blob/main/edict/backend/app/workers/dispatch_worker.py"
click node_dashboard_server "https://github.com/cft0808/edict/blob/main/dashboard/server.py"
click node_frontend_api "https://github.com/cft0808/edict/blob/main/edict/frontend/src/api.ts"
click node_store "https://github.com/cft0808/edict/blob/main/edict/frontend/src/store.ts"
click node_app "https://github.com/cft0808/edict/blob/main/edict/frontend/src/App.tsx"
click node_kanban "https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/EdictBoard.tsx"
click node_task_detail "https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/TaskModal.tsx"
click node_monitor "https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/MonitorPanel.tsx"
click node_memorials "https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/MemorialPanel.tsx"
click node_court "https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/CourtDiscussion.tsx"
click node_court_service "https://github.com/cft0808/edict/blob/main/dashboard/court_discuss.py"
click node_morning "https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/MorningPanel.tsx"
click node_models "https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/ModelConfig.tsx"
click node_skills "https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/SkillsConfig.tsx"
click node_sessions "https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/SessionsPanel.tsx"
click node_officials "https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/OfficialPanel.tsx"
click node_templates "https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/TemplatePanel.tsx"
click node_ceremony "https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/CourtCeremony.tsx"

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_taizi,node_zhongshu,node_menxia,node_shangshu,node_departments toneBlue
class node_task_api,node_task_service,node_task_model,node_db,node_outbox,node_event_bus,node_orchestrator,node_dispatch_worker,node_redis toneAmber
class node_dashboard_server,node_frontend_api,node_store,node_app,node_kanban,node_task_detail,node_monitor,node_memorials,node_court,node_court_service,node_morning,node_models,node_skills,node_sessions,node_officials,node_templates,node_ceremony toneMint
class node_channels,node_openclaw toneRose
class node_operator toneIndigo
```

## Components

### Task Workflow

- **Taizi Triage**
- **Zhongshu Planning**
- **Menxia Review**
- **Shangshu Dispatch**
- **Department Agents**

### Event Backend

- [Task API](https://github.com/cft0808/edict/blob/main/edict/backend/app/api/tasks.py): `edict/backend/app/api/tasks.py`
- [Task Service](https://github.com/cft0808/edict/blob/main/edict/backend/app/services/task_service.py): `edict/backend/app/services/task_service.py`
- [Task State Model](https://github.com/cft0808/edict/blob/main/edict/backend/app/models/task.py): `edict/backend/app/models/task.py`
- [Database Layer](https://github.com/cft0808/edict/blob/main/edict/backend/app/db.py): `edict/backend/app/db.py`
- [Outbox Relay](https://github.com/cft0808/edict/blob/main/edict/backend/app/workers/outbox_relay.py): `edict/backend/app/workers/outbox_relay.py`
- [Event Bus](https://github.com/cft0808/edict/blob/main/edict/backend/app/services/event_bus.py): `edict/backend/app/services/event_bus.py`
- [Orchestrator](https://github.com/cft0808/edict/blob/main/edict/backend/app/workers/orchestrator_worker.py): `edict/backend/app/workers/orchestrator_worker.py`
- [Dispatch Worker](https://github.com/cft0808/edict/blob/main/edict/backend/app/workers/dispatch_worker.py): `edict/backend/app/workers/dispatch_worker.py`
- **Redis Streams**

### Operations Dashboard

- [Dashboard API](https://github.com/cft0808/edict/blob/main/dashboard/server.py): `dashboard/server.py`
- [Frontend API Client](https://github.com/cft0808/edict/blob/main/edict/frontend/src/api.ts): `edict/frontend/src/api.ts`
- [Dashboard Store](https://github.com/cft0808/edict/blob/main/edict/frontend/src/store.ts): `edict/frontend/src/store.ts`
- [Dashboard App](https://github.com/cft0808/edict/blob/main/edict/frontend/src/App.tsx): `edict/frontend/src/App.tsx`
- [Edict Kanban](https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/EdictBoard.tsx): `edict/frontend/src/components/EdictBoard.tsx`
- [Task Detail](https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/TaskModal.tsx): `edict/frontend/src/components/TaskModal.tsx`
- [Agent Monitor](https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/MonitorPanel.tsx): `edict/frontend/src/components/MonitorPanel.tsx`
- [Memorial Archive](https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/MemorialPanel.tsx): `edict/frontend/src/components/MemorialPanel.tsx`
- [Court Discussion](https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/CourtDiscussion.tsx): `edict/frontend/src/components/CourtDiscussion.tsx`
- [Discussion Service](https://github.com/cft0808/edict/blob/main/dashboard/court_discuss.py): `dashboard/court_discuss.py`
- [News Briefing](https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/MorningPanel.tsx): `edict/frontend/src/components/MorningPanel.tsx`
- [Model Settings](https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/ModelConfig.tsx): `edict/frontend/src/components/ModelConfig.tsx`
- [Skills Manager](https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/SkillsConfig.tsx): `edict/frontend/src/components/SkillsConfig.tsx`
- [Session Monitor](https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/SessionsPanel.tsx): `edict/frontend/src/components/SessionsPanel.tsx`
- [Officials Overview](https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/OfficialPanel.tsx): `edict/frontend/src/components/OfficialPanel.tsx`
- [Edict Templates](https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/TemplatePanel.tsx): `edict/frontend/src/components/TemplatePanel.tsx`
- [Court Ceremony](https://github.com/cft0808/edict/blob/main/edict/frontend/src/components/CourtCeremony.tsx): `edict/frontend/src/components/CourtCeremony.tsx`

### Agent Integrations

- [Messaging Channels](https://github.com/cft0808/edict/tree/main/edict/backend/app/channels): `edict/backend/app/channels`
- **OpenClaw Gateway**

### Other components

- **Operator**

## Connections

- Operator → Messaging Channels: issues edict
- Messaging Channels → Taizi Triage: delivers request
- Taizi Triage → Zhongshu Planning: routes edict
- Zhongshu Planning → Menxia Review: submits plan
- Menxia Review → Shangshu Dispatch: approves plan
- Menxia Review → Zhongshu Planning: returns for rework
- Shangshu Dispatch → Department Agents: dispatches tasks
- Department Agents → Operator: reports result
- Operator → Task API: submits task
- Task API → Task Service: calls service (evidence: `edict/backend/app/api/tasks.py`)
- Task Service → Task State Model: reads and updates (evidence: `edict/backend/app/services/task_service.py`)
- Task Service → Database Layer: commits task (evidence: `edict/backend/app/services/task_service.py`)
- Task Service → Outbox Relay: writes events (evidence: `edict/backend/app/services/task_service.py`)
- Outbox Relay → Event Bus: relays events
- Event Bus → Redis Streams: publishes streams (evidence: `edict/backend/app/services/event_bus.py`)
- Orchestrator → Event Bus: consumes and publishes (evidence: `edict/backend/app/workers/orchestrator_worker.py`)
- Orchestrator → Dispatch Worker: requests dispatch (evidence: `edict/backend/app/workers/orchestrator_worker.py`)
- Dispatch Worker → OpenClaw Gateway: dispatches agent work
- Operator → Dashboard App: uses dashboard
- Dashboard App → Dashboard Store: starts polling (evidence: `edict/frontend/src/App.tsx`)
- Dashboard App → Edict Kanban: renders panel (evidence: `edict/frontend/src/App.tsx`)
- Dashboard App → Task Detail: renders modal (evidence: `edict/frontend/src/App.tsx`)
- Dashboard App → Agent Monitor: renders panel (evidence: `edict/frontend/src/App.tsx`)
- Dashboard App → Memorial Archive: renders panel (evidence: `edict/frontend/src/App.tsx`)
- Dashboard App → Court Discussion: renders panel (evidence: `edict/frontend/src/App.tsx`)
- Dashboard App → News Briefing: renders panel (evidence: `edict/frontend/src/App.tsx`)
- Dashboard App → Model Settings: renders panel (evidence: `edict/frontend/src/App.tsx`)
- Dashboard App → Skills Manager: renders panel (evidence: `edict/frontend/src/App.tsx`)
- Dashboard App → Session Monitor: renders panel (evidence: `edict/frontend/src/App.tsx`)
- Dashboard App → Officials Overview: renders panel (evidence: `edict/frontend/src/App.tsx`)
- Dashboard App → Edict Templates: renders panel (evidence: `edict/frontend/src/App.tsx`)
- Dashboard App → Court Ceremony: renders overlay (evidence: `edict/frontend/src/App.tsx`)
- Dashboard Store → Frontend API Client: loads dashboard data (evidence: `edict/frontend/src/store.ts`)
- Frontend API Client → Dashboard API: requests endpoints (evidence: `edict/frontend/src/api.ts`)
- Dashboard API → Discussion Service: invokes discussion (evidence: `dashboard/server.py`)
- Court Discussion → Frontend API Client: requests discussion data (evidence: `edict/frontend/src/components/CourtDiscussion.tsx`)
