PyArch-CLI 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.
Files changed (67) hide show
  1. pyarch_cli-0.1.0/.gitignore +11 -0
  2. pyarch_cli-0.1.0/.python-version +1 -0
  3. pyarch_cli-0.1.0/LICENSE +21 -0
  4. pyarch_cli-0.1.0/PKG-INFO +378 -0
  5. pyarch_cli-0.1.0/README.md +352 -0
  6. pyarch_cli-0.1.0/pyarch/__init__.py +1 -0
  7. pyarch_cli-0.1.0/pyarch/cli/__init__.py +1 -0
  8. pyarch_cli-0.1.0/pyarch/cli/add.py +27 -0
  9. pyarch_cli-0.1.0/pyarch/cli/app.py +83 -0
  10. pyarch_cli-0.1.0/pyarch/cli/common.py +28 -0
  11. pyarch_cli-0.1.0/pyarch/cli/generate.py +34 -0
  12. pyarch_cli-0.1.0/pyarch/config/__init__.py +1 -0
  13. pyarch_cli-0.1.0/pyarch/config/manifest.py +161 -0
  14. pyarch_cli-0.1.0/pyarch/config/models.py +51 -0
  15. pyarch_cli-0.1.0/pyarch/generators/__init__.py +1 -0
  16. pyarch_cli-0.1.0/pyarch/generators/common/__init__.py +1 -0
  17. pyarch_cli-0.1.0/pyarch/generators/common/commands.py +6 -0
  18. pyarch_cli-0.1.0/pyarch/generators/common/filesystem.py +55 -0
  19. pyarch_cli-0.1.0/pyarch/generators/common/gitignore.py +65 -0
  20. pyarch_cli-0.1.0/pyarch/generators/common/renderer.py +32 -0
  21. pyarch_cli-0.1.0/pyarch/generators/integration/__init__.py +1 -0
  22. pyarch_cli-0.1.0/pyarch/generators/integration/auth.py +158 -0
  23. pyarch_cli-0.1.0/pyarch/generators/module/__init__.py +1 -0
  24. pyarch_cli-0.1.0/pyarch/generators/module/layered.py +186 -0
  25. pyarch_cli-0.1.0/pyarch/generators/project/__init__.py +1 -0
  26. pyarch_cli-0.1.0/pyarch/generators/project/base.py +52 -0
  27. pyarch_cli-0.1.0/pyarch/generators/project/layered.py +167 -0
  28. pyarch_cli-0.1.0/pyarch/main.py +9 -0
  29. pyarch_cli-0.1.0/pyarch/services/__init__.py +1 -0
  30. pyarch_cli-0.1.0/pyarch/services/add_integration.py +37 -0
  31. pyarch_cli-0.1.0/pyarch/services/create_module.py +46 -0
  32. pyarch_cli-0.1.0/pyarch/services/create_project.py +20 -0
  33. pyarch_cli-0.1.0/pyarch/templates/layered/alembic_env.py.j2 +58 -0
  34. pyarch_cli-0.1.0/pyarch/templates/layered/auth/config.py.j2 +30 -0
  35. pyarch_cli-0.1.0/pyarch/templates/layered/auth/dependencies.py.j2 +75 -0
  36. pyarch_cli-0.1.0/pyarch/templates/layered/auth/refresh_session_model.py.j2 +31 -0
  37. pyarch_cli-0.1.0/pyarch/templates/layered/auth/routes.py.j2 +51 -0
  38. pyarch_cli-0.1.0/pyarch/templates/layered/auth/schemas.py.j2 +31 -0
  39. pyarch_cli-0.1.0/pyarch/templates/layered/auth/service.py.j2 +160 -0
  40. pyarch_cli-0.1.0/pyarch/templates/layered/auth/tokens.py.j2 +29 -0
  41. pyarch_cli-0.1.0/pyarch/templates/layered/auth/user_model.py.j2 +52 -0
  42. pyarch_cli-0.1.0/pyarch/templates/layered/auth/utils.py.j2 +70 -0
  43. pyarch_cli-0.1.0/pyarch/templates/layered/config.py.j2 +14 -0
  44. pyarch_cli-0.1.0/pyarch/templates/layered/env.example.j2 +7 -0
  45. pyarch_cli-0.1.0/pyarch/templates/layered/models_init.py.j2 +5 -0
  46. pyarch_cli-0.1.0/pyarch/templates/layered/module/module_model.py.j2 +25 -0
  47. pyarch_cli-0.1.0/pyarch/templates/layered/module/module_repo.py.j2 +49 -0
  48. pyarch_cli-0.1.0/pyarch/templates/layered/module/module_router.py.j2 +87 -0
  49. pyarch_cli-0.1.0/pyarch/templates/layered/module/module_router_protected.py.j2 +97 -0
  50. pyarch_cli-0.1.0/pyarch/templates/layered/module/module_schema.py.j2 +30 -0
  51. pyarch_cli-0.1.0/pyarch/templates/layered/module/module_service.py.j2 +76 -0
  52. pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/config.py.j2 +15 -0
  53. pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/conftest.py.j2 +36 -0
  54. pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/env.example.j2 +2 -0
  55. pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/module/module_model.py.j2 +11 -0
  56. pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/module/module_repo.py.j2 +99 -0
  57. pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/module/module_router.py.j2 +97 -0
  58. pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/module/module_service.py.j2 +69 -0
  59. pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/session.py.j2 +14 -0
  60. pyarch_cli-0.1.0/pyarch/templates/layered/router.py.j2 +8 -0
  61. pyarch_cli-0.1.0/pyarch/templates/layered/session.py.j2 +33 -0
  62. pyarch_cli-0.1.0/pyarch/templates/project/base/README.md.j2 +22 -0
  63. pyarch_cli-0.1.0/pyarch/templates/project/base/conftest.py.j2 +101 -0
  64. pyarch_cli-0.1.0/pyarch/templates/project/base/main.py.j2 +11 -0
  65. pyarch_cli-0.1.0/pyproject.toml +41 -0
  66. pyarch_cli-0.1.0/script_base.py +355 -0
  67. pyarch_cli-0.1.0/uv.lock +326 -0
