# vishnu-manalan/self-healing-rag architecture

> Architecture diagram of the GitHub repository vishnu-manalan/self-healing-rag, 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/vishnu-manalan/self-healing-rag
- Repository: https://github.com/vishnu-manalan/self-healing-rag

## Overview

This is a web application for interactive self-healing retrieval-augmented generation. A user submits a query in the Playground; the backend API hands it to the RAG orchestrator, which can enhance the query, retrieve candidates, validate them, rerank results, and generate an answer. Feedback supports a learning loop. The README also documents Architecture, Documentation, and Statistics views. Some subsystem links are based on explicit README descriptions or indexed imports; unsampled API and orchestration details are not assumed beyond that evidence.

Main entry points: [`backend/self_healing_rag.py`](https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/self_healing_rag.py) (RAG orchestrator), [`frontend/src/App.jsx`](https://github.com/vishnu-manalan/self-healing-rag/blob/main/frontend/src/App.jsx) (App shell), [`frontend/src/components/Playground.jsx`](https://github.com/vishnu-manalan/self-healing-rag/blob/main/frontend/src/components/Playground.jsx) (Query playground), [`backend/api_server.py`](https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/api_server.py) (Backend API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_entry["Web entry<br/>[main.jsx]"]
  node_app["App shell<br/>[App.jsx]"]
  node_playground["Query playground<br/>[Playground.jsx]"]
  node_architecture_ui["Architecture view<br/>[Architecture.jsx]"]
  node_documentation["Documentation view<br/>[Documentation.jsx]"]
  node_statistics["Statistics view<br/>[Statistics.jsx]"]
end

subgraph group_service["API service"]
  node_api["Backend API<br/>[api_server.py]"]
end

subgraph group_rag["RAG workflow"]
  node_orchestrator["RAG orchestrator"]
  node_hyde["HyDE enhancement<br/>[hyde.py]"]
  node_decomposition["Query decomposition"]
  node_retrieval["Vector retrieval"]
  node_crag["CRAG validation<br/>[corrective_rag.py]"]
  node_reranker["Cross-encoder ranking<br/>[reranker.py]"]
end

subgraph group_learning["Learning"]
  node_learning_manager["Example learning"]
  node_example_store[("Example index")]
end

node_user(("User"))
node_web_search["Tavily search"]

node_user -->|"submits query"| node_playground
node_entry -->|"renders"| node_app
node_app -->|"shows"| node_playground
node_app -->|"shows"| node_architecture_ui
node_app -->|"shows"| node_documentation
node_app -->|"shows"| node_statistics
node_playground -->|"posts feedback"| node_api
node_playground -.->|"submits query"| node_api
node_statistics -.->|"requests metrics"| node_api
node_api -->|"serves RAG API"| node_orchestrator
node_orchestrator -->|"enhances query"| node_hyde
node_orchestrator -->|"decomposes query"| node_decomposition
node_orchestrator -->|"retrieves candidates"| node_retrieval
node_orchestrator -->|"validates documents"| node_crag
node_orchestrator -->|"reranks documents"| node_reranker
node_orchestrator -->|"uses examples"| node_learning_manager
node_crag -->|"falls back"| node_web_search
node_learning_manager -->|"stores examples"| node_example_store
node_playground -.->|"sends feedback"| node_learning_manager
node_api -.->|"records feedback"| node_learning_manager

click node_entry "https://github.com/vishnu-manalan/self-healing-rag/blob/main/frontend/src/main.jsx"
click node_app "https://github.com/vishnu-manalan/self-healing-rag/blob/main/frontend/src/App.jsx"
click node_playground "https://github.com/vishnu-manalan/self-healing-rag/blob/main/frontend/src/components/Playground.jsx"
click node_architecture_ui "https://github.com/vishnu-manalan/self-healing-rag/blob/main/frontend/src/components/Architecture.jsx"
click node_documentation "https://github.com/vishnu-manalan/self-healing-rag/blob/main/frontend/src/components/Documentation.jsx"
click node_statistics "https://github.com/vishnu-manalan/self-healing-rag/blob/main/frontend/src/components/Statistics.jsx"
click node_api "https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/api_server.py"
click node_orchestrator "https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/self_healing_rag.py"
click node_hyde "https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/hyde.py"
click node_decomposition "https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/query_decomposition.py"
click node_retrieval "https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/self_healing_rag.py"
click node_crag "https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/corrective_rag.py"
click node_reranker "https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/reranker.py"
click node_learning_manager "https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/dynamic_prompting.py"
click node_example_store "https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/dynamic_prompting.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_entry,node_app,node_playground,node_architecture_ui,node_documentation,node_statistics,node_user toneBlue
class node_api toneAmber
class node_orchestrator,node_hyde,node_decomposition,node_retrieval,node_crag,node_reranker toneMint
class node_learning_manager,node_example_store toneRose
class node_web_search toneIndigo
```

## Components

### Web interface

- [Web entry](https://github.com/vishnu-manalan/self-healing-rag/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`
- [App shell](https://github.com/vishnu-manalan/self-healing-rag/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Query playground](https://github.com/vishnu-manalan/self-healing-rag/blob/main/frontend/src/components/Playground.jsx): `frontend/src/components/Playground.jsx`
- [Architecture view](https://github.com/vishnu-manalan/self-healing-rag/blob/main/frontend/src/components/Architecture.jsx): `frontend/src/components/Architecture.jsx`
- [Documentation view](https://github.com/vishnu-manalan/self-healing-rag/blob/main/frontend/src/components/Documentation.jsx): `frontend/src/components/Documentation.jsx`
- [Statistics view](https://github.com/vishnu-manalan/self-healing-rag/blob/main/frontend/src/components/Statistics.jsx): `frontend/src/components/Statistics.jsx`

### API service

- [Backend API](https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/api_server.py): `backend/api_server.py`

### RAG workflow

- [RAG orchestrator](https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/self_healing_rag.py): `backend/self_healing_rag.py`
- [HyDE enhancement](https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/hyde.py): `backend/hyde.py`
- [Query decomposition](https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/query_decomposition.py): `backend/query_decomposition.py`
- [Vector retrieval](https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/self_healing_rag.py): `backend/self_healing_rag.py`
- [CRAG validation](https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/corrective_rag.py): `backend/corrective_rag.py`
- [Cross-encoder ranking](https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/reranker.py): `backend/reranker.py`

### Learning

- [Example learning](https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/dynamic_prompting.py): `backend/dynamic_prompting.py`
- [Example index](https://github.com/vishnu-manalan/self-healing-rag/blob/main/backend/dynamic_prompting.py): `backend/dynamic_prompting.py`

### Other components

- **User**
- **Tavily search**

## Connections

- User → Query playground: submits query (evidence: `README.md`)
- Web entry → App shell: renders (evidence: `frontend/src/main.jsx`)
- App shell → Query playground: shows (evidence: `frontend/src/App.jsx`)
- App shell → Architecture view: shows (evidence: `frontend/src/App.jsx`)
- App shell → Documentation view: shows (evidence: `frontend/src/App.jsx`)
- App shell → Statistics view: shows (evidence: `frontend/src/App.jsx`)
- Query playground → Backend API: posts feedback (evidence: `frontend/src/components/Playground.jsx`)
- Query playground → Backend API: submits query
- Statistics view → Backend API: requests metrics
- Backend API → RAG orchestrator: serves RAG API (evidence: `README.md`)
- RAG orchestrator → HyDE enhancement: enhances query (evidence: `backend/self_healing_rag.py`)
- RAG orchestrator → Query decomposition: decomposes query (evidence: `backend/self_healing_rag.py`)
- RAG orchestrator → Vector retrieval: retrieves candidates (evidence: `README.md`)
- RAG orchestrator → CRAG validation: validates documents (evidence: `backend/self_healing_rag.py`)
- RAG orchestrator → Cross-encoder ranking: reranks documents (evidence: `backend/self_healing_rag.py`)
- RAG orchestrator → Example learning: uses examples (evidence: `backend/self_healing_rag.py`)
- CRAG validation → Tavily search: falls back (evidence: `README.md`)
- Example learning → Example index: stores examples (evidence: `backend/dynamic_prompting.py`)
- Query playground → Example learning: sends feedback
- Backend API → Example learning: records feedback
