Comprehensive evaluation and rationale for every foundational library, database engine, machine learning model, and framework chosen for the Agentic RAG Platform.
| Architectural Concern | Selected Technology | Primary Trade-off Rationale | Key Reference |
|---|---|---|---|
| Backend Runtime | Python 3.11 + FastAPI + Pydantic v2 | Async I/O concurrency, strict runtime typing, ML/PyTorch ecosystem synergy. | src/ |
| Unified Storage | PostgreSQL 16 + pgvector 0.7 + GIN |
Single datastore for relational RBAC, vector embeddings, and full-text search. | ADR-001 |
| Dense Embeddings | BAAI/bge-m3 (Local PyTorch) |
1024-dim dense geometry, multilingual (100+ languages), zero external API cost. | embeddings.md |
| Cross-Encoder Reranker | BAAI/bge-reranker-v2-m3 |
Joint query-document attention scoring; improves Recall@5 from 62.4% to 84.2%. | ADR-003 |
| Agent Orchestration | Custom State Machine | Pure Python deterministic state transitions; eliminates framework lock-in. | ADR-004 |
| LLM Synthesis Engine | OpenAI gpt-4o-mini + Provider Bridge |
High reasoning capability at low unit cost (~$0.0007/query); swappable via provider interface. | src/llm/provider.py |
| User Interface | Next.js 14 + React + Tailwind CSS | Server-side rendering, responsive conversational chat, citation inspection inspector. | apps/web/ |
| Distributed Telemetry | OpenTelemetry + Self-Hosted Langfuse | Vendor-neutral wire protocol; local trace sovereignty and LLM cost accounting. | ADR-007 |
| Low-Latency Cache | Redis 7 Alpine | In-memory key-value caching of embedding vectors, query results, and rate limits. | docker-compose.yml |
| Database Migrations | Alembic + SQLAlchemy 2.0 | Declarative asynchronous schema migrations with reversible downgrade operations. | alembic/ |
| Document Ingestion | Docling (PDF) + Trafilatura (HTML) | Layout-aware structural parsing of tables, headings, and Markdown conversion. | src/ingestion/loaders.py |
| Evaluation Framework | Ragas + Golden Benchmark | Automated CI quality gates measuring Faithfulness, Recall@K, and Hallucination rate. | rag-evaluation.md |
rag.access_matches()) and vector similarity search execute in a single atomic SQL query. Specialized vector databases require either syncing relational permissions to the external vector index or performing insecure post-retrieval filtering.pgvector 0.7, HNSW index construction and query latency (<15ms) easily satisfy production SLA demands for corporas under 10M chunks.src/agents/orchestrator.py) is implemented in <350 lines of explicit, typed Python code with four strict mathematical invariants (step ceiling, tool invocation cap, wall-clock timeout, SHA-256 loop detection).StreamingResponse. The client receives the initial token stream in <300ms, while verified citation metadata and trace attributes are transmitted in the final closing event frame.asyncio queues provide sufficient throughput without message broker operational overhead.