Skip to content
Rael Corrales edited this page Nov 26, 2026 · 6 revisions

AI RAG Common Framework - Wiki Home

Welcome to the Official Engineering & Architecture Wiki for ai-rag-common-framework.

Bienvenido a la Wiki Oficial de Arquitectura e Ingeniería de ai-rag-common-framework.


Language Hub / Selector de Idioma

Select your preferred language to explore the complete documentation suite:

Language / Idioma Home & Learning Paths Master Index (Índice Completo) API Cheat Sheet
English English Wiki (en/README.md) English Index (en/INDEX.md) API Cheat Sheet
Español Wiki en Español (es/README.md) Índice en Español (es/INDEX.md) Hoja de Referencia

High-Level System Architecture

ai-rag-common-framework is a zero-bloat, strongly typed foundation library for building production-grade RAG systems, autonomous multi-agent teams, and Model Context Protocol (MCP 2.x) microservices:

flowchart TD
    %% Global Class Definitions
    classDef clientStyle fill:#eff6ff,stroke:#2563eb,stroke-width:1.5px,color:#1e3a8a,rx:8px,ry:8px;
    classDef secStyle fill:#fff1f2,stroke:#e11d48,stroke-width:1.5px,color:#881337,rx:8px,ry:8px;
    classDef coreStyle fill:#ecfdf5,stroke:#059669,stroke-width:1.5px,color:#064e3b,rx:8px,ry:8px;
    classDef infraStyle fill:#fffbeb,stroke:#d97706,stroke-width:1.5px,color:#78350f,rx:8px,ry:8px;

    subgraph Clients ["  🌐 1. Driving Clients (Inbound Layer)  "]
        CLI["💻 <b>CLI Tooling</b><br/><small>ai-rag repl • doctor • init</small>"]:::clientStyle
        FastAPI["⚡ <b>FastAPI Gateway</b><br/><small>REST Endpoints & SSE Streaming</small>"]:::clientStyle
        MCPClient["🔌 <b>Model Context Protocol</b><br/><small>stdio & SSE Client / Server</small>"]:::clientStyle
    end

    subgraph Security ["  🛡️ 2. Edge Security & Guardrails Layer  "]
        Guard["🛡️ <b>PromptGuardrail</b><br/><small>Jailbreak & Delimiter Breakout Defense</small>"]:::secStyle
        PII["🔒 <b>PIISanitizer</b><br/><small>In-Flight PII Redaction & Luhn Check</small>"]:::secStyle
        SSRF["🌐 <b>SSRF Firewall</b><br/><small>DNS Rebinding & Cloud Metadata Defense</small>"]:::secStyle
    end

    subgraph CoreEngine ["  🧠 3. Domain Core Engine Layer  "]
        RAG["🔍 <b>RAGEngine</b><br/><small>BM25 + Dense + RRF + Cross-Encoder</small>"]:::coreStyle
        Agents["🤖 <b>Autonomous Agents</b><br/><small>ReAct Loops & Supervisor Teams</small>"]:::coreStyle
        StateGraph["🔀 <b>StateGraph Workflows</b><br/><small>Deterministic Cyclic State Machines</small>"]:::coreStyle
        Memory["🧠 <b>Dual Memory</b><br/><small>Sliding Buffer + Vector Memory</small>"]:::coreStyle
        Cache["⚡ <b>SemanticCache</b><br/><small>O(1) Exact Fast-Path + Cosine Sim</small>"]:::coreStyle
    end

    subgraph Infrastructure ["  💾 4. Driven Infrastructure & Adapters  "]
        Storage[("💾 <b>SQLiteVectorStore</b><br/><small>FTS5 Lexical + BLAS GEMV</small>")]:::infraStyle
        LLMs["🧠 <b>Unified LLM Engine</b><br/><small>Gemini • OpenAI • Claude • Ollama</small>"]:::infraStyle
        Sandbox["📦 <b>CodeInterpreter Sandbox</b><br/><small>Isolated Ephemeral Subprocess</small>"]:::infraStyle
        Telemetry["📊 <b>Observability & FinOps</b><br/><small>TokenCostTracker • Prometheus • OTel</small>"]:::infraStyle
    end

    Clients ==>|Inbound Requests| Security
    Security ==>|Sanitized Inputs| CoreEngine
    CoreEngine ==>|Operations & Storage| Infrastructure

    style Clients fill:#f8fafc,stroke:#94a3b8,stroke-width:2px,stroke-dasharray: 4 4;
    style Security fill:#fdf2f8,stroke:#f472b6,stroke-width:2px,stroke-dasharray: 4 4;
    style CoreEngine fill:#f0fdf4,stroke:#4ade80,stroke-width:2px,stroke-dasharray: 4 4;
    style Infrastructure fill:#fefce8,stroke:#facc15,stroke-width:2px,stroke-dasharray: 4 4;
