Advanced RAG-powered document analysis system with intelligent chat interface, comprehensive evaluation framework, and modern web UI. Upload documents, ask questions in natural language, and get intelligent responses with source attribution and confidence scoring.
- Multi-format Document Processing: PDF, DOCX, TXT, Markdown support with intelligent chunking
- Advanced RAG Pipeline: Claude 4 Sonnet-powered generation with multiple prompt styles
- Hybrid Search: Semantic + keyword retrieval for optimal results
- Real-time Chat Interface: Conversational experience with session management
- Modern Web UI: React + TypeScript with Material-UI design system
- Multiple Prompt Styles: Default, Analytical, Concise response modes
- Context Enhancement: Query refinement based on chat history
- Source Attribution: Transparent citation with relevance scoring
- Confidence Metrics: AI-generated reliability assessment
- Session Management: Persistent chat histories with message tracking
- RAGAS Integration: Industry-standard RAG evaluation metrics
- Custom Metrics: Faithfulness, relevancy, precision, recall scoring
- Batch Evaluation: Automated testing on question datasets
- Performance Analytics: Response time and quality monitoring
- Interactive Testing: Single question and batch evaluation interfaces
- Dark/Light Theme: Adaptive design with user preference
- Responsive Layout: Mobile-friendly Material-UI components
- Real-time Updates: Live document processing and chat updates
- Animated Transitions: Smooth user interactions and feedback
- Dashboard Analytics: Visual metrics and system health monitoring
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ React/TS │ │ FastAPI │ │ ChromaDB │
│ Frontend │◄──►│ Backend │◄──►│ Vector Store │
│ (Port 3000) │ │ (Port 8000) │ │ (Embeddings) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
┌───────▼───────┐
│ SQLite DB │
│ (Metadata) │
└───────────────┘
Document Processor
- Multi-format text extraction (PDF, DOCX, TXT, MD)
- Intelligent preprocessing with metadata extraction
- Asynchronous chunking with configurable overlap
- Error handling and processing status tracking
Vector Store (ChromaDB)
- Efficient embedding storage and retrieval
- Hybrid search combining semantic and keyword matching
- Sentence-transformers embeddings
- Configurable similarity thresholds
RAG Engine
- Context-aware query enhancement with chat history
- Multiple generation strategies (Default, Analytical, Concise)
- Confidence scoring and source attribution
- Performance timing and metrics
Chat Service
- Session-based conversation management
- Real-time message processing
- Source tracking and citation
- Performance monitoring
Frontend Application
- Modern React with TypeScript
- Material-UI component library
- React Query for data management
- Responsive design with dark/light themes
Backend
- FastAPI (async Python web framework)
- SQLAlchemy + SQLite (data persistence)
- ChromaDB (vector embeddings)
- Anthropic Claude 4 Sonnet (LLM)
- Sentence-Transformers (embeddings)
- RAGAS (evaluation framework)
- PyPDF2, python-docx (document processing)
Frontend
- React 18 + TypeScript
- Material-UI (MUI) design system
- TanStack React Query (data fetching)
- React Router (navigation)
- React Dropzone (file uploads)
Infrastructure
- Docker + Docker Compose
- Alembic (database migrations)
- Pytest (testing)
- Development scripts for setup and monitoring
- Docker & Docker Compose
- Anthropic API key (get one here)
- 8GB+ RAM recommended
git clone <repository-url>
cd smart-doc-analyzer
cp .env.example .envEdit .env with your API key:
ANTHROPIC_API_KEY=your_anthropic_api_key_here# Start all services with Docker Compose
docker-compose up -d
# Or start with logs visible
docker-compose up- Web Interface:
http://localhost:3000 - API Documentation:
http://localhost:8000/docs - API Health Check:
http://localhost:8000/health
- Upload Documents: Drag & drop or click to upload PDF, DOCX, TXT, or MD files
- Processing: Documents are automatically processed and chunked for AI analysis
- Status Tracking: Monitor processing status and view document statistics
- Start Conversation: Click "New Chat" to begin
- Ask Questions: Type questions about your uploaded documents
- Response Styles: Choose between Default, Analytical, or Concise responses
- View Sources: Expand source citations to see relevant document chunks
- Session History: Access previous conversations from the sidebar
- Single Question Test: Test individual questions with optional expected answers
- Batch Evaluation: Run multiple questions and get aggregated metrics
- Performance Metrics: View faithfulness, relevancy, precision, and recall scores
- Response Analysis: Monitor AI response times and quality
- Document Statistics: Track upload counts, processing rates, and storage usage
- Chat Metrics: Monitor conversation activity and engagement
- System Health: Real-time status monitoring and performance metrics
# AI Configuration
ANTHROPIC_API_KEY=your_anthropic_api_key_here
DEFAULT_MODEL=claude-3-sonnet-20240229
# RAG Parameters
CHUNK_SIZE=1000
CHUNK_OVERLAP=200
TOP_K_RETRIEVAL=5
SIMILARITY_THRESHOLD=0.7
# File Upload
MAX_FILE_SIZE=10485760 # 10MB
UPLOAD_DIR=./uploads
# Vector Store
CHROMA_PERSIST_DIRECTORY=./chroma_db
EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
# Security
SECRET_KEY=your-secret-key-change-in-productionThe system uses Claude 4 Sonnet by default. You can modify the model in backend/app/core/config.py:
DEFAULT_MODEL = "claude-3-sonnet-20240229"React app configuration in frontend/package.json and environment:
{
"proxy": "http://localhost:8000"
}# Run setup script
chmod +x scripts/setup_dev.sh
./scripts/setup_dev.sh
# Manual setup
cd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
# Start backend
uvicorn app.main:app --reload
# In another terminal, start frontend
cd frontend
npm install
npm startcd backend
# Run with auto-reload
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
# Run tests
pytest
# Database migrations
alembic revision --autogenerate -m "description"
alembic upgrade headcd frontend
# Start development server
npm start
# Build for production
npm run build
# Run tests
npm testPOST /api/v1/documents/upload- Upload documentGET /api/v1/documents/- List documentsDELETE /api/v1/documents/{id}- Delete document
POST /api/v1/chat/- Send messageGET /api/v1/chat/sessions- List chat sessionsGET /api/v1/chat/sessions/{id}/messages- Get session messagesDELETE /api/v1/chat/sessions/{id}- Delete session
POST /api/v1/evaluation/single- Single question evaluationGET /api/v1/evaluation/batches- List evaluation batchesGET /api/v1/evaluation/test-dataset- Get test questions
# Check system status
./scripts/monitor.sh
# Manual health check
curl http://localhost:8000/health# Create backup
./scripts/backup.sh
# Backup includes:
# - SQLite database
# - ChromaDB vector store
# - Uploaded files
# - Configuration# Deploy to production
./scripts/deploy_prod.sh production your-domain.com
# Monitor production
./scripts/monitor.shDocument processing fails
- Check file format and size (max 10MB)
- Verify upload directory permissions
- Monitor disk space and memory usage
Vector search returns no results
- Ensure documents are processed successfully
- Check similarity threshold settings
- Verify embedding model is loaded
Frontend connection issues
- Confirm backend is running on port 8000
- Check CORS settings in backend
- Verify proxy configuration in package.json
Slow response times
- Monitor Claude API latency
- Check vector store index size
- Review chunk size configuration
- Verify memory and CPU usage
# Enable detailed logging
export LOG_LEVEL=DEBUG
# Run backend with debug output
cd backend
uvicorn app.main:app --reload --log-level debug- Database: Use PostgreSQL for production (see config backup)
- Caching: Implement Redis for vector store caching
- Scaling: Use horizontal scaling for multiple instances
- Memory: Monitor embedding model memory usage
- Fork the repository
- Create a feature branch
- Implement changes with tests
- Run evaluation suite
- Submit pull request
- Python: Type hints, docstrings, Black formatting
- TypeScript: Strict mode, proper component types
- Testing: Unit tests for core components
- Documentation: Update README for new features
smart-doc-analyzer/
├── backend/ # FastAPI backend
│ ├── app/
│ │ ├── api/ # API endpoints
│ │ ├── core/ # Configuration
│ │ ├── models/ # Database models
│ │ └── services/ # Business logic
│ ├── tests/ # Backend tests
│ └── requirements.txt
├── frontend/ # React frontend
│ ├── src/
│ │ ├── components/ # UI components
│ │ ├── pages/ # Page components
│ │ ├── lib/ # API client
│ │ └── types/ # TypeScript types
│ └── package.json
├── scripts/ # Deployment scripts
├── docker-compose.yml # Container orchestration
└── .env.example # Environment template
MIT License - see LICENSE file for details.
- Anthropic for Claude AI
- ChromaDB for vector storage
- Material-UI for React components
- RAGAS for evaluation framework
Smart Document Analyzer - Transform how you work with documents using AI-powered analysis and natural language conversations.