# amroquqa99-art/d_ai architecture

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

- Interactive diagram: https://gitdiagram.com/amroquqa99-art/d_ai
- Repository: https://github.com/amroquqa99-art/d_ai

## Overview

D_AI is a local, host-independent state and policy layer for AI-assisted work, with OpenCode as its documented beta host. A user request enters through the lead agent or a local interface, gets scoped by an explicit charter, and can be coordinated as durable tasks and team work; results rely on model routing, gated tools, and persistent memory. Decisions, external-component adoption, and update watching are additional capabilities. The README documents the workflow; sampled source confirms selected service and adapter calls, but not all host routing or domain integrations.

Main entry points: [`src/dai/memory.py`](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/memory.py) (Encrypted memory), [`adapters/opencode/agent/dai-lead.md`](https://github.com/amroquqa99-art/d_ai/blob/main/adapters/opencode/agent/dai-lead.md) (Lead agent), [`src/dai/tasks.py`](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/tasks.py) (Task graph), [`src/dai/charters.py`](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/charters.py) (Charters)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_lead["Lead agent<br/>[dai-lead.md]"]
  node_domain_agents["Specialist agents"]
  node_commands["Slash commands"]
  node_skills["Skills"]
end

subgraph group_coordination["Work coordination"]
  node_charters["Charters<br/>[charters.py]"]
  node_tasks["Task graph<br/>[tasks.py]"]
  node_teams["Teams<br/>[teams.py]"]
  node_mission["Missions<br/>[mission.py]"]
end

subgraph group_policy["Policy and capabilities"]
  node_decisions["Decisions<br/>[decisions.py]"]
  node_models["Model routing<br/>[models.py]"]
  node_tools["Tool gate<br/>[tools.py]"]
  node_components["Component adoption<br/>[components.py]"]
  node_updates["Update watcher<br/>[updates.py]"]
end

subgraph group_runtime["Host integration"]
  node_cli["Local CLI<br/>[cli.py]"]
  node_mcp["MCP server<br/>[server.py]"]
  node_bridge["Core bridge<br/>[dai_core_bridge.py]"]
  node_pi["Pi adapter<br/>[pi_adapter.py]"]
end

subgraph group_persistence["State and storage"]
  node_memory[("Encrypted memory<br/>[memory.py]")]
  node_vault["Key vault<br/>[vault.py]"]
  node_contracts["Shared contracts<br/>[contracts.py]"]
end

node_user(("User"))
node_result["Inspectable output"]

node_user -->|"submits request"| node_lead
node_lead -->|"delegates work"| node_domain_agents
node_lead -->|"selects skills"| node_skills
node_user -->|"invokes command"| node_commands
node_commands -.->|"routes request"| node_lead
node_user -->|"runs locally"| node_cli
node_cli -->|"calls service"| node_tasks
node_mcp -->|"dispatches tools"| node_bridge
node_bridge -->|"calls service"| node_tasks
node_bridge -->|"reads records"| node_memory
node_pi -.->|"uses core state"| node_memory
node_lead -.->|"defines work"| node_charters
node_charters -->|"authorizes tasks"| node_tasks
node_tasks -->|"stores tasks"| node_memory
node_teams -->|"stores team records"| node_memory
node_mission -->|"stores mission data"| node_memory
node_decisions -->|"stores decisions"| node_memory
node_models -.->|"stores routing state"| node_memory
node_tools -.->|"stores tool state"| node_memory
node_components -->|"stores adoption records"| node_memory
node_updates -->|"records checks"| node_memory
node_memory -->|"uses encryption keys"| node_vault
node_charters -->|"validates fields"| node_contracts
node_tasks -->|"uses shared types"| node_contracts
node_decisions -->|"uses shared types"| node_contracts
node_lead -->|"integrates output"| node_result
node_cli -->|"serializes receipts"| node_result

click node_lead "https://github.com/amroquqa99-art/d_ai/blob/main/adapters/opencode/agent/dai-lead.md"
click node_domain_agents "https://github.com/amroquqa99-art/d_ai/tree/main/adapters/opencode/agent/dai"
click node_commands "https://github.com/amroquqa99-art/d_ai/tree/main/adapters/opencode/command"
click node_skills "https://github.com/amroquqa99-art/d_ai/tree/main/adapters/opencode/skill"
click node_cli "https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/cli.py"
click node_mcp "https://github.com/amroquqa99-art/d_ai/blob/main/adapters/opencode/mcp/server.py"
click node_bridge "https://github.com/amroquqa99-art/d_ai/blob/main/adapters/opencode/mcp/dai_core_bridge.py"
click node_pi "https://github.com/amroquqa99-art/d_ai/blob/main/adapters/pi/pi_adapter.py"
click node_charters "https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/charters.py"
click node_tasks "https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/tasks.py"
click node_teams "https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/teams.py"
click node_mission "https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/mission.py"
click node_decisions "https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/decisions.py"
click node_models "https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/models.py"
click node_tools "https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/tools.py"
click node_components "https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/components.py"
click node_updates "https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/updates.py"
click node_memory "https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/memory.py"
click node_vault "https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/vault.py"
click node_contracts "https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/contracts.py"

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_lead,node_domain_agents,node_commands,node_skills,node_user toneBlue
class node_charters,node_tasks,node_teams,node_mission toneAmber
class node_decisions,node_models,node_tools,node_components,node_updates toneMint
class node_cli,node_mcp,node_bridge,node_pi toneRose
class node_memory,node_vault,node_contracts,node_result toneIndigo
```

## Components

### User experience

- [Lead agent](https://github.com/amroquqa99-art/d_ai/blob/main/adapters/opencode/agent/dai-lead.md): `adapters/opencode/agent/dai-lead.md`
- [Specialist agents](https://github.com/amroquqa99-art/d_ai/tree/main/adapters/opencode/agent/dai): `adapters/opencode/agent/dai`
- [Slash commands](https://github.com/amroquqa99-art/d_ai/tree/main/adapters/opencode/command): `adapters/opencode/command`
- [Skills](https://github.com/amroquqa99-art/d_ai/tree/main/adapters/opencode/skill): `adapters/opencode/skill`

### Work coordination

- [Charters](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/charters.py): `src/dai/charters.py`
- [Task graph](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/tasks.py): `src/dai/tasks.py`
- [Teams](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/teams.py): `src/dai/teams.py`
- [Missions](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/mission.py): `src/dai/mission.py`

### Policy and capabilities

- [Decisions](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/decisions.py): `src/dai/decisions.py`
- [Model routing](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/models.py): `src/dai/models.py`
- [Tool gate](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/tools.py): `src/dai/tools.py`
- [Component adoption](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/components.py): `src/dai/components.py`
- [Update watcher](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/updates.py): `src/dai/updates.py`

### Host integration

- [Local CLI](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/cli.py): `src/dai/cli.py`
- [MCP server](https://github.com/amroquqa99-art/d_ai/blob/main/adapters/opencode/mcp/server.py): `adapters/opencode/mcp/server.py`
- [Core bridge](https://github.com/amroquqa99-art/d_ai/blob/main/adapters/opencode/mcp/dai_core_bridge.py): `adapters/opencode/mcp/dai_core_bridge.py`
- [Pi adapter](https://github.com/amroquqa99-art/d_ai/blob/main/adapters/pi/pi_adapter.py): `adapters/pi/pi_adapter.py`

### State and storage

- [Encrypted memory](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/memory.py): `src/dai/memory.py`
- [Key vault](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/vault.py): `src/dai/vault.py`
- [Shared contracts](https://github.com/amroquqa99-art/d_ai/blob/main/src/dai/contracts.py): `src/dai/contracts.py`

### Other components

- **User**
- **Inspectable output**

## Connections

- User → Lead agent: submits request (evidence: `README.md`)
- Lead agent → Specialist agents: delegates work (evidence: `README.md`)
- Lead agent → Skills: selects skills (evidence: `README.md`)
- User → Slash commands: invokes command (evidence: `README.md`)
- Slash commands → Lead agent: routes request
- User → Local CLI: runs locally (evidence: `README.md`)
- Local CLI → Task graph: calls service (evidence: `src/dai/cli.py`)
- MCP server → Core bridge: dispatches tools (evidence: `adapters/opencode/mcp/server.py`)
- Core bridge → Task graph: calls service (evidence: `adapters/opencode/mcp/dai_core_bridge.py`)
- Core bridge → Encrypted memory: reads records (evidence: `adapters/opencode/mcp/dai_core_bridge.py`)
- Pi adapter → Encrypted memory: uses core state
- Lead agent → Charters: defines work
- Charters → Task graph: authorizes tasks (evidence: `src/dai/tasks.py`)
- Task graph → Encrypted memory: stores tasks (evidence: `src/dai/tasks.py`)
- Teams → Encrypted memory: stores team records (evidence: `src/dai/teams.py`)
- Missions → Encrypted memory: stores mission data (evidence: `src/dai/mission.py`)
- Decisions → Encrypted memory: stores decisions (evidence: `src/dai/decisions.py`)
- Model routing → Encrypted memory: stores routing state (evidence: `src/dai/models.py`)
- Tool gate → Encrypted memory: stores tool state (evidence: `src/dai/tools.py`)
- Component adoption → Encrypted memory: stores adoption records (evidence: `src/dai/components.py`)
- Update watcher → Encrypted memory: records checks (evidence: `src/dai/updates.py`)
- Encrypted memory → Key vault: uses encryption keys (evidence: `src/dai/memory.py`)
- Charters → Shared contracts: validates fields (evidence: `src/dai/charters.py`)
- Task graph → Shared contracts: uses shared types (evidence: `src/dai/tasks.py`)
- Decisions → Shared contracts: uses shared types (evidence: `src/dai/decisions.py`)
- Lead agent → Inspectable output: integrates output (evidence: `README.md`)
- Local CLI → Inspectable output: serializes receipts (evidence: `src/dai/cli.py`)
