A simple, powerful AI tool that helps lawyers, judges, and law students research legal cases quickly and efficiently.
π‘ Think of it like having a super-smart legal assistant that can instantly read through thousands of legal documents and answer your questions!
This Legal Research Engine is like having a personal AI lawyer that can:
β
Answer legal questions by searching through your law documents
β
Find similar cases to the one you're working on
β
Create case summaries automatically
β
Show connections between different legal cases
β
Extract important citations from legal documents
β
Compare different legal documents side by side
- Lawyers researching case law and precedents
- Judges reviewing similar cases and legal principles
- Law Students studying and understanding legal concepts
- Legal Researchers analyzing large volumes of legal documents
- Court Staff preparing case briefs and summaries
You'll need these programs installed on your computer:
- Python 3.8+ - Download here
- LM Studio - Download here (This runs the AI on your computer)
- Git - Download here (To download the code)
Open your computer's terminal/command prompt and type:
# Download the legal research engine
git clone https://github.com/PiKa919/Research-Engine-For-Courts.git
# Go into the folder
cd "Research-Engine-For-Courts"# Create a special Python environment for this project
conda create -n legal python=3.11 -y
# Switch to this environment
conda activate legal
# Install all the required tools
pip install -r requirements.txt- Open LM Studio (the app you downloaded)
- Download Models:
- Go to the "Search" tab
- Download:
text-embedding-embeddinggemma-300m-qat(for understanding documents) - Download any chat model like:
Llama-2-7B-ChatorMistral-7B(for answering questions)
- Start the Server:
- Go to "Developer" tab
- Load both models
- Click "Start Server" - it should run on
http://127.0.0.1:1234
# Put your PDF legal documents in the data folder
# Then tell the system to read them
python src/ingest.py# Make sure you're using the legal environment
conda activate legal
# Start the web application
streamlit run app.py- Open your web browser (Chrome, Firefox, etc.)
- Go to:
http://localhost:8501 - Start researching! π
What it does: Ask questions about your legal documents and get instant answers with references.
How to use:
- Type your question like: "What are the main provisions of the Commercial Courts Act?"
- Press Enter
- Get a detailed answer with citations from your documents
- Ask follow-up questions for more details
Example Questions:
- "What is the limitation period for commercial disputes?"
- "How are commercial court judges appointed?"
- "What are the key differences between civil and commercial procedures?"
What it does: Change how the app looks to suit your preference.
Available Themes:
- Light Theme - Bright and clean (default)
- Dark Theme - Easy on the eyes
- Legal Blue - Professional blue colors
- Legal Classic - Traditional legal styling
- Auto - Matches your system theme
What it does: Shows you how legal cases are connected to each other in a visual network.
How to use:
- The system automatically analyzes your documents
- Click and drag to explore the network
- See which cases cite which other cases
- Understand the relationships between legal precedents
What it does: Shows you statistics about your legal document collection.
You'll see:
- Most cited cases
- Citation frequency charts
- Document usage patterns
- Legal trend analysis
What it does: Automatically creates professional case briefs from legal documents.
How to use:
- Select a document from your collection
- Click "Generate Brief"
- Get a structured summary with:
- Case facts
- Legal issues
- Court decision
- Key legal principles
- Citations
What it does: Finds cases similar to your current legal issue.
How to use:
- Describe your legal situation
- The AI finds similar cases from your documents
- See how courts decided similar issues
- Use these as precedents for your case
What it does: Compares two or more legal documents side by side.
How to use:
- Select documents to compare
- See similarities and differences highlighted
- Understand how legal positions differ
- Export comparison reports
What it does: Save your research results in different formats.
Available Formats:
- π PDF - Professional reports for printing
- π Word Document - Editable legal documents
- πΎ Text File - Simple text format
- π JSON - Data format for further analysis
- π HTML - Web page format
What it does: Shows you how well the system is working and usage statistics.
You'll see:
- Query response times
- System performance metrics
- Usage patterns
- Success rates
What it does: Create custom research workflows for specific types of legal work.
How to use:
- Choose your research type (case law, statutory analysis, etc.)
- Configure the steps
- Save as a template for future use
- Share workflows with colleagues
What it does: Shows relationships between legal concepts, cases, and statutes.
Features:
- Interactive concept mapping
- Legal principle connections
- Statute-case relationships
- Searchable knowledge network
What it does: Adjust settings to customize how the system works.
Options:
- Model selection
- Performance settings
- Export preferences
- Theme customization
- Cache management
- Case Research: "Find all cases related to breach of contract in commercial disputes"
- Precedent Analysis: "Show me similar cases to my current client's situation"
- Brief Preparation: "Generate a case brief for [specific case]"
- Case Review: "What are the key legal principles in this type of case?"
- Precedent Research: "How have similar cases been decided?"
- Legal Analysis: "What are the statutory provisions relevant to this matter?"
- Study Aid: "Explain the main points of the Contract Act"
- Case Analysis: "Break down this judgment for me"
- Research Help: "Find cases that illustrate this legal principle"
Problem: The AI can't talk to LM Studio
Solution:
- Make sure LM Studio is running
- Check that the server is started in LM Studio
- Verify the URL is
http://127.0.0.1:1234
Problem: Error messages when starting the app
Solution:
- Make sure you're in the right folder
- Activate the conda environment:
conda activate legal - Reinstall packages:
pip install -r requirements.txt
Problem: The system can't find your legal documents
Solution:
- Put PDF files in the
data/folder - Run:
python src/ingest.py - Wait for processing to complete
Problem: AI takes too long to answer
Solution:
- Use smaller AI models in LM Studio
- Close other programs to free up memory
- Process fewer documents at once
Problem: Computer runs out of memory
Solution:
- Increase RAM allocation in LM Studio
- Use smaller models
- Process documents in smaller batches
- Restart the application
- Use clear, text-based PDFs (not scanned images)
- Name files clearly (e.g., "Supreme_Court_2023_Contract_Case.pdf")
- Organize by topic or case type for better results
- Be specific: Instead of "Tell me about contracts", ask "What are the essential elements of a valid contract under Indian law?"
- Use legal terms when you know them
- Ask follow-up questions to get more detail
- Always verify AI answers with original sources
- Cross-reference with multiple cases
- Use citations provided to find original documents
- Check this README first
- Look at the troubleshooting section above
- Open an issue on GitHub if you find bugs
- Review LM Studio documentation for AI model issues
- Suggest new features by opening a GitHub issue
- Report bugs with detailed descriptions
- Contribute code if you're a developer
This project is free to use under the MIT License. You can use it, modify it, and share it for any purpose, including commercial use.
Congratulations! You now have a powerful AI legal research assistant at your fingertips. This tool can help you:
- Save hours of manual research time
- Find relevant cases you might have missed
- Create professional documents quickly
- Understand complex legal relationships
- Make your legal work more efficient
Remember: This AI assistant is a tool to help you, not replace your legal expertise. Always verify important information and use your professional judgment.
Happy Legal Researching! βοΈβ¨
Built with β€οΈ for the legal community | Last updated: September 29, 2025
- π Human-in-the-Loop: Built-in approval workflows for critical decisions
- Citation Graph Visualization: Interactive network of legal citations
- π Automated Case Brief Generation: AI-generated structured legal summaries
- π Advanced Precedent Analysis: Multi-agent case law research
- Document Comparison: Side-by-side analysis of multiple documents
- Timeline Builder: Chronological case progression tracking
- π Workflow Monitoring: Real-time tracking of analysis progress
- Indian Law Focus: Specialized for Indian legal system and courts
- π Automatic Citation Extraction: AI-powered legal reference identification
- Case Law Research: Intelligent precedent finding and analysis
- Document Similarity: Semantic search across legal documents
- π Confidence Scoring: Quality assessment of analysis results
- Python 3.8+: Programming language runtime
- LM Studio: Local AI model server (download)
- Git: Version control system
- RAM: Minimum 8GB, Recommended 16GB+
- Storage: 5GB+ free space for models and documents
- OS: Windows 10/11, macOS, or Linux
-
Clone the repository
git clone https://github.com/PiKa919/Research-Engine-For-Courts.git cd Research-Engine-For-Courts -
Create conda environment
conda create -n legal python=3.11 -y conda activate legal
-
Install dependencies
pip install -r requirements.txt
-
Install LM Studio
- Download from lmstudio.ai
- Install and launch LM Studio
- Download models:
- Embedding:
text-embedding-embeddinggemma-300m-qat - Chat: Any compatible model (Llama 2, Mistral, etc.)
- Embedding:
-
Configure LM Studio
- Go to "Developer" tab
- Load your downloaded models
- Start local server (should run on
http://127.0.0.1:1234)
# Add PDF documents to the data/ folder
# Then run ingestion
python src/ingest.py# Start the Streamlit app
streamlit run app.py --server.headless true --server.port 8501
# Access at: http://localhost:8501Ask questions about your legal documents and get AI-powered answers with citations.
Interactive visualization of legal citations and case relationships.
Frequency analysis and citation patterns in your document collection.
Generate structured case briefs with key legal elements.
Find similar legal cases and analyze legal principles.
Compare multiple legal documents with legal implications.
DeepEval metrics and system accuracy assessment.
- Embedding Model:
text-embedding-embeddinggemma-300m-qator similar - Chat Model: Any compatible model (Llama 2, Mistral, etc.)
git clone https://github.com/PiKa919/Research-Engine-For-Courts.git
cd "Research Engine For Courts"# Create new environment
conda create -n legal python=3.11 -y
# Activate environment
conda activate legal
## Recent Updates
### v1.0.1 - September 2025
- **β
Fixed** `langchain_experimental` import error - added missing package dependency
- **β
Fixed** RAG chain TypeError - corrected chain structure for proper string input handling
- **β
Improved** error handling and logging throughout the application
- **β
Enhanced** documentation and setup instructions
## Project Structure
Research-Engine-For-Courts/ βββ app.py # Main Streamlit application βββ src/ β βββ init.py β βββ api.py # FastAPI REST endpoints β βββ config.py # Configuration management β βββ retrieval.py # RAG implementation & vector search β βββ ingest.py # Document ingestion pipeline β βββ enhanced_document_processor.py # Advanced document processing β βββ precedent_analyzer.py # Legal precedent analysis β βββ document_comparator.py # Document comparison tools β βββ case_brief_generator.py # Automated case brief generation β βββ knowledge_graph.py # Citation graph visualization β βββ evaluation.py # System evaluation & metrics β βββ caching.py # Performance caching system β βββ monitoring.py # Performance monitoring β βββ evaluation.py # Model evaluation tools βββ data/ # Legal document storage βββ chroma/ # Vector database storage βββ requirements.txt # Python dependencies βββ pyrightconfig.json # Python type checking βββ README.md # This file
## Configuration
### Model Configuration
```python
# LM Studio models (local)
EMBEDDING_MODEL = "text-embedding-embeddinggemma-300m-qat"
LLM_MODEL = "local-model"
# Performance settings
MAX_TOKENS = 2048
TEMPERATURE = 0.1
TOP_P = 0.9
# Optional: Create .env file for additional configuration
LM_STUDIO_BASE_URL=http://127.0.0.1:1234
DATA_PATH=./data
CHROMA_PATH=./chromaThe system provides REST API endpoints for integration:
GET /health- Health checkPOST /query/- Synchronous legal research queryPOST /query/async- Asynchronous legal research queryGET /documents/- List available documentsPOST /documents/ingest- Ingest new documents
from src.retrieval import create_rag_chain
# Initialize the system
async_rag_chain, sync_rag_chain = create_rag_chain()
# Perform legal research
result = sync_rag_chain("What are the provisions for commercial courts?")
print(result["answer"])# Check if LM Studio server is running
curl http://127.0.0.1:1234/v1/models# Reinstall dependencies
pip install -r requirements.txt --force-reinstall# Reset vector database
rm -rf chroma/
python src/ingest.py- Increase RAM allocation in LM Studio
- Use smaller models
- Process documents in smaller batches
- Document Processing: ~50 pages/minute
- Query Response: < 3 seconds average
- Vector Search: < 100ms for similarity search
- Memory Usage: ~2GB base + 0.5GB per 1000 documents
- Use GPU acceleration in LM Studio for better performance
- Batch document ingestion for large collections
- Configure appropriate chunk sizes for your documents
- Monitor system resources during heavy usage
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes
- Test thoroughly
- Submit a pull request
- Follow PEP 8 for Python code
- Add docstrings to all functions
- Include type hints where possible
- Write comprehensive tests
- Create feature in appropriate module in
src/ - Update configuration if needed
- Add to Streamlit interface in
app.py - Update documentation
This project is licensed under the MIT License - see the LICENSE file for details.
- LangChain - Framework for LLM applications
- Streamlit - Web application framework
- LM Studio - Local AI model server
- Chroma - Vector database
- PyVis - Network visualization
Built with β€οΈ for legal professionals and researchers
Last updated: September 22, 2025
# Make sure you're in the project directory
cd "c:\FILES_PIKA\Research Engine For Courts"
# Activate environment
conda activate legal
# Run the application
streamlit run app.py --server.headless true --server.port 8501- Open your browser
- Navigate to:
http://localhost:8501 - The application will load with multiple tabs
- Ask questions about your legal documents
- Get AI-powered answers with citations
- Explore document relationships
- Interactive visualization of legal citations
- Explore connections between cases
- Network analysis of legal precedents
- Frequency analysis of citations
- Document usage statistics
- Citation patterns and trends
- Generate structured case briefs
- Extract key legal elements
- Professional legal document formatting
- Find similar legal cases
- Analyze legal principles and holdings
- Precedent research and validation
- Compare multiple legal documents
- Identify similarities and differences
- Legal implications analysis
- DeepEval metrics and benchmarks
- System accuracy assessment
- Performance optimization insights
Question: "What are the key principles of Section 138 of the Negotiable Instruments Act?"
Response: The system will search your documents and provide:
- Relevant case law
- Section references
- Legal analysis with citations
# Add new documents
# 1. Place PDF in data/ folder
# 2. Run: python src/ingest.py
# 3. New documents are automatically indexedResearch Engine For Courts/
βββ app.py # Main Streamlit application
βββ src/
β βββ __init__.py
β βββ app.py # Alternative app interface
β βββ config.py # Configuration settings
β βββ retrieval.py # RAG implementation
β βββ ingest.py # Data ingestion pipeline
β βββ enhanced_document_processor.py # Document processing
β βββ precedent_analyzer.py # Legal precedent analysis
β βββ document_comparator.py # Document comparison
β βββ case_brief_generator.py # Case brief generation
β βββ knowledge_graph.py # Citation graph visualization
β βββ evaluation.py # System evaluation
βββ data/ # Legal document storage
β βββ Commercial Courts Act, 2015.pdf
β βββ Commercial Courts Rules, 2019.pdf
β βββ ...
βββ chroma/ # Vector database storage
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ pyrightconfig.json # Python type checking
# LM Studio models (local)
EMBEDDING_MODEL = "text-embedding-embeddinggemma-300m-qat"
LLM_MODEL = "local-model" # LM Studio will use loaded model
# Paths
DATA_PATH = "data/"
CHROMA_PATH = "chroma/"Create a .env file for sensitive configurations:
# .env file
GOOGLE_API_KEY=your_key_here # Only if using Google models (not recommended)# Reinstall dependencies
pip install -r requirements.txt --force-reinstall- Check if LM Studio is running
- Verify server URL:
http://127.0.0.1:1234 - Ensure models are loaded in LM Studio
- Check firewall settings
# Reset vector store
rm -rf chroma/
python src/ingest.py- Increase RAM allocation in LM Studio
- Use smaller models
- Process documents in smaller batches
# Use different port
streamlit run app.py --server.port 8502- Use GPU in LM Studio (if available)
- Optimize model parameters
- Use smaller embedding models
- Increase batch sizes in ingestion
- Use larger models
- Fine-tune prompts
- Add more legal documents
- Improve document preprocessing
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name
- Make your changes
- Test thoroughly
- Submit a pull request
- Follow PEP 8 for Python code
- Add docstrings to all functions
- Include type hints where possible
- Write comprehensive tests
- Create feature in appropriate module
- Update configuration if needed
- Add to Streamlit interface
- Update documentation
This project is licensed under the MIT License - see the LICENSE file for details.
- LangChain - Framework for LLM applications
- Streamlit - Web application framework
- LM Studio - Local AI model server
- Chroma - Vector database
- PyVis - Network visualization
For support and questions:
- Open an issue on GitHub
- Check the troubleshooting section
- Review LM Studio documentation
Built with β€οΈ for legal professionals and researchers
Last updated: September 16, 2025