A sophisticated legal document processing system that uses Retrieval-Augmented Generation (RAG) to provide intelligent document analysis with comprehensive change history tracking.
- Multi-format Document Processing: Support for PDF, DOCX, TXT, and RTF files
- Intelligent Text Chunking: Legal clause-aware text segmentation
- Change History Tracking: Semantic analysis of clause changes over time
- Conflict Detection: Automated identification of conflicting clauses
- Interactive Chat Interface: RAG-powered document Q&A
- Vector Search: Semantic similarity search across document corpus
- Background Processing: Async document processing with Celery workers
- FastAPI: Modern async web framework for API endpoints
- PostgreSQL: Primary database with pgvector extension for embeddings
- Redis: Message broker and caching layer
- Weaviate: Vector database for semantic search
- Celery: Distributed task queue for background processing
- Docker: Containerized deployment
- Docker and Docker Compose
- At least 4GB RAM available for containers
git clone <repository-url>
cd hackathoncp .env.example .env
# Edit .env file with your preferred settings# Start all services
docker-compose up -d
# View logs
docker-compose logs -f api# Check API health
curl http://localhost:8000/health
# Access API documentation
open http://localhost:8000/docs
# Monitor Celery tasks
open http://localhost:5555 # Flower UIPOST /api/v1/documents/upload- Upload documents for processingGET /api/v1/documents/- List uploaded documentsGET /api/v1/documents/{id}- Get document detailsDELETE /api/v1/documents/{id}- Delete documentGET /api/v1/documents/{id}/status- Check processing status
POST /api/v1/chat/query- Ask questions about documentsGET /api/v1/chat/sessions- List chat sessionsGET /api/v1/chat/sessions/{id}/messages- Get chat history
GET /api/v1/history/clauses/{id}- Get clause change historyGET /api/v1/history/documents/{id}/changes- Get document changesGET /api/v1/history/recent- Get recent changes across all documents
GET /api/v1/conflicts/- List detected conflictsGET /api/v1/conflicts/{id}- Get conflict detailsPATCH /api/v1/conflicts/{id}/status- Update conflict status
curl -X POST "http://localhost:8000/api/v1/documents/upload" \
-H "Content-Type: multipart/form-data" \
-F "file=@contract.pdf"curl -X POST "http://localhost:8000/api/v1/chat/query" \
-H "Content-Type: application/json" \
-d '{"message": "What are the payment terms in the uploaded contracts?"}'curl "http://localhost:8000/api/v1/documents/{document_id}/status"# Install dependencies
cd app
pip install -r requirements.txt
# Run database migrations
python -m alembic upgrade head
# Start development server
uvicorn app.api.main:app --reload --host 0.0.0.0 --port 8000# Run all tests
pytest
# Run with coverage
pytest --cov=app tests/# Format code
black app/
# Check linting
flake8 app/| Variable | Description | Default |
|---|---|---|
DEBUG |
Enable debug mode | false |
DATABASE_URL |
PostgreSQL connection string | Required |
REDIS_URL |
Redis connection string | Required |
WEAVIATE_URL |
Weaviate endpoint | Required |
MAX_FILE_SIZE |
Maximum upload file size (bytes) | 52428800 |
CHUNK_SIZE |
Text chunking size (tokens) | 500 |
EMBEDDING_MODEL |
Sentence transformer model | all-MiniLM-L6-v2 |
hybrid(default): Legal clause detection + sentence chunkinglegal: Legal clause-based chunking onlysentence: Sentence-based chunking with overlapparagraph: Simple paragraph-based chunking
- API:
http://localhost:8000/health - Database: Check via API or direct connection
- Redis: Check via Flower UI
- Weaviate:
http://localhost:8080/v1/meta
# View API logs
docker-compose logs -f api
# View worker logs
docker-compose logs -f worker
# View all logs
docker-compose logs -f- Out of Memory: Increase Docker memory allocation to 4GB+
- Slow Processing: Check if Weaviate is properly started
- Database Connection: Verify PostgreSQL is accessible
# Reset database (DANGER: loses all data)
docker-compose down -v
docker-compose up -d postgres
# Wait for postgres to start, then:
docker-compose up -d- ✅ Basic document upload and processing
- ✅ Text extraction and chunking
- ✅ Database schema and API structure
- ✅ Docker deployment setup
- 🔄 Vector embeddings and similarity search
- 🔄 Basic RAG chat functionality
- ⏳ Change history detection
- ⏳ Conflict identification
- ⏳ Advanced clause matching
- ⏳ ML-based conflict resolution
- ⏳ Web frontend interface
- ⏳ Advanced analytics and reporting
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For questions and support, please open an issue in the repository or contact the development team.