Skip to content

Repository files navigation

JusticeGuide

IPC-focused legal RAG assistant with citation-backed answers, Next.js UI, and Ragas evaluation.

Live Demo Python FastAPI Next.js License: MIT

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.


Highlights

  • 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 + uv workflow

Architecture

Next.js (apps/web)
      │
      ▼
POST /api/ask  ──►  FastAPI backend (src/)
                         │
                         ├─ query enhancement (LCEL)
                         ├─ FAISS retriever (dataset/corpus)
                         └─ answer generation + citations

Tech stack

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

Quick start

Prerequisites

  • Python 3.11–3.13
  • uv
  • Node.js 20+
  • GEMINI_API_KEY (and optional GROQ_API_KEY)

Backend

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 8000

Health check: http://localhost:8000/api/health

Frontend

cd apps/web
npm install
npm run dev

Set NEXT_PUBLIC_API_BASE_URL=http://localhost:8000 if needed.

Default UI: http://localhost:3000


Corpus ingestion

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

Core API endpoints

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)

Project structure

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

Evaluations & tests

uv run python -m src.evals.eval_pipeline
SKIP_PHOENIX=1 uv run pytest

Docker

docker compose up --build

API: http://localhost:8000


Links

License

MIT — see LICENSE.

About

IPC-focused legal RAG with FastAPI, FAISS, Next.js, and Ragas evaluation

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages