# gioo007/gus-rag architecture

> Architecture diagram of the GitHub repository gioo007/gus-rag, 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/gioo007/gus-rag
- Repository: https://github.com/gioo007/gus-rag

## Overview

Gus AI is a session-scoped document Q&A product: users ingest files or web pages, then ask questions and receive answers with source citations. The dashboard calls the FastAPI API; document routes dispatch to loaders and persist chunks, while query routes coordinate history, retrieval, and generation. v1 retrieves before a single generation call; v2 uses an agent that can invoke retrieval. README documents hybrid retrieval, reranking, and multi-hop search; evaluation is a separate harness, not part of the user-facing runtime. Links follow shown calls or README claims; unsampled subsystems are represented only where documented.

Main entry points: [`backend/app/routers/query.py`](https://github.com/gioo007/gus-rag/blob/main/backend/app/routers/query.py) (Query route), [`backend/app/routers/documents.py`](https://github.com/gioo007/gus-rag/blob/main/backend/app/routers/documents.py) (Document routes), [`backend/app/services/retrieval.py`](https://github.com/gioo007/gus-rag/blob/main/backend/app/services/retrieval.py) (Retrieval strategies), [`backend/app/services/generation.py`](https://github.com/gioo007/gus-rag/blob/main/backend/app/services/generation.py) (Answer generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User interface"]
  node_dashboard["RAG dashboard<br/>[rag-dashboard.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["API and orchestration"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
  node_config["Environment config<br/>[config.py]"]
end

subgraph group_documents["Document management"]
  node_document_routes["Document routes<br/>[documents.py]"]
  node_ingestion["Document loaders<br/>[ingestion.py]"]
end

subgraph group_qa["Question answering"]
  node_query_routes["Query route<br/>[query.py]"]
  node_retrieval["Retrieval strategies<br/>[retrieval.py]"]
  node_generation["Answer generation<br/>[generation.py]"]
  node_agent_tool["Retrieval agent tool<br/>[generation.py]"]
end

subgraph group_state["Persistence and providers"]
  node_vectorstore[("Vector store<br/>[vectorstore.py]")]
  node_history[("Chat history<br/>[chat_history.py]")]
  node_embedding_provider["Voyage embeddings"]
  node_postgres[("Neon Postgres")]
  node_groq["Groq model"]
  node_cohere["Cohere reranker"]
end

node_user(("Document user"))
node_web(("Web pages"))
node_eval_harness["RAGAS evaluation<br/>[run_eval.py]"]
node_eval_dataset["Evaluation questions<br/>[dataset.py]"]

node_user -->|"uses"| node_dashboard
node_dashboard -->|"calls"| node_api_client
node_api_client -->|"HTTP requests"| node_fastapi
node_fastapi -->|"registers"| node_document_routes
node_fastapi -->|"registers"| node_query_routes
node_fastapi -->|"configures CORS"| node_config
node_document_routes -->|"validates and returns"| node_schemas
node_query_routes -->|"validates and returns"| node_schemas
node_document_routes -->|"dispatches loaders"| node_ingestion
node_web -->|"submits URL"| node_document_routes
node_ingestion -->|"fetches page"| node_web
node_document_routes -->|"stores and manages"| node_vectorstore
node_document_routes -->|"invalidates cache"| node_retrieval
node_vectorstore -->|"embeds chunks"| node_embedding_provider
node_vectorstore -->|"reads and writes"| node_postgres
node_query_routes -->|"loads and saves turns"| node_history
node_query_routes -->|"requests chunks"| node_retrieval
node_query_routes -->|"generates v1 answer"| node_generation
node_query_routes -->|"runs v2 agent"| node_generation
node_generation -->|"invokes model"| node_groq
node_generation -->|"registers tool"| node_agent_tool
node_agent_tool -->|"searches documents"| node_retrieval
node_retrieval -->|"dense search and corpus reads"| node_vectorstore
node_retrieval -->|"reranks candidates"| node_cohere
node_eval_harness -->|"uses questions"| node_eval_dataset
node_eval_harness -->|"benchmarks"| node_retrieval
node_eval_harness -->|"benchmarks"| node_generation

click node_dashboard "https://github.com/gioo007/gus-rag/blob/main/frontend/components/rag-dashboard.tsx"
click node_api_client "https://github.com/gioo007/gus-rag/blob/main/frontend/lib/api.ts"
click node_fastapi "https://github.com/gioo007/gus-rag/blob/main/backend/app/main.py"
click node_schemas "https://github.com/gioo007/gus-rag/blob/main/backend/app/models/schemas.py"
click node_config "https://github.com/gioo007/gus-rag/blob/main/backend/app/core/config.py"
click node_document_routes "https://github.com/gioo007/gus-rag/blob/main/backend/app/routers/documents.py"
click node_ingestion "https://github.com/gioo007/gus-rag/blob/main/backend/app/services/ingestion.py"
click node_vectorstore "https://github.com/gioo007/gus-rag/blob/main/backend/app/services/vectorstore.py"
click node_query_routes "https://github.com/gioo007/gus-rag/blob/main/backend/app/routers/query.py"
click node_history "https://github.com/gioo007/gus-rag/blob/main/backend/app/services/chat_history.py"
click node_retrieval "https://github.com/gioo007/gus-rag/blob/main/backend/app/services/retrieval.py"
click node_generation "https://github.com/gioo007/gus-rag/blob/main/backend/app/services/generation.py"
click node_agent_tool "https://github.com/gioo007/gus-rag/blob/main/backend/app/services/generation.py"
click node_eval_harness "https://github.com/gioo007/gus-rag/blob/main/eval/run_eval.py"
click node_eval_dataset "https://github.com/gioo007/gus-rag/blob/main/eval/dataset.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_dashboard,node_api_client,node_user toneBlue
class node_fastapi,node_schemas,node_config toneAmber
class node_document_routes,node_ingestion toneMint
class node_query_routes,node_retrieval,node_generation,node_agent_tool toneRose
class node_vectorstore,node_history,node_embedding_provider,node_postgres,node_groq,node_cohere,node_web toneIndigo
class node_eval_harness,node_eval_dataset toneTeal
```

## Components

### User interface

- [RAG dashboard](https://github.com/gioo007/gus-rag/blob/main/frontend/components/rag-dashboard.tsx): `frontend/components/rag-dashboard.tsx`
- [API client](https://github.com/gioo007/gus-rag/blob/main/frontend/lib/api.ts): `frontend/lib/api.ts`

### API and orchestration

- [FastAPI app](https://github.com/gioo007/gus-rag/blob/main/backend/app/main.py): `backend/app/main.py`
- [API schemas](https://github.com/gioo007/gus-rag/blob/main/backend/app/models/schemas.py): `backend/app/models/schemas.py`
- [Environment config](https://github.com/gioo007/gus-rag/blob/main/backend/app/core/config.py): `backend/app/core/config.py`

### Document management

- [Document routes](https://github.com/gioo007/gus-rag/blob/main/backend/app/routers/documents.py): `backend/app/routers/documents.py`
- [Document loaders](https://github.com/gioo007/gus-rag/blob/main/backend/app/services/ingestion.py): `backend/app/services/ingestion.py`

### Question answering

- [Query route](https://github.com/gioo007/gus-rag/blob/main/backend/app/routers/query.py): `backend/app/routers/query.py`
- [Retrieval strategies](https://github.com/gioo007/gus-rag/blob/main/backend/app/services/retrieval.py): `backend/app/services/retrieval.py`
- [Answer generation](https://github.com/gioo007/gus-rag/blob/main/backend/app/services/generation.py): `backend/app/services/generation.py`
- [Retrieval agent tool](https://github.com/gioo007/gus-rag/blob/main/backend/app/services/generation.py): `backend/app/services/generation.py`

### Persistence and providers

- [Vector store](https://github.com/gioo007/gus-rag/blob/main/backend/app/services/vectorstore.py): `backend/app/services/vectorstore.py`
- [Chat history](https://github.com/gioo007/gus-rag/blob/main/backend/app/services/chat_history.py): `backend/app/services/chat_history.py`
- **Voyage embeddings**
- **Neon Postgres**
- **Groq model**
- **Cohere reranker**

### Other components

- **Document user**
- **Web pages**
- [RAGAS evaluation](https://github.com/gioo007/gus-rag/blob/main/eval/run_eval.py): `eval/run_eval.py`
- [Evaluation questions](https://github.com/gioo007/gus-rag/blob/main/eval/dataset.py): `eval/dataset.py`

## Connections

- Document user → RAG dashboard: uses (evidence: `README.md`)
- RAG dashboard → API client: calls (evidence: `README.md`)
- API client → FastAPI app: HTTP requests (evidence: `README.md`)
- FastAPI app → Document routes: registers (evidence: `backend/app/main.py`)
- FastAPI app → Query route: registers (evidence: `backend/app/main.py`)
- FastAPI app → Environment config: configures CORS (evidence: `backend/app/main.py`)
- Document routes → API schemas: validates and returns (evidence: `backend/app/routers/documents.py`)
- Query route → API schemas: validates and returns (evidence: `backend/app/routers/query.py`)
- Document routes → Document loaders: dispatches loaders (evidence: `backend/app/routers/documents.py`)
- Web pages → Document routes: submits URL (evidence: `README.md`)
- Document loaders → Web pages: fetches page (evidence: `backend/app/services/ingestion.py`)
- Document routes → Vector store: stores and manages (evidence: `backend/app/routers/documents.py`)
- Document routes → Retrieval strategies: invalidates cache (evidence: `backend/app/routers/documents.py`)
- Vector store → Voyage embeddings: embeds chunks (evidence: `README.md`)
- Vector store → Neon Postgres: reads and writes (evidence: `README.md`)
- Query route → Chat history: loads and saves turns (evidence: `backend/app/routers/query.py`)
- Query route → Retrieval strategies: requests chunks (evidence: `backend/app/routers/query.py`)
- Query route → Answer generation: generates v1 answer (evidence: `backend/app/routers/query.py`)
- Query route → Answer generation: runs v2 agent (evidence: `backend/app/routers/query.py`)
- Answer generation → Groq model: invokes model (evidence: `README.md`)
- Answer generation → Retrieval agent tool: registers tool (evidence: `backend/app/services/generation.py`)
- Retrieval agent tool → Retrieval strategies: searches documents (evidence: `backend/app/services/generation.py`)
- Retrieval strategies → Vector store: dense search and corpus reads (evidence: `backend/app/services/retrieval.py`)
- Retrieval strategies → Cohere reranker: reranks candidates (evidence: `README.md`)
- RAGAS evaluation → Evaluation questions: uses questions (evidence: `eval/run_eval.py`)
- RAGAS evaluation → Retrieval strategies: benchmarks (evidence: `eval/run_eval.py`)
- RAGAS evaluation → Answer generation: benchmarks (evidence: `eval/run_eval.py`)
