Metadata-Version: 2.4
Name: atlas-ragkit
Version: 1.2.11
Summary: Atlas — Local-First RAG Engineering Platform
Author: Rishi Bhanushali
License: MIT
Project-URL: Homepage, https://atlas-steel-nu-90.vercel.app/
Project-URL: Documentation, https://atlas-steel-nu-90.vercel.app/
Project-URL: Repository, https://github.com/bhanushali222/atlas
Project-URL: Issues, https://github.com/bhanushali222/atlas/issues
Keywords: rag,llm,ai,local,retrieval,augmented,generation,nlp
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi>=0.100.0
Requires-Dist: uvicorn>=0.22.0
Requires-Dist: python-multipart>=0.0.6
Requires-Dist: typer>=0.9.0
Requires-Dist: rich>=13.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: pymupdf>=1.23.0
Requires-Dist: python-docx>=1.1.0
Requires-Dist: beautifulsoup4>=4.12.0
Requires-Dist: markdown-it-py>=3.0.0
Requires-Dist: gitpython>=3.1.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: faiss-cpu>=1.7.4
Requires-Dist: rank-bm25>=0.2.2
Requires-Dist: groq>=0.9.0
Requires-Dist: tiktoken>=0.7.0
Requires-Dist: scikit-learn>=1.2.0
Requires-Dist: sentence-transformers>=2.2.2
Requires-Dist: chromadb>=0.4.0
Requires-Dist: umap-learn>=0.5.3
Dynamic: license-file

# ⚡ Atlas RAGKit — Local-First RAG Engineering Platform

<div align="center">

