legal-AI-case-management

ramanareddy-ai/legal-AI-case-management

3.2

If you are the rightful owner of legal-AI-case-management and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This project implements an AI-powered legal assistant that processes legal documents and generates demand letters using a Retrieval-Augmented Generation (RAG) pipeline.

Legal AI Case Management System

Overview

This project implements an AI-powered legal assistant that:

  • Ingests structured medical/legal PDFs
  • Uses a Retrieval-Augmented Generation (RAG) pipeline with legal-specific chunking
  • Embeds document chunks using OpenAIEmbeddings and indexes with ChromaDB
  • Queries those chunks based on natural-language questions
  • Generates demand letters using Jinja2 templates
  • Serves the solution via an MCP server built with FastAPI

Prerequisites

  • Python 3.10+
  • Docker & Docker Compose (optional but supported)
  • OpenAI API Key (for embeddings + LLM)

Setup

  1. Start services (if using Docker):

    docker-compose up -d
    
  2. Install Python dependencies:

    pip install -r requirements.txt
    
  3. Ingest PDFs and build vector store:

    python app/rag_pipeline.py
    

Running

  • Launch the MCP API server:

    uvicorn app.main:app --reload
    
  • Generate a demand letter:

    python generate_letter.py
    

    Output saved to generated_letter.txt.

RAG Workflow

  1. Chunk PDFs using PyMuPDF
  2. Embed text using OpenAIEmbeddings (LangChain)
  3. Store vectors in ChromaDB
  4. Query using natural language
  5. Retrieve top-k chunks
  6. Use Jinja2 to fill demand letter template with contextual info

Dependencies

  • PyMuPDF – Parse PDF files
  • openai, langchain – Embedding & LLM pipeline
  • chromadb – Vector storage
  • jinja2 – Demand letter templating
  • fastapi, uvicorn – MCP REST API server

Repo Structure

ā”œā”€ā”€ app/
│   ā”œā”€ā”€ main.py
│   ā”œā”€ā”€ rag_pipeline.py
│   ā”œā”€ā”€ db.py
│   ā”œā”€ā”€ models.py
ā”œā”€ā”€ templates/
│   └── demand_letter.jinja2
ā”œā”€ā”€ generate_letter.py
ā”œā”€ā”€ requirements.txt
ā”œā”€ā”€ README.md

āœ… Deliverables

  • āœ… End-to-end pipeline (PDF → demand letter)
  • āœ… RAG-based retrieval with chunking & embeddings
  • āœ… MCP server via FastAPI
  • āœ… Sample demand letter generated
  • āœ… This documentation with architecture & instructions

For any questions, feel free to reach out at: ramanadata568@gmail.com