# alfa5nm/dako architecture

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

- Interactive diagram: https://gitdiagram.com/alfa5nm/dako
- Repository: https://github.com/alfa5nm/dako

## Overview

Agritech is a work-in-progress Bengali agricultural phone assistant. Its current user workflow connects a farmer’s incoming Alaap call through browser WebRTC to a live voice assistant; the broader documented workflow captures and confirms case facts, then retrieves reviewed agricultural evidence or refers unsupported cases. Operator tools manage cases and sources. The graph also shows Bangla speech comparison and model research. Several UI and backend details are unsampled, so their connections are included only where the README or source index supports them.

Main entry points: [`alaap-test/backend/api.js`](https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/api.js) (Backend API), [`alaap-test/backend/tools.js`](https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/tools.js) (Voice workflow tools), [`alaap-test/app.js`](https://github.com/alfa5nm/dako/blob/main/alaap-test/app.js) (Call interface), [`alaap-test/vertex.js`](https://github.com/alfa5nm/dako/blob/main/alaap-test/vertex.js) (Live AI session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_call["Phone and voice"]
  node_browser["Call interface<br/>[app.js]"]
  node_signalling["WebRTC signalling<br/>[client.js]"]
  node_voice["Voice bridge<br/>[voice.js]"]
  node_server["Local server<br/>[server.mjs]"]
  node_vertex["Live AI session<br/>[vertex.js]"]
end

subgraph group_case["Case workflow"]
  node_speech["Speech safeguards<br/>[speech-guard.js]"]
  node_tools["Voice workflow tools<br/>[tools.js]"]
  node_workflow["Fact workflow<br/>[workflow.js]"]
  node_confirmation["Fact confirmation<br/>[confirmation.js]"]
  node_workspace["Workspace projection<br/>[workspace.js]"]
end

subgraph group_ops["Operator and knowledge"]
  node_operator["Operator console<br/>[operator.js]"]
  node_api["Backend API<br/>[api.js]"]
  node_sessions["Operator sessions<br/>[sessions.js]"]
  node_database[("Encrypted case store<br/>[database.js]")]
  node_knowledge["Reviewed retrieval<br/>[knowledge.js]"]
  node_jobs["Referral requests<br/>[jobs.js]"]
end

subgraph group_research["Bangla research"]
  node_bangla["Bangla speech comparison<br/>[bangla.js]"]
  node_dataset["Reviewed dataset validation<br/>[dataset.py]"]
  node_models["Model training and evaluation<br/>[run_models.py]"]
end

node_farmer(("Farmer"))
node_alaap{{"Alaap phone service"}}
node_google{{"Google Vertex AI"}}
node_supabase[("Supabase")]

node_farmer -->|"calls"| node_alaap
node_alaap -->|"signals call"| node_signalling
node_browser -->|"connects"| node_signalling
node_signalling -->|"registers call"| node_alaap
node_browser -->|"starts voice"| node_voice
node_browser -->|"starts comparison"| node_bangla
node_server -->|"attaches bridge"| node_vertex
node_vertex -->|"streams audio"| node_google
node_vertex -->|"uses declarations"| node_tools
node_workflow -->|"checks transcripts"| node_speech
node_tools -->|"applies events"| node_workflow
node_tools -->|"interprets readback"| node_confirmation
node_tools -->|"projects state"| node_workspace
node_operator -.->|"uses API"| node_api
node_server -->|"creates backend"| node_api
node_api -->|"routes case operations"| node_database
node_api -->|"searches evidence"| node_knowledge
node_api -->|"serves job requests"| node_jobs
node_api -->|"uses sessions"| node_sessions
node_sessions -->|"uses encryption"| node_database
node_database -->|"reads and writes"| node_supabase
node_knowledge -->|"queries evidence"| node_supabase
node_dataset -->|"validates examples"| node_models

click node_browser "https://github.com/alfa5nm/dako/blob/main/alaap-test/app.js"
click node_signalling "https://github.com/alfa5nm/dako/blob/main/alaap-test/client.js"
click node_voice "https://github.com/alfa5nm/dako/blob/main/alaap-test/voice.js"
click node_server "https://github.com/alfa5nm/dako/blob/main/alaap-test/server.mjs"
click node_vertex "https://github.com/alfa5nm/dako/blob/main/alaap-test/vertex.js"
click node_speech "https://github.com/alfa5nm/dako/blob/main/alaap-test/speech-guard.js"
click node_bangla "https://github.com/alfa5nm/dako/blob/main/alaap-test/bangla.js"
click node_operator "https://github.com/alfa5nm/dako/blob/main/alaap-test/operator.js"
click node_api "https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/api.js"
click node_sessions "https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/sessions.js"
click node_tools "https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/tools.js"
click node_workflow "https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/workflow.js"
click node_confirmation "https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/confirmation.js"
click node_workspace "https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/workspace.js"
click node_database "https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/database.js"
click node_knowledge "https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/knowledge.js"
click node_jobs "https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/jobs.js"
click node_dataset "https://github.com/alfa5nm/dako/blob/main/research/dataset.py"
click node_models "https://github.com/alfa5nm/dako/blob/main/research/run_models.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_browser,node_signalling,node_voice,node_server,node_vertex toneBlue
class node_speech,node_tools,node_workflow,node_confirmation,node_workspace,node_supabase toneAmber
class node_operator,node_api,node_sessions,node_database,node_knowledge,node_jobs toneMint
class node_bangla,node_dataset,node_models toneRose
class node_farmer,node_alaap,node_google toneIndigo
```

## Components

### Phone and voice

- [Call interface](https://github.com/alfa5nm/dako/blob/main/alaap-test/app.js): `alaap-test/app.js`
- [WebRTC signalling](https://github.com/alfa5nm/dako/blob/main/alaap-test/client.js): `alaap-test/client.js`
- [Voice bridge](https://github.com/alfa5nm/dako/blob/main/alaap-test/voice.js): `alaap-test/voice.js`
- [Local server](https://github.com/alfa5nm/dako/blob/main/alaap-test/server.mjs): `alaap-test/server.mjs`
- [Live AI session](https://github.com/alfa5nm/dako/blob/main/alaap-test/vertex.js): `alaap-test/vertex.js`

### Case workflow

- [Speech safeguards](https://github.com/alfa5nm/dako/blob/main/alaap-test/speech-guard.js): `alaap-test/speech-guard.js`
- [Voice workflow tools](https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/tools.js): `alaap-test/backend/tools.js`
- [Fact workflow](https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/workflow.js): `alaap-test/backend/workflow.js`
- [Fact confirmation](https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/confirmation.js): `alaap-test/backend/confirmation.js`
- [Workspace projection](https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/workspace.js): `alaap-test/backend/workspace.js`

### Operator and knowledge

- [Operator console](https://github.com/alfa5nm/dako/blob/main/alaap-test/operator.js): `alaap-test/operator.js`
- [Backend API](https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/api.js): `alaap-test/backend/api.js`
- [Operator sessions](https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/sessions.js): `alaap-test/backend/sessions.js`
- [Encrypted case store](https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/database.js): `alaap-test/backend/database.js`
- [Reviewed retrieval](https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/knowledge.js): `alaap-test/backend/knowledge.js`
- [Referral requests](https://github.com/alfa5nm/dako/blob/main/alaap-test/backend/jobs.js): `alaap-test/backend/jobs.js`

### Bangla research

- [Bangla speech comparison](https://github.com/alfa5nm/dako/blob/main/alaap-test/bangla.js): `alaap-test/bangla.js`
- [Reviewed dataset validation](https://github.com/alfa5nm/dako/blob/main/research/dataset.py): `research/dataset.py`
- [Model training and evaluation](https://github.com/alfa5nm/dako/blob/main/research/run_models.py): `research/run_models.py`

### Other components

- **Farmer**
- **Alaap phone service**
- **Google Vertex AI**
- **Supabase**

## Connections

- Farmer → Alaap phone service: calls (evidence: `README.md`)
- Alaap phone service → WebRTC signalling: signals call (evidence: `README.md`)
- Call interface → WebRTC signalling: connects (evidence: `alaap-test/app.js`)
- WebRTC signalling → Alaap phone service: registers call (evidence: `alaap-test/client.js`)
- Call interface → Voice bridge: starts voice (evidence: `alaap-test/app.js`)
- Call interface → Bangla speech comparison: starts comparison (evidence: `alaap-test/app.js`)
- Local server → Live AI session: attaches bridge (evidence: `alaap-test/server.mjs`)
- Live AI session → Google Vertex AI: streams audio (evidence: `README.md`)
- Live AI session → Voice workflow tools: uses declarations (evidence: `alaap-test/vertex.js`)
- Fact workflow → Speech safeguards: checks transcripts (evidence: `alaap-test/backend/workflow.js`)
- Voice workflow tools → Fact workflow: applies events (evidence: `alaap-test/backend/tools.js`)
- Voice workflow tools → Fact confirmation: interprets readback (evidence: `alaap-test/backend/tools.js`)
- Voice workflow tools → Workspace projection: projects state (evidence: `alaap-test/backend/tools.js`)
- Operator console → Backend API: uses API
- Local server → Backend API: creates backend (evidence: `alaap-test/server.mjs`)
- Backend API → Encrypted case store: routes case operations (evidence: `alaap-test/backend/api.js`)
- Backend API → Reviewed retrieval: searches evidence (evidence: `alaap-test/backend/api.js`)
- Backend API → Referral requests: serves job requests (evidence: `alaap-test/backend/api.js`)
- Backend API → Operator sessions: uses sessions (evidence: `alaap-test/backend/api.js`)
- Operator sessions → Encrypted case store: uses encryption (evidence: `alaap-test/backend/sessions.js`)
- Encrypted case store → Supabase: reads and writes (evidence: `alaap-test/backend/database.js`)
- Reviewed retrieval → Supabase: queries evidence (evidence: `alaap-test/backend/knowledge.js`)
- Reviewed dataset validation → Model training and evaluation: validates examples (evidence: `research/run_models.py`)
