Skip to content

Smart Legal Form Assistant is a web-based platform designed to help common citizens understand, identify, and accurately fill out legal forms in a simple, user-friendly way. The project aims to bridge the gap between complex legal documentation and the general public, using guided form-filling, plain-language explanations, and AI-powered assistance

Notifications You must be signed in to change notification settings

Vishalghost/Smart-Legal-Form-Assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Smart Legal Form Assistant

🎯 AI-powered legal form assistance platform designed to help common citizens understand, identify, and accurately fill out legal forms in a simple, user-friendly way.

License Python Next.js Status

✨ Features

🧠 RAG-based Legal Assistant

  • AI-powered chatbot using Google Gemini and LangChain
  • Retrieval-Augmented Generation for accurate legal information
  • Context-aware responses with form recommendations
  • Multi-turn conversations with memory

πŸ“˜ Intelligent Form Recommendation

  • Graph-based recommendation engine using TF-IDF
  • Natural language query understanding
  • Relevance scoring with keyword matching
  • Category-based filtering

πŸ“ Guided Form Filling

  • Step-by-step wizard interface
  • Plain-language instructions for each field
  • Field validation and helpful tooltips
  • Progress tracking and auto-save

πŸ“„ PDF Generation

  • Professional, ready-to-print PDFs
  • Automatic form formatting with ReportLab
  • Download and share completed forms
  • Signature sections included

🌐 Modern UI/UX

  • Stunning glassmorphism design
  • Smooth animations with Framer Motion
  • Fully responsive layout
  • Premium gradient aesthetics

🌍 Multilingual Support

  • English and Tamil languages
  • Easy to extend for more languages
  • Localized form templates

πŸ—οΈ Tech Stack

Backend

  • Framework: FastAPI
  • AI/ML: LangChain, Google Gemini API, FAISS
  • NLP: scikit-learn, sentence-transformers
  • PDF: ReportLab
  • Database: SQLite (SQLAlchemy ORM)

Frontend

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS, Custom CSS
  • Animations: Framer Motion
  • Icons: Lucide React
  • HTTP Client: Axios

πŸš€ Getting Started

🎯 New to the project? Check out our Quick Start Guide (QUICKSTART.md) for a 5-minute setup!

We provide automated setup scripts to get you running quickly:

  • Windows: Run .\setup.ps1
  • macOS/Linux: Run ./setup.sh

Prerequisites

  • Python 3.8+
  • Node.js 18+
  • Google Gemini API key (Get one here)

Installation

  1. Clone the repository
git clone https://github.com/Vishalghost/Smart-Legal-Form-Assistant.git
cd Smart-Legal-Form-Assistant
  1. Backend Setup
cd backend

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Create .env file
copy .env.example .env  # Windows
# OR
cp .env.example .env    # macOS/Linux

# Edit .env and add your Google API key
# GOOGLE_API_KEY=your_api_key_here
  1. Frontend Setup
cd ../frontend

# Install dependencies
npm install

# Create environment file
copy .env.local.example .env.local  # Windows
# OR
cp .env.local.example .env.local    # macOS/Linux

Running the Application

  1. Start the Backend (in backend/ directory)
uvicorn app:app --reload

Backend will run at http://localhost:8000

  1. Start the Frontend (in frontend/ directory)
npm run dev

Frontend will run at http://localhost:3000

  1. Access the Application
    • Open your browser and navigate to http://localhost:3000
    • Start by clicking "Get Started" or ask the AI assistant a question!

πŸ“– Usage Guide

Finding Forms

  1. Click "Get Started" or navigate to the recommendation page
  2. Describe your legal situation in plain language
    • Example: "I need to rent out my apartment"
  3. Review the recommended forms with relevance scores
  4. Click "Start Filling This Form" on your preferred form

Filling Forms

  1. Follow the step-by-step wizard
  2. Read the plain-language help text for each field
  3. Fill in your information
  4. Navigate using Previous/Next buttons
  5. Generate and download your PDF when complete

