# unfettered-one/well-tell architecture

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

- Interactive diagram: https://gitdiagram.com/unfettered-one/well-tell
- Repository: https://github.com/unfettered-one/well-tell

## Overview

Well Tell is a well-operations copilot: users ask questions through an HTTP API, which routes a conversation through OpenCode and MCP tools to dataset-derived SQLite views and supporting documents. Dataset ingestion builds the database and derived views; the query path supports citations and visual specifications, while MCP also provides user-bound recall and audited corrections and rule updates. The graph preserves README-documented capabilities; links from sampled files use the excerpts or SOURCE INDEX, so unsampled implementation details are not inferred.

Main entry points: [`mcp/server.py`](https://github.com/unfettered-one/well-tell/blob/main/mcp/server.py) (Well MCP tools), [`ingest/ingest.py`](https://github.com/unfettered-one/well-tell/blob/main/ingest/ingest.py) (Dataset loader), [`backend/api.py`](https://github.com/unfettered-one/well-tell/blob/main/backend/api.py) (Chat API), [`mcp/documents.py`](https://github.com/unfettered-one/well-tell/blob/main/mcp/documents.py) (Document resolver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Dataset ingestion"]
  node_ingest["Dataset loader<br/>[ingest.py]"]
  node_schema["Database schema<br/>[create.py]"]
  node_views["Derived views<br/>[views.py]"]
  node_verification["Ingest verification<br/>[verify.py]"]
  node_dataset["Dataset files"]
end

subgraph group_serving["Conversation serving"]
  node_api["Chat API<br/>[api.py]"]
  node_bridge["OpenCode bridge<br/>[opencode.py]"]
  node_agent["Copilot agent"]
end

subgraph group_knowledge["Well knowledge tools"]
  node_mcp["Well MCP tools<br/>[server.py]"]
  node_prompts["Tool guidance<br/>[prompts.py]"]
  node_documents["Document resolver<br/>[documents.py]"]
  node_dbaccess["SQLite access<br/>[db.py]"]
  node_reports["Manuals and reports"]
end

subgraph group_state["Data and sessions"]
  node_sqlite[("Well Copilot SQLite")]
  node_conversations[("Conversation mappings<br/>[api.py]")]
end

node_user(("Questioner"))

node_user -->|"asks via HTTP"| node_api
node_api -->|"routes turns"| node_bridge
node_bridge -->|"starts conversation"| node_agent
node_agent -->|"calls tools"| node_mcp
node_api -->|"binds sessions"| node_conversations
node_api -->|"checks datasets"| node_sqlite
node_ingest -->|"reads dataset"| node_dataset
node_ingest -->|"uses schema"| node_schema
node_ingest -->|"creates views"| node_views
node_ingest -->|"runs verification"| node_verification
node_ingest -->|"loads records"| node_sqlite
node_schema -->|"creates tables"| node_sqlite
node_views -->|"defines derived views"| node_sqlite
node_verification -->|"checks database"| node_sqlite
node_mcp -->|"uses connections"| node_dbaccess
node_mcp -->|"resolves documents"| node_documents
node_mcp -->|"exposes prompts"| node_prompts
node_dbaccess -->|"reads and writes"| node_sqlite
node_documents -->|"looks up catalog"| node_dbaccess
node_documents -->|"reads files"| node_reports
node_mcp -->|"queries and records"| node_sqlite
node_mcp -->|"binds user context"| node_conversations

click node_api "https://github.com/unfettered-one/well-tell/blob/main/backend/api.py"
click node_bridge "https://github.com/unfettered-one/well-tell/blob/main/backend/opencode.py"
click node_ingest "https://github.com/unfettered-one/well-tell/blob/main/ingest/ingest.py"
click node_schema "https://github.com/unfettered-one/well-tell/blob/main/ingest/create.py"
click node_views "https://github.com/unfettered-one/well-tell/blob/main/ingest/views.py"
click node_verification "https://github.com/unfettered-one/well-tell/blob/main/ingest/verify.py"
click node_mcp "https://github.com/unfettered-one/well-tell/blob/main/mcp/server.py"
click node_prompts "https://github.com/unfettered-one/well-tell/blob/main/mcp/prompts.py"
click node_documents "https://github.com/unfettered-one/well-tell/blob/main/mcp/documents.py"
click node_dbaccess "https://github.com/unfettered-one/well-tell/blob/main/mcp/db.py"
click node_conversations "https://github.com/unfettered-one/well-tell/blob/main/backend/api.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_ingest,node_schema,node_views,node_verification,node_dataset toneBlue
class node_api,node_bridge,node_agent toneAmber
class node_mcp,node_prompts,node_documents,node_dbaccess,node_reports toneMint
class node_sqlite,node_conversations toneRose
class node_user toneIndigo
```

## Components

### Dataset ingestion

- [Dataset loader](https://github.com/unfettered-one/well-tell/blob/main/ingest/ingest.py): `ingest/ingest.py`
- [Database schema](https://github.com/unfettered-one/well-tell/blob/main/ingest/create.py): `ingest/create.py`
- [Derived views](https://github.com/unfettered-one/well-tell/blob/main/ingest/views.py): `ingest/views.py`
- [Ingest verification](https://github.com/unfettered-one/well-tell/blob/main/ingest/verify.py): `ingest/verify.py`
- **Dataset files**

### Conversation serving

- [Chat API](https://github.com/unfettered-one/well-tell/blob/main/backend/api.py): `backend/api.py`
- [OpenCode bridge](https://github.com/unfettered-one/well-tell/blob/main/backend/opencode.py): `backend/opencode.py`
- **Copilot agent**

### Well knowledge tools

- [Well MCP tools](https://github.com/unfettered-one/well-tell/blob/main/mcp/server.py): `mcp/server.py`
- [Tool guidance](https://github.com/unfettered-one/well-tell/blob/main/mcp/prompts.py): `mcp/prompts.py`
- [Document resolver](https://github.com/unfettered-one/well-tell/blob/main/mcp/documents.py): `mcp/documents.py`
- [SQLite access](https://github.com/unfettered-one/well-tell/blob/main/mcp/db.py): `mcp/db.py`
- **Manuals and reports**

### Data and sessions

- **Well Copilot SQLite**
- [Conversation mappings](https://github.com/unfettered-one/well-tell/blob/main/backend/api.py): `backend/api.py`

### Other components

- **Questioner**

## Connections

- Questioner → Chat API: asks via HTTP (evidence: `README.md`)
- Chat API → OpenCode bridge: routes turns (evidence: `backend/api.py`)
- OpenCode bridge → Copilot agent: starts conversation (evidence: `README.md`)
- Copilot agent → Well MCP tools: calls tools (evidence: `README.md`)
- Chat API → Conversation mappings: binds sessions (evidence: `backend/api.py`)
- Chat API → Well Copilot SQLite: checks datasets (evidence: `backend/api.py`)
- Dataset loader → Dataset files: reads dataset (evidence: `README.md`)
- Dataset loader → Database schema: uses schema (evidence: `ingest/ingest.py`)
- Dataset loader → Derived views: creates views (evidence: `ingest/ingest.py`)
- Dataset loader → Ingest verification: runs verification (evidence: `ingest/ingest.py`)
- Dataset loader → Well Copilot SQLite: loads records (evidence: `README.md`)
- Database schema → Well Copilot SQLite: creates tables (evidence: `ingest/create.py`)
- Derived views → Well Copilot SQLite: defines derived views (evidence: `ingest/views.py`)
- Ingest verification → Well Copilot SQLite: checks database (evidence: `ingest/verify.py`)
- Well MCP tools → SQLite access: uses connections (evidence: `mcp/server.py`)
- Well MCP tools → Document resolver: resolves documents (evidence: `mcp/server.py`)
- Well MCP tools → Tool guidance: exposes prompts (evidence: `mcp/server.py`)
- SQLite access → Well Copilot SQLite: reads and writes (evidence: `mcp/db.py`)
- Document resolver → SQLite access: looks up catalog (evidence: `mcp/documents.py`)
- Document resolver → Manuals and reports: reads files (evidence: `mcp/documents.py`)
- Well MCP tools → Well Copilot SQLite: queries and records (evidence: `README.md`)
- Well MCP tools → Conversation mappings: binds user context (evidence: `README.md`)
