# ramprakash-munugapati/ragram_core architecture

> Architecture diagram of the GitHub repository ramprakash-munugapati/ragram_core, 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_core
- Repository: https://github.com/ramprakash-munugapati/ragram_core

## Overview

RAGRAM Core is a pluggable Naive RAG library: documents are chunked, embedded, and stored; questions are embedded and searched, then either refused when retrieval is insufficient or answered with cited sources. The engine owns the pipeline and uses separate storage, embedding, and synthesis interfaces. The README also documents a Streamlit UI. Its source was not sampled, so its internal calls are omitted; the documented interaction with the engine is shown with an unverified edge.

Main entry points: [`engine.py`](https://github.com/ramprakash-munugapati/ragram_core/blob/main/engine.py) (RAG engine), [`embeddings.py`](https://github.com/ramprakash-munugapati/ragram_core/blob/main/embeddings.py) (Embedding provider), [`ui/app.py`](https://github.com/ramprakash-munugapati/ragram_core/blob/main/ui/app.py) (Streamlit UI), [`llm.py`](https://github.com/ramprakash-munugapati/ragram_core/blob/main/llm.py) (LLM client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_flow["RAG workflow"]
  node_ui["Streamlit UI<br/>[app.py]"]
  node_engine["RAG engine<br/>[engine.py]"]
  node_chunker["Text chunking<br/>[chunking.py]"]
  node_prompts["Grounding prompts<br/>[prompts.py]"]
end

subgraph group_providers["Pluggable providers"]
  node_embed["Embedding provider<br/>[embeddings.py]"]
  node_openai_embed["OpenAI embeddings<br/>[embeddings.py]"]
  node_hf_embed["HuggingFace embeddings<br/>[embeddings.py]"]
  node_llm["LLM client<br/>[llm.py]"]
  node_openai_llm["OpenAI synthesis<br/>[llm.py]"]
end

subgraph group_storage["Vector storage"]
  node_storage_interface["Storage interface<br/>[base.py]"]
  node_postgres_adapter["Postgres adapter"]
  node_postgres[("PostgreSQL pgvector")]
end

subgraph group_runtime["Runtime setup"]
  node_config["Settings<br/>[config.py]"]
end

node_user(("User"))
node_openai_service{{"OpenAI API"}}
node_hf_service{{"SentenceTransformers"}}

node_user -.->|"uses"| node_ui
node_ui -.->|"queries and ingests"| node_engine
node_engine -->|"splits documents"| node_chunker
node_engine -->|"embeds text"| node_embed
node_engine -->|"stores and searches"| node_storage_interface
node_engine -->|"builds grounded context"| node_prompts
node_engine -->|"synthesizes answers"| node_llm
node_config -->|"configures provider"| node_embed
node_embed -->|"selects"| node_openai_embed
node_embed -->|"selects"| node_hf_embed
node_openai_embed -->|"requests vectors"| node_openai_service
node_hf_embed -->|"encodes locally"| node_hf_service
node_llm -->|"implements"| node_openai_llm
node_openai_llm -->|"requests completions"| node_openai_service
node_storage_interface -->|"implemented by"| node_postgres_adapter
node_postgres_adapter -->|"upserts and searches"| node_postgres

click node_ui "https://github.com/ramprakash-munugapati/ragram_core/blob/main/ui/app.py"
click node_engine "https://github.com/ramprakash-munugapati/ragram_core/blob/main/engine.py"
click node_chunker "https://github.com/ramprakash-munugapati/ragram_core/blob/main/chunking.py"
click node_prompts "https://github.com/ramprakash-munugapati/ragram_core/blob/main/prompts.py"
click node_config "https://github.com/ramprakash-munugapati/ragram_core/blob/main/config.py"
click node_embed "https://github.com/ramprakash-munugapati/ragram_core/blob/main/embeddings.py"
click node_openai_embed "https://github.com/ramprakash-munugapati/ragram_core/blob/main/embeddings.py"
click node_hf_embed "https://github.com/ramprakash-munugapati/ragram_core/blob/main/embeddings.py"
click node_llm "https://github.com/ramprakash-munugapati/ragram_core/blob/main/llm.py"
click node_openai_llm "https://github.com/ramprakash-munugapati/ragram_core/blob/main/llm.py"
click node_storage_interface "https://github.com/ramprakash-munugapati/ragram_core/blob/main/adapters/base.py"
click node_postgres_adapter "https://github.com/ramprakash-munugapati/ragram_core/blob/main/adapters/postgres_adapter.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_ui,node_engine,node_chunker,node_prompts,node_user toneBlue
class node_embed,node_openai_embed,node_hf_embed,node_llm,node_openai_llm toneAmber
class node_storage_interface,node_postgres_adapter,node_postgres,node_openai_service toneMint
class node_config toneRose
class node_hf_service toneIndigo
```

## Components

### RAG workflow

- [Streamlit UI](https://github.com/ramprakash-munugapati/ragram_core/blob/main/ui/app.py): `ui/app.py`
- [RAG engine](https://github.com/ramprakash-munugapati/ragram_core/blob/main/engine.py): `engine.py`
- [Text chunking](https://github.com/ramprakash-munugapati/ragram_core/blob/main/chunking.py): `chunking.py`
- [Grounding prompts](https://github.com/ramprakash-munugapati/ragram_core/blob/main/prompts.py): `prompts.py`

### Pluggable providers

- [Embedding provider](https://github.com/ramprakash-munugapati/ragram_core/blob/main/embeddings.py): `embeddings.py`
- [OpenAI embeddings](https://github.com/ramprakash-munugapati/ragram_core/blob/main/embeddings.py): `embeddings.py`
- [HuggingFace embeddings](https://github.com/ramprakash-munugapati/ragram_core/blob/main/embeddings.py): `embeddings.py`
- [LLM client](https://github.com/ramprakash-munugapati/ragram_core/blob/main/llm.py): `llm.py`
- [OpenAI synthesis](https://github.com/ramprakash-munugapati/ragram_core/blob/main/llm.py): `llm.py`

### Vector storage

- [Storage interface](https://github.com/ramprakash-munugapati/ragram_core/blob/main/adapters/base.py): `adapters/base.py`
- [Postgres adapter](https://github.com/ramprakash-munugapati/ragram_core/blob/main/adapters/postgres_adapter.py): `adapters/postgres_adapter.py`
- **PostgreSQL pgvector**

### Runtime setup

- [Settings](https://github.com/ramprakash-munugapati/ragram_core/blob/main/config.py): `config.py`

### Other components

- **User**
- **OpenAI API**
- **SentenceTransformers**

## Connections

- User → Streamlit UI: uses (evidence: `README.md`)
- Streamlit UI → RAG engine: queries and ingests (evidence: `README.md`)
- RAG engine → Text chunking: splits documents (evidence: `engine.py`)
- RAG engine → Embedding provider: embeds text (evidence: `engine.py`)
- RAG engine → Storage interface: stores and searches (evidence: `engine.py`)
- RAG engine → Grounding prompts: builds grounded context (evidence: `engine.py`)
- RAG engine → LLM client: synthesizes answers (evidence: `engine.py`)
- Settings → Embedding provider: configures provider (evidence: `embeddings.py`)
- Embedding provider → OpenAI embeddings: selects (evidence: `embeddings.py`)
- Embedding provider → HuggingFace embeddings: selects (evidence: `embeddings.py`)
- OpenAI embeddings → OpenAI API: requests vectors (evidence: `embeddings.py`)
- HuggingFace embeddings → SentenceTransformers: encodes locally (evidence: `embeddings.py`)
- LLM client → OpenAI synthesis: implements (evidence: `llm.py`)
- OpenAI synthesis → OpenAI API: requests completions (evidence: `llm.py`)
- Storage interface → Postgres adapter: implemented by (evidence: `adapters/postgres_adapter.py`)
- Postgres adapter → PostgreSQL pgvector: upserts and searches (evidence: `adapters/postgres_adapter.py`)
