# rhithor/obsidian-engine architecture

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

- Interactive diagram: https://gitdiagram.com/rhithor/obsidian-engine
- Repository: https://github.com/rhithor/obsidian-engine

## Overview

Obsidian Engine is a document-grounded Q&A application: users upload PDFs, which are chunked and indexed per document, then select a collection and receive streaming answers with source metadata. The graph follows the sampled endpoint ownership and calls. README-documented scrubbing and summary endpoints are included; their wiring is explicit in main.py, though model files beyond the sampled request schemas were not inspected.

Main entry points: [`backend/main.py`](https://github.com/rhithor/obsidian-engine/blob/main/backend/main.py) (FastAPI endpoints), [`frontend/src/api.ts`](https://github.com/rhithor/obsidian-engine/blob/main/frontend/src/api.ts) (API client), [`backend/services/ai_service.py`](https://github.com/rhithor/obsidian-engine/blob/main/backend/services/ai_service.py) (RAG and summary chains), [`frontend/src/App.tsx`](https://github.com/rhithor/obsidian-engine/blob/main/frontend/src/App.tsx) (Chat and sidebar)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat client"]
  node_ui["Chat and sidebar<br/>[App.tsx]"]
  node_client_api["API client<br/>[api.ts]"]
  node_frontend_state["Chat results<br/>[App.tsx]"]
end

subgraph group_api["API orchestration"]
  node_backend["FastAPI endpoints<br/>[main.py]"]
  node_ingest_models["Ingest schemas<br/>[ingest.py]"]
  node_query_models["Query schema<br/>[query.py]"]
  node_health_models["Health schema<br/>[health.py]"]
  node_privacy_models["Privacy schemas<br/>[privacy.py]"]
end

subgraph group_documents["Document indexing"]
  node_ingestion["PDF chunking"]
  node_db[("Vector collections<br/>[db.py]")]
  node_vector_store[("ChromaDB store")]
  node_retrieval["Context retrieval<br/>[db.py]"]
end

subgraph group_rag["Retrieval and AI"]
  node_ai["RAG and summary chains<br/>[ai_service.py]"]
  node_llm["Configured LLM"]
end

subgraph group_privacy["Privacy tools"]
  node_privacy_service["PII scrubbing<br/>[privacy_service.py]"]
  node_presidio["Presidio engines"]
end

node_user(("User"))
node_pdf["PDF upload"]

node_user -->|"uses"| node_ui
node_ui -->|"requests"| node_client_api
node_client_api -->|"HTTP calls"| node_backend
node_pdf -->|"uploads"| node_client_api
node_backend -->|"validates response"| node_ingest_models
node_backend -->|"validates query"| node_query_models
node_backend -->|"returns health"| node_health_models
node_backend -->|"returns privacy"| node_privacy_models
node_backend -->|"dispatches indexing"| node_ingestion
node_backend -->|"manages collections"| node_db
node_ingestion -->|"adds chunks"| node_db
node_db -->|"reads and writes"| node_vector_store
node_backend -->|"requests context"| node_retrieval
node_retrieval -->|"queries chunks"| node_vector_store
node_backend -->|"requests answers"| node_ai
node_ai -->|"invokes chains"| node_llm
node_backend -->|"scrubs text"| node_privacy_service
node_privacy_service -->|"analyzes and anonymizes"| node_presidio
node_privacy_service -->|"summary input"| node_ai
node_backend -->|"checks provider health"| node_ai
node_client_api -->|"streams tokens and sources"| node_frontend_state
node_ui -->|"updates"| node_frontend_state

click node_ui "https://github.com/rhithor/obsidian-engine/blob/main/frontend/src/App.tsx"
click node_client_api "https://github.com/rhithor/obsidian-engine/blob/main/frontend/src/api.ts"
click node_backend "https://github.com/rhithor/obsidian-engine/blob/main/backend/main.py"
click node_ingest_models "https://github.com/rhithor/obsidian-engine/blob/main/backend/models/ingest.py"
click node_query_models "https://github.com/rhithor/obsidian-engine/blob/main/backend/models/query.py"
click node_health_models "https://github.com/rhithor/obsidian-engine/blob/main/backend/models/health.py"
click node_privacy_models "https://github.com/rhithor/obsidian-engine/blob/main/backend/models/privacy.py"
click node_ingestion "https://github.com/rhithor/obsidian-engine/blob/main/backend/services/ingestion_service.py"
click node_db "https://github.com/rhithor/obsidian-engine/blob/main/backend/database/db.py"
click node_vector_store "https://github.com/rhithor/obsidian-engine/tree/main/backend/chroma_data"
click node_retrieval "https://github.com/rhithor/obsidian-engine/blob/main/backend/database/db.py"
click node_ai "https://github.com/rhithor/obsidian-engine/blob/main/backend/services/ai_service.py"
click node_privacy_service "https://github.com/rhithor/obsidian-engine/blob/main/backend/services/privacy_service.py"
click node_frontend_state "https://github.com/rhithor/obsidian-engine/blob/main/frontend/src/App.tsx"

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_ui,node_client_api,node_frontend_state,node_user toneBlue
class node_backend,node_ingest_models,node_query_models,node_health_models,node_privacy_models toneAmber
class node_ingestion,node_db,node_vector_store,node_retrieval toneMint
class node_ai,node_llm toneRose
class node_privacy_service,node_presidio,node_pdf toneIndigo
```

## Components

### Chat client

- [Chat and sidebar](https://github.com/rhithor/obsidian-engine/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/rhithor/obsidian-engine/blob/main/frontend/src/api.ts): `frontend/src/api.ts`
- [Chat results](https://github.com/rhithor/obsidian-engine/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`

### API orchestration

- [FastAPI endpoints](https://github.com/rhithor/obsidian-engine/blob/main/backend/main.py): `backend/main.py`
- [Ingest schemas](https://github.com/rhithor/obsidian-engine/blob/main/backend/models/ingest.py): `backend/models/ingest.py`
- [Query schema](https://github.com/rhithor/obsidian-engine/blob/main/backend/models/query.py): `backend/models/query.py`
- [Health schema](https://github.com/rhithor/obsidian-engine/blob/main/backend/models/health.py): `backend/models/health.py`
- [Privacy schemas](https://github.com/rhithor/obsidian-engine/blob/main/backend/models/privacy.py): `backend/models/privacy.py`

### Document indexing

- [PDF chunking](https://github.com/rhithor/obsidian-engine/blob/main/backend/services/ingestion_service.py): `backend/services/ingestion_service.py`
- [Vector collections](https://github.com/rhithor/obsidian-engine/blob/main/backend/database/db.py): `backend/database/db.py`
- [ChromaDB store](https://github.com/rhithor/obsidian-engine/tree/main/backend/chroma_data): `backend/chroma_data`
- [Context retrieval](https://github.com/rhithor/obsidian-engine/blob/main/backend/database/db.py): `backend/database/db.py`

### Retrieval and AI

- [RAG and summary chains](https://github.com/rhithor/obsidian-engine/blob/main/backend/services/ai_service.py): `backend/services/ai_service.py`
- **Configured LLM**

### Privacy tools

- [PII scrubbing](https://github.com/rhithor/obsidian-engine/blob/main/backend/services/privacy_service.py): `backend/services/privacy_service.py`
- **Presidio engines**

### Other components

- **User**
- **PDF upload**

## Connections

- User → Chat and sidebar: uses
- Chat and sidebar → API client: requests
- API client → FastAPI endpoints: HTTP calls
- PDF upload → API client: uploads
- FastAPI endpoints → Ingest schemas: validates response
- FastAPI endpoints → Query schema: validates query
- FastAPI endpoints → Health schema: returns health
- FastAPI endpoints → Privacy schemas: returns privacy
- FastAPI endpoints → PDF chunking: dispatches indexing
- FastAPI endpoints → Vector collections: manages collections
- PDF chunking → Vector collections: adds chunks
- Vector collections → ChromaDB store: reads and writes
- FastAPI endpoints → Context retrieval: requests context
- Context retrieval → ChromaDB store: queries chunks
- FastAPI endpoints → RAG and summary chains: requests answers
- RAG and summary chains → Configured LLM: invokes chains
- FastAPI endpoints → PII scrubbing: scrubs text
- PII scrubbing → Presidio engines: analyzes and anonymizes
- PII scrubbing → RAG and summary chains: summary input
- FastAPI endpoints → RAG and summary chains: checks provider health
- API client → Chat results: streams tokens and sources
- Chat and sidebar → Chat results: updates
