Democratizing Legal Access for Everyone
LawSage is an open-source AI-powered platform designed to empower individuals representing themselves in court (Pro Se litigants). By leveraging advanced AI models and real-time legal grounding, LawSage analyzes your unique legal situation and generates a personalized, court-admissible roadmap and legal filings.
Legal Disclaimer: I am an AI, not an attorney. This tool provides legal information, not legal advice. Use of this tool does not create an attorney-client relationship.
- Voice Input: Describe your situation naturally using your microphone.
- Jurisdiction-Specific Analysis: Tailor your legal strategy and filings to your specific state or federal jurisdiction.
- AI-Powered Strategy: Receive clear, plain-language analysis and a step-by-step procedural roadmap.
- Court-Admissible Filings: Generate draft legal documents (motions, answers, etc.) formatted for court submission.
- Real-Time Grounding: All responses are grounded in current statutes and legal resources, with direct links to sources.
- Local & Private: Your data never leaves your browser. Your API key is stored locally in
localStorage. - Comprehensive History: Save and revisit your past cases with a full audit trail.
- Document Upload: Analyze PDF, DOCX, or TXT files to receive a "Red Team" analysis identifying weaknesses and recommendations.
- Export & Share: Copy all content to your clipboard or download your filings as a Markdown file.
- Import/Export History: Backup your case history to a JSON file or restore it on another device.
LawSage is built on a modern, performant full-stack architecture:
- Frontend: Next.js 16 (React 19) with Tailwind CSS and Lucide Icons.
- Backend: FastAPI (Python) for a robust, asynchronous API.
- AI Engine: Google Gemini 2.5 Flash (via the Google AI Python SDK) with web search grounding for real-time legal research.
- AI Safety & Structure: Custom Python validation layer ensures consistent, safe output with mandatory disclaimers and structure.
- State Management: Local browser storage (
localStorage) for user preferences and case history. - Document Processing: PyPDF2 and python-docx for extracting text from uploaded documents.
- Vector Search: LangChain with Google Generative AI embeddings for semantic search over local legal documents.
- Deployment: Optimized for Vercel (frontend) and local/Python hosting (backend).
- Node.js (v18+ recommended)
- Python (v3.9+ recommended)
- A Google Gemini API Key (Get one from the Google AI Studio)
- Clone the Repository
git clone https://github.com/tomwolfe/lawsage.git
cd lawsage- Install Frontend Dependencies
npm install- Install Backend Dependencies
pip install -r api/requirements.txt- Set Your API Key
- Open the application in your browser (
http://localhost:3000). - Click the "Settings" button in the top right corner.
- Enter your Google Gemini API Key and click "Save Settings".
- Your key is stored securely in your browser's
localStorageand is never sent to any server except when making requests to Google's API.
Start both the Next.js frontend and the FastAPI backend simultaneously:
npm run devThis command runs next dev and uvicorn api.index:app --host 127.0.0.1 --port 8000 --reload in parallel.
Open your browser and navigate to http://localhost:3000 to begin.
- Input: Describe your legal issue in plain language (e.g., "I was evicted from my apartment without notice").
- Jurisdiction: Select your relevant state or "Federal" from the dropdown.
- Analyze: Click "Analyze Case" or use the voice input button.
- Output: LawSage's AI:
- Searches the web for the latest statutes and court rules.
- Generates a clear, step-by-step legal strategy and procedural roadmap.
- Creates a draft, court-admissible legal filing (e.g., an Answer or Motion).
- Provides direct links to the legal sources used for grounding.
- Action: Review, edit, and copy the generated content to use in your case. You can also download it as a
.mdfile.
- Upload: Use the "Upload Document for Analysis" button to select a PDF, DOCX, or TXT file.
- Analyze: LawSage will automatically analyze the document and display a "Red Team Analysis" tab.
- Output: The AI will provide:
- A summary of the document.
- A list of potential legal and procedural weaknesses.
- Strategic recommendations to improve your position.
The easiest way to deploy LawSage is on Vercel.
- Push your code to a public GitHub repository.
- Go to https://vercel.com/new.
- Import your repository.
- Important: Vercel only deploys the frontend. To use the AI features, you must host the FastAPI backend separately.
- You can deploy the backend to a service like Render, Railway, or a cloud VM.
- Update the
next.config.tsfile'srewritesto point to your deployed backend URL.
- Set the
GEMINI_API_KEYenvironment variable in your Vercel project settings.
LawSage is an open-source project dedicated to legal democratization. Contributions are welcome!
- Fork the repository.
- Create a feature branch (
git checkout -b feature/your-feature-name). - Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/your-feature-name). - Open a pull request.
Please ensure your code adheres to the existing style and includes tests for new features.
This project is licensed under the MIT License - see the LICENSE file for details.