cornerpin.app · how it runs
How Cornerpin is built
A multi-tenant app for selling subdivision lots, with an AI assistant that follows up with buyers, advisory risk scores from a model in its own service, an owner dashboard, and integrations with Slack and Salesforce. It runs on Google Cloud, with its database on Neon. Terraform defines every piece, and a merge to main deploys it.
- Region us-west1, Oregon
- Database Neon, AWS us-west-2
- Hosting cost about $0–1 a month
Request path
From a browser to the database
- Browser or installed appBuyers browse lots and ask questions. Owners use the portal, which the service worker never caches.
- Firebase Hosting
cornerpin.appandwww, with Google-managed HTTPS certificates. It passes every request to the web service. - Cloud Run: web (Next.js)Renders the pages and forwards
/v1/*to the API. - Cloud Run: api (FastAPI)REST for writes, GraphQL for public reads, plus webhooks. Every change that needs an outside call is written to an outbox in the same transaction.
- What the API reaches
- Neon Postgres + PostGISRow-level security keeps tenants apart
- Cloud StorageLot photos and documents
- Outbox → Cloud TasksBackground jobs: Claude, Resend, Slack, Salesforce, web push, scoring
- Cloud Run: decisioningThe risk model, called from background jobs with a Google ID token
Google Cloud
The services it runs on
| Service | What it does here |
|---|---|
| Cloud Run services | web (Next.js), api (FastAPI) and decisioning (the LightGBM risk model, which only the API may call). All three scale to zero when idle. |
| Cloud Run jobs | migrate runs the database migrations on every deploy; ops runs one-off commands such as seeding the demo. |
| Firebase Hosting | The custom domains and certificates, in front of the web service. Free at this traffic. |
| Cloud Tasks | Wakes the API to process background jobs right after a change, and again when a delayed job is due, such as the assistant's follow-up 15 minutes after a question. |
| Cloud Scheduler | An hourly outbox sweep as a safety net, and daily housekeeping. |
| Secret Manager | Every secret: database URLs, API keys, Slack and Resend secrets, and the key that encrypts each tenant's integration credentials. A feature's secrets reach the services only when that feature is switched on. |
| Cloud Storage | Photos and documents for each lot. |
| Artifact Registry | The Docker images for api, decisioning and web. |
| IAM and Workload Identity | GitHub Actions deploys without a stored Google key. Separate service accounts for the API, web, decisioning, tasks and deploys. |
| Billing budget | An alert at $5 a month. |
Outside services
What it connects to
| Service | Use |
|---|---|
| Neonfree plan | Postgres 17 with PostGIS for lot shapes and maps. The API connects as a role that can only see the signed-in tenant's rows. |
| Anthropic ClaudeSonnet 5.5 | The outreach assistant. It states only prices and availability it read through its tools, and hands a buyer to a person when unsure. |
| Resend | Sends sign-in codes, alerts and the assistant's emails, and receives buyers' replies at reply.cornerpin.app through a signed webhook. |
| Slack | Each owner adds the app to their own workspace. New leads, hold requests and handoffs post to a channel; /lot answers with a lot's status and price. |
| Salesforce | Each owner connects their own org. Leads, approved holds (as Opportunities) and lots (as Products) stay in step. |
| Cloudflare Turnstile | The bot check on public forms. Sign-in is passwordless. |
| GoDaddy | Domain registrar and DNS. |
| GitHub Actions | Checks every pull request and push to main, deploys once those checks pass on main, and runs the assistant's live evals on request. |
Delivery
What a merge to main does
- Step 1CheckCI must pass: lint, type checks, API tests, web tests and browser tests
- Step 2BuildDocker images for the API, decisioning and web, pushed to Artifact Registry
- Step 3MigrateThe migrate job brings the database up to date
- Step 4DeployDecisioning, then the API, then web, each a new Cloud Run revision. One outbox drain runs between the API and web.
- Step 5Smoke checkHealth through web to the private API, a lot page, and the service worker
Languages
What it's written in
- Python API
- FastAPI, Pydantic, SQLAlchemy, Alembic and the Anthropic SDK; LightGBM for the risk model, in its own service. Tested with pytest, checked with Ruff and Pyright.
- TypeScript web
- Next.js App Router and React, an installable app with a service worker. Types are generated from the API's schema. Tested with Vitest and Playwright.
- SQL data
- Postgres and PostGIS, with row-level security policies, triggers that queue integration events, and the dashboard's views.
- HCL infrastructure
- Terraform for every Google Cloud resource on this page.
- And supporting
- GraphQL for public reads, Bash for deploy and secrets scripts, YAML for GitHub Actions and the Slack app manifest, and Docker.
Engineering practice
How it's kept honest
- API tests
- 439
- web unit tests
- 137
- browser tests, phone and desktop
- 86
- scripted conversations for the assistant
- 13
- architecture decision records
- 52
- Every tenant table has row-level security, with a test proving one tenant can't read another's rows.
- Calls to Claude, email, Slack and Salesforce never run during a page load. They run in background jobs fed by the outbox, with retries.
- The assistant sends nothing without recorded consent, honours opt-outs first, respects quiet hours in the buyer's time zone, and logs every send.
- Its evals replay recorded conversations free on every CI run, and include a planted made-up price that the checks must catch.
- Secrets live in Secret Manager, never in the web bundle or the repository. Tenants' own credentials are encrypted per tenant.
- Risk scores are advisory. Each is stored with the model version, its inputs and its reasons, and a person decides. The decision records the score they saw.
- The models look only at what a person did, never who they are. A test fails if a feature is added outside the allowed list. They train on synthetic history, and the portal says so.
Built by Gigadev, LLC. To see it from a buyer's side, read how Cornerpin works or open the demo subdivision.