Skip to content

en Home

Rael Corrales edited this page Nov 17, 2026 · 1 revision

AI RAG Common Framework - Engineering Wiki

Welcome to the Official Architecture, Implementation, and Best Practices Wiki for ai-rag-common-framework.

This wiki is engineered as a definitive technical source of truth to empower developers and architects to implement production-grade generative AI systems at 100% capacity: from junior developers writing their first RAG pipeline to Staff and Principal Engineers designing mission-critical distributed AI platforms.


Learning Pathways by Engineering Role

flowchart TD
    Goal["What is your primary goal?"]
    
    Goal --> GettingStarted["Getting Started<br/><b>From Zero to Production</b>"]
    Goal --> Senior["Senior Pathway<br/><b>Architecture, Agents & APIs</b>"]
    Goal --> Staff["Staff Pathway<br/><b>Distributed Systems & FinOps</b>"]

    GettingStarted --> G1["• Quickstart (15 lines)<br/>• Setup & Environments (.env)<br/>• CLI (Doctor & REPL)<br/>• Glossary & Mental Models"]
    Senior --> S1["• FastAPI Gateway & Routes<br/>• Dual Memory in Agents<br/>• Namespaces & Multi-Tenancy<br/>• Testing & CI/CD ($0 APIs)"]
    Staff --> St1["• Latency Budgets (p95)<br/>• W3C OpenTelemetry Tracing<br/>• FinOps & Token Cost Tracking<br/>• Production Runbook & Triage"]
Loading

1. Getting Started (Building Solid Foundations)

  1. Quickstart: Your First RAG in 15 Lines: Build a fully functional, embedded RAG pipeline in minutes with zero database daemons.
  2. Installation, Configuration, and Environments: Modular feature bundles ([api], [mcp], [rag], [all]), environment variables, and settings precedence.
  3. CLI Interactive Guide and Playground: Master environment diagnostics with doctor, live terminal prototyping with repl, and scaffolding with init.
  4. Key Concepts, Glossary, and Mental Models: Tokens, Embeddings, BM25, Cosine Similarity, RRF, Cross-Encoders, and the RAG Triad formally explained.

2. Architecture, Components, and APIs (Senior Engineer)

  1. System Philosophy and Hexagonal Architecture: Clean Architecture, Zero-Bloat design, and Architectural Trade-off Matrix.
  2. Design Patterns in RAG and Agents: Factory, Strategy, Circuit Breaker, Proxy, Interceptor, and State Machine patterns.
  3. Data Anatomy and Lifecycle: Dual ingestion (FTS5 + Dense Vectors), GEMV BLAS, WAL concurrency, and online query lifecycle.
  4. Multi-Agent Systems and Orchestration Topologies: ReAct, Supervisor-Workers, deterministic StateGraph, and mitigation of agent failure modes.
  5. LLM Engine, Resilience, and Semantic Caching: Automatic failover, Structured Outputs, and Sub-millisecond Semantic Cache.
  6. Advanced RAG, Hybrid Search, and Reranking: Okapi BM25 + Dense Vectors fused via RRF, HyDE, MultiQuery, and Cross-Encoders.
  7. Autonomous Agents and StateGraph: ReAct loops, AgentBus, cyclic state machines, and Human-in-the-Loop (HITL) hooks.
  8. Model Context Protocol (MCP 2.x): Servers and Clients over stdio and SSE, dynamic tool mounting, and as_tool().
  9. Security, Guardrails, and Sandboxing: Ephemeral CodeInterpreter sandbox, PII sanitization, and Prompt Injection mitigation.
  10. FastAPI API Gateway and Routes: Production HTTP microservice, endpoints /query, /retrieve, /ingest, SSE streaming, and MCP auth.
  11. Conversational and Vector Memory: Short-term buffer preserving system prompts and long-term semantic VectorMemory.
  12. Collections and Multi-Tenancy: Logical partitioning with namespaces in SQLite vs physical multi-database isolation.
  13. Deterministic Testing, Mocking, and CI/CD ($0 APIs): Offline unit tests with MockEmbeddingProvider, pytest fixtures, and GitHub Actions.
  14. Migration Guide from LangChain and LlamaIndex: Direct class mapping, removing bloatware, and side-by-side code comparisons.

