GitHunt
ZO

zobiakanwal/legal-ai-assistant

An AI-powered FastAPI backend for selecting and filling legal document templates using GPT-4.

Legal AI Assistant πŸ§‘β€βš–οΈβš–οΈπŸ€–

This is an AI-powered assistant for generating and filling legal document templates.
Users can describe their legal issue, and the assistant selects the appropriate template, collects details step-by-step, and generates a ready-to-use document.


πŸ› οΈ Tech Stack

  • Frontend: React + TypeScript + Vite + TailwindCSS
  • Backend: FastAPI (Python)
  • AI Integration: OpenAI GPT-4 API
  • Document Handling: python-docx
  • Environment Management: dotenv

πŸ“ Project Structure

legal-assistant-app/
β”œβ”€β”€ backend/                 # FastAPI backend with AI + docx handling
β”‚   β”œβ”€β”€ main.py
β”‚   β”œβ”€β”€ summarize_templates.py
β”‚   β”œβ”€β”€ templates/
β”‚   β”œβ”€β”€ .env.example
β”‚   └── requirements.txt
β”œβ”€β”€ frontend/                # Vite + React frontend with chat interface
β”‚   β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ package.json
β”‚   └── tsconfig.json
β”œβ”€β”€ .gitignore
└── README.md

πŸ§ͺ Setup Instructions

πŸ”Ή Backend (FastAPI + OpenAI)

# Create and activate virtual environment
python -m venv venv
venv\Scripts\activate  # Windows

# Install dependencies
pip install -r requirements.txt

# Create a .env file based on the example
# .env
OPENAI_API_KEY=your_openai_api_key

# Run the FastAPI server
uvicorn main:app --reload

πŸ”Ή Frontend (React + Vite)

# Navigate to the frontend folder:
cd frontend

#Install frontend dependencies:
npm install

#Start the development server:
npm run dev

πŸš€ Features

  • βœ… AI selects the best legal template based on user input.
  • βœ… Asks one question at a time to collect details efficiently.
  • βœ… Auto-fills legal document placeholders using GPT.
  • βœ… Allows download of ready-to-use .docx legal files.
  • βœ… Built-in support for multiple legal categories and templates.

πŸ”’ Environment & Security

This project uses .env to manage sensitive keys like your OpenAI API key.
Example .env file:

#.env.example
OPENAI_API_KEY=your_openai_api_key

🌐 Live Demo

🚧 Deployment link coming soon…