# daveebbelaar/document-copilot architecture

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

- Interactive diagram: https://gitdiagram.com/daveebbelaar/document-copilot
- Repository: https://github.com/daveebbelaar/document-copilot

## Overview

Document Copilot is described as an analyst-facing chatbot for querying financial-document corpora and receiving sourced answers. The repository snapshot is a scaffold: the README documents the intended frontend, API, retrieval, authentication, database, and AI stack, but no application source files are present in the tree. The graph therefore shows documented architecture, not verified runtime calls; the separate SEC downloader is the only sampled executable product code.

Main entry points: [`backend`](https://github.com/daveebbelaar/document-copilot/tree/main/backend) (FastAPI service), [`frontend`](https://github.com/daveebbelaar/document-copilot/tree/main/frontend) (Chat interface), [`data/download.py`](https://github.com/daveebbelaar/document-copilot/blob/main/data/download.py) (Filing downloader), [`data`](https://github.com/daveebbelaar/document-copilot/tree/main/data) (Local filings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Analyst interface"]
  node_frontend["Chat interface"]
end

subgraph group_service["Query service"]
  node_backend["FastAPI service"]
end

subgraph group_knowledge["Document knowledge"]
  node_retrieval["Hybrid retrieval"]
  node_corpus[("Document corpus")]
  node_chatdata[("Chats and chunks")]
  node_downloader["Filing downloader<br/>[download.py]"]
  node_localfilings["Local filings"]
end

subgraph group_platform["Identity and AI"]
  node_supabase[("Supabase platform")]
  node_auth["Email authentication"]
  node_openai{{"LLM and embeddings"}}
end

node_analyst(("Analyst"))
node_sec{{"SEC EDGAR"}}

node_analyst -->|"asks questions"| node_frontend
node_frontend -.->|"sends queries"| node_backend
node_backend -.->|"requests search"| node_retrieval
node_retrieval -.->|"searches documents"| node_corpus
node_retrieval -.->|"retrieves chunks"| node_chatdata
node_backend -.->|"generates answers"| node_openai
node_backend -->|"returns cited answers"| node_frontend
node_auth -.->|"authenticates users"| node_supabase
node_retrieval -->|"uses pgvector and text search"| node_supabase
node_backend -->|"stores chats and documents"| node_supabase
node_backend -->|"creates embeddings"| node_openai
node_sec -->|"provides filings"| node_downloader
node_downloader -->|"writes filing files"| node_localfilings

click node_frontend "https://github.com/daveebbelaar/document-copilot/tree/main/frontend"
click node_backend "https://github.com/daveebbelaar/document-copilot/tree/main/backend"
click node_retrieval "https://github.com/daveebbelaar/document-copilot/tree/main/backend"
click node_corpus "https://github.com/daveebbelaar/document-copilot/tree/main/backend"
click node_chatdata "https://github.com/daveebbelaar/document-copilot/tree/main/backend"
click node_auth "https://github.com/daveebbelaar/document-copilot/tree/main/backend"
click node_downloader "https://github.com/daveebbelaar/document-copilot/blob/main/data/download.py"
click node_localfilings "https://github.com/daveebbelaar/document-copilot/tree/main/data"

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_frontend toneBlue
class node_backend toneAmber
class node_retrieval,node_corpus,node_chatdata,node_downloader,node_localfilings toneMint
class node_supabase,node_auth,node_openai toneRose
class node_analyst,node_sec toneIndigo
```

## Components

### Analyst interface

- [Chat interface](https://github.com/daveebbelaar/document-copilot/tree/main/frontend): `frontend`

### Query service

- [FastAPI service](https://github.com/daveebbelaar/document-copilot/tree/main/backend): `backend`

### Document knowledge

- [Hybrid retrieval](https://github.com/daveebbelaar/document-copilot/tree/main/backend): `backend`
- [Document corpus](https://github.com/daveebbelaar/document-copilot/tree/main/backend): `backend`
- [Chats and chunks](https://github.com/daveebbelaar/document-copilot/tree/main/backend): `backend`
- [Filing downloader](https://github.com/daveebbelaar/document-copilot/blob/main/data/download.py): `data/download.py`
- [Local filings](https://github.com/daveebbelaar/document-copilot/tree/main/data): `data`

### Identity and AI

- **Supabase platform**
- [Email authentication](https://github.com/daveebbelaar/document-copilot/tree/main/backend): `backend`
- **LLM and embeddings**

### Other components

- **Analyst**
- **SEC EDGAR**

## Connections

- Analyst → Chat interface: asks questions (evidence: `README.md`)
- Chat interface → FastAPI service: sends queries
- FastAPI service → Hybrid retrieval: requests search
- Hybrid retrieval → Document corpus: searches documents
- Hybrid retrieval → Chats and chunks: retrieves chunks
- FastAPI service → LLM and embeddings: generates answers
- FastAPI service → Chat interface: returns cited answers (evidence: `README.md`)
- Email authentication → Supabase platform: authenticates users
- Hybrid retrieval → Supabase platform: uses pgvector and text search (evidence: `README.md`)
- FastAPI service → Supabase platform: stores chats and documents (evidence: `README.md`)
- FastAPI service → LLM and embeddings: creates embeddings (evidence: `README.md`)
- SEC EDGAR → Filing downloader: provides filings (evidence: `data/download.py`)
- Filing downloader → Local filings: writes filing files (evidence: `data/download.py`)
