Case study

CruftFree: Generating a Whole Platform from One Spec

Describing a whole aviation data platform once, and compiling it into consistent backends and clients instead of writing them one by one.

SunFox productCompiler & code generationPython + TypeScript

1Problem

The first microservice is always easy. By service four, after new developers join and requirements shift, services drift apart: one returns snake_case fields and another camelCase, a user ID is a UUID in one service and an integer in another, and auth middleware is wired three different ways. A cross-service change, such as adding Kafka events everywhere, touches every service.

2Approach

We built CruftFree, a compiler for whole platforms: backends, web and mobile clients, and infrastructure. The whole system is described once in a purpose-built DSL, and then:

  1. A real lexer, parser, and AST validate the spec, including cross-service types and event contracts, before any code is emitted.
  2. Application generators produce FastAPI (Python) or NestJS (TypeScript) services, SQL schemas and migrations, and config and docs.
  3. Platform generators add Docker, AWS (CDK, CloudFormation) or Azure (Bicep, ARM) infrastructure, and Angular web and Flutter mobile clients.

Because the clients and the services are generated from the same spec, client and server contracts cannot drift.

3Result

A production aviation data platform is described in 89 .dtrx files: 97,874 lines of code, with comments and blank lines excluded, plus 6,438 lines of configuration. CruftFree compiles that into about 15 times as much code, so we write and maintain roughly one line for every fifteen that ship. The same input always produces the same output, and a change in the spec updates every service that references it, with matching migration scripts.

Have a similar problem?

Book a free 30-minute call with the architect who would do the work, and we'll talk through what it would take.