Gravity Standard

00 · Gravity Standard Architecture

Define the data. Define the process. The Standard supplies the rest.

A reference architecture and foundation for business applications that AI builds from specifications. Serverless on AWS, Go on Lambda, Postgres underneath. Secure by default and opinionated on purpose.

A Data Domain and a Business Process flow into the Standard, which supplies authentication, authorization, forms, workflow, audit history and observability. DATA DOMAIN Borrowing loan_numberamountstatusborrower textmoneystatusreference BUSINESS PROCESS Loan Request intake · review · approve · fund THE STANDARD AUTHENTICATION AUTHORIZATION FORMS WORKFLOW AUDIT HISTORY OBSERVABILITY
You write the two definitions that are specific to your business. Everything every application needs comes from the foundation.

The problem

The same application, rebuilt slightly differently, again and again.

Intake, review, approve, fulfil, report. Business applications of this kind are built repeatedly, and each build re-creates the same architecture with small differences.

  • Duplicated effort on identity, access control, workflow, notifications and audit.
  • Uneven quality: security and operations differ from one application to the next.
  • Slow change, because a business-rule tweak becomes a code release.
  • Invisible processes that live only in code and in people's heads, so nobody can say what actually happens.

The Gravity Standard makes two things formal and first-class: Data Domains and Business Processes. Forms, navigation, task lists, permissions, notifications and dashboards follow from them.

Three manuals

An operator's manual first, like a device from the 1980s.

A business stakeholder writes the manual for the application they want. An AI builds the software against it, and tests prove the software does what the manual says. Unlike old manuals, this one comes first and stays binding.

Operator's manualWhat it does

Purpose, data, procedures, decisions, rules, timeouts and troubleshooting, in the operator's terms.

Written by business stakeholders, with AI help.

Service manualHow it's kept running

The architecture, a runbook for every alarm, and the permit process.

Written by engineers.

Installation manualHow it's stood up

The library, tooling, infrastructure modules and foundation applications.

Written by the foundation team.

Guiding principles

When a situation isn't covered, reason from these.

PrincipleIn practice
Simplicity over clevernessBoring, small, well-understood technology. Every dependency is a liability.
Secure by defaultThe default outcome of a bug is "no data", not "all data".
The database is the foundationThe schema is the contract. Code is generated from it, not the reverse.
Events over pollingState changes push to interested parties. Nobody asks "are we there yet?"
Managed over self-runAWS-managed services, so teams operate business logic, not infrastructure.
Maintainable by a strangerA new developer, or an AI, understands it with little ramp-up.
Push governance leftCompliance lives in permits and policy, not in approval emails.
Say it, do it, prove itState what you will do, do it, then demonstrate that you did. See Permits.

Technology

One answer per concern.

The choices are deliberately few, so teams and AI assistants make the same decision every time.

ConcernChoice
Back-end languageGo, compiled to native arm64
ComputeAWS Lambda (provided.al2023, arm64)
Relational dataPostgres: RDS by default, Aurora when scale demands. DynamoDB where access patterns are known.
Data accesssqlc-generated, type-safe queries
WorkflowAWS Step Functions
PushAPI Gateway WebSocket, with database triggers through aws_lambda
Front endHTML, htmx, vanilla JS and CSS on S3 and CloudFront; server-side rendering for sensitive screens
EdgeAWS WAF on every public entry point; GuardDuty scanning for uploads
AuthenticationSSO preferred; passkeys at minimum; no stored passwords
AuthorizationAmazon Verified Permissions (Cedar), backed by Postgres row level security
EncryptionAWS KMS, with envelope encryption for personal data
InfrastructureTerraform

Non-negotiables

The rules most often broken, with the worst consequences.

These are the flight rules. Newcomers and AI assistants break them most. Where a rule can be checked mechanically, the pipeline checks it.

  1. The UI shapes; the server enforces. Hiding a button is usability, never security. Every handler authorizes, and RLS backs it up.
  2. No secrets in environment variables, source control, front-end code or local storage.
  3. A database trigger is a hint, not a guarantee. Anything vital uses an outbox with positive confirmation.
  4. Never swallow an error. A failed handler returns failure so retries and dead-letter queues engage.
  5. Every dead-letter queue has an alarm and a runbook.
  6. Every UPDATE and DELETE has a WHERE clause, and write handlers assert how many rows they changed.
  7. No Lambda-to-Lambda Invoke. Services call each other over HTTPS.
  8. A Lambda isn't publishable without readable logs, interior timings, defined metrics and an alarm.
  9. HTTPS and WSS only, with a WAF in front of every public entry point.
  10. Uploads are hostile until scanned.
  11. Build once and promote the same artifact, one environment at a time.
  12. Every alarm links to a runbook.

Reference company

Tidewater, a fictional lender.

Every example in the Standard uses one company: a small-business lender that services loans for about 40 partner community banks, which are its tenants. It's deliberately contrived, in the way Contoso is, with awkward test scenarios built in.

ApplicationShape
LendingForm-driven, with human tasks and nested sub-processes
PaymentsFile-driven, with waiting, timers and reconciliation
Support DeskThe simplest human-task process, built from specifications alone