One-shot bootstrap generator for database models, API models, routes, and tests
Project description
Model Generator
A one-shot bootstrap code generator that turns JSON specifications into production-ready API backends — database models, API endpoints, tests, and migrations. The generator is stack-agnostic by design; it currently ships the python-fastapi stack (chosen with --stack, the default).
What It Does
- Database models — SQLAlchemy ORM with constraints, relationships, and indexes
- API models — Pydantic request/response schemas with validators
- API routes — FastAPI CRUD endpoints
- Tests — pytest contract tests with FactoryBoy factories (a full contract suite in the example project)
- Migrations — Alembic infrastructure
Install
model-generator is a build-time scaffolding tool, not a runtime dependency of
the backends it generates. Install it as an isolated global CLI:
uv tool install model-generator-kit # or: pipx install model-generator-kit
This puts model-gen and model-val on your PATH. For the interactive wizard,
add the extra: uv tool install "model-generator-kit[interactive]".
The PyPI package is
model-generator-kit(the namemodel-generatorwas already taken); the commands it installs aremodel-genandmodel-val.
Quick Start
# In any project directory, scaffold from your JSON specs
model-gen models/ --target all
model-gen --version # confirm the install
To try the bundled example from a clone of this repo:
git clone https://github.com/nuncaeslupus/model-generator && cd model-generator
uv sync --extra dev
cd examples/user-auth-project
uv run model-gen models/ --target all
uv venv && uv sync --extra dev
uv run pytest # the generated contract suite passes
For your own project, see the Installation Guide.
Documentation
For Users
- Installation Guide — Install, configure, first project
- Model Design Guide — How to design comprehensive JSON specifications
- Usage Guide — CLI workflows, generation, cleanup, interactive mode
- Quick Reference — Lookup tables: field types, constraints, options
- Extending Generated Code — Business logic, custom routes, migrations
For Agents
- Model Design Questions — Systematic Q&A for eliciting model specs from users
- Template Extension Guide — Add types, templates, generators
- JSON Specification Reference — Exact format, every key, every option
Deep Dives
- Constraints — DB vs API constraint placement, cross-field constraints
- Completeness Guide — JSON specification checklist
- Custom Tests — Extending the generated test suite
For Contributors
- Skill Reusability — Core principles for reusable generation
- Project-Agnostic Rules — Coding rules for templates and scripts
Development
# Install in editable mode with dev dependencies
uv sync --extra dev
# Run the test suite
uv run pytest tests/ -v
Test Suite
| File | What It Covers |
|---|---|
test_generators.py |
Each generator (database, API models, routes, tests, enums, constraints, infrastructure), immutable entities |
test_edge_cases.py |
JSON comments, invalid input, config loading, deep merge, shared enums/constraints, file scanners, partial generation |
test_wizard.py |
Wizard imports, prompt fallbacks, menu flow, project setup, clean and test runner actions |
test_template_utils.py |
path_to_import, wrap_text, template environment, custom Jinja2 filters |
test_cli.py |
CLI flags: --interactive, --clear-only, --dry-run, --diff, missing model |
test_full_generation.py |
End-to-end generation from example project |
test_integration.py |
Full generation pipeline |
test_validation.py |
JSON schema validation |
test_utils.py |
Utility functions |
Philosophy
Define specifications once in JSON. Generate production-ready scaffolds. Then maintain and evolve manually. The generated code is yours — no lock-in, no regeneration, full control.
Model Generator | Bootstrap Tool for API Backends | v0.1.1
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file model_generator_kit-0.1.1.tar.gz.
File metadata
- Download URL: model_generator_kit-0.1.1.tar.gz
- Upload date:
- Size: 152.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
891033791fd2571dffce3f850a994b467d911e2421df0ea16548c3decd2d4818
|
|
| MD5 |
0bf0e70fe2a992a505c2521f71ca1c2f
|
|
| BLAKE2b-256 |
0f07c85f41e20ced523ad99119230c43ef973096e4746a7868b6cb9681ee7737
|
Provenance
The following attestation bundles were made for model_generator_kit-0.1.1.tar.gz:
Publisher:
release.yml on nuncaeslupus/model-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
model_generator_kit-0.1.1.tar.gz -
Subject digest:
891033791fd2571dffce3f850a994b467d911e2421df0ea16548c3decd2d4818 - Sigstore transparency entry: 1790428690
- Sigstore integration time:
-
Permalink:
nuncaeslupus/model-generator@f1968aed9975b983df63e53bee1d8efc25eceac8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/nuncaeslupus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f1968aed9975b983df63e53bee1d8efc25eceac8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file model_generator_kit-0.1.1-py3-none-any.whl.
File metadata
- Download URL: model_generator_kit-0.1.1-py3-none-any.whl
- Upload date:
- Size: 129.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e65616b3fcf77cd2a566425bc131b8c1862ee1a6c3f5c6fec3ae608136a432e6
|
|
| MD5 |
0c33b33d41c5d195d25e14bd9b4c4523
|
|
| BLAKE2b-256 |
3d184bf46abdece0aaba8d025609c9316b2ba4614ea3e3962e2880fbe1dd6e12
|
Provenance
The following attestation bundles were made for model_generator_kit-0.1.1-py3-none-any.whl:
Publisher:
release.yml on nuncaeslupus/model-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
model_generator_kit-0.1.1-py3-none-any.whl -
Subject digest:
e65616b3fcf77cd2a566425bc131b8c1862ee1a6c3f5c6fec3ae608136a432e6 - Sigstore transparency entry: 1790428708
- Sigstore integration time:
-
Permalink:
nuncaeslupus/model-generator@f1968aed9975b983df63e53bee1d8efc25eceac8 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/nuncaeslupus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f1968aed9975b983df63e53bee1d8efc25eceac8 -
Trigger Event:
push
-
Statement type: