Veritas AI is a legal research assistant built with adversarial multi-agent RAG.
It retrieves relevant contract clauses, generates a grounded answer, challenges that answer with a counter-argument agent, verifies citations, and produces confidence/risk signals before returning a final response.
This repository is currently optimized for a portfolio/demo workflow, while keeping the architecture extensible for future production hardening.
| Item | Description |
|---|---|
| Product | Veritas AI |
| Tagline | Legal research, verified and challenged |
| Core Pattern | Multi-agent RAG with adversarial validation |
| Primary Model Provider | Groq (configurable to OpenAI/Anthropic) |
| Backend | Python 3.11, FastAPI, LangGraph, LangChain |
| Frontend | Next.js 14 (App Router), Tailwind CSS |
| Retrieval | FAISS + sentence-transformers embeddings |
flowchart TD
A[User Query] --> B[Query Classification]
B --> C[Jurisdiction Detection]
C --> D[Clause Retrieval]
D --> E[Answer Agent]
E --> F[Counter-Argument Agent]
F --> G[Citation Verification]
G --> H[Confidence and Risk Scoring]
H --> I[Decision Gate]
I -->|answer| J[Final Answer]
I -->|refuse| K[Refusal with rationale]
| Stage | Purpose | Output |
|---|---|---|
| Query Classification | Determine question type and scope | Structured query intent |
| Jurisdiction Detection | Capture legal context where available | Jurisdiction hint |
| Clause Retrieval | Semantic retrieval from indexed documents | Top-k relevant clauses |
| Answer Agent | Generate grounded legal response | Answer + citations |
| Counter-Argument Agent | Stress-test reasoning for weaknesses | Contradictions/exceptions/ambiguities |
| Citation Verification | Validate quote grounding against source text | Verification status |
| Confidence & Risk Scorer | Aggregate retrieval quality + adversarial signals | Confidence score + risk tier |
| Decision Gate | Apply safety/quality policy | Answer or refusal |
LegalAI RAG/
├── backend/
│ ├── main.py
│ ├── requirements.txt
│ ├── src/
│ │ ├── agents/
│ │ ├── api/
│ │ ├── graph/
│ │ ├── ingestion/
│ │ ├── retrieval/
│ │ ├── schemas/
│ │ └── utils/
│ └── test_*.py
├── frontend/
│ ├── app/
│ ├── components/
│ ├── lib/
│ └── package.json
├── data/
├── docs/
└── setup.sh
The backend mounts these route groups:
| Route Group | Prefix | Responsibility |
|---|---|---|
| Health | /api/health |
Service readiness |
| Query | /api/query |
End-to-end multi-agent legal analysis |
| Documents | /api/documents |
Upload/list/delete indexed docs |
| Stats | /api/stats |
Indexed corpus/system metadata |
| Docs UI | /api/docs |
OpenAPI Swagger interface |
| Page | Path | Purpose |
|---|---|---|
| Landing | / |
Product overview and capability framing |
| Query | /query |
Ask legal questions and inspect grounded responses |
| Upload | /upload |
Upload and annotate legal documents |
| Documents | /documents |
Manage indexed documents |
| History | /history |
Review previous query runs |
- Python 3.11
- Node.js 18+ and npm
- A Groq API key
cd "LegalAI RAG"
source legalRAG/bin/activate
pip install -r backend/requirements.txtCreate backend/.env (example values):
GROQ_API_KEY=your_key_here
LLM_PROVIDER=groq
LLM_MODEL=llama-3.1-8b-instant
LLM_TEMPERATURE=0.0Start backend:
cd backend
python main.pyBackend will be available at:
http://localhost:8000/api/healthhttp://localhost:8000/api/docs
cd "../frontend"
npm installCreate frontend/.env.local:
NEXT_PUBLIC_API_URL=http://localhost:8000/apiStart frontend:
npm run devFrontend will be available at http://localhost:3000.
| Layer | Platform | Cost Profile |
|---|---|---|
| Frontend | Vercel Hobby | Free |
| Backend | Render Free Web Service | Free (cold starts) |
Deployment order:
- Deploy backend (
backendroot) and set runtime env vars. - Deploy frontend (
frontendroot) and setNEXT_PUBLIC_API_URLto backend URL. - Smoke test upload and query flow on deployed URLs.
- Frontend production build passes (
npm run buildinfrontend) - Backend starts successfully and serves
/api/health - Upload accepts only supported document types
- Query returns answer + citations + confidence/risk metadata
- Counter-argument and citation verification render without schema errors
- Legal disclaimer is visible in UI
- Designed for portfolio/demo usage, not hardened for regulated production environments.
- Current API CORS defaults are local-development oriented.
- Vector index persistence is file-based FAISS for simplicity.
- Model outputs are constrained/validated, but LLM variability still applies.
Veritas AI provides AI-assisted legal research outputs and is not legal advice.
Always consult a licensed attorney before acting on legal interpretations.