# ramprakash-munugapati/ragram_pro architecture

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

- Interactive diagram: https://gitdiagram.com/ramprakash-munugapati/ragram_pro
- Repository: https://github.com/ramprakash-munugapati/ragram_pro

## Overview

RAGRAM_Pro is a hybrid-retrieval library for grounding RAG responses: users index chunks, query them through dense and lexical search, fuse and rerank candidates, then package surviving evidence for a prompt. Its internal layers cover embeddings, storage backends, fusion, reranking and integration adapters. The README documents LangChain, LlamaIndex and generation integrations; their individual implementations were not sampled, so those links are documented capabilities rather than inspected call paths.

Main entry points: [`engine.py`](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/engine.py) (Fusion engine), [`app.py`](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/app.py) (Demo application), [`rerank/base.py`](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/rerank/base.py) (Reranker interface), [`storage/base.py`](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/storage/base.py) (Storage interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_demo["Demo application<br/>[app.py]"]
  node_config["Fusion configuration<br/>[config.py]"]
  node_env["Environment loader<br/>[envfile.py]"]
end

subgraph group_pipeline["Retrieval pipeline"]
  node_engine["Fusion engine<br/>[engine.py]"]
  node_contracts["Chunk and result models<br/>[models.py]"]
  node_embedder["Embedder implementations<br/>[embedding.py]"]
  node_coordinator["Hybrid coordinator<br/>[coordinator.py]"]
  node_fusion["Rank fusion<br/>[fusion.py]"]
  node_rerankbase["Reranker interface<br/>[base.py]"]
  node_threshold["Threshold and top-N<br/>[engine.py]"]
  node_prompts["Evidence prompt builder<br/>[prompts.py]"]
end

subgraph group_backends["Retrieval backends"]
  node_storagebase["Storage interface<br/>[base.py]"]
  node_memory[("In-memory storage<br/>[memory.py]")]
  node_bm25["BM25 lexical index<br/>[bm25.py]"]
  node_postgres[("Postgres storage<br/>[postgres.py]")]
  node_hf["HuggingFace reranker<br/>[huggingface.py]"]
  node_cohere["Cohere reranker<br/>[cohere.py]"]
  node_noop["Term-overlap reranker<br/>[noop.py]"]
end

subgraph group_integrations["RAG integrations"]
  node_langchain["LangChain retriever<br/>[langchain.py]"]
  node_llama["LlamaIndex retriever<br/>[llamaindex.py]"]
  node_compat["Sync async bridge<br/>[compat.py]"]
  node_generation["Generation backends<br/>[generation.py]"]
end

node_user(("Application user"))
node_database[("PostgreSQL database")]
node_cohereapi["Cohere API"]
node_llm["Chat model"]

node_user -->|"runs demo"| node_demo
node_demo -->|"loads settings"| node_env
node_demo -->|"configures"| node_config
node_demo -->|"indexes and queries"| node_engine
node_engine -->|"embeds chunks"| node_embedder
node_engine -->|"writes chunks"| node_storagebase
node_engine -->|"dispatches search"| node_coordinator
node_coordinator -->|"embeds query"| node_embedder
node_coordinator -->|"dispatches streams"| node_storagebase
node_engine -->|"fuses streams"| node_fusion
node_engine -->|"reranks candidates"| node_rerankbase
node_engine -->|"filters and truncates"| node_threshold
node_engine -->|"builds prompt"| node_prompts
node_memory -->|"implements"| node_storagebase
node_memory -->|"builds and searches"| node_bm25
node_postgres -->|"implements"| node_storagebase
node_postgres -->|"queries and writes"| node_database
node_hf -->|"implements"| node_rerankbase
node_cohere -->|"implements"| node_rerankbase
node_cohere -->|"sends rerank request"| node_cohereapi
node_noop -.->|"implements"| node_rerankbase
node_langchain -.->|"retrieves through"| node_engine
node_llama -->|"retrieves through"| node_engine
node_llama -->|"bridges async call"| node_compat
node_generation -.->|"generates response"| node_llm
node_engine -.->|"returns results"| node_contracts
node_prompts -.->|"packages evidence for"| node_llm

click node_demo "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/app.py"
click node_config "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/config.py"
click node_env "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/envfile.py"
click node_engine "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/engine.py"
click node_contracts "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/models.py"
click node_embedder "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/embedding.py"
click node_coordinator "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/search/coordinator.py"
click node_fusion "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/search/fusion.py"
click node_rerankbase "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/rerank/base.py"
click node_threshold "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/engine.py"
click node_prompts "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/prompts.py"
click node_storagebase "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/storage/base.py"
click node_memory "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/storage/memory.py"
click node_bm25 "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/storage/bm25.py"
click node_postgres "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/storage/postgres.py"
click node_hf "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/rerank/huggingface.py"
click node_cohere "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/rerank/cohere.py"
click node_noop "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/rerank/noop.py"
click node_langchain "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/integrations/langchain.py"
click node_llama "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/integrations/llamaindex.py"
click node_compat "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/integrations/compat.py"
click node_generation "https://github.com/ramprakash-munugapati/ragram_pro/blob/main/integrations/generation.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_demo,node_config,node_env,node_user toneBlue
class node_engine,node_contracts,node_embedder,node_coordinator,node_fusion,node_rerankbase,node_threshold,node_prompts,node_database toneAmber
class node_storagebase,node_memory,node_bm25,node_postgres,node_hf,node_cohere,node_noop,node_cohereapi toneMint
class node_langchain,node_llama,node_compat,node_generation toneRose
class node_llm toneIndigo
```

## Components

### Application entry

- [Demo application](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/app.py): `app.py`
- [Fusion configuration](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/config.py): `config.py`
- [Environment loader](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/envfile.py): `envfile.py`

### Retrieval pipeline

- [Fusion engine](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/engine.py): `engine.py`
- [Chunk and result models](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/models.py): `models.py`
- [Embedder implementations](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/embedding.py): `embedding.py`
- [Hybrid coordinator](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/search/coordinator.py): `search/coordinator.py`
- [Rank fusion](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/search/fusion.py): `search/fusion.py`
- [Reranker interface](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/rerank/base.py): `rerank/base.py`
- [Threshold and top-N](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/engine.py): `engine.py`
- [Evidence prompt builder](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/prompts.py): `prompts.py`

### Retrieval backends

- [Storage interface](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/storage/base.py): `storage/base.py`
- [In-memory storage](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/storage/memory.py): `storage/memory.py`
- [BM25 lexical index](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/storage/bm25.py): `storage/bm25.py`
- [Postgres storage](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/storage/postgres.py): `storage/postgres.py`
- [HuggingFace reranker](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/rerank/huggingface.py): `rerank/huggingface.py`
- [Cohere reranker](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/rerank/cohere.py): `rerank/cohere.py`
- [Term-overlap reranker](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/rerank/noop.py): `rerank/noop.py`

### RAG integrations

- [LangChain retriever](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/integrations/langchain.py): `integrations/langchain.py`
- [LlamaIndex retriever](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/integrations/llamaindex.py): `integrations/llamaindex.py`
- [Sync async bridge](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/integrations/compat.py): `integrations/compat.py`
- [Generation backends](https://github.com/ramprakash-munugapati/ragram_pro/blob/main/integrations/generation.py): `integrations/generation.py`

### Other components

- **Application user**
- **PostgreSQL database**
- **Cohere API**
- **Chat model**

## Connections

- Application user → Demo application: runs demo (evidence: `README.md`)
- Demo application → Environment loader: loads settings (evidence: `app.py`)
- Demo application → Fusion configuration: configures (evidence: `app.py`)
- Demo application → Fusion engine: indexes and queries (evidence: `app.py`)
- Fusion engine → Embedder implementations: embeds chunks (evidence: `engine.py`)
- Fusion engine → Storage interface: writes chunks (evidence: `engine.py`)
- Fusion engine → Hybrid coordinator: dispatches search (evidence: `engine.py`)
- Hybrid coordinator → Embedder implementations: embeds query (evidence: `search/coordinator.py`)
- Hybrid coordinator → Storage interface: dispatches streams (evidence: `search/coordinator.py`)
- Fusion engine → Rank fusion: fuses streams (evidence: `engine.py`)
- Fusion engine → Reranker interface: reranks candidates (evidence: `engine.py`)
- Fusion engine → Threshold and top-N: filters and truncates (evidence: `engine.py`)
- Fusion engine → Evidence prompt builder: builds prompt (evidence: `engine.py`)
- In-memory storage → Storage interface: implements (evidence: `storage/memory.py`)
- In-memory storage → BM25 lexical index: builds and searches (evidence: `storage/memory.py`)
- Postgres storage → Storage interface: implements (evidence: `storage/postgres.py`)
- Postgres storage → PostgreSQL database: queries and writes (evidence: `storage/postgres.py`)
- HuggingFace reranker → Reranker interface: implements (evidence: `rerank/huggingface.py`)
- Cohere reranker → Reranker interface: implements (evidence: `rerank/cohere.py`)
- Cohere reranker → Cohere API: sends rerank request (evidence: `rerank/cohere.py`)
- Term-overlap reranker → Reranker interface: implements (evidence: `README.md`)
- LangChain retriever → Fusion engine: retrieves through (evidence: `README.md`)
- LlamaIndex retriever → Fusion engine: retrieves through (evidence: `integrations/llamaindex.py`)
- LlamaIndex retriever → Sync async bridge: bridges async call (evidence: `integrations/llamaindex.py`)
- Generation backends → Chat model: generates response (evidence: `README.md`)
- Fusion engine → Chunk and result models: returns results (evidence: `README.md`)
- Evidence prompt builder → Chat model: packages evidence for (evidence: `README.md`)
