Schema-first Contract Toolchain (Dart & Python)
JSON Schema → typed Dart and Pydantic models, versioned and released by CI
- Status
- Maintained
- Timeline
- 2025–26
- Kind
- Professional
- Role
- Built the model generator and release CI
- Client
- BlokxBlok (UK), via Cybage Software
Overview
A contract layer for a platform that spans a Flutter app, Python backend services and an internal admin tool. JSON Schema files describe every Firestore collection. A Python CLI that I built on Typer validates them and generates typed models: Pydantic v2 for Python, using datamodel-code-generator, and plain Dart model classes.
Problem
Without one schema source, every data change had to be made separately in the app, the backend and the console — and the three quietly drifted apart.
Approach
When a schema changes, CI validates it, blocks the merge if the schema version wasn't bumped, and releases new versions automatically: Dart packages as Git tags, Python packages on Google Artifact Registry. The app, the functions and the console always use the same versioned models. I also moved the Python codegen off quicktype so it keeps discriminated unions, validation patterns and descriptions, and recorded the change in an architecture decision record.
Stack
- data
- JSON Schema
- backend
- Python
- Pydantic
- mobile
- Dart
- tools
- Typer
- cloud-devops
- Google Artifact Registry
- GitHub Actions