Skip to content

Repository files navigation

Safety Net Blueprint

Status: Active development — See the roadmap.

A systems integration blueprint for safety net benefits programs. Contract artifacts — OpenAPI specs, state machines, decision rules, metrics, and field metadata — define the full API surface for backend development. States adopt the blueprint, customize it with overlays, and build adapters to their vendor systems. Frontends develop against a mock server without waiting for a production backend.

Frontend harness packages (form engine, safety harness, harness designer) live in a separate repository: codeforamerica/safety-net-harness.

New here? Browse all diagrams and reference tools in the Explorer hub.

About This Repository

This repository contains the base contract artifacts, tooling, and documentation for the contract-driven architecture. It provides:

  • Base contract artifacts — OpenAPI specs, state machine definitions, decision rules, metrics, and field metadata that define both data operations (REST) and behavioral operations (RPC)
  • Conversion scripts — generate contract YAML from tables (spreadsheets) so business users can author requirements directly
  • Validation — check OpenAPI specs and cross-artifact consistency
  • Mock server — interprets contracts with an in-memory database for development without a production backend, serving REST APIs, RPC APIs, and event streams
  • Field metadata — annotations (program relevance, verification requirements, regulatory citations), field-level permissions, and multilingual labels as contract artifacts served by the backend
  • Client generation — typed TypeScript SDK and Zod schemas from resolved specs
  • State overlays — states customize contracts without forking the base files

The architecture is being proven through steel thread prototypes that exercise the most complex parts of the design before domains are built out at scale.

Adopting the Blueprint

To adopt the blueprint, create a repository, install the base packages, apply overlays to customize the contracts for your context, and point the CLIs at the resolved output. See the Setup Guide for the full walkthrough and the Overlay Guide for overlay authoring.

Getting Started

Choose your path based on your role:

Role You want to... Start here
UX Designer Explore the data model and design reference UX Designer Guide
Backend Developer Author contracts, validate specs, build production adapters Backend Developer Guide
Frontend Developer Build UIs against REST and RPC APIs, use generated clients Frontend Developer Guide
Tester Run tests, write integration tests, test against the mock Tester Guide

Quick Start

npm install

# Start mock server + Swagger UI
npm run mock:start:all

Visit http://localhost:3000 for interactive API docs.

Contributing

After cloning, run the one-time setup to install the pre-push git hook:

npm run setup:hooks

This installs a hook that runs before every push. The hook rebuilds explorer outputs and commits them if stale, then runs npm run preflight — which validates specs, runs tests, and runs integration tests. Use git push --no-verify to skip for work-in-progress pushes.

Commands

Command Description
npm start Start mock server
npm run mock:start:all Start mock server + Swagger UI
npm run validate Validate OpenAPI specs
npm run resolve -- --spec=<spec-dir> --overlay=<overlay-dir> --out=<out-dir> Resolve overlays against base specs
npm run build --workspace=packages/explorer Build all explorer reference tools
node packages/explorer/build.js --resolved=<dir> --clients=<dir> Build explorer from state-specific resolved specs
npm run api:new Scaffold a new API spec
npm run mock:reset Reset database to example data
npm test Run unit tests
npm run test:integration Run integration tests (includes Postman/newman)

Full command reference →

Documentation

Architecture

Guides

Integration

Reference

Decisions

Changelogs

Requirements

Node.js >= 20.19.0

License

PolyForm Noncommercial License 1.0.0

About

OpenAPI Specifications for Safety Net Applications

Resources

Security policy

Stars

7 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages