← Work

001 · 2025

Making Peru's laws fast and readable

Peru's official legislation portal is slow, fragile, and written in language almost no one outside law school can parse. I rebuilt the experience, end to end, as a fast, plain-language, connected way to read the law.

Role
Lead Design Engineer · solo build, with a practicing attorney for legal validation
Status
Shipped · open source · covered by Peruvian national press
Next.js 15RSCPostgres + pgvectorClaudeD3civic tech
Making Peru's laws fast and readable

The problem

The government portal for Peruvian legislation routinely took 8 to 12 seconds to load and fell over under modest traffic. Worse than the speed was the comprehension: legal Spanish is dense, amendments are invisible, and there's no way to see how one law connects to another. In sessions I ran with lawyers, students and journalists, people gave up before they found what they came for.

Decision

The bet: transparency over magic

Early versions just summarised laws with AI, and people didn't trust them. So I changed the frame: never replace the source, sit beside it. The final design shows the original legal text and a plain-language explanation side by side, clearly labelled as a summary, with the model's reasoning legible. Trust came from showing the seams, not hiding them.

How it's built

How I built it

React Server Components and edge caching for sub-second loads; a custom parser for Spanish legal citations; recursive CTEs to traverse the citation graph; pgvector + full-text search for retrieval; and a queue-based pipeline that runs Claude with structured outputs so summaries stay consistent and don't hallucinate. The citation network is a D3 force graph; the whole thing ships as an offline-first PWA.

Where it landed

legalize.pe is live, open source, and was picked up by Peru's major outlets (El Comercio, La República, Gestión) as a reference for civic technology in the region. The honest wins I can stand behind: a Lighthouse score in the high 90s, a JS payload an order of magnitude lighter than the official portal, and a reading experience real users told me they finally understood.