- Upload a PDF or paste text; we extract text (PyPDF2 for PDFs) -## Folder guide
main.py # FastAPI app and endpoints (serves React SPA)
client/ # React frontend (Vite, TypeScript)
src/
routes/
LegalDocumentPage/ # Main legal document analysis page
requirements.txt # Python dependencies
Dockerfile, app.yaml, cloudbuild.yaml
scripts/ # Helper scripts (frontend build helpers)
backup_frontend/ # Original Jinja2 templates (preserved for reference)
- The UI is a custom React app designed specifically for legal document analysis
- Chat history shows previous Q&A and can be cleared per session
- PDF extraction uses PyPDF2's text; image-only PDFs won't be OCR'd
- Build the frontend with
npm run client:buildwhenever static assets need to be refreshedctured analysis: summary, key points, risks, recommendations, simple explanation - Ask follow-up questions grounded in the uploaded content, with confidence level and supporting snippets
- Keep a local chat history per session (no DB required)
- Backend: FastAPI, Uvicorn, requests
- AI: Google Gemini (via HTTPS REST call)
- Parsing: PyPDF2
- Frontend: React/Vite app (TypeScript, custom legal document analysis UI)
- Tooling: npm + Vite build pipeline, python-dotenv; Docker & GCP configs includedment Demystifier
AI app to turn dense legal docs into clear, actionable insights with follow‑up Q&A. Built with FastAPI and Google Gemini.
- Upload a PDF or paste text; we extract text (PyPDF2 for PDFs)
- Generate a structured analysis: summary, key points, risks, recommendations, simple explanation
- Ask follow‑up questions grounded in the uploaded content, with confidence level and supporting snippets
- Keep a local chat history per session (no DB required)
- Backend: FastAPI, Uvicorn, requests
- AI: Google Gemini (via HTTPS REST call)
- Parsing: PyPDF2
- Frontend: Makyo React/Vite app (TypeScript, Radix UI, TanStack Query)
- Tooling: npm + Vite build pipeline, python-dotenv; Docker & GCP configs included
Prereqs: Python 3.10+, Node.js 18+, a Gemini API key.
Visit https://aistudio.google.com/app/apikey and create a free API key.
# Copy the example file
copy .env.example .envThen edit .env and replace your-gemini-api-key-here with your actual API key.
OR set it directly in PowerShell:
$env:GEMINI_API_KEY="your-actual-api-key"pip install -r requirements.txtnpm install --legacy-peer-deps
npm run client:buildTip: for iterative UI work run
npm run clientin a second terminal (Vite dev server on http://localhost:8441). The FastAPI backend continues to run on http://localhost:8080.
- Set environment variables (Windows PowerShell)
$env:GEMINI_API_KEY="your-api-key"
# Optional Makyo settings
$env:MAKYO_API_TOKEN="changeme"
$env:MAKYO_OLLAMA_HOST="http://host.docker.internal:11434" # or unset if not using Ollama- Start the backend
python main.pyOpen http://localhost:8080. FastAPI now serves the built React SPA.
- GEMINI_API_KEY (required): Google Generative Language API key
- PORT (optional, default 8080)
- GET / → React SPA entry point (Legal Document Demystifier UI)
- GET /assets/* → Hashed static assets served from Vite build output
- POST /analyze-document → file upload (PDF/TXT); returns JSON analysis + document_id
- POST /analyze-text → raw text; returns JSON analysis + document_id
- POST /ask-question → question + document_id or document_text; returns answer, relevant_sections, confidence_level
- POST /save-chat → persist chat in memory for session
- GET /chat-history → session chat history
- POST /clear-chat-history → clear session chat
- GET /health → health probe
Responses from Gemini are coerced to strict JSON. If parsing fails, we return a graceful fallback with the raw snippet and guidance to retry.
- Documents and chats are stored in memory only (per process)
- No external storage; clear chat endpoint included
- Provide your own API key via environment variable
The easiest way to deploy this application to production is using Microsoft Azure App Service.
Quick Deploy:
# 1. Build frontend
npm run client:build
# 2. Login to Azure
az login
# 3. Deploy using automated script
.\deploy_azure.ps1 -ResourceGroup "legal-demystifier-rg" -AppName "your-unique-app-name"Documentation:
- 📖 Full Guide: See
AZURE_DEPLOYMENT_GUIDE.mdfor comprehensive deployment instructions - ✅ Checklist: See
AZURE_CHECKLIST.mdfor pre-deployment checklist - ⚡ Quick Reference: See
AZURE_QUICK_REFERENCE.mdfor essential commands
Requirements:
- Azure account (free tier available)
- Azure CLI installed
- Gemini API key
- Dockerfile now performs a multi-stage build (Node → Python) so the React assets are bundled automatically.
deploy.sh/deploy_windows.batinstall Node deps, build the frontend, then call the existing GCP deployment flow.cloudbuild.yamldeploys the same container; provide_GEMINI_API_KEYsubstitution or set GEMINI_API_KEY in the target environment.
# Build the image
docker build -t legal-demystifier .
# Run the container
docker run -p 8080:8080 -e GEMINI_API_KEY="your-api-key" legal-demystifiermain.py # FastAPI app and endpoints (serves React SPA)
client/ # Makyo React frontend (Vite, TypeScript)
server/ # Makyo server code (available for future integration)
shared/ # Shared TypeScript types used by the frontend/server
requirements.txt # Python dependencies
Dockerfile, app.yaml, cloudbuild.yaml
scripts/ # Helper scripts (frontend build helpers)
- The UI is now powered by Makyo’s modern React experience (dark theme, personas, snippets, etc.)
- Chat history shows previous Q&A and can be cleared per session
- PDF extraction uses PyPDF2’s text; image-only PDFs won’t be OCR’d
- Build the frontend with
npm run client:buildwhenever static assets need to be refreshed