Skip to content

Repository files navigation

Safety Net Blueprint

A systems integration blueprint for safety net benefits programs, built on a reusable contract-driven development framework. 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.

Stability: All packages are at 0.x — minor versions may include breaking changes until 1.0.0 is declared. Pin your versions if stability matters.

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

About This Repository

This repository has two layers:

  • The Blueprint Framework — domain-agnostic tooling for contract-driven API development: overlay resolution, validation, state machine engine, mock server, client generation, and explorer. The framework packages (blueprint-core, blueprint-cli, blueprint-mock-server, blueprint-explorer) can be used independently to build contract-driven systems for any domain.
  • The Safety Net Contracts — the reference implementation of the framework for safety net benefits programs: OpenAPI specs, state machines, annotations, and overlays across a dozen domains.

Together they provide:

  • Base contract artifacts — OpenAPI specs, state machine definitions, metrics, and field metadata that define both data operations (REST) and behavioral operations (RPC)
  • 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, field-level permissions, and multilingual labels as contract artifacts served by the backend
  • Client generation — typed TypeScript SDK from resolved specs
  • State overlays — states customize contracts without forking the base files

Repository Structure

The monorepo separates domain-agnostic framework tooling from safety-net-specific contracts:

Package npm name Purpose
packages/blueprint-core @codeforamerica/blueprint-core Framework library: overlay resolution, validation, state machines, annotations
packages/blueprint-cli @codeforamerica/blueprint-cli CLI scripts: blueprint-resolve, blueprint-validate, blueprint-generate-ts-clients, etc.
packages/blueprint-mock-server @codeforamerica/blueprint-mock-server Mock API server: blueprint-mock, blueprint-swagger
packages/blueprint-explorer @codeforamerica/blueprint-explorer Explorer build tooling (outputs to packages/safety-net-explorer/)
packages/safety-net-contracts @codeforamerica/blueprint-safety-net-contracts Safety-net domain contracts: OpenAPI specs, state machines, overlays
packages/generated — Generated artifacts: resolved specs, TypeScript clients, Postman collection (gitignored)

blueprint-core and blueprint-cli are domain-agnostic — they can be used for any contract-driven project. safety-net-contracts depends on blueprint-cli and uses blueprint-core as its framework.

At the core of the blueprint is a domain-agnostic framework (blueprint-core) that implements the architectural patterns — contract-first API design, overlay-based customization, state machine-driven behavior, event-driven integration — as reusable tooling. The safety net contracts package applies these patterns to the safety net benefits domain. Other domains could use the same framework to build their own contract-driven systems.

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

Adopting the Safety Net Blueprint

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

Building a new domain

Using the framework to define a new contract-driven API domain — whether extending safety net or building something in the same space? Start here: Building a New Domain

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.

If your change affects a published package, include a changeset before opening a PR. See CONTRIBUTING.md for guidance on writing changeset descriptions and how the release process works.

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/blueprint-explorer Build all explorer reference tools
node packages/blueprint-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

Changelogs

Requirements

Node.js >= 22.11.0

License

PolyForm Noncommercial License 1.0.0

About

OpenAPI Specifications for Safety Net Applications

Resources

Contributing

Security policy

Stars

7 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages