# techwithtim/productiongraderagpythonapp architecture

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

- Interactive diagram: https://gitdiagram.com/techwithtim/productiongraderagpythonapp
- Repository: https://github.com/techwithtim/productiongraderagpythonapp

## Overview

#### Purpose and Entry Points
This is a compact Python document-vectorization/retrieval project. Its source layout indicates a pipeline that loads data, represents it with shared types, persists/searches vectors, and exposes either a script or Streamlit interface.

- Script entry point: `main.py`
- Interactive UI entry point: `streamlit_app.py`
- Package/runtime definition: `pyproject.toml`

#### Application Orchestration
`main.py` is the likely control-plane entry point for initializing the document pipeline or executing queries. `streamlit_app.py` is a separate presentation boundary, likely invoking the same loading/vector-store capabilities for user-driven interaction.

- `main.py`
- `streamlit_app.py`

The repository has no visible service/API layer or frontend asset tree; Streamlit is the apparent user-facing runtime.

#### Document Ingestion
`data_loader.py` defines the source-data boundary. It likely converts external or local document inputs into application-level records before indexing. This is the place to change supported input formats, extraction behavior, chunking inputs, or source metadata.

- `data_loader.py`
- `custom_types.py`

#### Domain Contracts
`custom_types.py` is the shared contract boundary between ingestion, vector persistence, and callers. Its types likely carry document text, metadata, IDs, query results, or similar transport objects. Changes here can affect both the script and Streamlit paths.

- `custom_types.py`
- `data_loader.py`
- `vector_db.py`

#### Vector Storage and Retrieval
`vector_db.py` is the storage adapter boundary. The checked-in storage identifies Qdrant as the vector database implementation and indicates a collection named `docs`. The adapter should isolate Qdrant client calls, collection lifecycle, upserts, and similarity-search result mapping from the rest of the application.

- `vector_db.py`
- `qdrant_storage/collections/docs/config.json`
- `qdrant_storage/collections/docs/0/shard_config.json`

Primary flow is expected to be: source documents → `data_loader.py` → shared records in `custom_types.py` → embeddings/vector writes through `vector_db.py` → retrieval results returned to `main.py` or `streamlit_app.py`.

#### Persistence Boundary
`qdrant_storage/` is local, stateful Qdrant persistence rather than application source. It contains collection metadata, shard write-ahead logs, payload storage, and vector segments. It must be treated as durable runtime data: deleting or replacing it changes indexed content.

- `qdrant_storage/collections/docs/0/wal`
- `qdrant_storage/collections/docs/0/segments/62205516-fdd8-4d26-ae0e-bc9c79076f59/vector_storage/vectors/chunk_0.mmap`
- `qdrant_storage/collections/docs/0/segments/62205516-fdd8-4d26-ae0e-bc9c79076f59/payload_storage/page_0.dat`

#### Runtime and External Dependencies
The project targets Python, with version selection in `.python-version` and dependency/environment resolution in `pyproject.toml` and `uv.lock`. Material infrastructure consists of Streamlit for the interactive runtime and local Qdrant-backed vector persistence. No cloud service, remote database, or external embedding provider can be confirmed from the provided tree.

- `.python-version`
- `pyproject.toml`
- `uv.lock`

