A production-grade, agentic Retrieval-Augmented Generation (RAG) system designed for procurement document processing and analysis.
This system provides intelligent document processing and retrieval capabilities that:
- Continuously learns from users through feedback, edits, and link confirmations
- Uses IBM Granite-Docling-258M for advanced document parsing and conversion
- Leverages OpenAI embeddings for high-quality vectorization
- Stores vectors in ChromaDB and metadata in PostgreSQL
- Implements contextual retrieval with three-hop search pattern
- Supports multi-tenant isolation for enterprise deployment
- API Gateway: FastAPI-based REST API with authentication
- Ingestion Service: Document upload, parsing, chunking, and embedding
- Retrieval Service: Three-hop retrieval (RFQ → Offers → Offer Chunks)
- Agent Orchestrator: Specialized agents for different tasks
- Feedback Service: Continuous learning from user interactions
- Storage Layer: PostgreSQL + ChromaDB + Object Storage
Upload → Granite-Docling → Contextual Chunking → OpenAI Embeddings → ChromaDB/PostgreSQL
Query → RFQ Search → Link Traversal → Chunk Retrieval → LLM Synthesis → Response
- Docker and Docker Compose
- Python 3.11+
- Git
-
Clone the repository
git clone <repository-url> cd agentic-contextual-rag
-
Set up environment variables
cp .env.example .env # Edit .env with your configuration -
Start development environment
docker-compose up -d
-
Install dependencies
pip install -e ".[dev]" -
Run database migrations
alembic upgrade head
-
Start the development server
uvicorn agentic_rag.api.main:app --reload
The API will be available at http://localhost:8000
agentic-contextual-rag/
├── src/agentic_rag/ # Main application code
│ ├── api/ # REST API endpoints
│ ├── services/ # Business logic and orchestration
│ ├── adapters/ # External service integrations
│ └── models/ # Data models and database schemas
├── tests/ # Test suites
│ ├── unit/ # Unit tests
│ ├── integration/ # Integration tests
│ └── e2e/ # End-to-end tests
├── ops/ # Operations and deployment
│ ├── docker/ # Docker configurations
│ ├── k8s/ # Kubernetes manifests
│ ├── helm/ # Helm charts
│ └── grafana/ # Monitoring dashboards
├── sprints/ # Sprint planning and documentation
└── docs/ # Additional documentation
- Backend: Python 3.11+, FastAPI, SQLAlchemy, Alembic
- Databases: PostgreSQL 14+, ChromaDB, Redis
- AI/ML: OpenAI GPT-4, text-embedding-3-large, IBM Granite-Docling-258M
- Storage: MinIO (S3-compatible), Object Storage
- Infrastructure: Docker, Kubernetes, Helm
- Monitoring: Prometheus, Grafana, OpenTelemetry
The system supports multi-tenant deployment with:
- Row-Level Security (RLS) in PostgreSQL
- Tenant-isolated collections in ChromaDB
- Secure API access with tenant-scoped authentication
- Data isolation across all storage layers
- Support for PDFs, images, Office documents
- Advanced layout analysis and structure extraction
- Intelligent chunking with contextual information
- Automatic document linking and relationship detection
- Three-hop search pattern for precision
- Contextual query processing
- LLM-based result reranking
- Citation-rich answer synthesis
- User feedback collection and processing
- Continuous improvement through learning algorithms
- Quality metrics and analytics
- Automated system optimization
- JWT-based authentication and authorization
- Role-based access control (RBAC)
- Data encryption at rest and in transit
- PII/sensitive data redaction
- Comprehensive audit logging
- Application metrics with Prometheus
- Distributed tracing with OpenTelemetry
- Log aggregation and analysis
- Custom dashboards and alerting
- Performance monitoring and optimization
Run the test suite:
# Unit tests
pytest tests/unit
# Integration tests
pytest tests/integration
# End-to-end tests
pytest tests/e2e
# All tests with coverage
pytest --cov=agentic_rag tests/- Project Documentation - Complete technical specification
- Sprint Planning - Development roadmap and sprint breakdown
- API Documentation - Interactive API documentation (when running)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue in the GitHub repository
- Check the documentation
- Review the sprint planning for implementation details
The project is organized into 7 sprints over 14 weeks:
- Sprint 1: Foundation & Core Infrastructure
- Sprint 2: Document Ingestion Pipeline
- Sprint 3: Basic Retrieval & Vector Search
- Sprint 4: Contextual Retrieval & Three-Hop Search
- Sprint 5: Agent Orchestration & Advanced Features
- Sprint 6: Feedback System & Learning
- Sprint 7: Production Deployment & Observability
See sprints/README.md for detailed sprint planning and progress tracking.