Using the AI Assistant

  1. Navigate to the Chat page
  2. Ask questions about legal forms and processes
    • Example: "What is a power of attorney?"
  3. Get instant, context-aware answers
  4. Receive form recommendations in chat

πŸ“š API Documentation

Once the backend is running, access the interactive API docs:

  • Swagger UI: http://localhost:8000/api/docs
  • ReDoc: http://localhost:8000/api/redoc

Key Endpoints

  • GET /api/forms/ - List all forms
  • POST /api/forms/recommend - Get form recommendations
  • POST /api/chat/ - Chat with AI assistant
  • POST /api/pdf/generate - Generate filled PDF
  • GET /api/health - Health check

πŸ—‚οΈ Project Structure

Smart-Legal-Form-Assistant/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app.py                 # Main FastAPI application
β”‚   β”œβ”€β”€ models.py              # Pydantic models
β”‚   β”œβ”€β”€ database.py            # SQLAlchemy setup
β”‚   β”œβ”€β”€ rag_chatbot.py         # RAG chatbot implementation
β”‚   β”œβ”€β”€ form_recommender.py    # Form recommendation engine
β”‚   β”œβ”€β”€ pdf_generator.py       # PDF generation service
β”‚   β”œβ”€β”€ routes/                # API route handlers
β”‚   β”‚   β”œβ”€β”€ forms.py
β”‚   β”‚   β”œβ”€β”€ chatbot.py
β”‚   β”‚   └── pdf.py
β”‚   └── data/
β”‚       └── legal_forms.json   # Form templates
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ page.tsx           # Landing page
β”‚   β”‚   β”œβ”€β”€ chat/              # AI chat interface
β”‚   β”‚   β”œβ”€β”€ recommend/         # Form recommendations
β”‚   β”‚   └── fill/[formId]/     # Form filling wizard
β”‚   └── lib/
β”‚       └── api.ts             # API client
└── README.md

πŸ“ Available Forms

Currently includes sample templates for:

  • πŸ“„ Residential Rental Agreement
  • βš–οΈ General Power of Attorney
  • πŸ“‹ General Affidavit
  • πŸ’Ό Employment Contract

Note: You can easily add more forms by editing backend/data/legal_forms.json

πŸ”§ Configuration

Backend Environment Variables

GOOGLE_API_KEY=your_gemini_api_key
DATABASE_URL=sqlite:///./legal_assistant.db
CORS_ORIGINS=http://localhost:3000
DEBUG=True

Frontend Environment Variables

NEXT_PUBLIC_API_URL=http://localhost:8000

🎨 Customization

Adding New Forms

  1. Edit backend/data/legal_forms.json
  2. Add your form following the existing schema
  3. Restart the backend server
  4. Forms will automatically appear in the UI

Changing the AI Model

  • Edit backend/rag_chatbot.py
  • Replace ChatGoogleGenerativeAI with your preferred LLM
  • Update environment variables accordingly

UI Theming

  • Edit frontend/app/globals.css for colors and styles
  • Modify frontend/tailwind.config.js for Tailwind theme

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

⚠️ Disclaimer

This application provides general legal form assistance and information. It is not a substitute for professional legal advice. Always consult with a qualified attorney for your specific legal situation.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Google Gemini for AI capabilities
  • LangChain for RAG framework
  • FastAPI for backend framework
  • Next.js for frontend framework
  • The open-source community

πŸ“§ Contact

Project Link: https://github.com/Vishalghost/Smart-Legal-Form-Assistant


Made with ❀️ to make legal forms accessible to everyone

About

Smart Legal Form Assistant is a web-based platform designed to help common citizens understand, identify, and accurately fill out legal forms in a simple, user-friendly way. The project aims to bridge the gap between complex legal documentation and the general public, using guided form-filling, plain-language explanations, and AI-powered assistance

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published