3. Production, Resilience, and Scale (Staff & Principal Engineer)

  1. Staff Engineer Guide: SLAs, Observabilidad, FinOps, and Production:
    • Latency Budgets Breakdown (p50, p95, p99).
    • FinOps governance with TokenCostTracker and tenant quotas.
    • Distributed telemetry with W3C traceparent context propagation and native Prometheus /metrics.
    • Continuous CI/CD evaluation using the RAG Triad and sentence-level hallucination scoring.
    • Enterprise Production Readiness Checklist.
  2. Production Troubleshooting and Runbook: Fast triage trees for RateLimits, 502 Bad Gateway, SQLite database locks, SSRF rejections, and MCP transport issues.
  3. Practical and Advanced Recipes: Self-healing code pipelines, FinOps caching shields, and < 100MB Docker microservices.

Quick Reference

  • Check out the API Cheat Sheet for copy-paste ready signatures, parameters, and snippets of all public classes and functions across the framework.

Master Table of Contents

Module Document Focus Area
Reference API Cheat Sheet Compact signatures, parameters, and snippets for the entire framework
01. Architecture 01. System Philosophy and Design Zero-Bloat principles, Ports & Adapters, Trade-off Matrix
01. Architecture 02. Design Patterns in RAG and Agents Factory, Strategy, Circuit Breaker, Proxy, HITL
01. Architecture 03. Data Anatomy and Lifecycle Dual indexing (FTS5 + Dense), GEMV BLAS, WAL concurrency
01. Architecture 04. Multi-Agent Systems and Topologies ReAct vs Supervisor vs StateGraph, loop mitigations
02. Getting Started 01. Quickstart: Your First RAG 15-line RAG pipeline with SQLiteVectorStore
02. Getting Started 02. Installation and Environments Optional bundles, .env guide, and Settings precedence
02. Getting Started 03. CLI Guide and Playground doctor, interactive repl, init scaffolding, and rag-mcp
02. Getting Started 04. Key Concepts and Glossary Tokens, Embeddings, BM25, RRF, Cross-Encoders, RAG Triad
03. Deep Dive 01. LLM Engine, Resilience & Cache Multi-provider, Failover, Structured Outputs, Cache
03. Deep Dive 02. Advanced RAG and Reranking FTS5 + Dense with RRF, HyDE, MultiQuery, Cross-Encoders
03. Deep Dive 03. Autonomous Agents & StateGraph ReAct, Supervisor-Worker, AgentBus, StateGraph, HITL
03. Deep Dive 04. Model Context Protocol (MCP) MCP 2.x Servers and Clients (stdio / SSE), as_tool()
03. Deep Dive 05. Security, Guardrails & Sandboxing Subprocess isolation, PII Sanitizer, Prompt Injection
03. Deep Dive 06. FastAPI Gateway and Routes create_app, RAG router, SSE streaming, exception mapping
03. Deep Dive 07. Conversational & Vector Memory ConversationBufferMemory, VectorMemory, associative recall
03. Deep Dive 08. Collections and Multi-Tenancy Logical namespaces in SQLite vs physical multi-database isolation
04. Patterns 01. Practical and Advanced Recipes Self-healing pipelines, Cost-Shield FinOps, Multi-Tenant
04. Patterns 02. Testing, Mocking, and CI/CD Offline unit tests with MockEmbeddingProvider
04. Patterns 03. Migration from LangChain & LlamaIndex Direct class mapping, reducing dependencies and lines of code
05. Production 01. Staff Engineer Guide Latency budgets, OpenTelemetry W3C, Prometheus, Evals
05. Production 02. Troubleshooting and Runbook Fast triage tree for RateLimits, 502, SQLite locks, SSRF

Core Philosophy in One Sentence

"Build with clean, strongly-typed, asynchronous primitives on top of Python's standard library and Pydantic, eliminating unnecessary abstractions to deliver auditable, deterministic, and ultra-low latency systems."

English Documentation | Documentación en Español


English Documentation (EN)


Documentación en Español (ES)

Clone this wiki locally