This is a fully operational Intelligent Agentic RAG (Retrieval-Augmented Generation) System built with FastAPI and LangGraph. The system provides advanced document classification, ontological mapping, and comparative analysis capabilities for PDF documents. It uses AI agents to perform multi-step reasoning for intelligent document retrieval, analysis, and cross-document comparison.
The system integrates multiple AI services and frameworks to create a comprehensive document intelligence platform that can understand, classify, and analyze documents across HealthCare Benefits domain while maintaining semantic relationships through ontological structures.
- Static Web Interface: Bootstrap-based responsive UI with JavaScript for dynamic interactions
- Real-time Updates: Event-driven interface with modals for loading states and error handling
- Document Management: Interactive document list with selection capabilities for comparison
- Progressive Enhancement: Fallback support for various browser capabilities
- FastAPI Framework: Asynchronous web framework with automatic API documentation
- LangGraph Agents: Multi-step reasoning agents using state graphs for complex workflows
- Service-Oriented Design: Modular services for PDF parsing, document classification, chunking, and vector operations
- Dependency Injection: FastAPI dependency system for service management and lifecycle
- RAG Agent: Multi-step retrieval and reasoning using LangGraph state machines
- Comparative Agent: Cross-document analysis with structured comparison workflows
- Agentic Workflows: State-based processing with validation and iteration capabilities
- PDF Parser: Advanced extraction using pdfplumber with table recognition
- Semantic Chunking: Context-aware document segmentation with overlap management
- Document Classification: AI-powered domain and type classification using Gemini
- Ontological Mapping: Knowledge graph integration for semantic relationships
- ChromaDB: Persistent vector database for document embeddings
- Hierarchical Indexing: Multi-level indexing by domain, type, and ontological concepts
- Semantic Search: Embedding-based similarity search with metadata filtering
- Ontology Manager: Combines RDFLib-based programmatic ontology creation with manual refinement using Protégé, a widely adopted tool for editing and visualizing OWL and RDF schemas.
- Domain-Specific Structures: Maintains distinct ontologies tailored to healthcare, legal, and financial domains, enabling modular reasoning and compliance-aware modeling.
- Concept Mapping: Automates the linking of document content to ontological concepts, with Protégé facilitating validation, class hierarchy adjustments, and semantic consistency checks.
- Google Gemini API: Primary LLM for classification, analysis, and response generation
- Sentence Transformers: Local embedding generation using all-MiniLM-L6-v2 model
- spaCy: Natural language processing for entity recognition and text analysis
- ChromaDB: Persistent vector storage with collection management
- Local Storage: File-based persistence for vector embeddings and metadata
- pdfplumber: PDF parsing with table extraction capabilities
- pandas: Data manipulation for structured content processing
- RDFLib: RDF graph creation and SPARQL querying
- owlready2: OWL ontology manipulation and reasoning
- FastAPI: Asynchronous web framework with OpenAPI support
- Jinja2: Template rendering for web interface
- Uvicorn: ASGI server for production deployment
- Bootstrap 5: UI component framework
- Font Awesome: Icon library for interface elements
- NLTK: Text processing utilities and stopword management
- scikit-learn: Machine learning utilities for similarity calculations
- LangGraph: State graph framework for multi-step agent workflows
- LangChain: Tool integration and agent utilities
Create a .env file in the main directory:
# Required
GEMINI_API_KEY=your_gemini_api_key_here
-
Setup and activate Virtual Environment:
# Create virtual environment python -m venv venv # Activate and you should see '(venv)' source venv/Scripts/activate
-
Install dependencies:
# Navigate to Backend ## Deployment using local Virtual Machine (venv)folder ./setup.sh -
Set environment variables:
# The "GEMINI_API_KEY" is automatically loaded into the environment from the .env file via python-dotenv, so manual declaration is not required. -
Run the server:
# Navigate to the folder containing main.py uvicorn main:app --host 0.0.0.0 --port 5000 --reload -
Close out the server and Virtual Environment:
# Ctrl + C to terminate API, and run the following in base to terminate virtual envorment deactivate # Remove 'venv' folder under project rm -rf venv/
Docker setup instructions are available in the 'Docker' folder's README.md
-
Start development container:
cd docker docker-compose -f docker-compose.dev.yml up --build -
Access the application:
- API: http://localhost:5000
- Documentation: http://localhost:5000/docs