Main entry points: [`qdrant_storage/collections/docs/config.json`](https://github.com/techwithtim/productiongraderagpythonapp/blob/main/qdrant_storage/collections/docs/config.json) (docs collection), [`data_loader.py`](https://github.com/techwithtim/productiongraderagpythonapp/blob/main/data_loader.py) (Document loader), [`vector_db.py`](https://github.com/techwithtim/productiongraderagpythonapp/blob/main/vector_db.py) (Vector DB adapter), [`main.py`](https://github.com/techwithtim/productiongraderagpythonapp/blob/main/main.py) (Script entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_script["Script entry<br/>Python entry point<br/>[main.py]"]
  node_streamlit["Streamlit UI<br/>interactive entry point<br/>[streamlit_app.py]"]
  node_runtime_config["Python environment<br/>runtime definition<br/>[pyproject.toml]"]
end

subgraph group_pipeline["Document Pipeline"]
  node_source_documents["Source documents<br/>input data"]
  node_loader["Document loader<br/>ingestion boundary<br/>[data_loader.py]"]
  node_contracts["Shared records<br/>domain contracts<br/>[custom_types.py]"]
  node_vector_adapter["Vector DB adapter<br/>Qdrant adapter<br/>[vector_db.py]"]
end

subgraph group_persistence["Local Vector Persistence"]
  node_qdrant_collection[("docs collection<br/>Qdrant collection<br/>[config.json]")]
  node_shard_config["Shard configuration<br/>collection shard metadata<br/>[shard_config.json]"]
  node_write_ahead_log["Write-ahead log<br/>durable mutation log"]
  node_vector_segments[("Vector segments<br/>persisted vectors<br/>[chunk_0.mmap]")]
  node_payload_segments[("Payload segments<br/>persisted metadata<br/>[page_0.dat]")]
end

node_runtime_config -->|"defines runtime"| node_script
node_runtime_config -->|"defines runtime"| node_streamlit
node_script -->|"loads documents"| node_loader
node_streamlit -->|"loads documents"| node_loader
node_source_documents -->|"ingested by"| node_loader
node_loader -->|"creates records"| node_contracts
node_contracts -->|"indexes and queries"| node_vector_adapter
node_script -->|"runs retrieval"| node_vector_adapter
node_streamlit -->|"runs retrieval"| node_vector_adapter
node_vector_adapter -->|"manages and searches"| node_qdrant_collection
node_qdrant_collection -->|"contains shard"| node_shard_config
node_qdrant_collection -->|"records writes"| node_write_ahead_log
node_qdrant_collection -->|"stores vectors"| node_vector_segments
node_qdrant_collection -->|"stores payloads"| node_payload_segments

click node_script "https://github.com/techwithtim/productiongraderagpythonapp/blob/main/main.py"
click node_streamlit "https://github.com/techwithtim/productiongraderagpythonapp/blob/main/streamlit_app.py"
click node_runtime_config "https://github.com/techwithtim/productiongraderagpythonapp/blob/main/pyproject.toml"
click node_loader "https://github.com/techwithtim/productiongraderagpythonapp/blob/main/data_loader.py"
click node_contracts "https://github.com/techwithtim/productiongraderagpythonapp/blob/main/custom_types.py"
click node_vector_adapter "https://github.com/techwithtim/productiongraderagpythonapp/blob/main/vector_db.py"
click node_qdrant_collection "https://github.com/techwithtim/productiongraderagpythonapp/blob/main/qdrant_storage/collections/docs/config.json"
click node_shard_config "https://github.com/techwithtim/productiongraderagpythonapp/blob/main/qdrant_storage/collections/docs/0/shard_config.json"
click node_write_ahead_log "https://github.com/techwithtim/productiongraderagpythonapp/tree/main/qdrant_storage/collections/docs/0/wal"
click node_vector_segments "https://github.com/techwithtim/productiongraderagpythonapp/blob/main/qdrant_storage/collections/docs/0/segments/62205516-fdd8-4d26-ae0e-bc9c79076f59/vector_storage/vectors/chunk_0.mmap"
click node_payload_segments "https://github.com/techwithtim/productiongraderagpythonapp/blob/main/qdrant_storage/collections/docs/0/segments/62205516-fdd8-4d26-ae0e-bc9c79076f59/payload_storage/page_0.dat"

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_script,node_streamlit,node_runtime_config toneBlue
class node_source_documents,node_loader,node_contracts,node_vector_adapter toneAmber
class node_qdrant_collection,node_shard_config,node_write_ahead_log,node_vector_segments,node_payload_segments toneMint
```

## Components

### Runtime

- [Script entry](https://github.com/techwithtim/productiongraderagpythonapp/blob/main/main.py): Python entry point · `main.py`
- [Streamlit UI](https://github.com/techwithtim/productiongraderagpythonapp/blob/main/streamlit_app.py): interactive entry point · `streamlit_app.py`
- [Python environment](https://github.com/techwithtim/productiongraderagpythonapp/blob/main/pyproject.toml): runtime definition · `pyproject.toml`

### Document Pipeline

- **Source documents**: input data
- [Document loader](https://github.com/techwithtim/productiongraderagpythonapp/blob/main/data_loader.py): ingestion boundary · Converts source inputs into application records. · `data_loader.py`
- [Shared records](https://github.com/techwithtim/productiongraderagpythonapp/blob/main/custom_types.py): domain contracts · Document and retrieval types shared across pipeline boundaries. · `custom_types.py`
- [Vector DB adapter](https://github.com/techwithtim/productiongraderagpythonapp/blob/main/vector_db.py): Qdrant adapter · Owns collection lifecycle, upserts, and similarity search mapping. · `vector_db.py`

### Local Vector Persistence

- [docs collection](https://github.com/techwithtim/productiongraderagpythonapp/blob/main/qdrant_storage/collections/docs/config.json): Qdrant collection · `qdrant_storage/collections/docs/config.json`
- [Shard configuration](https://github.com/techwithtim/productiongraderagpythonapp/blob/main/qdrant_storage/collections/docs/0/shard_config.json): collection shard metadata · `qdrant_storage/collections/docs/0/shard_config.json`
- [Write-ahead log](https://github.com/techwithtim/productiongraderagpythonapp/tree/main/qdrant_storage/collections/docs/0/wal): durable mutation log · `qdrant_storage/collections/docs/0/wal`
- [Vector segments](https://github.com/techwithtim/productiongraderagpythonapp/blob/main/qdrant_storage/collections/docs/0/segments/62205516-fdd8-4d26-ae0e-bc9c79076f59/vector_storage/vectors/chunk_0.mmap): persisted vectors · `qdrant_storage/collections/docs/0/segments/62205516-fdd8-4d26-ae0e-bc9c79076f59/vector_storage/vectors/chunk_0.mmap`
- [Payload segments](https://github.com/techwithtim/productiongraderagpythonapp/blob/main/qdrant_storage/collections/docs/0/segments/62205516-fdd8-4d26-ae0e-bc9c79076f59/payload_storage/page_0.dat): persisted metadata · `qdrant_storage/collections/docs/0/segments/62205516-fdd8-4d26-ae0e-bc9c79076f59/payload_storage/page_0.dat`

## Connections

- Python environment → Script entry: defines runtime
- Python environment → Streamlit UI: defines runtime
- Script entry → Document loader: loads documents
- Streamlit UI → Document loader: loads documents
- Source documents → Document loader: ingested by
- Document loader → Shared records: creates records
- Shared records → Vector DB adapter: indexes and queries
- Script entry → Vector DB adapter: runs retrieval
- Streamlit UI → Vector DB adapter: runs retrieval
- Vector DB adapter → docs collection: manages and searches
- docs collection → Shard configuration: contains shard
- docs collection → Write-ahead log: records writes
- docs collection → Vector segments: stores vectors
- docs collection → Payload segments: stores payloads
