# harshith8899/agrythm-connect architecture

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

- Interactive diagram: https://gitdiagram.com/harshith8899/agrythm-connect
- Repository: https://github.com/harshith8899/agrythm-connect

## Overview

Agrythm Connect is a prototype voice-first farmer relationship and execution layer; its current product loop is text-only. The CLI seeds demo data if needed, selects an approved advisory, creates a validated event and conversation, and starts a session. The session builds verified farmer and advisory context, interprets English/Hindi/Hinglish input, checks every reply against approved content, and records a structured outcome, follow-up, or escalation. SQLite is the prototype system of record. The README describes safety and human escalation; phone, speech, and external provider integrations are not implemented in this prototype. Edges reflect excerpts or README statements; unsampled behavior is not inferred.

Main entry points: [`connect/orchestrator.py`](https://github.com/harshith8899/agrythm-connect/blob/main/connect/orchestrator.py) (Conversation session), [`connect/cli.py`](https://github.com/harshith8899/agrythm-connect/blob/main/connect/cli.py) (Text CLI), [`connect/db.py`](https://github.com/harshith8899/agrythm-connect/blob/main/connect/db.py) (SQLite records), [`connect/context.py`](https://github.com/harshith8899/agrythm-connect/blob/main/connect/context.py) (Verified context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and triggers"]
  node_cli["Text CLI<br/>[cli.py]"]
  node_event["Event trigger<br/>[events.py]"]
end

subgraph group_conversation["Conversation runtime"]
  node_session["Conversation session<br/>[orchestrator.py]"]
  node_context["Verified context<br/>[context.py]"]
  node_adapter["Intent and replies<br/>[llm.py]"]
end

subgraph group_safety["Safety and outcomes"]
  node_policy["Reply safety gate<br/>[policy.py]"]
  node_state["States and outcomes<br/>[models.py]"]
end

subgraph group_records["Farmer records"]
  node_store[("SQLite records<br/>[db.py]")]
  node_demo["Demo data<br/>[seed.py]"]
end

node_farmer(("Farmer"))
node_human(("Human reviewer"))

node_farmer -->|"provides input"| node_cli
node_cli -->|"opens records"| node_store
node_cli -->|"seeds if empty"| node_demo
node_cli -->|"creates trigger"| node_event
node_event -->|"validates and writes"| node_store
node_cli -->|"starts session"| node_session
node_session -->|"builds context"| node_context
node_context -->|"reads approved records"| node_store
node_session -->|"interprets and replies"| node_adapter
node_adapter -->|"uses context pack"| node_context
node_session -->|"checks replies"| node_policy
node_session -->|"uses transitions"| node_state
node_session -->|"records turns and outcomes"| node_store
node_session -->|"escalates cases"| node_human

click node_cli "https://github.com/harshith8899/agrythm-connect/blob/main/connect/cli.py"
click node_event "https://github.com/harshith8899/agrythm-connect/blob/main/connect/events.py"
click node_session "https://github.com/harshith8899/agrythm-connect/blob/main/connect/orchestrator.py"
click node_context "https://github.com/harshith8899/agrythm-connect/blob/main/connect/context.py"
click node_adapter "https://github.com/harshith8899/agrythm-connect/blob/main/connect/llm.py"
click node_policy "https://github.com/harshith8899/agrythm-connect/blob/main/connect/policy.py"
click node_state "https://github.com/harshith8899/agrythm-connect/blob/main/connect/models.py"
click node_store "https://github.com/harshith8899/agrythm-connect/blob/main/connect/db.py"
click node_demo "https://github.com/harshith8899/agrythm-connect/blob/main/connect/seed.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_cli,node_event,node_human toneBlue
class node_session,node_context,node_adapter toneAmber
class node_policy,node_state toneMint
class node_store,node_demo toneRose
class node_farmer toneIndigo
```

## Components

### Entry and triggers

- [Text CLI](https://github.com/harshith8899/agrythm-connect/blob/main/connect/cli.py): `connect/cli.py`
- [Event trigger](https://github.com/harshith8899/agrythm-connect/blob/main/connect/events.py): `connect/events.py`

### Conversation runtime

- [Conversation session](https://github.com/harshith8899/agrythm-connect/blob/main/connect/orchestrator.py): `connect/orchestrator.py`
- [Verified context](https://github.com/harshith8899/agrythm-connect/blob/main/connect/context.py): `connect/context.py`
- [Intent and replies](https://github.com/harshith8899/agrythm-connect/blob/main/connect/llm.py): `connect/llm.py`

### Safety and outcomes

- [Reply safety gate](https://github.com/harshith8899/agrythm-connect/blob/main/connect/policy.py): `connect/policy.py`
- [States and outcomes](https://github.com/harshith8899/agrythm-connect/blob/main/connect/models.py): `connect/models.py`

### Farmer records

- [SQLite records](https://github.com/harshith8899/agrythm-connect/blob/main/connect/db.py): `connect/db.py`
- [Demo data](https://github.com/harshith8899/agrythm-connect/blob/main/connect/seed.py): `connect/seed.py`

### Other components

- **Farmer**
- **Human reviewer**

## Connections

- Farmer → Text CLI: provides input (evidence: `README.md`)
- Text CLI → SQLite records: opens records (evidence: `connect/cli.py`)
- Text CLI → Demo data: seeds if empty (evidence: `connect/cli.py`)
- Text CLI → Event trigger: creates trigger (evidence: `connect/cli.py`)
- Event trigger → SQLite records: validates and writes (evidence: `connect/events.py`)
- Text CLI → Conversation session: starts session (evidence: `connect/cli.py`)
- Conversation session → Verified context: builds context (evidence: `connect/orchestrator.py`)
- Verified context → SQLite records: reads approved records (evidence: `connect/context.py`)
- Conversation session → Intent and replies: interprets and replies (evidence: `connect/orchestrator.py`)
- Intent and replies → Verified context: uses context pack (evidence: `connect/llm.py`)
- Conversation session → Reply safety gate: checks replies (evidence: `connect/orchestrator.py`)
- Conversation session → States and outcomes: uses transitions (evidence: `connect/orchestrator.py`)
- Conversation session → SQLite records: records turns and outcomes (evidence: `connect/orchestrator.py`)
- Conversation session → Human reviewer: escalates cases (evidence: `README.md`)