Loading

Direct Navigation by Subject

flowchart LR
    classDef homeStyle fill:#f8fafc,stroke:#475569,stroke-width:2px,color:#0f172a,rx:8px,ry:8px;
    classDef catStyle fill:#e0f2fe,stroke:#0284c7,stroke-width:1.5px,color:#0369a1,rx:8px,ry:8px;
    classDef itemStyle fill:#ffffff,stroke:#cbd5e1,stroke-width:1px,color:#334155,rx:6px,ry:6px;

    Home["🏛️ <b>Wiki Home</b><br/><small>Main Hub</small>"]:::homeStyle

    Home --> GS["🚀 <b>Getting Started</b>"]:::catStyle
    Home --> Arch["📐 <b>Architecture</b>"]:::catStyle
    Home --> Impl["⚙️ <b>Deep Dives</b>"]:::catStyle
    Home --> Recipes["🧪 <b>Recipes</b>"]:::catStyle
    Home --> Staff["👔 <b>Staff & Production</b>"]:::catStyle

    GS --> G1["• Quickstart in 15 Lines<br/>• Setup & .env Config<br/>• CLI Doctor & REPL<br/>• Mental Models & Glossary"]:::itemStyle
    Arch --> A1["• Philosophy & Trade-offs<br/>• Clean RAG Design Patterns<br/>• Data Anatomy & WAL<br/>• Multi-Agent Topologies"]:::itemStyle
    Impl --> I1["• LLM Resilience & Caching<br/>• Hybrid BM25 + Dense RRF<br/>• ReAct & StateGraph<br/>• MCP 2.x Client & Server<br/>• FastAPI Gateway & SSE<br/>• Namespaces & Multi-Tenancy"]:::itemStyle
    Recipes --> R1["• Self-Healing Pipelines<br/>• FinOps Cost Shields<br/>• Deterministic Offline Tests<br/>• LangChain Migration"]:::itemStyle
    Staff --> S1["• Latency Budgets (p95)<br/>• TokenCostTracker (O(1))<br/>• Prometheus & OpenTelemetry<br/>• RAG Triad Evaluations<br/>• Incident Triage Runbook"]:::itemStyle
Loading

Key Highlights & Capabilities

  • Zero-Bloat Philosophy: No 12-layer inheritance trees, no magic prompt templates, no dependency hell. Native Python standard library + Pydantic V2.
  • Embedded Storage: ACID-compliant SQLiteVectorStore with full-text search (FTS5) and BLAS GEMV vector acceleration—zero external database daemons required.
  • Model Context Protocol (MCP 2.x): Full native implementation of MCP servers and clients over stdio and SSE.
  • Bulletproof Resilience: Multi-provider fallback chain (FallbackLLMClient) automatically circuit-breaks across OpenAI, Gemini, Anthropic, and local Ollama models.
  • Enterprise FinOps & Observability: Real-time token and dollar tracking (TokenCostTracker), native Prometheus /metrics, and W3C traceparent OpenTelemetry distributed tracing.

Quick Links to Most Popular Articles

English Documentation | Documentación en Español


English Documentation (EN)


Documentación en Español (ES)

Clone this wiki locally