[![PyPI version](https://img.shields.io/pypi/v/atlas-ragkit?color=06b6d4&style=flat-square)](https://pypi.org/project/atlas-ragkit/)
[![Python](https://img.shields.io/pypi/pyversions/atlas-ragkit?color=3b82f6&style=flat-square)](https://pypi.org/project/atlas-ragkit/)
[![FastAPI](https://img.shields.io/badge/FastAPI-0.100+-009688?style=flat-square&logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
[![CI](https://img.shields.io/github/actions/workflow/status/bhanushali222/atlas/publish.yml?branch=main&label=CI&style=flat-square)](https://github.com/bhanushali222/atlas/actions/workflows/publish.yml)

**Atlas** is a **local-first, zero-cloud** Retrieval-Augmented Generation (RAG) engineering workbench. Ingest documents, benchmark chunking strategies, visualize embeddings in interactive 3D, execute multi-stage RAG pipelines, and quantitatively evaluate output quality — completely offline on your machine with zero data leakage.

[🌐 **Documentation Website**](https://atlas-steel-nu-90.vercel.app/)

</div>

---

## ✨ Key Features

| Capability | Description |
|---|---|
| 📄 **Document Ingestion** | Ingest PDF, DOCX, PPTX, HTML, Markdown, and source code files with automatic content hashing. |
| 🔪 **Chunking Lab** | Benchmark 6 chunking algorithms side-by-side: `fixed_size`, `recursive_character`, `semantic`, `markdown_structure`, `sentence_window`, and `code_aware`. |
| 🧬 **Embedding Studio** | Project high-dimensional chunk embeddings into an interactive 3D point cloud using UMAP (with automatic PCA fallback) to visually inspect semantic cluster density and retrieval collisions. |
| 🚀 **Pipeline Execution** | Execute declarative YAML-based RAG pipelines spanning Chunking, Embedding, Retrieval (Dense FAISS, Lexical BM25, Chroma, or Hybrid), Cross-Encoder Reranking, Context Synthesis, and Generation. |
| 💬 **Conversational RAG** | Chat with indexed documents using real-time retrieval citations, configurable history depth, and per-turn latency and token profiling. |
| 📊 **RAG Triad Evaluation** | Compute objective quality scores: Context Relevance, Groundedness/Faithfulness, and Answer Relevance. |
| 🔌 **Plugin Architecture** | Extensible architecture leveraging Python `entry_points` (`atlas.chunkers`, `atlas.embeddings`, `atlas.retrievers`, `atlas.rerankers`, `atlas.evaluators`, `atlas.llm`). |
| 🔑 **Universal Multi-LLM** | Connect local offline models (Ollama, LM Studio) or cloud inference providers (Groq, OpenAI, Anthropic Claude, Google Gemini) with resilient rate-limit retries. |

---

## 🏗️ System Architecture

### 1. High-Level System Topology & Component Interaction

```mermaid
flowchart TD
    User["👤 Developer / User"]
    CLI["⚡ atlas CLI\n(atlas_cli.main:app)"]
    Server["🌐 FastAPI Server\n(atlas_server.main:app)"]
    SPA["💻 Web Dashboard SPA\n(atlas_server/static/index.html)"]
    DB[("🗄️ SQLite Database\n(atlas.db)")]

    subgraph CoreEngine["🧠 Atlas Core Engine (atlas_core)"]
        Ingestion["📄 Ingestion Engine\n(parsers.DocumentIngestionEngine)"]
        ChunkLab["🔪 Chunking Lab\n(studio_context.chunking_lab)"]
        EmbedStudio["🧬 Embedding Studio\n(studio_context.embedding_studio)"]
        PipelineExec["🚀 Execution Engine\n(execution_context.services)"]
        ChatSvc["💬 Chat Service\n(chat_context.services)"]
        StorageProvider["💾 Storage Provider\n(providers.storage.sqlite)"]
        Registry["🔌 Plugin Registry\n(registry.plugin_registry)"]
    end

    subgraph SDKPlugins["🧩 Atlas SDK Plugins (atlas_sdk)"]
        Chunkers["Chunkers\n(fixed, recursive, semantic, md, code, window)"]
        Embedders["Embeddings\n(sentence-transformers)"]
        Retrievers["Retrievers\n(FAISS dense, BM25, Chroma, Hybrid)"]
        Rerankers["Rerankers\n(cross-encoder)"]
        LLM["LLM Providers\n(Groq, OpenAI, Anthropic, Gemini, Ollama)"]
        Evaluators["Evaluators\n(RAG Triad: context, faith, answer)"]
    end

    User -->|"atlas server"| CLI
    CLI -->|"boots server & opens browser"| Server
    User <-->|"interacts via browser (HTTP / REST)"| SPA
    SPA <-->|"REST API (/api/v1/*)"| Server

    Server -->|"orchestrates"| Ingestion
    Server -->|"orchestrates"| ChunkLab
    Server -->|"orchestrates"| EmbedStudio
    Server -->|"orchestrates"| PipelineExec
    Server -->|"orchestrates"| ChatSvc

    PipelineExec -->|"discovers plugins"| Registry
    ChunkLab -->|"discovers plugins"| Registry
    EmbedStudio -->|"discovers plugins"| Registry

    Registry -->|"loads via entry-points"| Chunkers
    Registry -->|"loads via entry-points"| Embedders
    Registry -->|"loads via entry-points"| Retrievers
    Registry -->|"loads via entry-points"| Rerankers
    Registry -->|"loads via entry-points"| LLM
    Registry -->|"loads via entry-points"| Evaluators

    PipelineExec -->|"persists runs & traces"| StorageProvider
    ChatSvc -->|"persists turns & metrics"| StorageProvider
    StorageProvider <-->|"reads & writes"| DB
```

---

### 2. End-to-End Pipeline Execution Sequence

```mermaid
sequenceDiagram
    autonumber
    actor User as User / Web UI
    participant Ingest as Document Ingestion
    participant Chunker as Chunker Plugin
    participant Embedder as Embedding Provider
    participant Store as Vector Store / Retriever
    participant Reranker as Reranker Plugin
    participant Context as Context Builder
    participant LLM as LLM Provider (Groq / Local)
    participant Storage as SQLite & Trace Storage

    User->>Ingest: Ingest Document (PDF/MD/TXT/HTML/DOCX/Code)
    Ingest->>Ingest: Compute Content Hash (sha256)
    Ingest->>Chunker: Pass Extracted Text & Metadata
    Chunker->>Chunker: Split Text (Fixed/Recursive/Semantic/Window/Code)
    Chunker->>Embedder: Pass Chunks
    Embedder->>Embedder: Generate Vector Embeddings (384-dim)
    Embedder->>Store: Upsert Chunks & Vectors (FAISS/Chroma/BM25)
    
    User->>Store: Query (Natural Language Prompt)
    Store->>Store: Retrieve Top-K Candidate Chunks (Dense/Sparse/Hybrid)
    Store->>Reranker: Pass Candidate Chunks (Optional Stage)
    Reranker->>Reranker: Cross-Encoder Score & Filter Top-N Chunks
    Reranker->>Context: Pass Reranked Scored Chunks
    
    Context->>Context: Deduplicate & Assemble Context Window Prompt
    Context->>LLM: Send System + Context + Query Prompt
    LLM->>LLM: Generate Answer & Token Usage Metrics
    LLM->>Storage: Save Run Record & Scores to atlas.db
    LLM->>Storage: Write Event Trace Log to traces/<run_id>.jsonl
    Storage-->>User: Return Generated Response & Latency Metrics
```

---

### 3. Module & Package Dependencies

```mermaid
flowchart LR
    CLI["atlas-cli\n(CLI entrypoint & workspace init)"]
    Server["atlas-server\n(FastAPI endpoints & SPA static files)"]
    Core["atlas-core\n(Domain models, engines & services)"]
    SDK["atlas-sdk-python\n(Interfaces & plugin implementations)"]
    Scripts["scripts/\n(dev_server & build_check)"]
    Tests["tests/\n(Unit & API test suite)"]
    Website["website/\n(Marketing landing page - React/Vite)"]

    CLI --> Server
    CLI --> Core
    Server --> Core
    Server --> SDK
    Core --> SDK
    Scripts --> Server
    Scripts --> Core
    Tests --> Server
    Tests --> Core
    Tests --> SDK
```

---

### 4. Input Modalities & Ingestion Processing

| Input Type | Extension / Source | Parser Engine | Output Metadata |
|---|---|---|---|
| **PDF Document** | `.pdf` | `PyMuPDF` (`fitz`) | `page_count`, `mime_type`, `content_hash` |
| **Word Document** | `.docx` | `python-docx` | `paragraph_count`, `mime_type`, `content_hash` |
| **HTML Webpage** | `.html`, `.htm` | `BeautifulSoup4` | `title`, `mime_type`, `content_hash` |
| **Markdown / Text** | `.md`, `.txt` | Native parser | `char_count`, `mime_type`, `content_hash` |
| **Source Code** | `.py`, `.js`, `.rs`, `.go` | `CodeAwareChunker` | `block_index`, `line_count`, `content_hash` |
| **Git Repository** | `https://github.com/...` | `GitPython` | `repo_name`, `file_tree`, `content_hash` |
| **Custom Pipeline** | `pipelines/*.yaml` | `PipelineConfig` | `config_hash` (`sha256:...`), `steps` |

---

### 5. Storage & Persistence Layout

```mermaid
graph LR
    subgraph Config ["Pipeline Configuration"]
        P1["Stage 1: Chunk (fixed / recursive / semantic / window / code)"]
        P2["Stage 2: Embed (bge-small / e5-small / MiniLM)"]
        P3["Stage 3: Retrieve (dense / chroma / bm25 / hybrid / parent_doc)"]
        P4["Stage 4: Rerank (cross_encoder ms-marco-MiniLM-L-6-v2)"]
        P5["Stage 5: Context Assembly (deduplication & windowing)"]
        P6["Stage 6: Generate (Groq / Ollama / OpenAI / Claude / Gemini)"]
    end

    subgraph StorageLayout ["Workspace Storage Layer"]
        D1["atlas.yaml (Workspace Config)"]
        D2["atlas.db (SQLite Database: runs, chats, embeddings, evaluations)"]
        D3["pipelines/ (YAML Pipeline Specifications)"]
        D4[".atlas/indexes/ (FAISS & Chroma Vector Files)"]
        D5[".atlas/traces/ (JSONL Event Trace Logs)"]
        D6[".atlas/evaluations/ (RAG Triad Evaluation Results)"]
    end

    Config --> D3
    D3 --> D2
    D3 --> D4
    D3 --> D5
    D3 --> D6
```

---

## 📁 Repository Structure

```
atlas/
├── atlas-cli/                  # Command-line interface package
│   ├── atlas_cli/
│   │   ├── main.py             # CLI dispatcher (`atlas server`, banner, workspace scaffold)
│   │   └── templates/          # Bundled workspace templates copied on init
│   │       ├── demo_sandbox/   # Demo documents (PDF, DOCX, PPTX, HTML, code, markdown)
│   │       └── pipelines/      # 8 built-in pipeline presets (hybrid, precision, code, etc.)
│   └── pyproject.toml
│
├── atlas-core/                 # Bounded context services & domain models
│   ├── atlas_core/
│   │   ├── domain/             # Pydantic schemas (PipelineConfig, Run, Chat, Evaluation)
│   │   ├── contexts/           # Bounded contexts (ingestion, execution, studio, chat)
│   │   ├── providers/storage/  # SQLite persistence provider
│   │   └── registry/           # Dynamic importlib entry-point plugin registry
│   └── pyproject.toml
│
├── atlas-sdk-python/           # Plugin protocols & reference implementations
│   ├── atlas_sdk/
│   │   ├── interfaces.py       # Plugin ABCs (BaseChunker, BaseRetriever, BaseLLM, etc.)
│   │   ├── chunkers/           # 6 chunkers (fixed, recursive, semantic, md, code, window)
│   │   ├── embeddings/         # SentenceTransformers embedding provider
│   │   ├── retrievers/         # FAISS dense, BM25, ChromaDB, Hybrid, ParentDocument
│   │   ├── rerankers/          # Cross-encoder semantic reranker
│   │   ├── evaluators/         # RAG Triad evaluators (context, faith, answer relevance)
│   │   └── llm/                # Multi-LLM provider factory with rate-limit retry backoff
│   └── pyproject.toml
│
├── atlas-server/               # Web API server & embedded SPA
│   ├── atlas_server/
│   │   ├── main.py             # FastAPI REST routes, service loader & static mount
│   │   └── static/             # Bundled single-page UI (index.html)
│   └── pyproject.toml
│
├── docs/                       # Specifications, guides, blueprints, & installation
│   ├── INSTALL.md              # Installation & setup guide
│   └── architecture.md         # System architecture & lifecycle documentation
│
├── pipelines/                  # Workspace pipeline YAML configs
├── scripts/                    # Development server and distribution verification scripts
├── tests/                      # Automated test suite (pytest)
├── website/                    # Public marketing site (React + Vite + Tailwind CSS)
└── pyproject.toml              # Unified monorepo build manifest (atlas-ragkit)
```

---

## 📄 License

This project is licensed under the [MIT License](LICENSE).
