IPC-focused legal RAG assistant with citation-backed answers, Next.js UI, and Ragas evaluation.
JusticeGuide helps users explore Indian Penal Code (IPC) topics through grounded Q&A. It retrieves from a legal corpus, generates answers with citations, and includes evaluation and observability hooks for answer quality.
Disclaimer: Educational / research assistant. Not legal advice.
- RAG pipeline: query enhancement → FAISS retrieval (LlamaIndex) → cited answer generation
- Models: Gemini primary, Groq fallback
- Frontend: Next.js app in
apps/web - Quality: Ragas eval pipeline + optional Arize Phoenix tracing
- Ingestion: PDF / Markdown / TXT corpus import CLI
- Deployable backend: Docker +
uvworkflow
Next.js (apps/web)
│
▼
POST /api/ask ──► FastAPI backend (src/)
│
├─ query enhancement (LCEL)
├─ FAISS retriever (dataset/corpus)
└─ answer generation + citations
| Layer | Tools |
|---|---|
| Backend | Python, FastAPI, LangChain, LlamaIndex, FAISS, sentence-transformers |
| Frontend | Next.js, React, TypeScript |
| LLMs | Gemini, Groq |
| Eval / observability | Ragas, Arize Phoenix |
| Tooling | uv, Docker, pytest |
- Python 3.11–3.13
- uv
- Node.js 20+
GEMINI_API_KEY(and optionalGROQ_API_KEY)
git clone https://github.com/Znaxh/Justice-Guide.git
cd Justice-Guide
cp .env.example .env # add API keys
uv sync --all-groups
uv run uvicorn src.main:app --host 0.0.0.0 --port 8000Health check: http://localhost:8000/api/health
cd apps/web
npm install
npm run devSet NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 if needed.
Default UI: http://localhost:3000
Supported formats under dataset/ (recursive): .pdf, .md, .txt
# Import a folder of legal docs
uv run python -m src.ingest --from-dir /path/to/legal-docs
# Import specific files and rebuild index
uv run python -m src.ingest ./notes/section302.md --rebuild-index| Method | Endpoint | Description |
|---|---|---|
POST |
/api/ask |
Ask a legal question |
GET |
/api/health |
Health check |
POST |
/api/admin/rebuild-index |
Rebuild FAISS index (admin key) |
POST |
/api/admin/run-evals |
Run Ragas evaluation job (admin key) |
Justice-Guide/
├── apps/web/ # Next.js frontend
├── src/ # FastAPI + RAG backend
├── dataset/corpus/ # Seed legal corpus
├── data/ # Eval datasets and results
├── tests/
├── Dockerfile
└── docker-compose.yml
uv run python -m src.evals.eval_pipeline
SKIP_PHOENIX=1 uv run pytestdocker compose up --buildAPI: http://localhost:8000
- Live demo: https://lawhelpai.netlify.app/
- Author: Znaxh
MIT — see LICENSE.