# sumitnemade/ragify architecture

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

- Interactive diagram: https://gitdiagram.com/sumitnemade/ragify
- Repository: https://github.com/sumitnemade/ragify

## Overview

#### Purpose and Entry Points
Ragify is a Python framework for assembling LLM context from documents, APIs, databases, and real-time feeds. Its public integration point is `ContextOrchestrator`, exported from `src/ragify/__init__.py` and implemented in `src/ragify/core.py`. Applications register source adapters, then asynchronously request ranked, conflict-resolved context.

The primary runnable product integration is the Streamlit/OpenAI RAG example at `examples/rag_chat_assistant/rag_chat_assistant.py`.

#### Orchestration Layer
`ContextOrchestrator` coordinates the request lifecycle: source registration, concurrent retrieval, downstream scoring/fusion, and returned context assembly.
- `src/ragify/core.py`
- `src/ragify/models.py`
- `src/ragify/exceptions.py`

This is the boundary between an LLM application and Ragify internals; callers provide a query and retrieval limits rather than invoking engines directly.

#### Source Adapter Boundary
A shared source abstraction separates orchestration from source-specific ingestion/retrieval. Implementations cover local documents, HTTP APIs, databases, and streaming/live systems.
- `src/ragify/sources/base.py`
- `src/ragify/sources/document.py`
- `src/ragify/sources/api.py`
- `src/ragify/sources/database.py`
- `src/ragify/sources/realtime.py`

Sources are intended to be processed concurrently. External-system connectivity and format handling remain inside these adapters.

#### Context Evaluation and Fusion
The scoring engine evaluates candidate relevance, while the fusion engine combines source results and detects/resolves contradictions using signals such as authority and freshness.
- `src/ragify/engines/scoring.py`
- `src/ragify/engines/fusion.py`
- `src/ragify/models.py`

The key control flow is: retrieved source chunks → relevance ranking → conflict resolution/fusion → coherent context with source-aware information for the consuming LLM workflow.

#### Storage, Search, and Cache
Persistent context handling is isolated behind storage components. Vector search is a pluggable infrastructure boundary supporting vector database backends; caching reduces repeated retrieval work.
- `src/ragify/engines/storage.py`
- `src/ragify/storage/vector_db.py`
- `src/ragify/storage/cache.py`

The README identifies ChromaDB, Pinecone, Weaviate, and FAISS as supported vector-store targets, with Redis and Memcached as cache options. The chat example specifically uses FAISS.

#### Live Updates
Update processing is a separate engine, enabling refreshed context rather than treating ingestion as a one-time batch operation.
- `src/ragify/engines/updates.py`
- `src/ragify/sources/realtime.py`

Real-time adapters form the boundary for WebSocket, MQTT, and Kafka-style inputs; update handling should feed changed material back into storage/indexing and subsequent retrieval.

#### Security, Privacy, and Compliance
Security concerns are implemented as storage-adjacent controls rather than delegated to callers: encryption/key handling and access control, privacy classification/anonymization, and regulatory compliance workflows.
- `src/ragify/storage/security.py`
- `src/ragify/storage/privacy.py`
- `src/ragify/storage/compliance.py`

These controls are material for deployments handling sensitive context and should sit on data persistence and retrieval paths.

#### Runtime and Packaging
The project is a Python package using the `src/` layout, with package metadata/install behavior in `pyproject.toml` and `setup.py`. Model artifacts for a random-forest-based capability are bundled under `models/`, indicating optional ML-backed scoring or ensemble behavior.
- `pyproject.toml`
- `setup.py`
- `models/ml_model_random_forest.joblib`

