# griffins2005/mandategraph architecture

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

- Interactive diagram: https://gitdiagram.com/griffins2005/mandategraph
- Repository: https://github.com/griffins2005/mandategraph

## Overview

MandateGraph provides delegated authority and budget accounting, with a contract, indexer/verifier, reference model, backend workflow, and dashboard. The principal flow is a user exploring or initiating a workflow in the dashboard; backend orchestration demonstrates delegation, work, evaluation, and settlement evidence, while chain-facing services expose contract state and operations. The contract enforces protocol rules, and the indexer reconstructs state from events and reconciles it with views. Some backend and frontend paths are unsampled; edges below rely on shown calls or README statements where available.

Main entry points: [`backend/app/agents/orchestrator.py`](https://github.com/griffins2005/mandategraph/blob/main/backend/app/agents/orchestrator.py) (Workflow orchestrator), [`backend/app/main.py`](https://github.com/griffins2005/mandategraph/blob/main/backend/app/main.py) (API routes), [`indexer/src/main.rs`](https://github.com/griffins2005/mandategraph/blob/main/indexer/src/main.rs) (Event indexer), [`backend/app/chain.py`](https://github.com/griffins2005/mandategraph/blob/main/backend/app/chain.py) (Chain access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_app["Dashboard app<br/>[App.tsx]"]
end

subgraph group_backend["Backend workflow"]
  node_api["API routes<br/>[main.py]"]
  node_orchestrator["Workflow orchestrator<br/>[orchestrator.py]"]
  node_research["Research roles<br/>[research.py]"]
  node_role_plan["Role planning<br/>[roles.py]"]
  node_artifact_check["Artifact verification<br/>[verification.py]"]
  node_artifact_hash["Artifact hashing<br/>[artifacts.py]"]
  node_contract_calls["Contract call builder<br/>[transactions.py]"]
  node_chain_access["Chain access<br/>[chain.py]"]
  node_preview["Policy preview<br/>[preview.py]"]
  node_policy["Authorization policy<br/>[policy.py]"]
end

subgraph group_protocol["Mandate protocol"]
  node_contract["Mandate contract<br/>[lib.rs]"]
  node_mandate_state["Mandate state<br/>[mandate.rs]"]
  node_delegation["Delegation rules<br/>[delegation.rs]"]
  node_settlement["Settlement rules<br/>[settlement.rs]"]
end

subgraph group_indexing["Indexing and verification"]
  node_indexer["Event indexer<br/>[main.rs]"]
  node_codec["Event codec<br/>[codec.rs]"]
end

subgraph group_model["Reference model"]
  node_ledger["Python reference ledger<br/>[mandategraph.py]"]
end

node_user(("Dashboard user"))
node_concordium[("Concordium node")]

node_user -->|"uses"| node_app
node_app -->|"requests workflow"| node_api
node_api -->|"runs workflow"| node_orchestrator
node_orchestrator -->|"executes reference model"| node_ledger
node_orchestrator -->|"plans jobs"| node_role_plan
node_orchestrator -->|"uses research roles"| node_research
node_orchestrator -->|"checks artifacts"| node_artifact_check
node_artifact_check -->|"hashes artifact"| node_artifact_hash
node_api -->|"previews actions"| node_preview
node_preview -->|"uses policy"| node_policy
node_api -->|"loads chain state"| node_chain_access
node_chain_access -->|"reads finalized state"| node_indexer
node_chain_access -->|"queries chain"| node_concordium
node_contract_calls -->|"checks decisions"| node_preview
node_contract_calls -.->|"prepares contract calls"| node_concordium
node_contract -->|"dispatches delegation"| node_delegation
node_contract -->|"dispatches settlement"| node_settlement
node_delegation -->|"updates mandate state"| node_mandate_state
node_settlement -->|"uses mandate state"| node_mandate_state
node_indexer -->|"decodes events"| node_codec
node_indexer -->|"reads events and views"| node_concordium
node_indexer -->|"reconciles state"| node_contract

click node_app "https://github.com/griffins2005/mandategraph/blob/main/frontend/src/App.tsx"
click node_api "https://github.com/griffins2005/mandategraph/blob/main/backend/app/main.py"
click node_orchestrator "https://github.com/griffins2005/mandategraph/blob/main/backend/app/agents/orchestrator.py"
click node_research "https://github.com/griffins2005/mandategraph/blob/main/backend/app/agents/research.py"
click node_role_plan "https://github.com/griffins2005/mandategraph/blob/main/backend/app/agents/roles.py"
click node_artifact_check "https://github.com/griffins2005/mandategraph/blob/main/backend/app/evidence/verification.py"
click node_artifact_hash "https://github.com/griffins2005/mandategraph/blob/main/backend/app/evidence/artifacts.py"
click node_contract_calls "https://github.com/griffins2005/mandategraph/blob/main/backend/app/blockchain/transactions.py"
click node_chain_access "https://github.com/griffins2005/mandategraph/blob/main/backend/app/chain.py"
click node_preview "https://github.com/griffins2005/mandategraph/blob/main/backend/app/preview.py"
click node_policy "https://github.com/griffins2005/mandategraph/blob/main/backend/app/policy.py"
click node_contract "https://github.com/griffins2005/mandategraph/blob/main/contracts/mandate/src/lib.rs"
click node_mandate_state "https://github.com/griffins2005/mandategraph/blob/main/contracts/mandate/src/mandate.rs"
click node_delegation "https://github.com/griffins2005/mandategraph/blob/main/contracts/mandate/src/delegation.rs"
click node_settlement "https://github.com/griffins2005/mandategraph/blob/main/contracts/mandate/src/settlement.rs"
click node_indexer "https://github.com/griffins2005/mandategraph/blob/main/indexer/src/main.rs"
click node_codec "https://github.com/griffins2005/mandategraph/blob/main/indexer/src/codec.rs"
click node_ledger "https://github.com/griffins2005/mandategraph/blob/main/mandategraph.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_app,node_user toneBlue
class node_api,node_orchestrator,node_research,node_role_plan,node_artifact_check,node_artifact_hash,node_contract_calls,node_chain_access,node_preview,node_policy,node_concordium toneAmber
class node_contract,node_mandate_state,node_delegation,node_settlement toneMint
class node_indexer,node_codec toneRose
class node_ledger toneIndigo
```

## Components

### Dashboard

- [Dashboard app](https://github.com/griffins2005/mandategraph/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`

### Backend workflow

- [API routes](https://github.com/griffins2005/mandategraph/blob/main/backend/app/main.py): `backend/app/main.py`
- [Workflow orchestrator](https://github.com/griffins2005/mandategraph/blob/main/backend/app/agents/orchestrator.py): `backend/app/agents/orchestrator.py`
- [Research roles](https://github.com/griffins2005/mandategraph/blob/main/backend/app/agents/research.py): `backend/app/agents/research.py`
- [Role planning](https://github.com/griffins2005/mandategraph/blob/main/backend/app/agents/roles.py): `backend/app/agents/roles.py`
- [Artifact verification](https://github.com/griffins2005/mandategraph/blob/main/backend/app/evidence/verification.py): `backend/app/evidence/verification.py`
- [Artifact hashing](https://github.com/griffins2005/mandategraph/blob/main/backend/app/evidence/artifacts.py): `backend/app/evidence/artifacts.py`
- [Contract call builder](https://github.com/griffins2005/mandategraph/blob/main/backend/app/blockchain/transactions.py): `backend/app/blockchain/transactions.py`
- [Chain access](https://github.com/griffins2005/mandategraph/blob/main/backend/app/chain.py): `backend/app/chain.py`
- [Policy preview](https://github.com/griffins2005/mandategraph/blob/main/backend/app/preview.py): `backend/app/preview.py`
- [Authorization policy](https://github.com/griffins2005/mandategraph/blob/main/backend/app/policy.py): `backend/app/policy.py`

### Mandate protocol

- [Mandate contract](https://github.com/griffins2005/mandategraph/blob/main/contracts/mandate/src/lib.rs): `contracts/mandate/src/lib.rs`
- [Mandate state](https://github.com/griffins2005/mandategraph/blob/main/contracts/mandate/src/mandate.rs): `contracts/mandate/src/mandate.rs`
- [Delegation rules](https://github.com/griffins2005/mandategraph/blob/main/contracts/mandate/src/delegation.rs): `contracts/mandate/src/delegation.rs`
- [Settlement rules](https://github.com/griffins2005/mandategraph/blob/main/contracts/mandate/src/settlement.rs): `contracts/mandate/src/settlement.rs`

### Indexing and verification

- [Event indexer](https://github.com/griffins2005/mandategraph/blob/main/indexer/src/main.rs): `indexer/src/main.rs`
- [Event codec](https://github.com/griffins2005/mandategraph/blob/main/indexer/src/codec.rs): `indexer/src/codec.rs`

### Reference model

- [Python reference ledger](https://github.com/griffins2005/mandategraph/blob/main/mandategraph.py): `mandategraph.py`

### Other components

- **Dashboard user**
- **Concordium node**

## Connections

- Dashboard user → Dashboard app: uses (evidence: `frontend/src/App.tsx`)
- Dashboard app → API routes: requests workflow (evidence: `frontend/src/App.tsx`)
- API routes → Workflow orchestrator: runs workflow (evidence: `backend/app/main.py`)
- Workflow orchestrator → Python reference ledger: executes reference model (evidence: `backend/app/agents/orchestrator.py`)
- Workflow orchestrator → Role planning: plans jobs (evidence: `backend/app/agents/orchestrator.py`)
- Workflow orchestrator → Research roles: uses research roles (evidence: `backend/app/agents/orchestrator.py`)
- Workflow orchestrator → Artifact verification: checks artifacts (evidence: `backend/app/agents/orchestrator.py`)
- Artifact verification → Artifact hashing: hashes artifact (evidence: `backend/app/evidence/verification.py`)
- API routes → Policy preview: previews actions (evidence: `backend/app/main.py`)
- Policy preview → Authorization policy: uses policy (evidence: `backend/app/preview.py`)
- API routes → Chain access: loads chain state (evidence: `backend/app/main.py`)
- Chain access → Event indexer: reads finalized state (evidence: `backend/app/chain.py`)
- Chain access → Concordium node: queries chain (evidence: `README.md`)
- Contract call builder → Policy preview: checks decisions (evidence: `backend/app/blockchain/transactions.py`)
- Contract call builder → Concordium node: prepares contract calls (evidence: `README.md`)
- Mandate contract → Delegation rules: dispatches delegation (evidence: `contracts/mandate/src/lib.rs`)
- Mandate contract → Settlement rules: dispatches settlement (evidence: `contracts/mandate/src/lib.rs`)
- Delegation rules → Mandate state: updates mandate state (evidence: `contracts/mandate/src/delegation.rs`)
- Settlement rules → Mandate state: uses mandate state (evidence: `contracts/mandate/src/settlement.rs`)
- Event indexer → Event codec: decodes events (evidence: `indexer/src/main.rs`)
- Event indexer → Concordium node: reads events and views (evidence: `indexer/src/main.rs`)
- Event indexer → Mandate contract: reconciles state (evidence: `README.md`)
