model-generator-kit 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- model_generator_kit-0.1.0/LICENSE +21 -0
- model_generator_kit-0.1.0/PKG-INFO +143 -0
- model_generator_kit-0.1.0/README.md +107 -0
- model_generator_kit-0.1.0/pyproject.toml +112 -0
- model_generator_kit-0.1.0/setup.cfg +4 -0
- model_generator_kit-0.1.0/src/model_generator/__init__.py +6 -0
- model_generator_kit-0.1.0/src/model_generator/generate.py +1030 -0
- model_generator_kit-0.1.0/src/model_generator/generators/__init__.py +38 -0
- model_generator_kit-0.1.0/src/model_generator/generators/api.py +287 -0
- model_generator_kit-0.1.0/src/model_generator/generators/constraints.py +176 -0
- model_generator_kit-0.1.0/src/model_generator/generators/database.py +147 -0
- model_generator_kit-0.1.0/src/model_generator/generators/enums.py +88 -0
- model_generator_kit-0.1.0/src/model_generator/generators/infrastructure.py +679 -0
- model_generator_kit-0.1.0/src/model_generator/generators/migrations.py +146 -0
- model_generator_kit-0.1.0/src/model_generator/py.typed +0 -0
- model_generator_kit-0.1.0/src/model_generator/schema/model.schema.json +758 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/config.yaml +403 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/_shared/_base.j2 +26 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/_shared/_entity.j2 +48 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/_shared/_examples.j2 +50 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/_shared/_fields.j2 +48 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/_shared/_tests.j2 +143 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/api/init.py.j2 +55 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/api/pagination.py.j2 +79 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/api/request.py.j2 +448 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/api/response.py.j2 +222 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/api/route.py.j2 +507 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/database/constraints.py.j2 +439 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/database/enums.py.j2 +55 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/database/factory.py.j2 +265 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/database/init.py.j2 +37 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/database/model.py.j2 +476 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/infrastructure/auth_router.py.j2 +434 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/infrastructure/base.py.j2 +16 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/infrastructure/csrf.py.j2 +121 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/infrastructure/database_init.py.j2 +12 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/infrastructure/encrypted_bytes.py.j2 +62 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/infrastructure/engine.py.j2 +51 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/infrastructure/errors.py.j2 +74 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/infrastructure/gitignore.j2 +48 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/infrastructure/main.py.j2 +94 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/infrastructure/pyproject.toml.j2 +92 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/infrastructure/rate_limit.py.j2 +41 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/infrastructure/types.py.j2 +94 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/infrastructure/utils.py.j2 +50 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/infrastructure/validators.py.j2 +126 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/migrations/env.py.j2 +125 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/migrations/ini.j2 +109 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/migrations/script.py.mako.j2 +35 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/tests/conftest_root.py.j2 +122 -0
- model_generator_kit-0.1.0/src/model_generator/stacks/python-fastapi/templates/tests/contract.py.j2 +1860 -0
- model_generator_kit-0.1.0/src/model_generator/utils/__init__.py +31 -0
- model_generator_kit-0.1.0/src/model_generator/utils/conftest_generator.py +683 -0
- model_generator_kit-0.1.0/src/model_generator/utils/constants.py +6 -0
- model_generator_kit-0.1.0/src/model_generator/utils/loaders.py +292 -0
- model_generator_kit-0.1.0/src/model_generator/utils/parser.py +129 -0
- model_generator_kit-0.1.0/src/model_generator/utils/quality.py +43 -0
- model_generator_kit-0.1.0/src/model_generator/utils/templates.py +128 -0
- model_generator_kit-0.1.0/src/model_generator/validate.py +219 -0
- model_generator_kit-0.1.0/src/model_generator/wizard/__init__.py +10 -0
- model_generator_kit-0.1.0/src/model_generator/wizard/actions/__init__.py +1 -0
- model_generator_kit-0.1.0/src/model_generator/wizard/actions/clean.py +55 -0
- model_generator_kit-0.1.0/src/model_generator/wizard/actions/generate.py +166 -0
- model_generator_kit-0.1.0/src/model_generator/wizard/actions/project_setup.py +142 -0
- model_generator_kit-0.1.0/src/model_generator/wizard/actions/test_runner.py +60 -0
- model_generator_kit-0.1.0/src/model_generator/wizard/menu.py +43 -0
- model_generator_kit-0.1.0/src/model_generator/wizard/prompts.py +80 -0
- model_generator_kit-0.1.0/src/model_generator_kit.egg-info/PKG-INFO +143 -0
- model_generator_kit-0.1.0/src/model_generator_kit.egg-info/SOURCES.txt +83 -0
- model_generator_kit-0.1.0/src/model_generator_kit.egg-info/dependency_links.txt +1 -0
- model_generator_kit-0.1.0/src/model_generator_kit.egg-info/entry_points.txt +3 -0
- model_generator_kit-0.1.0/src/model_generator_kit.egg-info/requires.txt +19 -0
- model_generator_kit-0.1.0/src/model_generator_kit.egg-info/top_level.txt +1 -0
- model_generator_kit-0.1.0/tests/test_cleanup.py +200 -0
- model_generator_kit-0.1.0/tests/test_cli.py +402 -0
- model_generator_kit-0.1.0/tests/test_edge_cases.py +1092 -0
- model_generator_kit-0.1.0/tests/test_enum_examples.py +219 -0
- model_generator_kit-0.1.0/tests/test_full_generation.py +125 -0
- model_generator_kit-0.1.0/tests/test_generators.py +4649 -0
- model_generator_kit-0.1.0/tests/test_integration.py +99 -0
- model_generator_kit-0.1.0/tests/test_template_utils.py +207 -0
- model_generator_kit-0.1.0/tests/test_utils.py +44 -0
- model_generator_kit-0.1.0/tests/test_validate.py +734 -0
- model_generator_kit-0.1.0/tests/test_validation.py +149 -0
- model_generator_kit-0.1.0/tests/test_wizard.py +281 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 nuncaeslupus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: model-generator-kit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: One-shot bootstrap generator for database models, API models, routes, and tests
|
|
5
|
+
Author-email: nuncaeslupus <imarcos@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: generator,code-generator,fastapi,sqlalchemy,pydantic,boilerplate
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: jinja2>=3.0.0
|
|
19
|
+
Requires-Dist: pyyaml>=6.0.0
|
|
20
|
+
Requires-Dist: jsonschema>=4.0.0
|
|
21
|
+
Provides-Extra: interactive
|
|
22
|
+
Requires-Dist: questionary>=2.0.0; extra == "interactive"
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
26
|
+
Requires-Dist: questionary>=2.0.0; extra == "dev"
|
|
27
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
28
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
29
|
+
Requires-Dist: types-PyYAML>=6.0.0; extra == "dev"
|
|
30
|
+
Requires-Dist: types-jsonschema>=4.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: mutmut>=2.4.0; extra == "dev"
|
|
32
|
+
Requires-Dist: sqlalchemy>=2.0; extra == "dev"
|
|
33
|
+
Requires-Dist: build>=1.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# Model Generator
|
|
38
|
+
|
|
39
|
+
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).
|
|
40
|
+
|
|
41
|
+
## What It Does
|
|
42
|
+
|
|
43
|
+
- **Database models** — SQLAlchemy ORM with constraints, relationships, and indexes
|
|
44
|
+
- **API models** — Pydantic request/response schemas with validators
|
|
45
|
+
- **API routes** — FastAPI CRUD endpoints
|
|
46
|
+
- **Tests** — pytest contract tests with FactoryBoy factories (a full contract suite in the example project)
|
|
47
|
+
- **Migrations** — Alembic infrastructure
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
`model-generator` is a build-time scaffolding tool, not a runtime dependency of
|
|
52
|
+
the backends it generates. Install it as an isolated global CLI:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv tool install model-generator-kit # or: pipx install model-generator-kit
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This puts `model-gen` and `model-val` on your PATH. For the interactive wizard,
|
|
59
|
+
add the extra: `uv tool install "model-generator-kit[interactive]"`.
|
|
60
|
+
|
|
61
|
+
> The PyPI package is `model-generator-kit` (the name `model-generator` was already
|
|
62
|
+
> taken); the commands it installs are `model-gen` and `model-val`.
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# In any project directory, scaffold from your JSON specs
|
|
68
|
+
model-gen models/ --target all
|
|
69
|
+
|
|
70
|
+
model-gen --version # confirm the install
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
To try the bundled example from a clone of this repo:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
git clone https://github.com/nuncaeslupus/model-generator && cd model-generator
|
|
77
|
+
uv sync --extra dev
|
|
78
|
+
cd examples/user-auth-project
|
|
79
|
+
uv run model-gen models/ --target all
|
|
80
|
+
uv venv && uv sync --extra dev
|
|
81
|
+
uv run pytest # the generated contract suite passes
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
For your own project, see the [Installation Guide](./docs/user/installation.md).
|
|
85
|
+
|
|
86
|
+
## Documentation
|
|
87
|
+
|
|
88
|
+
### For Users
|
|
89
|
+
|
|
90
|
+
- **[Installation Guide](./docs/user/installation.md)** — Install, configure, first project
|
|
91
|
+
- **[Model Design Guide](./docs/user/model-design-guide.md)** — How to design comprehensive JSON specifications
|
|
92
|
+
- **[Usage Guide](./docs/user/usage-guide.md)** — CLI workflows, generation, cleanup, interactive mode
|
|
93
|
+
- **[Quick Reference](./docs/user/quick-reference.md)** — Lookup tables: field types, constraints, options
|
|
94
|
+
- **[Extending Generated Code](./docs/user/extending-generated-code.md)** — Business logic, custom routes, migrations
|
|
95
|
+
|
|
96
|
+
### For Agents
|
|
97
|
+
|
|
98
|
+
- **[Model Design Questions](./docs/agent/model-design-questions.md)** — Systematic Q&A for eliciting model specs from users
|
|
99
|
+
- **[Template Extension Guide](./docs/agent/template-extension-guide.md)** — Add types, templates, generators
|
|
100
|
+
- **[JSON Specification Reference](./docs/agent/json-specification-reference.md)** — Exact format, every key, every option
|
|
101
|
+
|
|
102
|
+
### Deep Dives
|
|
103
|
+
|
|
104
|
+
- **[Constraints](./docs/deep-dives/constraints.md)** — DB vs API constraint placement, cross-field constraints
|
|
105
|
+
- **[Completeness Guide](./docs/deep-dives/completeness-guide.md)** — JSON specification checklist
|
|
106
|
+
- **[Custom Tests](./docs/deep-dives/custom-tests.md)** — Extending the generated test suite
|
|
107
|
+
|
|
108
|
+
### For Contributors
|
|
109
|
+
|
|
110
|
+
- **[Skill Reusability](./docs/contributor/skill-reusability.md)** — Core principles for reusable generation
|
|
111
|
+
- **[Project-Agnostic Rules](./docs/contributor/project-agnostic-rules.md)** — Coding rules for templates and scripts
|
|
112
|
+
|
|
113
|
+
## Development
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Install in editable mode with dev dependencies
|
|
117
|
+
uv sync --extra dev
|
|
118
|
+
|
|
119
|
+
# Run the test suite
|
|
120
|
+
uv run pytest tests/ -v
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Test Suite
|
|
124
|
+
|
|
125
|
+
| File | What It Covers |
|
|
126
|
+
|------|---------------|
|
|
127
|
+
| `test_generators.py` | Each generator (database, API models, routes, tests, enums, constraints, infrastructure), immutable entities |
|
|
128
|
+
| `test_edge_cases.py` | JSON comments, invalid input, config loading, deep merge, shared enums/constraints, file scanners, partial generation |
|
|
129
|
+
| `test_wizard.py` | Wizard imports, prompt fallbacks, menu flow, project setup, clean and test runner actions |
|
|
130
|
+
| `test_template_utils.py` | `path_to_import`, `wrap_text`, template environment, custom Jinja2 filters |
|
|
131
|
+
| `test_cli.py` | CLI flags: `--interactive`, `--clear-only`, `--dry-run`, `--diff`, missing model |
|
|
132
|
+
| `test_full_generation.py` | End-to-end generation from example project |
|
|
133
|
+
| `test_integration.py` | Full generation pipeline |
|
|
134
|
+
| `test_validation.py` | JSON schema validation |
|
|
135
|
+
| `test_utils.py` | Utility functions |
|
|
136
|
+
|
|
137
|
+
## Philosophy
|
|
138
|
+
|
|
139
|
+
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.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
**Model Generator** | Bootstrap Tool for API Backends | v0.1.0
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Model Generator
|
|
2
|
+
|
|
3
|
+
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).
|
|
4
|
+
|
|
5
|
+
## What It Does
|
|
6
|
+
|
|
7
|
+
- **Database models** — SQLAlchemy ORM with constraints, relationships, and indexes
|
|
8
|
+
- **API models** — Pydantic request/response schemas with validators
|
|
9
|
+
- **API routes** — FastAPI CRUD endpoints
|
|
10
|
+
- **Tests** — pytest contract tests with FactoryBoy factories (a full contract suite in the example project)
|
|
11
|
+
- **Migrations** — Alembic infrastructure
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
`model-generator` is a build-time scaffolding tool, not a runtime dependency of
|
|
16
|
+
the backends it generates. Install it as an isolated global CLI:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
uv tool install model-generator-kit # or: pipx install model-generator-kit
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
This puts `model-gen` and `model-val` on your PATH. For the interactive wizard,
|
|
23
|
+
add the extra: `uv tool install "model-generator-kit[interactive]"`.
|
|
24
|
+
|
|
25
|
+
> The PyPI package is `model-generator-kit` (the name `model-generator` was already
|
|
26
|
+
> taken); the commands it installs are `model-gen` and `model-val`.
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# In any project directory, scaffold from your JSON specs
|
|
32
|
+
model-gen models/ --target all
|
|
33
|
+
|
|
34
|
+
model-gen --version # confirm the install
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
To try the bundled example from a clone of this repo:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
git clone https://github.com/nuncaeslupus/model-generator && cd model-generator
|
|
41
|
+
uv sync --extra dev
|
|
42
|
+
cd examples/user-auth-project
|
|
43
|
+
uv run model-gen models/ --target all
|
|
44
|
+
uv venv && uv sync --extra dev
|
|
45
|
+
uv run pytest # the generated contract suite passes
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For your own project, see the [Installation Guide](./docs/user/installation.md).
|
|
49
|
+
|
|
50
|
+
## Documentation
|
|
51
|
+
|
|
52
|
+
### For Users
|
|
53
|
+
|
|
54
|
+
- **[Installation Guide](./docs/user/installation.md)** — Install, configure, first project
|
|
55
|
+
- **[Model Design Guide](./docs/user/model-design-guide.md)** — How to design comprehensive JSON specifications
|
|
56
|
+
- **[Usage Guide](./docs/user/usage-guide.md)** — CLI workflows, generation, cleanup, interactive mode
|
|
57
|
+
- **[Quick Reference](./docs/user/quick-reference.md)** — Lookup tables: field types, constraints, options
|
|
58
|
+
- **[Extending Generated Code](./docs/user/extending-generated-code.md)** — Business logic, custom routes, migrations
|
|
59
|
+
|
|
60
|
+
### For Agents
|
|
61
|
+
|
|
62
|
+
- **[Model Design Questions](./docs/agent/model-design-questions.md)** — Systematic Q&A for eliciting model specs from users
|
|
63
|
+
- **[Template Extension Guide](./docs/agent/template-extension-guide.md)** — Add types, templates, generators
|
|
64
|
+
- **[JSON Specification Reference](./docs/agent/json-specification-reference.md)** — Exact format, every key, every option
|
|
65
|
+
|
|
66
|
+
### Deep Dives
|
|
67
|
+
|
|
68
|
+
- **[Constraints](./docs/deep-dives/constraints.md)** — DB vs API constraint placement, cross-field constraints
|
|
69
|
+
- **[Completeness Guide](./docs/deep-dives/completeness-guide.md)** — JSON specification checklist
|
|
70
|
+
- **[Custom Tests](./docs/deep-dives/custom-tests.md)** — Extending the generated test suite
|
|
71
|
+
|
|
72
|
+
### For Contributors
|
|
73
|
+
|
|
74
|
+
- **[Skill Reusability](./docs/contributor/skill-reusability.md)** — Core principles for reusable generation
|
|
75
|
+
- **[Project-Agnostic Rules](./docs/contributor/project-agnostic-rules.md)** — Coding rules for templates and scripts
|
|
76
|
+
|
|
77
|
+
## Development
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Install in editable mode with dev dependencies
|
|
81
|
+
uv sync --extra dev
|
|
82
|
+
|
|
83
|
+
# Run the test suite
|
|
84
|
+
uv run pytest tests/ -v
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Test Suite
|
|
88
|
+
|
|
89
|
+
| File | What It Covers |
|
|
90
|
+
|------|---------------|
|
|
91
|
+
| `test_generators.py` | Each generator (database, API models, routes, tests, enums, constraints, infrastructure), immutable entities |
|
|
92
|
+
| `test_edge_cases.py` | JSON comments, invalid input, config loading, deep merge, shared enums/constraints, file scanners, partial generation |
|
|
93
|
+
| `test_wizard.py` | Wizard imports, prompt fallbacks, menu flow, project setup, clean and test runner actions |
|
|
94
|
+
| `test_template_utils.py` | `path_to_import`, `wrap_text`, template environment, custom Jinja2 filters |
|
|
95
|
+
| `test_cli.py` | CLI flags: `--interactive`, `--clear-only`, `--dry-run`, `--diff`, missing model |
|
|
96
|
+
| `test_full_generation.py` | End-to-end generation from example project |
|
|
97
|
+
| `test_integration.py` | Full generation pipeline |
|
|
98
|
+
| `test_validation.py` | JSON schema validation |
|
|
99
|
+
| `test_utils.py` | Utility functions |
|
|
100
|
+
|
|
101
|
+
## Philosophy
|
|
102
|
+
|
|
103
|
+
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.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
**Model Generator** | Bootstrap Tool for API Backends | v0.1.0
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "model-generator-kit"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "One-shot bootstrap generator for database models, API models, routes, and tests"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "nuncaeslupus", email = "imarcos@gmail.com" }
|
|
14
|
+
]
|
|
15
|
+
keywords = ["generator", "code-generator", "fastapi", "sqlalchemy", "pydantic", "boilerplate"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Topic :: Software Development :: Code Generators",
|
|
24
|
+
]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"jinja2>=3.0.0",
|
|
27
|
+
"pyyaml>=6.0.0",
|
|
28
|
+
"jsonschema>=4.0.0",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
interactive = [
|
|
33
|
+
"questionary>=2.0.0",
|
|
34
|
+
]
|
|
35
|
+
dev = [
|
|
36
|
+
"pytest>=7.0.0",
|
|
37
|
+
"pytest-cov>=4.0.0",
|
|
38
|
+
"questionary>=2.0.0",
|
|
39
|
+
"ruff>=0.1.0",
|
|
40
|
+
"mypy>=1.0.0",
|
|
41
|
+
"types-PyYAML>=6.0.0",
|
|
42
|
+
"types-jsonschema>=4.0.0",
|
|
43
|
+
"mutmut>=2.4.0",
|
|
44
|
+
"sqlalchemy>=2.0",
|
|
45
|
+
"build>=1.0.0",
|
|
46
|
+
"twine>=4.0.0",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.scripts]
|
|
50
|
+
model-gen = "model_generator.generate:main"
|
|
51
|
+
model-val = "model_generator.validate:main"
|
|
52
|
+
|
|
53
|
+
[tool.setuptools]
|
|
54
|
+
package-dir = {"" = "src"}
|
|
55
|
+
|
|
56
|
+
[tool.setuptools.packages.find]
|
|
57
|
+
where = ["src"]
|
|
58
|
+
|
|
59
|
+
[tool.setuptools.package-data]
|
|
60
|
+
model_generator = ["py.typed", "schema/*.json", "stacks/**/*.yaml", "stacks/**/*.j2"]
|
|
61
|
+
|
|
62
|
+
[tool.ruff]
|
|
63
|
+
line-length = 88
|
|
64
|
+
target-version = "py311"
|
|
65
|
+
exclude = [".claude/"]
|
|
66
|
+
|
|
67
|
+
[tool.ruff.lint]
|
|
68
|
+
select = [
|
|
69
|
+
"E", # pycodestyle errors
|
|
70
|
+
"W", # pycodestyle warnings
|
|
71
|
+
"F", # pyflakes
|
|
72
|
+
"I", # isort
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
[tool.pytest.ini_options]
|
|
76
|
+
testpaths = ["tests"]
|
|
77
|
+
python_files = ["test_*.py"]
|
|
78
|
+
python_classes = ["Test*"]
|
|
79
|
+
python_functions = ["test_*"]
|
|
80
|
+
addopts = "--strict-markers --tb=short"
|
|
81
|
+
markers = [
|
|
82
|
+
"slow: marks tests as slow",
|
|
83
|
+
"integration: marks tests as integration tests",
|
|
84
|
+
"unit: marks tests as unit tests",
|
|
85
|
+
"cli: marks tests as CLI tests",
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
[tool.mypy]
|
|
89
|
+
python_version = "3.11"
|
|
90
|
+
mypy_path = "src"
|
|
91
|
+
strict = true
|
|
92
|
+
warn_unused_configs = true
|
|
93
|
+
warn_no_return = true
|
|
94
|
+
show_error_codes = true
|
|
95
|
+
exclude = [".claude/", "examples/", "tmp/"]
|
|
96
|
+
|
|
97
|
+
[tool.pyright]
|
|
98
|
+
include = ["src", "tests"]
|
|
99
|
+
exclude = ["**/.venv", "**/node_modules", "**/__pycache__", "**/.*", "examples", "tmp"]
|
|
100
|
+
typeCheckingMode = "standard"
|
|
101
|
+
pythonVersion = "3.11"
|
|
102
|
+
|
|
103
|
+
[tool.mutmut]
|
|
104
|
+
paths_to_mutate = ["src/model_generator/"]
|
|
105
|
+
tests_dir = ["tests/"]
|
|
106
|
+
also_copy = ["examples/"]
|
|
107
|
+
backup = false
|
|
108
|
+
|
|
109
|
+
[dependency-groups]
|
|
110
|
+
dev = [
|
|
111
|
+
"pyyaml>=6.0.3",
|
|
112
|
+
]
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""Model Generator — one-shot bootstrap code generator for FastAPI backends."""
|
|
2
|
+
|
|
3
|
+
# Single source of truth is pyproject.toml's [project].version. `make
|
|
4
|
+
# version-sync` propagates that value here; `make check-version-sync` (run in
|
|
5
|
+
# CI) fails the build if they drift. Do not edit by hand.
|
|
6
|
+
__version__ = "0.1.0"
|