π― 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.
- 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
- Graph-based recommendation engine using TF-IDF
- Natural language query understanding
- Relevance scoring with keyword matching
- Category-based filtering
- Step-by-step wizard interface
- Plain-language instructions for each field
- Field validation and helpful tooltips
- Progress tracking and auto-save
- Professional, ready-to-print PDFs
- Automatic form formatting with ReportLab
- Download and share completed forms
- Signature sections included
- Stunning glassmorphism design
- Smooth animations with Framer Motion
- Fully responsive layout
- Premium gradient aesthetics
- English and Tamil languages
- Easy to extend for more languages
- Localized form templates
- Framework: FastAPI
- AI/ML: LangChain, Google Gemini API, FAISS
- NLP: scikit-learn, sentence-transformers
- PDF: ReportLab
- Database: SQLite (SQLAlchemy ORM)
- Framework: Next.js 14 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS, Custom CSS
- Animations: Framer Motion
- Icons: Lucide React
- HTTP Client: Axios
π― 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
- Python 3.8+
- Node.js 18+
- Google Gemini API key (Get one here)
- Clone the repository
git clone https://github.com/Vishalghost/Smart-Legal-Form-Assistant.git
cd Smart-Legal-Form-Assistant- 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- 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- Start the Backend (in
backend/directory)
uvicorn app:app --reloadBackend will run at http://localhost:8000
- Start the Frontend (in
frontend/directory)
npm run devFrontend will run at http://localhost:3000
- Access the Application
- Open your browser and navigate to
http://localhost:3000 - Start by clicking "Get Started" or ask the AI assistant a question!
- Open your browser and navigate to
- Click "Get Started" or navigate to the recommendation page
- Describe your legal situation in plain language
- Example: "I need to rent out my apartment"
- Review the recommended forms with relevance scores
- Click "Start Filling This Form" on your preferred form
- Follow the step-by-step wizard
- Read the plain-language help text for each field
- Fill in your information
- Navigate using Previous/Next buttons
- Generate and download your PDF when complete
- Navigate to the Chat page
- Ask questions about legal forms and processes
- Example: "What is a power of attorney?"
- Get instant, context-aware answers
- Receive form recommendations in chat
Once the backend is running, access the interactive API docs:
- Swagger UI:
http://localhost:8000/api/docs - ReDoc:
http://localhost:8000/api/redoc
GET /api/forms/- List all formsPOST /api/forms/recommend- Get form recommendationsPOST /api/chat/- Chat with AI assistantPOST /api/pdf/generate- Generate filled PDFGET /api/health- Health check
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
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
GOOGLE_API_KEY=your_gemini_api_key
DATABASE_URL=sqlite:///./legal_assistant.db
CORS_ORIGINS=http://localhost:3000
DEBUG=TrueNEXT_PUBLIC_API_URL=http://localhost:8000- Edit
backend/data/legal_forms.json - Add your form following the existing schema
- Restart the backend server
- Forms will automatically appear in the UI
- Edit
backend/rag_chatbot.py - Replace
ChatGoogleGenerativeAIwith your preferred LLM - Update environment variables accordingly
- Edit
frontend/app/globals.cssfor colors and styles - Modify
frontend/tailwind.config.jsfor Tailwind theme
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
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.
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini for AI capabilities
- LangChain for RAG framework
- FastAPI for backend framework
- Next.js for frontend framework
- The open-source community
Project Link: https://github.com/Vishalghost/Smart-Legal-Form-Assistant
Made with β€οΈ to make legal forms accessible to everyone