Permit Pilot
Permits reviewed in days, not months

Permit intake and review for a city. Applicants submit plans, an AI pass checks them against the zoning and building code with citations, and reviewers approve or send corrections. Inspections and 311 requests live in the same queue.
Who uses it: Applicants and contractors, plan reviewers, inspectors and city staff.
Screens
Guided permit application with plan upload and fee estimate.
Permits by type and SLA day, oldest at risk first.
Plan sheet viewer beside the automated code check: pass, fail, needs review, each with the code section.
Reviewer sends a corrections letter built from the failed checks.
Scheduled inspections and resident requests on one board.
How it runs
Data model
- usersid, email, name, role (applicant | reviewer | inspector | admin)
- parcelsid, address, zone, lot_sq_ft
- permitsid, number, parcel_id, applicant_id, kind, status (submitted | in_review | corrections | approved | issued), submitted_at, sla_due
- documentsid, permit_id, kind (plan | survey | calc), storage_key, pages
- code_sectionsid, code (zoning | IRC | IBC), section, title, body, embedding vector(1024)
- checksid, permit_id, rule, result (pass | fail | review), measured, required, section_id, note
- inspectionsid, permit_id, kind, scheduled_for, inspector_id, result
- service_requestsid, category, address, description, status, created_at
API
- POST/api/permitsSubmit an application
- POST/api/permits/{id}/documentsUpload a plan (presigned or multipart)
- GET/api/permitsReview queue with SLA filters
- POST/api/permits/{id}/checkRun the automated code check (SSE)
- PATCH/api/checks/{id}Reviewer overrides a result with a note
- POST/api/permits/{id}/decisionApprove or send corrections
- POST/api/inspectionsSchedule an inspection
- POST/api/311File a resident request
Build it with your agent
Copy the prompt into Claude Code, Codex, Cursor or any coding agent connected to Nexlayer. It works from a spec: contracts first, then each phase with checks that must pass, then it ships to Nexlayer and verifies the live app.
- 1Spec + contract→
- 2API→
- 3Web→
- 4AI→
- 5End-to-end test→
- 6Ship + verify
Build Permit Pilot: permits reviewed in days, not months. A production full-stack web application, deployed live on Nexlayer.
Work spec-first. Before writing app code, write SPEC.md (from the spec below, plus your decisions), api/openapi.yaml and the first migration, and show me a short plan. Then build in phases and don't move on until each phase's checks pass.
## Product
Permit intake and review for a city. Applicants submit plans, an AI pass checks them against the zoning and building code with citations, and reviewers approve or send corrections. Inspections and 311 requests live in the same queue.
Users: Applicants and contractors, plan reviewers, inspectors and city staff.
## Screens
- Apply: Guided permit application with plan upload and fee estimate.
- Review queue: Permits by type and SLA day, oldest at risk first.
- Plan review: Plan sheet viewer beside the automated code check: pass, fail, needs review, each with the code section.
- Corrections: Reviewer sends a corrections letter built from the failed checks.
- Inspections & 311: Scheduled inspections and resident requests on one board.
## Data model (Postgres + pgvector)
- users(id, email, name, role (applicant | reviewer | inspector | admin))
- parcels(id, address, zone, lot_sq_ft)
- permits(id, number, parcel_id, applicant_id, kind, status (submitted | in_review | corrections | approved | issued), submitted_at, sla_due)
- documents(id, permit_id, kind (plan | survey | calc), storage_key, pages)
- code_sections(id, code (zoning | IRC | IBC), section, title, body, embedding vector(1024))
- checks(id, permit_id, rule, result (pass | fail | review), measured, required, section_id, note)
- inspections(id, permit_id, kind, scheduled_for, inspector_id, result)
- service_requests(id, category, address, description, status, created_at)
## API
- POST /api/permits — Submit an application
- POST /api/permits/{id}/documents — Upload a plan (presigned or multipart)
- GET /api/permits — Review queue with SLA filters
- POST /api/permits/{id}/check — Run the automated code check (SSE)
- PATCH /api/checks/{id} — Reviewer overrides a result with a note
- POST /api/permits/{id}/decision — Approve or send corrections
- POST /api/inspections — Schedule an inspection
- POST /api/311 — File a resident request
## AI
- Extract measurements from the application (setbacks, lot coverage, height, egress) into structured fields, then check them against code sections retrieved from pgvector.
- Each check stores measured value, required value and the code section; the model never decides without a cited section.
- Draft the corrections letter from the failed checks; the reviewer edits before sending.
## Seed data
One city's zoning table and 60 code sections with embeddings, 20 parcels, 15 permits across every status, 3 users per role.
## Core flow (must work end to end)
Submit a permit, run the code check, see a failed setback with its code section, send corrections, resubmit, approve and issue.
## Stack (fixed)
- web/: React 19 + TypeScript (strict) + Vite, React Router, TanStack Query, Tailwind CSS. A typed API client generated from the OpenAPI spec. Served as static files by a small web server in its own container.
- api/: Go (latest stable), net/http with Go 1.22+ routing patterns or chi, pgx v5, sqlc for queries, golang-migrate for migrations, log/slog JSON logs, OpenAPI 3.1 spec in api/openapi.yaml as the contract.
- Postgres 16 with the pgvector extension (HNSW indexes on embedding columns), on a persistent volume.
- AI: Nexlayer Inference. Read the endpoint, model and key from environment variables NEXLAYER_INFERENCE_URL, NEXLAYER_INFERENCE_MODEL and NEXLAYER_INFERENCE_API_KEY. The key comes from https://inference.nexlayer.com/app/#/models: ask me to add it as a secret in Nexlayer. Never ask me to paste it into this chat and never write it into the repo.
## Engineering bar
- Contract first: api/openapi.yaml is the source of truth; the Go handlers and the web client are generated from or checked against it.
- Errors as RFC 9457 problem+json. Validate every input at the edge. Cursor pagination on every list.
- Auth: email magic link or password with argon2id; HTTP-only, SameSite session cookies; role checks in the API, never only in the UI.
- Idempotency keys on every POST that creates or submits something. Request timeouts via context. Graceful shutdown.
- GET /api/healthz (process up) and GET /api/readyz (database reachable, migrations applied).
- Migrations run on start, forward only. Seed data behind a SEED=true flag.
- AI calls: timeouts, retries with backoff, streamed responses over SSE, prompts kept in files, structured JSON output validated before use, and a clear UI state when NEXLAYER_INFERENCE_API_KEY is missing (the rest of the app still works).
- Web: loading, empty and error states on every screen; keyboard accessible; no layout shift.
- Tests: Go table-driven tests, integration tests against a real Postgres (testcontainers), and one Playwright test for the core flow. Lint and typecheck clean.
## Phases
1. Contract: SPEC.md, openapi.yaml, schema and migrations, seed data. Check: migrations apply cleanly to an empty database.
2. API: every endpoint in the spec, with auth and role checks. Check: Go tests and integration tests pass.
3. Web: every screen, wired to the API through the generated client. Check: typecheck and lint pass; every screen has loading, empty and error states.
4. AI: retrieval, model calls and streaming as described. Check: works with a key, degrades clearly without one.
5. End to end: the Playwright test for the core flow passes locally.
6. Ship on Nexlayer (below).
## Ship it on Nexlayer
- Load the Nexlayer skill first: call nexlayer_get_skill_content with skillName "ship-it-nexlayer" and follow it.
- Dockerfiles: multi-stage, small runtime images, built for linux/amd64.
- nexlayer.yaml: three parts. web with path "/", api with path "/api", postgres with no path (private) and a volume. Set PGDATA to a subdirectory of the volume mount. The api reaches the database at postgres.pod; the browser reaches the api at <% URL %>/api. Secrets are ${NAME} references, never values.
- Deploy with `nexlayer ship --check /api/readyz` if the Nexlayer CLI is installed, otherwise through the Nexlayer MCP (validate, deploy, check status).
- Don't stop at "deployed": open the live URL, run the core flow against it, and send me the URL with what you verified.New to Nexlayer? Connect your agent first