An automated, high-fidelity legal document analysis platform that extracts critical legal insights, compliance risks, and core deadlines from complex legal PDFs with persistent cloud history orchestration.
LexiBrief AI transforms dense legal PDFs into four structured intelligence panels—Summary & Context, Core Legal Issues, Risk Obligations, and Deadline Alerts—backed by a cyberpunk-grade React dashboard and a resilient Node.js analysis pipeline.
| Capability | Description |
|---|---|
| Gen AI Parsing Core | Powered by Google Gemini 2.5 Flash for semantic document analysis and intelligent text-chunk processing across multi-page legal filings. |
| Fault-Tolerant Retry Engine | Dual-attempt recovery with automatic model fallback (2.5-flash → 2.0-flash → 1.5-flash) to bypass temporary 503 Service Unavailable spikes without breaking the UI. |
| Direct Shard-Pool Connectivity | Custom multi-seed MongoDB URI layout bypasses Windows local router DNS issues and mongodb+srv SRV lookup blockades. |
| Dynamic Sliding Dashboard | Interactive PDF dropzone with glassmorphism UI, typewriter stream animations, and a cloud-synchronized History Logs drawer with per-entry purge controls. |
- React (Vite) — SPA shell & component architecture
- Tailwind CSS — utility-first cyberpunk theming
- Framer Motion — slide-in history panel & micro-interactions
- Axios — REST orchestration to Express API
- Lucide React — premium iconography
- Node.js + Express — REST API gateway
- Multer — in-memory PDF ingestion
- pdf-parse-new — multi-page text extraction
- dotenv + cors — secure env & cross-origin config
- MongoDB Atlas with Mongoose ODM — persistent scan history, metadata indexing, and targeted record purging
- Google Gen AI SDK (
@google/genai) — structured 4-section legal synthesis engine
legal-saas-project/
├── README.md # Project documentation (this file)
├── backend/
│ ├── .env.example # Environment variable template
│ ├── .env # Local secrets (git-ignored)
│ ├── package.json
│ ├── server.js # Express API, Gemini engine, MongoDB layer
│ └── node_modules/
└── frontend/
├── index.html
├── vite.config.js
├── package.json
├── public/
│ └── favicon.svg
└── src/
├── main.jsx
├── App.jsx # LexiBrief AI dashboard & history drawer
├── App.css
└── index.css
- Node.js 18+
- npm 9+
- MongoDB Atlas cluster (with Network Access configured)
- Google AI Studio API key (Get API Key)
git clone <your-repository-url>
cd legal-saas-project
# Backend
cd backend
npm install
# Frontend
cd ../frontend
npm installCreate backend/.env from the template:
cd backend
cp .env.example .env # Windows: copy .env.example .envEdit backend/.env with your credentials:
PORT=5001
GEMINI_API_KEY=your_google_gemini_api_key_here
MONGO_URI=mongodb://username:encoded_password@shard-00-00.example.mongodb.net:27017,shard-00-01.example.mongodb.net:27017,shard-00-02.example.mongodb.net:27017/legal_saas_db?ssl=true&replicaSet=atlas-example-shard-0&authSource=admin&retryWrites=true&w=majorityPassword tip: If your MongoDB password contains
@, URL-encode it as%40in the connection string.
Example: password@MyPass123→%40MyPass123
| Variable | Description |
|---|---|
PORT |
Express server port (default 5001) |
GEMINI_API_KEY |
Google Gemini API key from AI Studio |
MONGO_URI |
Direct multi-shard MongoDB Atlas connection string |
Open two terminals:
Terminal 1 — Backend
cd backend
node server.js
# or: npm run dev (with nodemon)Expected output:
Server is LIVE and running on http://localhost:5001
🍃 MongoDB Database Engine Connected Successfully!
Terminal 2 — Frontend
cd frontend
npm run devOpen the dashboard at http://localhost:5173
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/analyze |
Upload PDF → Gemini analysis → persist to MongoDB |
GET |
/api/history |
List recent scan metadata (fileName, timestamp) |
GET |
/api/history/:id |
Fetch full historical analysis payload |
DELETE |
/api/history/:id |
Purge a specific history record |
Every successful scan returns four structured sections:
- 📋 Summary & Context
- ⚖️ Core Legal Issues & Clauses
⚠️ Key Risks & Critical Obligations- 📅 Detected Deadlines & Timeline Alerts
The frontend parser streams each block into dedicated glassmorphism cards with graceful empty-state fallbacks.
On each Analyze Document action:
- Up to 3 Gemini models are attempted in sequence
- Each model receives up to 2 attempts on
503overload errors - Maximum theoretical calls per scan: 6 (typically 1 on success)
- MongoDB writes use in-memory fallback only when Atlas is unreachable
- LexiBrief AI neon gradient hero branding
- Drag-and-drop PDF upload with pulse feedback
- Real-time typewriter + glitch stream rendering
- Right-side History Logs flyout (Framer Motion)
- One-click history restore & animated delete purge
| Symptom | Likely Cause | Fix |
|---|---|---|
503 UNAVAILABLE from Gemini |
Temporary Google model overload | Wait 1–2 min; retry (auto-fallback models enabled) |
Invalid URL MongoDB error |
Special chars in password (@) |
URL-encode password (%40) |
querySrv ECONNREFUSED |
Router DNS blocks SRV lookups | Use direct shard MONGO_URI (see .env.example) |
bad auth MongoDB |
Wrong username/password | Reset Atlas DB user password & update .env |
| History empty after restart | MongoDB was offline during scan | Confirm 🍃 MongoDB Connected in terminal |
This project is provided for educational and portfolio demonstration purposes. Configure your own API keys and database credentials before any production deployment.
LexiBrief AI ⚖️🚀
Precision legal intelligence. Structured. Persistent. Production-ready.