Run it yourself
Clone the repo, install, set the environment variable names, test, build, run the command-line tools and the live proof, and deploy your own copy.
You need Node 24 and npm. The command-line tools and the tests need no account and no key.
Install, build, test
git clone https://github.com/ramakrishnanhulk20/aavi.git
cd aavi
npm ci
npm run build
npm testnpm run build builds the engine first and the site second, so the site never builds against a stale classifier. The engine's tests refuse any real network call, so a test cannot quietly depend on a live city server. Over half of the test files are property tests written with fast-check.
The Kiro power has its own commands: npm run power:build and npm run power:test.
Run the site on your machine
- Run
npm cifrom the repository root, thennpm run build. The site reads@aavi/sourcesthrough its built output. - Copy
.env.examplefrom the repo root toapps/web/.env.localand fill in the four names the site reads. Next.js reads env files only fromapps/web. The file stays out of git. - From
apps/web, runnpm run dev. The site answers athttp://localhost:3000, and the routes at/api/<route>.
Environment variables
.env.example in the repo root lists every name the code reads. This page lists names and where to get each. It holds no value.
| Name | What it is | Where it goes | How to get it |
|---|---|---|---|
SOCRATA_APP_TOKEN | A free app token for a Socrata data portal. It is sent as the X-App-Token header to Socrata servers (New York State and Norfolk). Optional on the command line. | Your terminal session for the tools. Production only, for the site. | Sign in or sign up on a Socrata portal, for example health.data.ny.gov. Open Developer Settings in your profile and create an app token. |
DATABASE_URL | The connection string of the read-only database role aavi_reader | Production only, for the site | Create a Postgres database with any provider. Run the setup script below, which creates the role and writes the string to a file. |
KV_REST_API_URL | The REST address of an Upstash Redis database | Production only | In the Upstash console, create a Redis database, open its page, and copy the https address from the REST tab. |
KV_REST_API_TOKEN | The REST token of the same database | Production only | Copy the full token from the same REST tab, not the read-only one. |
DATABASE_OWNER_URL | The owner connection string of your database, used once to create the roles | Your terminal only. Never the hosting project, never a file in the repo. | Copy it from your database provider's console. |
WRITER_URL, READER_URL | The two strings the setup script writes, used by the attack script | Your terminal only | Made by apps/web/db/setup.mjs. |
The command-line tools read SOCRATA_APP_TOKEN from your terminal session. They do not read a .env file. A variable that holds a secret never gets a NEXT_PUBLIC_ prefix.
The Upstash database holds only the per-minute request counters. If it is unreachable, each server instance counts requests itself and keeps a limit.
Command-line tools
Every tool reads live from the city's own server. Where a source is optional, the default is Detroit.
| Command | What it does |
|---|---|
npm run lookup -- [SOURCE] "ADDRESS" | One lookup. Prints the full answer or non-answer as JSON. |
npm run census -- [SOURCE] | The source's own count by class, checked against its plain row count. |
npm run sample -- [SOURCE] COUNT | Reads random records and classifies each. COUNT is 1 to 100. |
npm run crosscheck -- [SOURCE] | Compares Aavi's class with the city's own whole-line class on every row. Rows milder than the city's class must be zero. |
npm run gate -- SOURCE | The city gate. Checks a source's spec against its live server and lists every raw value with the class it maps to. |
npm run fingerprint -- SOURCE | Prints the hash of the field list a spec reads. |
npm run accuracy -- SOURCE COUNT or -- --all COUNT [--write] | The accuracy run. See how we check our work. |
npm run prove | All ten sources, live. Looks up one public building in each, checks that Aavi's census total equals the city's own count, and ends with m3: pass or m3: fail. |
npm run prove:live -- --base HTTPS_ORIGIN | The live site. See below. |
Use a public building for lookups, not a home.
Prove it on the live site
npm run prove:live -- --base https://aavi.vercel.appRun npm ci and npm run build first. It ends with m7: pass and exit code 0, or m7: fail and exit code 1. The steps and the expected output are on the judges page. Wait a minute before running it again, because it uses one client's per-minute limits.
On a fresh deployment of your own, the cities step fails until the first census rows are in the store. That is expected.
Deploy your own
The full guide is docs/deploy.md. In short:
-
Create a Vercel project from the repo with these settings:
Setting Value Root Directory apps/webNode.js Version 24.x Install Command npm ci --prefix ../..Build Command npm run build --prefix ../..Turn on "Include source files outside of the Root Directory in the Build Step", because the site needs
packages/sources. -
Add
DATABASE_URL,KV_REST_API_URL,KV_REST_API_TOKENandSOCRATA_APP_TOKEN, each for Production only. Leave Preview and Development unchecked. -
Set the Ignored Build Step in the project's Git settings so that only the production branch builds. This setting lives in Vercel, not in a file in the repo.
-
Create the database roles. In your terminal, set
DATABASE_OWNER_URLto the owner string. It must end with no query, or with exactly?sslmode=verify-full. Then, from the repo root, run:node apps/web/db/setup.mjs READER_FILE WRITER_FILEEach file name is a new path outside the repo. The script prints
createdorexists, and writes the two connection strings into the files, readable by you only. -
Copy the reader string into
DATABASE_URLin Vercel. The writer string never goes in the Vercel project. Only the Crew App's census push uses it. Delete both files when you are done. -
Set
READER_URLandWRITER_URLin your terminal and runnode apps/web/db/attack.mjs. It tries an update, a delete and a row dated in the future, and exits with code 1 if the database accepts any of them. Run it again after every schema change. -
After the first production build, run the proof command against your domain.
The Vercel project must never hold an owner credential, or a credential that a hosting integration created for the database, because those carry owner rights.