Skip to content

Law AI

Law AI's direction is to become the ultimate open home for all things legal: data, tools, resources and transparency, with queryable and auditable case law and statutes, a citation knowledge graph, cited AI, LSAT and legal study, and API-first access for everyone (constitution §1).

CI License: MIT Live site

Who it is for

Law AI aims to become the ultimate open home for all things legal — data, tools, resources and transparency for all stakeholders, legal professionals and the general public. The missions are in constitution §1.

Audience What Law AI gives them
Prospective law students The LSAT lab: logical reasoning, reading comprehension, logic games and argumentative writing, with solving aids and playbooks, a continuous curriculum, question diagnosis and a knowledge library. Also published as a zero-server static site (bamr87.github.io/law-ai, built from lsat-static/).
Current law students The legal-journey platform: matters, scanned-page intake from a book (the ocrmd plug-in), an analysis studio, and agent traces that show how an argument is built, step by step.
Practicing lawyers IRAC analysis grounded in retrieved authority, precedent hunting, a Neo4j citation knowledge graph (GraphRAG: lexical retrieval plus CITES traversal), an audit trail for every model call and retrieval, human-approval gates on ingestion and high-stakes analysis, and a fully local mode (LLM_PROVIDER_CHAIN=ollama) for privileged data.
General public The same public sources, tools and trail of evidence: look up the law, follow a case, study for the LSAT, or learn how a doctrine works, without a firm or law-school affiliation.

Every output names the authority it rests on, labels asymmetry rather than filtering by it, and refuses honestly when it cannot ground an answer (docs/philosophy.md, docs/constitution.md §13).

How it works

  • Backend — Django 5 (ASGI via daphne), DRF, Channels (WebSocket agent streaming), Celery/Redis (async ingestion), Neo4j (knowledge graph) + Postgres + Redis. Each Django app owns one /api/* router: agentsapi, analysis, graph, lsat, matters, ingestionapp. Two routes are open without credentials: GET /health (liveness) and GET /version → {"name", "version", "commit", "built_at"} (UPS-BE-11). The version is the installed law-ai package's, which release-please bumps with every release, and commit / built_at come from the GIT_SHA / BUILT_AT build args and are null when unset. Full route list: docs/reference/http-routes.md.
  • Agents — CrewAI crews and LangGraph state graphs (backend/law_ai/agents_runtime/), running on ChatProviderChain, a LangChain BaseChatModel over the product's LLM provider chain (backend/law_ai/core/llm/): Anthropic Claude (subscription OAuth token, then ANTHROPIC_API_KEY), then xAI Grok (subscription OAuth, make xai-login), then local Ollama as the last tier. Pin LLM_PROVIDER_CHAIN=ollama for local-only operation — required for any data under a confidentiality obligation that forbids third-party processing (docs/constitution.md §1, docs/llm-provider-chain.md).
  • Frontend — Next.js 16 App Router, TypeScript strict, Tailwind v4, Cytoscape.js. Two UI apps (frontend/, lsat-static/) on a first-party design system (docs/ui-ux.md).
  • Infra — Docker Compose locally (Postgres, Neo4j, Redis, Ollama, Phoenix tracing), GitHub Actions in CI.

Full architecture: docs/architecture.md · agents: docs/agent-roles.md · data model: docs/data-model.md · product requirements: docs/prd.md · every document, one line each: docs/README.md.

Quick start (5 minutes to running)

git clone https://github.com/bamr87/law-ai.git
cd law-ai
cp .env.example .env
make dev            # or: docker compose up --build
# frontend: http://localhost:3000   API: http://localhost:8000 (routes under /api/agents, /api/analysis, /api/graph, /api/lsat)

Without Claude credentials in .env the provider chain falls through to the local Ollama tier automatically — you still get answers, from the local model. Add CLAUDE_CODE_OAUTH_TOKEN (from claude setup-token) or ANTHROPIC_API_KEY to use Claude.

Everything runs in Docker. Every dev/test/lint command is make … or docker compose …; there is no supported host-native toolchain. To wire your editor's language server to the same environment CI uses, open the repo in one of the Dev Containers (Law AI (backend): .devcontainer/devcontainer.json; Law AI (frontend): .devcontainer/frontend/devcontainer.json).

make test           # backend pytest + frontend vitest
make lint           # ruff + black + eslint
make typecheck      # mypy --strict (ratcheted) + tsc
make lint-specs     # the spec/backlog gate (the fleet's, via tools/fleet-kit.sh) + the UI shell audit
make test-legalbench

Project structure

Path What it is
backend/ Django (ASGI) API, agents, the LLM provider chain, ingestion, the LSAT content factory
frontend/ Next.js App Router platform app
lsat-static/ Static LSAT study site published to GitHub Pages (make lsat-export snapshots the bank)
lawmode/ The imported bamr87/lawmode legal reviewer for developers (its own README and tooling; runs from inside lawmode/)
specs/, BACKLOG.md The spec packages and the append-only backlog — the record of what shipped and what is next
docs/ Architecture, data model, agent roles, the constitution, ADRs, the PRD, runbooks; docs/history/ keeps the original proposal and planning notes
infra/, docker-compose*.yml Local stack: Postgres, Redis, Neo4j, Ollama and observability
scripts/, tools/, tests/ Repo-level stdlib scripts (UI audit, visual-evidence gate, mypy ratchet, LegalBench and Ollama helpers), hub-vendored tooling (fleet-kit.sh, unwrap-prose.py), and the repo-wide structural tests

Working on Law AI

AGENTS.md is the canonical guide for humans and AI agents alike: the locked stack, the layout, the Docker-first rule, the coding and testing standards, and the gates every PR must pass. GitHub Copilot and Claude Code are the sanctioned AI development surfaces; other coding agents (Cursor, Continue.dev, Aider, Codex, Gemini CLI) are not supported and their config files are rejected at review.

Development follows the fleet's spec-driven loop rather than a workflow of this repo's own: a non-trivial change starts as a spec package under specs/ (/spec-driven:specify → :clarify → :plan → :tasks → :implement, the spec-driven Claude Code plugin from the bamr87 hub), the spec and backlog gates run by reference in CI (Spec Drift Gate) and locally as make lint-specs, and every cycle mirrors the follow-ups it discovered into BACKLOG.md. docs/spec-driven.md maps the loop onto this repo and lists which checks block a merge.

All contributions, human or AI-generated, pass make lint + make typecheck, make test (backend coverage ≥75%), make lint-specs, the relevant LegalBench tasks (required on PRs labelled reasoning-change, weekly otherwise), screenshots for anything a user could see, and a review of the agent traces for auditability.

Report a security vulnerability privately, never in a public issue: SECURITY.md says how, and what counts as one here. The fleet-wide CONTRIBUTING.md, which GitHub inherits from bamr87/.github, applies too; where it and AGENTS.md differ, AGENTS.md wins.

Project status

Law AI is under active spec-driven development — there is no fixed roadmap snapshot here, because it drifts. For what is shipped, in flight, and planned:

  • Shipped features: the numbered spec packages under specs/ (each spec.md + plan.md + tasks.md), the source of truth for what exists.
  • What's next: the ## Open section of BACKLOG.md.
  • LegalBench regression gate: backend/law_ai/eval/legalbench.py, run via make test-legalbench / make legalbench-baseline.
  • Changes: CHANGELOG.md and the commit history.

License

MIT.


Part of the bamr87 portfolio — browse every project on Amr's GitHub profile.