A polished, Canadian-legal reader that helps users analyse a court or tribunal decision. Upload a judgment (PDF, DOCX, or plain text), and CaseLens:
- Parses it into numbered paragraphs and reads the case header — neutral citation, court, decision date, justice(s), style of cause, and docket number.
- Identifies citation-worthy passages and highlights them verbatim, in place, against the categories in the legend below.
- Explains each highlight in a right-side panel: what the judge is saying, why it matters, the legal type (ratio, test, application, finding, credibility, procedural, remedy, obiter, definition), a suggested proposition, and how to cite it.
- Lets the user mark passages Saved / Not useful, add notes, and export the saved set (copy,
.txt,.md).
The full uploaded judgment stays central — CaseLens never replaces it with a summary, and it never invents citations, parallel citations, history, or treatment. Anything it cannot confidently extract is shown as "Not detected".
- Default (no key): a built-in, transparent heuristic engine (regex + rules in
server/analyze.ts) that works out of the box and is labelled in the UI. - AI (recommended): set an
ANTHROPIC_API_KEYand the pipeline uses Claude for deep, structured extraction (server/ai.ts).CLAUDE_MODELoptionally overrides the default model.
👉 Add ANTHROPIC_API_KEY here: https://www.val.town/x/justinstevens/caselens-canada/environment-variables?key=ANTHROPIC_API_KEY
When AI is enabled, every highlight is still anchored to a verbatim substring of the uploaded text; candidates that can't be anchored are dropped. If the AI call fails, the app transparently falls back to the heuristic engine.
server/text.tssegments the document into paragraphs (preserving numbers/headings) and extracts case metadata (best-effort, honest).- The engine produces highlight candidates with an
exactQuote— AI or heuristic. server/analyze.tsfinds each quote as a character-exact substring, recordsstartChar/endCharoffsets, and dedupes overlapping spans (keeping the more important one).
Rendering mermaid diagram...
index.ts— Hono HTTP entrypoint; serves the SPA and/api/analyze.server/text.ts,server/analyze.ts,server/ai.ts— the analysis pipeline.frontend/— React SPA (landing, progress, two-pane reader, export).frontend/demo.ts— a clearly-labelled fictional sample judgment used by the "Try the sample judgment" button.types.ts— shared types + the highlight legend (single source of truth for categories and colors).
| Category | Meaning |
|---|---|
| Ratio / core holding | the binding principle the decision turns on |
| Legal test / rule | a test, standard, or governing rule |
| Application / reasoning | applying the law to the facts |
| Key factual finding | a fact the court relies on |
| Credibility finding | reliability / weight of evidence |
| Procedural ruling | jurisdiction, standing, admissibility, process |
| Remedy / disposition / order | the operative order |
| Notable obiter | persuasive, non-binding comment |
| Definition | definition or interpretation adopted |
Documents are parsed in the browser; only the extracted plain text is sent to CaseLens for analysis. No document is retained server-side.
CaseLens Canada analyses the text you upload only. It does not determine whether a case is still good law — that requires a citator (e.g. keyCite/CanLII treatment checking) which is not connected. Use this tool to accelerate reading, not to replace your own research.
Every page links to this val's source at /source.
Run the pipeline standalone with server/selftest.ts.