Main entry points: [`src/ragify/core.py`](https://github.com/sumitnemade/ragify/blob/master/src/ragify/core.py) (ContextOrchestrator), [`src/ragify/sources/base.py`](https://github.com/sumitnemade/ragify/blob/master/src/ragify/sources/base.py) (Source abstraction), [`src/ragify/engines/storage.py`](https://github.com/sumitnemade/ragify/blob/master/src/ragify/engines/storage.py) (Storage engine), [`src/ragify/engines/scoring.py`](https://github.com/sumitnemade/ragify/blob/master/src/ragify/engines/scoring.py) (Scoring engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public Integration"]
  node_chat_example["RAG chat example<br/>Streamlit/OpenAI app"]
  node_package_api["Package API<br/>Python export<br/>[__init__.py]"]
  node_orchestrator{{"ContextOrchestrator<br/>async coordinator<br/>[core.py]"}}
  node_exceptions["Error contracts<br/>exceptions<br/>[exceptions.py]"]
end

subgraph group_sources["Source Adapters"]
  node_source_base{{"Source abstraction<br/>adapter interface<br/>[base.py]"}}
  node_document_source["Document source<br/>source adapter<br/>[document.py]"]
  node_api_source["API source<br/>source adapter<br/>[api.py]"]
  node_database_source[("Database source<br/>source adapter<br/>[database.py]")]
  node_realtime_source["Real-time source<br/>live adapter<br/>[realtime.py]"]
end

subgraph group_processing["Context Processing"]
  node_models["Context models<br/>data contracts<br/>[models.py]"]
  node_scoring["Scoring engine<br/>relevance ranking<br/>[scoring.py]"]
  node_fusion["Fusion engine<br/>conflict resolution<br/>[fusion.py]"]
  node_updates["Update engine<br/>index refresh<br/>[updates.py]"]
  node_ml_model["Random forest model<br/>ML artifact"]
end

subgraph group_persistence["Storage &amp; Controls"]
  node_storage_engine["Storage engine<br/>persistence facade<br/>[storage.py]"]
  node_vector_db[("Vector search<br/>pluggable vector store<br/>[vector_db.py]")]
  node_cache["Retrieval cache<br/>cache backend<br/>[cache.py]"]
  node_security["Data protection<br/>security controls<br/>[security.py]"]
end

node_packaging["Package metadata<br/>Python packaging<br/>[pyproject.toml]"]

node_chat_example -->|"uses"| node_package_api
node_package_api -->|"exports"| node_orchestrator
node_orchestrator -->|"registers and queries"| node_source_base
node_source_base -->|"implemented by"| node_document_source
node_source_base -->|"implemented by"| node_api_source
node_source_base -->|"implemented by"| node_database_source
node_source_base -->|"implemented by"| node_realtime_source
node_orchestrator -->|"checks"| node_cache
node_orchestrator -->|"ranks candidates"| node_scoring
node_scoring -->|"ranked chunks"| node_fusion
node_fusion -->|"returns context"| node_models
node_orchestrator -->|"accepts query and limits"| node_models
node_scoring -.->|"optional model"| node_ml_model
node_storage_engine -->|"indexes and searches"| node_vector_db
node_storage_engine -->|"manages cache"| node_cache
node_security -->|"protects persistence"| node_storage_engine
node_orchestrator -->|"retrieves context"| node_storage_engine
node_realtime_source -->|"live changes"| node_updates
node_updates -->|"refreshes index"| node_storage_engine
node_packaging -.->|"installs"| node_package_api
node_orchestrator -.->|"raises"| node_exceptions

click node_chat_example "https://github.com/sumitnemade/ragify/blob/master/examples/rag_chat_assistant/rag_chat_assistant.py"
click node_package_api "https://github.com/sumitnemade/ragify/blob/master/src/ragify/__init__.py"
click node_orchestrator "https://github.com/sumitnemade/ragify/blob/master/src/ragify/core.py"
click node_models "https://github.com/sumitnemade/ragify/blob/master/src/ragify/models.py"
click node_exceptions "https://github.com/sumitnemade/ragify/blob/master/src/ragify/exceptions.py"
click node_source_base "https://github.com/sumitnemade/ragify/blob/master/src/ragify/sources/base.py"
click node_document_source "https://github.com/sumitnemade/ragify/blob/master/src/ragify/sources/document.py"
click node_api_source "https://github.com/sumitnemade/ragify/blob/master/src/ragify/sources/api.py"
click node_database_source "https://github.com/sumitnemade/ragify/blob/master/src/ragify/sources/database.py"
click node_realtime_source "https://github.com/sumitnemade/ragify/blob/master/src/ragify/sources/realtime.py"
click node_scoring "https://github.com/sumitnemade/ragify/blob/master/src/ragify/engines/scoring.py"
click node_fusion "https://github.com/sumitnemade/ragify/blob/master/src/ragify/engines/fusion.py"
click node_updates "https://github.com/sumitnemade/ragify/blob/master/src/ragify/engines/updates.py"
click node_storage_engine "https://github.com/sumitnemade/ragify/blob/master/src/ragify/engines/storage.py"
click node_vector_db "https://github.com/sumitnemade/ragify/blob/master/src/ragify/storage/vector_db.py"
click node_cache "https://github.com/sumitnemade/ragify/blob/master/src/ragify/storage/cache.py"
click node_security "https://github.com/sumitnemade/ragify/blob/master/src/ragify/storage/security.py"
click node_ml_model "https://github.com/sumitnemade/ragify/blob/master/models/ml_model_random_forest.joblib"
click node_packaging "https://github.com/sumitnemade/ragify/blob/master/pyproject.toml"

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_chat_example,node_package_api,node_orchestrator,node_exceptions toneBlue
class node_source_base,node_document_source,node_api_source,node_database_source,node_realtime_source toneAmber
class node_models,node_scoring,node_fusion,node_updates,node_ml_model toneMint
class node_storage_engine,node_vector_db,node_cache,node_security toneRose
class node_packaging toneNeutral
```

## Components

### Public Integration

- [RAG chat example](https://github.com/sumitnemade/ragify/blob/master/examples/rag_chat_assistant/rag_chat_assistant.py): Streamlit/OpenAI app · Runnable application integration. · `examples/rag_chat_assistant/rag_chat_assistant.py`
- [Package API](https://github.com/sumitnemade/ragify/blob/master/src/ragify/__init__.py): Python export · Exports the public orchestrator. · `src/ragify/__init__.py`
- [ContextOrchestrator](https://github.com/sumitnemade/ragify/blob/master/src/ragify/core.py): async coordinator · Registers sources and assembles requested context. · `src/ragify/core.py`
- [Error contracts](https://github.com/sumitnemade/ragify/blob/master/src/ragify/exceptions.py): exceptions · `src/ragify/exceptions.py`

### Source Adapters

- [Source abstraction](https://github.com/sumitnemade/ragify/blob/master/src/ragify/sources/base.py): adapter interface · Isolates orchestration from external retrieval systems. · `src/ragify/sources/base.py`
- [Document source](https://github.com/sumitnemade/ragify/blob/master/src/ragify/sources/document.py): source adapter · `src/ragify/sources/document.py`
- [API source](https://github.com/sumitnemade/ragify/blob/master/src/ragify/sources/api.py): source adapter · `src/ragify/sources/api.py`
- [Database source](https://github.com/sumitnemade/ragify/blob/master/src/ragify/sources/database.py): source adapter · `src/ragify/sources/database.py`
- [Real-time source](https://github.com/sumitnemade/ragify/blob/master/src/ragify/sources/realtime.py): live adapter · Handles WebSocket, MQTT, and Kafka-style inputs. · `src/ragify/sources/realtime.py`

### Context Processing

- [Context models](https://github.com/sumitnemade/ragify/blob/master/src/ragify/models.py): data contracts · Shared request, candidate, and context structures. · `src/ragify/models.py`
- [Scoring engine](https://github.com/sumitnemade/ragify/blob/master/src/ragify/engines/scoring.py): relevance ranking · Ranks retrieved candidate chunks. · `src/ragify/engines/scoring.py`
- [Fusion engine](https://github.com/sumitnemade/ragify/blob/master/src/ragify/engines/fusion.py): conflict resolution · Combines ranked results using authority and freshness. · `src/ragify/engines/fusion.py`
- [Update engine](https://github.com/sumitnemade/ragify/blob/master/src/ragify/engines/updates.py): index refresh · Feeds changed live material back into persistence. · `src/ragify/engines/updates.py`
- [Random forest model](https://github.com/sumitnemade/ragify/blob/master/models/ml_model_random_forest.joblib): ML artifact · Optional ML-backed scoring capability. · `models/ml_model_random_forest.joblib`

### Storage & Controls

- [Storage engine](https://github.com/sumitnemade/ragify/blob/master/src/ragify/engines/storage.py): persistence facade · Coordinates persistent context handling. · `src/ragify/engines/storage.py`
- [Vector search](https://github.com/sumitnemade/ragify/blob/master/src/ragify/storage/vector_db.py): pluggable vector store · Supports FAISS and external vector database backends. · `src/ragify/storage/vector_db.py`
- [Retrieval cache](https://github.com/sumitnemade/ragify/blob/master/src/ragify/storage/cache.py): cache backend · Avoids repeated retrieval work. · `src/ragify/storage/cache.py`
- [Data protection](https://github.com/sumitnemade/ragify/blob/master/src/ragify/storage/security.py): security controls · Encryption, access control, privacy, and compliance controls. · `src/ragify/storage/security.py`

### Other components

- [Package metadata](https://github.com/sumitnemade/ragify/blob/master/pyproject.toml): Python packaging · `pyproject.toml`

## Connections

- RAG chat example → Package API: uses
- Package API → ContextOrchestrator: exports
- ContextOrchestrator → Source abstraction: registers and queries
- Source abstraction → Document source: implemented by
- Source abstraction → API source: implemented by
- Source abstraction → Database source: implemented by
- Source abstraction → Real-time source: implemented by
- ContextOrchestrator → Retrieval cache: checks
- ContextOrchestrator → Scoring engine: ranks candidates
- Scoring engine → Fusion engine: ranked chunks
- Fusion engine → Context models: returns context
- ContextOrchestrator → Context models: accepts query and limits
- Scoring engine → Random forest model: optional model
- Storage engine → Vector search: indexes and searches
- Storage engine → Retrieval cache: manages cache
- Data protection → Storage engine: protects persistence
- ContextOrchestrator → Storage engine: retrieves context
- Real-time source → Update engine: live changes
- Update engine → Storage engine: refreshes index
- Package metadata → Package API: installs
- ContextOrchestrator → Error contracts: raises
