# vappador/rag_pgvector architecture

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

- Interactive diagram: https://gitdiagram.com/vappador/rag_pgvector
- Repository: https://github.com/vappador/rag_pgvector

## Overview

This is a local code-repository RAG service: repositories are parsed and indexed, then users retrieve code or ask questions answered from cited snippets. The graph preserves both agent implementations, hybrid search and reranking, provenance-based synthesis, and the documented dependency-graph endpoints. Some internal agent and ingestion details are only partially sampled; arrows follow visible calls or README descriptions, and unsampled implementation links are omitted.

Main entry points: [`app/api.py`](https://github.com/vappador/rag_pgvector/blob/main/app/api.py) (FastAPI service), [`app/search.py`](https://github.com/vappador/rag_pgvector/blob/main/app/search.py) (Hybrid search), [`app/strands_agent.py`](https://github.com/vappador/rag_pgvector/blob/main/app/strands_agent.py) (Strands agent), [`db/migrations/001_init.sql`](https://github.com/vappador/rag_pgvector/blob/main/db/migrations/001_init.sql) (Postgres + pgvector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Repository indexing"]
  node_ingest_pipeline["Ingest pipeline<br/>[ingest.py]"]
  node_ast_chunking["AST chunking<br/>[ingest.py]"]
  node_embedding_store["Embedding and indexing<br/>[ingest.py]"]
  node_pgvector[("Postgres + pgvector<br/>[001_init.sql]")]
end

subgraph group_retrieval["Retrieval and answers"]
  node_db_helpers["DB helpers<br/>[db.py]"]
  node_hybrid_search["Hybrid search<br/>[search.py]"]
  node_rerankers["Candidate rerankers<br/>[rerankers.py]"]
  node_answering["Provenance synthesis<br/>[answering.py]"]
end

subgraph group_service["API and graph analysis"]
  node_api["FastAPI service<br/>[api.py]"]
  node_graph_analysis["Relations and impact<br/>[api.py]"]
end

subgraph group_agents["Question agents"]
  node_langgraph_agent["LangGraph agent<br/>[agent_graph.py]"]
  node_strands_agent["Strands agent<br/>[strands_agent.py]"]
  node_observability["Agent observability<br/>[obs.py]"]
end

node_repo_source(("Code repositories"))
node_user(("API user"))
node_git["Git hosting"]
node_ollama["Ollama models"]

node_git -->|"hosts"| node_repo_source
node_repo_source -->|"provides repositories"| node_ingest_pipeline
node_ingest_pipeline -->|"parses and chunks"| node_ast_chunking
node_ast_chunking -->|"produces chunks"| node_embedding_store
node_embedding_store -->|"requests embeddings"| node_ollama
node_embedding_store -->|"indexes chunks"| node_pgvector
node_hybrid_search -->|"queries index"| node_pgvector
node_hybrid_search -->|"reranks candidates"| node_rerankers
node_answering -->|"uses candidates"| node_rerankers
node_answering -.->|"optionally synthesizes"| node_ollama
node_api -->|"runs retrieval"| node_hybrid_search
node_api -->|"uses reranking"| node_rerankers
node_api -->|"dispatches asks"| node_langgraph_agent
node_api -->|"dispatches asks"| node_strands_agent
node_api -->|"serves graph routes"| node_graph_analysis
node_graph_analysis -->|"reads relations"| node_pgvector
node_user -->|"requests results"| node_api
node_langgraph_agent -->|"retrieves context"| node_hybrid_search
node_langgraph_agent -->|"embeds and answers"| node_ollama
node_strands_agent -->|"retrieves context"| node_hybrid_search
node_strands_agent -->|"calls models"| node_ollama
node_strands_agent -->|"emits telemetry"| node_observability
node_db_helpers -.->|"connects to"| node_pgvector

click node_ingest_pipeline "https://github.com/vappador/rag_pgvector/blob/main/app/ingest.py"
click node_ast_chunking "https://github.com/vappador/rag_pgvector/blob/main/app/ingest.py"
click node_embedding_store "https://github.com/vappador/rag_pgvector/blob/main/app/ingest.py"
click node_pgvector "https://github.com/vappador/rag_pgvector/blob/main/db/migrations/001_init.sql"
click node_db_helpers "https://github.com/vappador/rag_pgvector/blob/main/app/db.py"
click node_hybrid_search "https://github.com/vappador/rag_pgvector/blob/main/app/search.py"
click node_rerankers "https://github.com/vappador/rag_pgvector/blob/main/app/rerankers.py"
click node_answering "https://github.com/vappador/rag_pgvector/blob/main/app/answering.py"
click node_api "https://github.com/vappador/rag_pgvector/blob/main/app/api.py"
click node_graph_analysis "https://github.com/vappador/rag_pgvector/blob/main/app/api.py"
click node_langgraph_agent "https://github.com/vappador/rag_pgvector/blob/main/app/agent_graph.py"
click node_strands_agent "https://github.com/vappador/rag_pgvector/blob/main/app/strands_agent.py"
click node_observability "https://github.com/vappador/rag_pgvector/blob/main/app/obs.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_pipeline,node_ast_chunking,node_embedding_store,node_pgvector,node_user toneBlue
class node_db_helpers,node_hybrid_search,node_rerankers,node_answering toneAmber
class node_api,node_graph_analysis toneMint
class node_langgraph_agent,node_strands_agent,node_observability toneRose
class node_repo_source,node_git,node_ollama toneIndigo
```

## Components

### Repository indexing

- [Ingest pipeline](https://github.com/vappador/rag_pgvector/blob/main/app/ingest.py): `app/ingest.py`
- [AST chunking](https://github.com/vappador/rag_pgvector/blob/main/app/ingest.py): `app/ingest.py`
- [Embedding and indexing](https://github.com/vappador/rag_pgvector/blob/main/app/ingest.py): `app/ingest.py`
- [Postgres + pgvector](https://github.com/vappador/rag_pgvector/blob/main/db/migrations/001_init.sql): `db/migrations/001_init.sql`

### Retrieval and answers

- [DB helpers](https://github.com/vappador/rag_pgvector/blob/main/app/db.py): `app/db.py`
- [Hybrid search](https://github.com/vappador/rag_pgvector/blob/main/app/search.py): `app/search.py`
- [Candidate rerankers](https://github.com/vappador/rag_pgvector/blob/main/app/rerankers.py): `app/rerankers.py`
- [Provenance synthesis](https://github.com/vappador/rag_pgvector/blob/main/app/answering.py): `app/answering.py`

### API and graph analysis

- [FastAPI service](https://github.com/vappador/rag_pgvector/blob/main/app/api.py): `app/api.py`
- [Relations and impact](https://github.com/vappador/rag_pgvector/blob/main/app/api.py): `app/api.py`

### Question agents

- [LangGraph agent](https://github.com/vappador/rag_pgvector/blob/main/app/agent_graph.py): `app/agent_graph.py`
- [Strands agent](https://github.com/vappador/rag_pgvector/blob/main/app/strands_agent.py): `app/strands_agent.py`
- [Agent observability](https://github.com/vappador/rag_pgvector/blob/main/app/obs.py): `app/obs.py`

### Other components

- **Code repositories**
- **API user**
- **Git hosting**
- **Ollama models**

## Connections

- Git hosting → Code repositories: hosts (evidence: `README.md`)
- Code repositories → Ingest pipeline: provides repositories (evidence: `README.md`)
- Ingest pipeline → AST chunking: parses and chunks (evidence: `README.md`)
- AST chunking → Embedding and indexing: produces chunks (evidence: `README.md`)
- Embedding and indexing → Ollama models: requests embeddings (evidence: `README.md`)
- Embedding and indexing → Postgres + pgvector: indexes chunks (evidence: `README.md`)
- Hybrid search → Postgres + pgvector: queries index (evidence: `README.md`)
- Hybrid search → Candidate rerankers: reranks candidates (evidence: `README.md`)
- Provenance synthesis → Candidate rerankers: uses candidates (evidence: `app/answering.py`)
- Provenance synthesis → Ollama models: optionally synthesizes (evidence: `app/answering.py`)
- FastAPI service → Hybrid search: runs retrieval (evidence: `README.md`)
- FastAPI service → Candidate rerankers: uses reranking (evidence: `app/api.py`)
- FastAPI service → LangGraph agent: dispatches asks (evidence: `app/api.py`)
- FastAPI service → Strands agent: dispatches asks (evidence: `app/api.py`)
- FastAPI service → Relations and impact: serves graph routes (evidence: `README.md`)
- Relations and impact → Postgres + pgvector: reads relations (evidence: `README.md`)
- API user → FastAPI service: requests results (evidence: `README.md`)
- LangGraph agent → Hybrid search: retrieves context (evidence: `app/agent_graph.py`)
- LangGraph agent → Ollama models: embeds and answers (evidence: `app/agent_graph.py`)
- Strands agent → Hybrid search: retrieves context (evidence: `README.md`)
- Strands agent → Ollama models: calls models (evidence: `app/strands_agent.py`)
- Strands agent → Agent observability: emits telemetry (evidence: `app/strands_agent.py`)
- DB helpers → Postgres + pgvector: connects to