@@ -0,0 +1,11 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+ after_script.txt
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 yona34
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,378 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyArch-CLI
3
+ Version: 0.1.0
4
+ Summary: Stateful CLI generator for Layered FastAPI projects
5
+ Project-URL: Homepage, https://github.com/Allcode-1/fastapi-skeleton-generator
6
+ Project-URL: Repository, https://github.com/Allcode-1/fastapi-skeleton-generator
7
+ Project-URL: Issues, https://github.com/Allcode-1/fastapi-skeleton-generator/issues
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: cli,fastapi,generator,jinja2,sqlalchemy,typer
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Framework :: FastAPI
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Code Generators
19
+ Requires-Python: >=3.13
20
+ Requires-Dist: cryptography>=46.0.3
21
+ Requires-Dist: jinja2>=3.1.6
22
+ Requires-Dist: rich>=15.0.0
23
+ Requires-Dist: tomlkit>=0.15.0
24
+ Requires-Dist: typer>=0.24.2
25
+ Description-Content-Type: text/markdown
26
+
27
+ # PyArch
28
+
29
+ ![Python](https://img.shields.io/badge/Python-3.13%2B-blue)
30
+ ![FastAPI](https://img.shields.io/badge/FastAPI-backend-green)
31
+ ![Typer](https://img.shields.io/badge/Typer-CLI-purple)
32
+ ![Jinja2](https://img.shields.io/badge/Jinja2-templates-orange)
33
+ ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
34
+ ![Status](https://img.shields.io/badge/status-MVP%2B-orange)
35
+
36
+ **PyArch is a stateful CLI that creates FastAPI projects and evolves them
37
+ through project-aware generation commands.**
38
+
39
+ It creates a backend project, stores its configuration in `pyarch.toml`, and
40
+ later uses that state to add modules and modify the existing application.
41
+
42
+ The CLI is the interface. The core idea is project-aware backend development
43
+ tooling built around a manifest, generators, templates, and FastAPI conventions.
44
+
45
+ ```text
46
+ pyarch init
47
+ ↓
48
+ Generated FastAPI project
49
+ ↓
50
+ pyarch.toml
51
+ ↓
52
+ pyarch generate module users
53
+ ↓
54
+ Project is extended
55
+ ↓
56
+ Manifest is updated
57
+ ```
58
+
59
+ ## Highlights
60
+
61
+ - Creates Layered FastAPI projects
62
+ - Supports PostgreSQL, SQLite and MongoDB
63
+ - Stateful project manifest (`pyarch.toml`)
64
+ - Project-aware module generation
65
+ - JWT auth integration with generated RSA keys
66
+ - Automatic router and model registration
67
+ - Jinja2 template rendering with `StrictUndefined`
68
+ - Dependency installation via `uv`
69
+
70
+ ## 30-second demo
71
+
72
+ ```bash
73
+ $ pyarch init demo --database postgres
74
+
75
+ ✓ Creating project...
76
+ ✓ Installing dependencies...
77
+ ✓ Configuring Alembic...
78
+ ✓ Writing manifest...
79
+ ✓ Done.
80
+
81
+ $ cd demo
82
+
83
+ $ pyarch generate module users
84
+
85
+ ✓ Creating module...
86
+ ✓ Registering model...
87
+ ✓ Registering router...
88
+ ✓ Updating manifest...
89
+ ✓ Done.
90
+
91
+ $ pyarch add integration auth
92
+
93
+ ✓ Creating auth files...
94
+ ✓ Generating RSA keys...
95
+ ✓ Registering auth router...
96
+ ✓ Updating manifest...
97
+ ✓ Done.
98
+
99
+ $ pyarch generate module tasks --protected
100
+
101
+ ✓ Creating protected module...
102
+ ✓ Registering model...
103
+ ✓ Registering router...
104
+ ✓ Updating manifest...
105
+ ✓ Done.
106
+
107
+ $ pyarch info
108
+
109
+ Project: demo
110
+ Architecture: Layered
111
+ Database: PostgreSQL
112
+ Modules:
113
+ - users
114
+ ```
115
+
116
+ ## Why PyArch?
117
+
118
+ PyArch started as a tool to remove repetitive setup work in FastAPI projects:
119
+ database configuration, layered structure, Alembic setup, tests and CRUD wiring.
120
+
121
+ PyArch was inspired by the developer experience of Nest CLI, but is focused on
122
+ FastAPI projects and incremental project evolution.
123
+
124
+ Unlike one-shot template generators, PyArch keeps project state in a manifest
125
+ and uses it for later commands. The goal is not only to create the first project
126
+ structure, but also to extend the project after it already exists.
127
+
128
+ ## Project Manifest
129
+
130
+ PyArch stores selected architecture, database backend, generated modules and
131
+ enabled integrations in `pyarch.toml`.
132
+
133
+ This allows later commands to understand and extend the existing project instead
134
+ of treating generation as a one-time template render.
135
+
136
+ The manifest currently records:
137
+
138
+ - schema version;
139
+ - PyArch version;
140
+ - project name;
141
+ - selected architecture;
142
+ - database engine;
143
+ - database access style;
144
+ - generated modules;
145
+ - enabled integrations;
146
+ - generated project paths.
147
+
148
+ ## Generated Module Flow
149
+
150
+ ```bash
151
+ pyarch generate module users
152
+ ```
153
+
154
+ The module generator:
155
+
156
+ ```text
157
+ pyarch generate module users
158
+ ↓
159
+ read manifest
160
+ ↓
161
+ detect backend
162
+ ↓
163
+ render templates
164
+ ↓
165
+ register model
166
+ ↓
167
+ register router
168
+ ↓
169
+ update manifest
170
+ ```
171
+
172
+ ## Architecture
173
+
174
+ ```text
175
+ User
176
+ │
177
+ ▼
178
+ Typer CLI
179
+ │
180
+ ▼
181
+ Application Services
182
+ │
183
+ ▼
184
+ Generators
185
+ │
186
+ ├──────────────┐
187
+ ▼ │
188
+ Jinja2 │
189
+ Templates │
190
+ │
191
+ ▼ │
192
+ Filesystem │
193
+ │
194
+ ▼ │
195
+ Generated Project
196
+ ▲
197
+ │
198
+ pyarch.toml
199
+ ```
200
+
201
+ ## Design Decisions
202
+
203
+ ### Why a manifest instead of scanning the filesystem?
204
+
205
+ Scanning the filesystem can show which files exist, but it cannot reliably
206
+ explain why they exist or which generator state produced them. The manifest
207
+ stores project-level decisions such as architecture, database backend, generated
208
+ modules, integrations, paths, schema version, and PyArch version. Later commands
209
+ can read that state directly instead of guessing from folders and imports.
210
+
211
+ ### Why marker-based registration instead of AST rewriting?
212
+
213
+ PyArch currently modifies files it generated itself, so explicit markers are
214
+ simple, readable, and predictable. For router and model registration, the tool
215
+ only needs stable insertion points, not a full Python code transformation
216
+ pipeline. AST rewriting may become useful later if PyArch needs to safely modify
217
+ arbitrary user-written code.
218
+
219
+ ### Why Jinja2?
220
+
221
+ Generated FastAPI files are mostly structured text, and Jinja2 keeps templates
222
+ close to the final code that users will read. `StrictUndefined` makes template
223
+ errors fail fast when required context is missing. This keeps generators simple
224
+ while still making missing data visible during development.
225
+
226
+ ## What Works Now
227
+
228
+ - creating a new Layered FastAPI project;
229
+ - choosing PostgreSQL, SQLite, or MongoDB during initialization;
230
+ - installing the matching runtime and development dependencies with `uv`;
231
+ - generating application layers, database configuration, test setup, and
232
+ Alembic configuration for relational databases;
233
+ - generating a basic CRUD module after project creation;
234
+ - adding a JWT auth integration for PostgreSQL and SQLite projects;
235
+ - generating protected CRUD routes with `pyarch generate module <name> --protected`;
236
+ - registering generated SQLAlchemy models in `app/models/__init__.py`;
237
+ - registering generated routers in `app/api/v1/router.py`;
238
+ - keeping project state in `pyarch.toml`;
239
+ - displaying the current project configuration through the CLI.
240
+
241
+ ## Usage
242
+
243
+ Create a project:
244
+
245
+ ```bash
246
+ pyarch init my_project
247
+ ```
248
+
249
+ Select a database explicitly:
250
+
251
+ ```bash
252
+ pyarch init my_project --database postgres
253
+ pyarch init my_project --database sqlite
254
+ pyarch init my_project --database mongodb
255
+ ```
256
+
257
+ Move into the generated project and inspect its recorded state:
258
+
259
+ ```bash
260
+ cd my_project
261
+ pyarch info
262
+ ```
263
+
264
+ Generate a CRUD module:
265
+
266
+ ```bash
267
+ pyarch generate module users
268
+ ```
269
+
270
+ Add auth and generate protected routes:
271
+
272
+ ```bash
273
+ pyarch add integration auth
274
+ pyarch generate module tasks --protected
275
+ ```
276
+
277
+ ## Roadmap
278
+
279
+ ### v0.2
280
+
281
+ - safe generation
282
+ - validation improvements
283
+ - rollback on failed generation
284
+ - Redis integration foundation
285
+
286
+ ### v0.3
287
+
288
+ - Redis integration
289
+ - scheduler integration
290
+ - dry-run mode
291
+
292
+ ### Later
293
+
294
+ - new architectures
295
+ - plugin system
296
+ - async database access
297
+
298
+ ## Generated Structure
299
+
300
+ <details>
301
+ <summary>Show generated project tree</summary>
302
+
303
+ A generated project currently follows this general structure:
304
+
305
+ ```text
306
+ my_project/
307
+ ├── app/
308
+ │ ├── api/
309
+ │ │ └── v1/
310
+ │ ├── core/
311
+ │ ├── db/
312
+ │ ├── dependencies/
313
+ │ ├── models/
314
+ │ ├── repositories/
315
+ │ ├── schemas/
316
+ │ ├── services/
317
+ │ └── main.py
318
+ ├── docs/
319
+ ├── tests/
320
+ ├── alembic/ # PostgreSQL and SQLite only
321
+ ├── certs/ # created by the auth integration
322
+ ├── .env.example
323
+ ├── pyarch.toml
324
+ └── pyproject.toml
325
+ ```
326
+
327
+ </details>
328
+
329
+ ## Requirements
330
+
331
+ - Python 3.13 or newer;
332
+ - [uv](https://docs.astral.sh/uv/).
333
+
334
+ ## Local Setup
335
+
336
+ Install from PyPI:
337
+
338
+ ```bash
339
+ pip install pyarch-cli
340
+ pyarch --help
341
+ ```
342
+
343
+ Clone the repository and install its dependencies:
344
+
345
+ ```bash
346
+ git clone <repository-url>
347
+ cd pathlib
348
+ uv sync
349
+ ```
350
+
351
+ Run the CLI directly from the repository:
352
+
353
+ ```bash
354
+ uv run pyarch --help
355
+ ```
356
+
357
+ Install the current checkout as a local CLI tool:
358
+
359
+ ```bash
360
+ uv tool install --editable .
361
+ ```
362
+
363
+ ## Project Status
364
+
365
+ **MVP+ — early development**
366
+
367
+ The first working CLI flow is in place. Commands, generated code, templates, and
368
+ the manifest format may still change while the project evolves.
369
+
370
+ ## Current Limitations
371
+
372
+ - only Layered Architecture is supported;
373
+ - generated applications use synchronous database access;
374
+ - only FastAPI projects are supported;
375
+ - auth integration currently supports PostgreSQL and SQLite projects;
376
+ - generated projects are starter scaffolds and still require application-specific
377
+ configuration and code;
378
+ - the manifest format may change before a stable release.