Inspiration
Building anything in Peru — a house, an apartment block, a school — means complying with a huge, fragmented, and constantly changing body of regulations: the National Building Code (RNE), national laws and decrees, and a different zoning ordinance for every district. All of it lives in scattered PDFs that get amended and repealed with no clear "what's in force today" view. We watched architects and engineers lose days — and sometimes make costly mistakes — just to answer one question: "What am I allowed to build on this lot, and which rule says so?" We built YARK to answer that, in seconds, with the source.
What it does
YARK is a regulatory copilot for construction in Peru. It does two things:
- Answers regulatory questions in natural language, grounded in the real, in-force norm — always citing the code and article, and explicitly saying "this isn't in my sources" instead of inventing an answer.
- Auto-resolves a lot's urban parameters (minimum lot size, frontage, open-space %) directly from its zoning, showing exactly which ordinance each number came from — and when the rule is conditional or ambiguous, it shows the options instead of guessing. ## How we built it YARK is a hybrid RAG system: TypeScript/Bun backend, a React + Vite dashboard, Supabase/PostgreSQL with pgvector, deployed on Google Cloud Run and Firebase Hosting. Google Gemini powers the intelligence in four roles:
- Embeddings (gemini-embedding-001) vectorize our curated legal corpus and every query for semantic retrieval (hybrid vector + BM25).
- Reasoning (gemini-2.5-flash) generates the final answer, grounded in the retrieved chunks, at low temperature with an anti-hallucination gate.
- A selective "Judge" (gemini-2.5-flash) re-ranks candidates only when the structural engine is unsure — an on-demand call that cut LLM usage by ~55%.
- Vision (gemini-2.5-flash) performs OCR and table extraction from regulation PDFs and plans during ingestion. On top of retrieval we built a bitemporal corpus — every norm knows what it said and from/until when — so YARK distinguishes an amended rule from its repealed version. The parameter resolver is a deterministic, LLM-free layer designed to fail toward silence: in doubt, it declines to apply a value rather than risk a false "compliant." ## Challenges we ran into
- The moat is the data, not the model. Hand-curating a bitemporal Peruvian legal corpus — the national chain (Law 29090, DS 029-2019, Law 27972) plus district zoning ordinances — anchored to the real text, was the hard part.
- Grounding vs. hallucination. In a legal domain, a confident wrong answer is a liability, so we invested heavily in retrieval quality and an answer gate that caps confidence when support is weak.
- Cost control. Running an LLM judge on every query is expensive, so we made it selective — it only fires on a low confidence gap.
- Ambiguity is real. A single zone can have sub-sectors with different parameters; instead of hiding that, the resolver surfaces the options for the professional to decide. ## Accomplishments that we're proud of
- A live product (yark.nearbycorp.info), not a prototype: natural-language Q&A and the parameter Pre-Check both working end-to-end.
- A curated, bitemporal corpus covering Lima and Callao plus the national chain.
- A continuous evaluation harness — a golden dataset that runs as a regression gate on every change — so quality never silently drifts.
- An Autodesk Revit add-in that runs the Pre-Check straight from the BIM model. ## What we learned Retrieval quality and honest grounding matter far more than raw model size for a trustworthy legal assistant. And a deliberately conservative design — fail toward silence — is what earns a professional's trust. ## What's next for YARK Cover all of Peru, across the entire construction sector — starting with true geographic orientation (coordinate → zone → parameters via PostGIS), more districts, and integrated payments and e-invoicing, so any professional can know in seconds, and with the source, what's legal to build.
Built With
- .net
- autodesk-revit-api
- bm25
- bun
- c#
- cloud-tasks
- express.js
- firebase-hosting
- gemini-embedding-001
- github-actions
- google-cloud-run
- google-gemini
- google-oauth
- node.js
- pgvector
- postgis
- postgresql
- python
- rag
- react
- supabase
- tailwindcss
- typescript
- vite
- zod
Log in or sign up for Devpost to join the conversation.