PyArch-CLI 0.1.0__tar.gz → 0.1.1__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.
- pyarch_cli-0.1.1/PKG-INFO +277 -0
- pyarch_cli-0.1.1/README.md +251 -0
- pyarch_cli-0.1.1/assets/Dockerfile.vhs +11 -0
- pyarch_cli-0.1.1/assets/pyarch-demo.gif +0 -0
- pyarch_cli-0.1.1/assets/pyarch-demo.tape +37 -0
- pyarch_cli-0.1.1/assets/vhs-uv +17 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1}/pyproject.toml +21 -18
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1}/script_base.py +354 -354
- pyarch_cli-0.1.1/src/pyarch/__init__.py +1 -0
- pyarch_cli-0.1.1/src/pyarch/cli/app.py +33 -0
- pyarch_cli-0.1.1/src/pyarch/cli/info.py +32 -0
- pyarch_cli-0.1.1/src/pyarch/cli/init.py +38 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/config/manifest.py +4 -5
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/config/models.py +0 -1
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/generators/integration/auth.py +6 -6
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/generators/module/layered.py +38 -57
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/generators/project/layered.py +20 -32
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/auth/config.py.j2 +21 -15
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/auth/routes.py.j2 +11 -12
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/auth/service.py.j2 +12 -8
- pyarch_cli-0.1.1/src/pyarch/templates/layered/auth/test_auth.py.j2 +117 -0
- pyarch_cli-0.1.1/src/pyarch/templates/layered/auth/test_helpers.py.j2 +47 -0
- {pyarch_cli-0.1.0/pyarch/templates/layered/mongodb → pyarch_cli-0.1.1/src/pyarch/templates/layered}/config.py.j2 +8 -1
- pyarch_cli-0.1.1/src/pyarch/templates/layered/errors.py.j2 +5 -0
- pyarch_cli-0.1.1/src/pyarch/templates/layered/exception_handlers.py.j2 +13 -0
- pyarch_cli-0.1.1/src/pyarch/templates/layered/module/module_repo.py.j2 +57 -0
- pyarch_cli-0.1.1/src/pyarch/templates/layered/module/module_router.py.j2 +60 -0
- pyarch_cli-0.1.1/src/pyarch/templates/layered/module/module_router_protected.py.j2 +74 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/module/module_schema.py.j2 +3 -10
- pyarch_cli-0.1.1/src/pyarch/templates/layered/module/module_service.py.j2 +67 -0
- pyarch_cli-0.1.1/src/pyarch/templates/layered/module/module_test.py.j2 +43 -0
- pyarch_cli-0.1.1/src/pyarch/templates/layered/module/module_test_protected.py.j2 +71 -0
- pyarch_cli-0.1.1/src/pyarch/templates/layered/pagination.py.j2 +22 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/project/base/README.md.j2 +0 -2
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/project/base/conftest.py.j2 +15 -17
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/project/base/main.py.j2 +9 -6
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1}/uv.lock +4 -1
- pyarch_cli-0.1.0/PKG-INFO +0 -378
- pyarch_cli-0.1.0/README.md +0 -352
- pyarch_cli-0.1.0/pyarch/__init__.py +0 -1
- pyarch_cli-0.1.0/pyarch/cli/app.py +0 -83
- pyarch_cli-0.1.0/pyarch/templates/layered/config.py.j2 +0 -14
- pyarch_cli-0.1.0/pyarch/templates/layered/module/module_repo.py.j2 +0 -49
- pyarch_cli-0.1.0/pyarch/templates/layered/module/module_router.py.j2 +0 -87
- pyarch_cli-0.1.0/pyarch/templates/layered/module/module_router_protected.py.j2 +0 -97
- pyarch_cli-0.1.0/pyarch/templates/layered/module/module_service.py.j2 +0 -76
- pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/conftest.py.j2 +0 -36
- pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/env.example.j2 +0 -2
- pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/module/module_model.py.j2 +0 -11
- pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/module/module_repo.py.j2 +0 -99
- pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/module/module_router.py.j2 +0 -97
- pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/module/module_service.py.j2 +0 -69
- pyarch_cli-0.1.0/pyarch/templates/layered/mongodb/session.py.j2 +0 -14
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1}/.gitignore +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1}/.python-version +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1}/LICENSE +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/cli/__init__.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/cli/add.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/cli/common.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/cli/generate.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/config/__init__.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/generators/__init__.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/generators/common/__init__.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/generators/common/commands.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/generators/common/filesystem.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/generators/common/gitignore.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/generators/common/renderer.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/generators/integration/__init__.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/generators/module/__init__.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/generators/project/__init__.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/generators/project/base.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/main.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/services/__init__.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/services/add_integration.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/services/create_module.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/services/create_project.py +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/alembic_env.py.j2 +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/auth/dependencies.py.j2 +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/auth/refresh_session_model.py.j2 +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/auth/schemas.py.j2 +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/auth/tokens.py.j2 +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/auth/user_model.py.j2 +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/auth/utils.py.j2 +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/env.example.j2 +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/models_init.py.j2 +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/module/module_model.py.j2 +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/router.py.j2 +0 -0
- {pyarch_cli-0.1.0 → pyarch_cli-0.1.1/src}/pyarch/templates/layered/session.py.j2 +0 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PyArch-CLI
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Stateful CLI generator for Layered FastAPI projects
|
|
5
|
+
Project-URL: Homepage, https://github.com/Allcode-1/PyArch
|
|
6
|
+
Project-URL: Repository, https://github.com/Allcode-1/PyArch
|
|
7
|
+
Project-URL: Issues, https://github.com/Allcode-1/PyArch/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
|
+
[](https://pypi.org/project/PyArch-CLI/)
|
|
30
|
+

|
|
31
|
+

|
|
32
|
+

|
|
33
|
+

|
|
34
|
+

|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
PyArch is a CLI for creating and extending Layered FastAPI projects. It sets up
|
|
38
|
+
the application structure, database, tests and Alembic, then lets you add CRUD
|
|
39
|
+
modules and integrations without wiring every file by hand.
|
|
40
|
+
|
|
41
|
+
Unlike a one-time project template, PyArch keeps a small manifest in the
|
|
42
|
+
generated project. Later commands use it to understand the project and update
|
|
43
|
+
the right files.
|
|
44
|
+
|
|
45
|
+
<p align="center">
|
|
46
|
+
<img src="./assets/pyarch-demo.gif" alt="PyArch CLI demo" width="900">
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
## Why PyArch?
|
|
50
|
+
|
|
51
|
+
PyArch removes repetitive setup while keeping the generated code readable and
|
|
52
|
+
ready to change.
|
|
53
|
+
|
|
54
|
+
- Layered FastAPI project structure
|
|
55
|
+
- PostgreSQL and SQLite support
|
|
56
|
+
- Complete CRUD modules with models, schemas, repositories, services and routes
|
|
57
|
+
- Automatic model and router registration
|
|
58
|
+
- JWT auth integration with generated RSA keys
|
|
59
|
+
- Protected CRUD routes
|
|
60
|
+
- Alembic setup for relational databases
|
|
61
|
+
- Tests and dependency setup through `uv`
|
|
62
|
+
- Project-aware generation through `pyarch.toml`
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
PyArch requires Python 3.13 or newer and
|
|
67
|
+
[`uv`](https://docs.astral.sh/uv/).
|
|
68
|
+
|
|
69
|
+
Install the latest release from PyPI:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install pyarch-cli
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Create a project and move into it:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pyarch init my_project --database postgres
|
|
79
|
+
cd my_project
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Copy `.env.example` to `.env` and set the database connection values. For
|
|
83
|
+
PostgreSQL or SQLite, create the first migration:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
uv run alembic revision --autogenerate -m "initial"
|
|
87
|
+
uv run alembic upgrade head
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Run the API:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
uv run uvicorn app.main:app --reload
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Open `http://127.0.0.1:8000/docs` to use the generated Swagger UI.
|
|
97
|
+
|
|
98
|
+
You can now extend the project:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pyarch generate module users
|
|
102
|
+
pyarch add integration auth
|
|
103
|
+
pyarch generate module tasks --protected
|
|
104
|
+
pyarch info
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## What Gets Generated
|
|
108
|
+
|
|
109
|
+
A new project includes the application layers, database configuration, test
|
|
110
|
+
setup and the files needed to run FastAPI:
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
my_project/
|
|
114
|
+
├── app/
|
|
115
|
+
│ ├── api/v1/
|
|
116
|
+
│ ├── core/
|
|
117
|
+
│ ├── db/
|
|
118
|
+
│ ├── dependencies/
|
|
119
|
+
│ ├── models/
|
|
120
|
+
│ ├── repositories/
|
|
121
|
+
│ ├── schemas/
|
|
122
|
+
│ ├── services/
|
|
123
|
+
│ └── main.py
|
|
124
|
+
├── tests/
|
|
125
|
+
├── alembic/ # PostgreSQL and SQLite only
|
|
126
|
+
├── .env.example
|
|
127
|
+
├── pyarch.toml
|
|
128
|
+
└── pyproject.toml
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Each generated CRUD module adds:
|
|
132
|
+
|
|
133
|
+
- a database model;
|
|
134
|
+
- create, update and response schemas;
|
|
135
|
+
- repository and service classes;
|
|
136
|
+
- list, get, create, update and delete routes;
|
|
137
|
+
- CRUD tests;
|
|
138
|
+
- model and router registration in the existing application.
|
|
139
|
+
|
|
140
|
+
## Commands
|
|
141
|
+
|
|
142
|
+
| Command | Description |
|
|
143
|
+
| --- | --- |
|
|
144
|
+
| `pyarch init <name>` | Create a Layered FastAPI project |
|
|
145
|
+
| `pyarch init <name> --database <engine>` | Select PostgreSQL or SQLite |
|
|
146
|
+
| `pyarch generate module <name>` | Add a CRUD module to the current project |
|
|
147
|
+
| `pyarch add integration auth` | Add JWT authentication and user management |
|
|
148
|
+
| `pyarch generate module <name> --protected` | Generate CRUD routes that require authentication |
|
|
149
|
+
| `pyarch info` | Show the current project configuration |
|
|
150
|
+
| `pyarch --help` | Show CLI help |
|
|
151
|
+
|
|
152
|
+
Generation commands must be run inside a project created by PyArch.
|
|
153
|
+
|
|
154
|
+
## Databases and Current Limitations
|
|
155
|
+
|
|
156
|
+
| Database | CRUD modules | Alembic | Auth integration | Protected modules |
|
|
157
|
+
| --- | --- | --- | --- | --- |
|
|
158
|
+
| PostgreSQL | Yes | Yes | Yes | Yes |
|
|
159
|
+
| SQLite | Yes | Yes | Yes | Yes |
|
|
160
|
+
|
|
161
|
+
Current limitations:
|
|
162
|
+
|
|
163
|
+
- only Layered Architecture is supported;
|
|
164
|
+
- generated applications use synchronous database access;
|
|
165
|
+
- generated projects are starter scaffolds and still require
|
|
166
|
+
application-specific configuration and code;
|
|
167
|
+
- the manifest format may change before a stable release.
|
|
168
|
+
|
|
169
|
+
## Project Manifest
|
|
170
|
+
|
|
171
|
+
Every generated project contains `pyarch.toml`. It records the selected
|
|
172
|
+
architecture and database, generated modules, enabled integrations and known
|
|
173
|
+
project paths.
|
|
174
|
+
|
|
175
|
+
Commands such as `generate module`, `add integration` and `info` read this file
|
|
176
|
+
instead of trying to infer project state from the directory structure. PyArch
|
|
177
|
+
updates the manifest after a successful generation step.
|
|
178
|
+
|
|
179
|
+
## Development
|
|
180
|
+
|
|
181
|
+
Clone the repository and install the development environment:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
git clone https://github.com/Allcode-1/PyArch.git
|
|
185
|
+
cd PyArch
|
|
186
|
+
uv sync
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Run the CLI from the checkout:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
uv run pyarch --help
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Or install the current checkout as an editable CLI tool:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
uv tool install --editable .
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Architecture and Design
|
|
202
|
+
|
|
203
|
+
<details>
|
|
204
|
+
<summary>How PyArch is structured</summary>
|
|
205
|
+
|
|
206
|
+
```text
|
|
207
|
+
Typer CLI
|
|
208
|
+
↓
|
|
209
|
+
Application services
|
|
210
|
+
↓
|
|
211
|
+
Generators
|
|
212
|
+
↓
|
|
213
|
+
Jinja2 templates
|
|
214
|
+
↓
|
|
215
|
+
Generated FastAPI project
|
|
216
|
+
↑
|
|
217
|
+
pyarch.toml
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The CLI handles user input and delegates work to application services.
|
|
221
|
+
Generators render Jinja2 templates and update files at explicit registration
|
|
222
|
+
markers. The manifest provides the project context needed by later commands.
|
|
223
|
+
|
|
224
|
+
</details>
|
|
225
|
+
|
|
226
|
+
<details>
|
|
227
|
+
<summary>Why use a manifest?</summary>
|
|
228
|
+
|
|
229
|
+
Scanning the filesystem shows which files exist, but not which project choices
|
|
230
|
+
produced them. The manifest stores those choices directly, so later commands do
|
|
231
|
+
not have to guess the architecture, database or enabled features.
|
|
232
|
+
|
|
233
|
+
</details>
|
|
234
|
+
|
|
235
|
+
<details>
|
|
236
|
+
<summary>Why marker-based registration?</summary>
|
|
237
|
+
|
|
238
|
+
PyArch modifies files it generated itself. Explicit markers provide stable and
|
|
239
|
+
readable insertion points for model and router imports without requiring a full
|
|
240
|
+
AST rewriting pipeline.
|
|
241
|
+
|
|
242
|
+
</details>
|
|
243
|
+
|
|
244
|
+
<details>
|
|
245
|
+
<summary>Why Jinja2?</summary>
|
|
246
|
+
|
|
247
|
+
Templates stay close to the Python code users receive and can edit. Jinja2 is
|
|
248
|
+
used with `StrictUndefined`, so missing template context fails during generation
|
|
249
|
+
instead of producing incomplete files.
|
|
250
|
+
|
|
251
|
+
</details>
|
|
252
|
+
|
|
253
|
+
## Roadmap
|
|
254
|
+
|
|
255
|
+
### v0.2
|
|
256
|
+
|
|
257
|
+
- safer generation and validation;
|
|
258
|
+
- rollback on failed generation;
|
|
259
|
+
- Redis integration foundation.
|
|
260
|
+
|
|
261
|
+
### v0.3
|
|
262
|
+
|
|
263
|
+
- Redis integration;
|
|
264
|
+
- scheduler integration;
|
|
265
|
+
- dry-run mode.
|
|
266
|
+
|
|
267
|
+
### Later
|
|
268
|
+
|
|
269
|
+
- more architectures;
|
|
270
|
+
- plugin system;
|
|
271
|
+
- asynchronous database access.
|
|
272
|
+
|
|
273
|
+
## Status
|
|
274
|
+
|
|
275
|
+
PyArch is in early development. The main workflow is usable, but commands,
|
|
276
|
+
templates, generated code and the manifest may still change before a stable
|
|
277
|
+
release.
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
# PyArch
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/PyArch-CLI/)
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
PyArch is a CLI for creating and extending Layered FastAPI projects. It sets up
|
|
12
|
+
the application structure, database, tests and Alembic, then lets you add CRUD
|
|
13
|
+
modules and integrations without wiring every file by hand.
|
|
14
|
+
|
|
15
|
+
Unlike a one-time project template, PyArch keeps a small manifest in the
|
|
16
|
+
generated project. Later commands use it to understand the project and update
|
|
17
|
+
the right files.
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<img src="./assets/pyarch-demo.gif" alt="PyArch CLI demo" width="900">
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
## Why PyArch?
|
|
24
|
+
|
|
25
|
+
PyArch removes repetitive setup while keeping the generated code readable and
|
|
26
|
+
ready to change.
|
|
27
|
+
|
|
28
|
+
- Layered FastAPI project structure
|
|
29
|
+
- PostgreSQL and SQLite support
|
|
30
|
+
- Complete CRUD modules with models, schemas, repositories, services and routes
|
|
31
|
+
- Automatic model and router registration
|
|
32
|
+
- JWT auth integration with generated RSA keys
|
|
33
|
+
- Protected CRUD routes
|
|
34
|
+
- Alembic setup for relational databases
|
|
35
|
+
- Tests and dependency setup through `uv`
|
|
36
|
+
- Project-aware generation through `pyarch.toml`
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
PyArch requires Python 3.13 or newer and
|
|
41
|
+
[`uv`](https://docs.astral.sh/uv/).
|
|
42
|
+
|
|
43
|
+
Install the latest release from PyPI:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install pyarch-cli
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Create a project and move into it:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pyarch init my_project --database postgres
|
|
53
|
+
cd my_project
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Copy `.env.example` to `.env` and set the database connection values. For
|
|
57
|
+
PostgreSQL or SQLite, create the first migration:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
uv run alembic revision --autogenerate -m "initial"
|
|
61
|
+
uv run alembic upgrade head
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Run the API:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
uv run uvicorn app.main:app --reload
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Open `http://127.0.0.1:8000/docs` to use the generated Swagger UI.
|
|
71
|
+
|
|
72
|
+
You can now extend the project:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pyarch generate module users
|
|
76
|
+
pyarch add integration auth
|
|
77
|
+
pyarch generate module tasks --protected
|
|
78
|
+
pyarch info
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## What Gets Generated
|
|
82
|
+
|
|
83
|
+
A new project includes the application layers, database configuration, test
|
|
84
|
+
setup and the files needed to run FastAPI:
|
|
85
|
+
|
|
86
|
+
```text
|
|
87
|
+
my_project/
|
|
88
|
+
├── app/
|
|
89
|
+
│ ├── api/v1/
|
|
90
|
+
│ ├── core/
|
|
91
|
+
│ ├── db/
|
|
92
|
+
│ ├── dependencies/
|
|
93
|
+
│ ├── models/
|
|
94
|
+
│ ├── repositories/
|
|
95
|
+
│ ├── schemas/
|
|
96
|
+
│ ├── services/
|
|
97
|
+
│ └── main.py
|
|
98
|
+
├── tests/
|
|
99
|
+
├── alembic/ # PostgreSQL and SQLite only
|
|
100
|
+
├── .env.example
|
|
101
|
+
├── pyarch.toml
|
|
102
|
+
└── pyproject.toml
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Each generated CRUD module adds:
|
|
106
|
+
|
|
107
|
+
- a database model;
|
|
108
|
+
- create, update and response schemas;
|
|
109
|
+
- repository and service classes;
|
|
110
|
+
- list, get, create, update and delete routes;
|
|
111
|
+
- CRUD tests;
|
|
112
|
+
- model and router registration in the existing application.
|
|
113
|
+
|
|
114
|
+
## Commands
|
|
115
|
+
|
|
116
|
+
| Command | Description |
|
|
117
|
+
| --- | --- |
|
|
118
|
+
| `pyarch init <name>` | Create a Layered FastAPI project |
|
|
119
|
+
| `pyarch init <name> --database <engine>` | Select PostgreSQL or SQLite |
|
|
120
|
+
| `pyarch generate module <name>` | Add a CRUD module to the current project |
|
|
121
|
+
| `pyarch add integration auth` | Add JWT authentication and user management |
|
|
122
|
+
| `pyarch generate module <name> --protected` | Generate CRUD routes that require authentication |
|
|
123
|
+
| `pyarch info` | Show the current project configuration |
|
|
124
|
+
| `pyarch --help` | Show CLI help |
|
|
125
|
+
|
|
126
|
+
Generation commands must be run inside a project created by PyArch.
|
|
127
|
+
|
|
128
|
+
## Databases and Current Limitations
|
|
129
|
+
|
|
130
|
+
| Database | CRUD modules | Alembic | Auth integration | Protected modules |
|
|
131
|
+
| --- | --- | --- | --- | --- |
|
|
132
|
+
| PostgreSQL | Yes | Yes | Yes | Yes |
|
|
133
|
+
| SQLite | Yes | Yes | Yes | Yes |
|
|
134
|
+
|
|
135
|
+
Current limitations:
|
|
136
|
+
|
|
137
|
+
- only Layered Architecture is supported;
|
|
138
|
+
- generated applications use synchronous database access;
|
|
139
|
+
- generated projects are starter scaffolds and still require
|
|
140
|
+
application-specific configuration and code;
|
|
141
|
+
- the manifest format may change before a stable release.
|
|
142
|
+
|
|
143
|
+
## Project Manifest
|
|
144
|
+
|
|
145
|
+
Every generated project contains `pyarch.toml`. It records the selected
|
|
146
|
+
architecture and database, generated modules, enabled integrations and known
|
|
147
|
+
project paths.
|
|
148
|
+
|
|
149
|
+
Commands such as `generate module`, `add integration` and `info` read this file
|
|
150
|
+
instead of trying to infer project state from the directory structure. PyArch
|
|
151
|
+
updates the manifest after a successful generation step.
|
|
152
|
+
|
|
153
|
+
## Development
|
|
154
|
+
|
|
155
|
+
Clone the repository and install the development environment:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
git clone https://github.com/Allcode-1/PyArch.git
|
|
159
|
+
cd PyArch
|
|
160
|
+
uv sync
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Run the CLI from the checkout:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
uv run pyarch --help
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Or install the current checkout as an editable CLI tool:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
uv tool install --editable .
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Architecture and Design
|
|
176
|
+
|
|
177
|
+
<details>
|
|
178
|
+
<summary>How PyArch is structured</summary>
|
|
179
|
+
|
|
180
|
+
```text
|
|
181
|
+
Typer CLI
|
|
182
|
+
↓
|
|
183
|
+
Application services
|
|
184
|
+
↓
|
|
185
|
+
Generators
|
|
186
|
+
↓
|
|
187
|
+
Jinja2 templates
|
|
188
|
+
↓
|
|
189
|
+
Generated FastAPI project
|
|
190
|
+
↑
|
|
191
|
+
pyarch.toml
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
The CLI handles user input and delegates work to application services.
|
|
195
|
+
Generators render Jinja2 templates and update files at explicit registration
|
|
196
|
+
markers. The manifest provides the project context needed by later commands.
|
|
197
|
+
|
|
198
|
+
</details>
|
|
199
|
+
|
|
200
|
+
<details>
|
|
201
|
+
<summary>Why use a manifest?</summary>
|
|
202
|
+
|
|
203
|
+
Scanning the filesystem shows which files exist, but not which project choices
|
|
204
|
+
produced them. The manifest stores those choices directly, so later commands do
|
|
205
|
+
not have to guess the architecture, database or enabled features.
|
|
206
|
+
|
|
207
|
+
</details>
|
|
208
|
+
|
|
209
|
+
<details>
|
|
210
|
+
<summary>Why marker-based registration?</summary>
|
|
211
|
+
|
|
212
|
+
PyArch modifies files it generated itself. Explicit markers provide stable and
|
|
213
|
+
readable insertion points for model and router imports without requiring a full
|
|
214
|
+
AST rewriting pipeline.
|
|
215
|
+
|
|
216
|
+
</details>
|
|
217
|
+
|
|
218
|
+
<details>
|
|
219
|
+
<summary>Why Jinja2?</summary>
|
|
220
|
+
|
|
221
|
+
Templates stay close to the Python code users receive and can edit. Jinja2 is
|
|
222
|
+
used with `StrictUndefined`, so missing template context fails during generation
|
|
223
|
+
instead of producing incomplete files.
|
|
224
|
+
|
|
225
|
+
</details>
|
|
226
|
+
|
|
227
|
+
## Roadmap
|
|
228
|
+
|
|
229
|
+
### v0.2
|
|
230
|
+
|
|
231
|
+
- safer generation and validation;
|
|
232
|
+
- rollback on failed generation;
|
|
233
|
+
- Redis integration foundation.
|
|
234
|
+
|
|
235
|
+
### v0.3
|
|
236
|
+
|
|
237
|
+
- Redis integration;
|
|
238
|
+
- scheduler integration;
|
|
239
|
+
- dry-run mode.
|
|
240
|
+
|
|
241
|
+
### Later
|
|
242
|
+
|
|
243
|
+
- more architectures;
|
|
244
|
+
- plugin system;
|
|
245
|
+
- asynchronous database access.
|
|
246
|
+
|
|
247
|
+
## Status
|
|
248
|
+
|
|
249
|
+
PyArch is in early development. The main workflow is usable, but commands,
|
|
250
|
+
templates, generated code and the manifest may still change before a stable
|
|
251
|
+
release.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
FROM ghcr.io/charmbracelet/vhs:latest
|
|
2
|
+
|
|
3
|
+
RUN apt-get update \
|
|
4
|
+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
|
5
|
+
python3-pip \
|
|
6
|
+
&& python3 -m pip install --break-system-packages uv \
|
|
7
|
+
&& mv /usr/local/bin/uv /usr/local/bin/uv-real \
|
|
8
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
9
|
+
|
|
10
|
+
COPY assets/vhs-uv /usr/local/bin/uv
|
|
11
|
+
RUN chmod +x /usr/local/bin/uv
|
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Output assets/pyarch-demo.gif
|
|
2
|
+
|
|
3
|
+
Set Shell "bash"
|
|
4
|
+
Set Width 1100
|
|
5
|
+
Set Height 650
|
|
6
|
+
Set FontSize 22
|
|
7
|
+
Set TypingSpeed 35ms
|
|
8
|
+
Set CursorBlink false
|
|
9
|
+
Set Theme { "name": "PyArch", "black": "#1e1e2e", "red": "#f38ba8", "green": "#a6e3a1", "yellow": "#f9e2af", "blue": "#89b4fa", "magenta": "#cba6f7", "cyan": "#94e2d5", "white": "#cdd6f4", "brightBlack": "#585b70", "brightRed": "#f38ba8", "brightGreen": "#a6e3a1", "brightYellow": "#f9e2af", "brightBlue": "#89b4fa", "brightMagenta": "#cba6f7", "brightCyan": "#94e2d5", "brightWhite": "#ffffff", "background": "#1e1e2e", "foreground": "#cdd6f4" }
|
|
10
|
+
|
|
11
|
+
Hide
|
|
12
|
+
Type "rm -rf pyarch_vhs_demo"
|
|
13
|
+
Enter
|
|
14
|
+
Type "clear"
|
|
15
|
+
Enter
|
|
16
|
+
Show
|
|
17
|
+
|
|
18
|
+
Type "pyarch init pyarch_vhs_demo --database sqlite"
|
|
19
|
+
Enter
|
|
20
|
+
Hide
|
|
21
|
+
Wait+Screen@5m /Project created:/
|
|
22
|
+
Show
|
|
23
|
+
Sleep 2s
|
|
24
|
+
|
|
25
|
+
Type "cd pyarch_vhs_demo"
|
|
26
|
+
Enter
|
|
27
|
+
Sleep 1s
|
|
28
|
+
|
|
29
|
+
Type "pyarch generate module users"
|
|
30
|
+
Enter
|
|
31
|
+
Wait+Screen@2m /Created module/
|
|
32
|
+
Sleep 2s
|
|
33
|
+
|
|
34
|
+
Type "pyarch info"
|
|
35
|
+
Enter
|
|
36
|
+
Wait+Screen@1m /PyArch project/
|
|
37
|
+
Sleep 4s
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
if [ "$1" = "init" ]; then
|
|
4
|
+
exec /usr/local/bin/uv-real "$@" --no-workspace
|
|
5
|
+
fi
|
|
6
|
+
|
|
7
|
+
if [ "$1" = "add" ]; then
|
|
8
|
+
exit 0
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
if [ "$1" = "run" ] && [ "$2" = "alembic" ] && [ "$3" = "init" ]; then
|
|
12
|
+
mkdir -p "$4"
|
|
13
|
+
touch "$4/env.py"
|
|
14
|
+
exit 0
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
exec /usr/local/bin/uv-real "$@"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "PyArch-CLI"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.1"
|
|
4
4
|
description = "Stateful CLI generator for Layered FastAPI projects"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.13"
|
|
@@ -18,24 +18,27 @@ classifiers = [
|
|
|
18
18
|
"Topic :: Software Development :: Code Generators",
|
|
19
19
|
]
|
|
20
20
|
dependencies = [
|
|
21
|
-
"cryptography>=46.0.3",
|
|
22
|
-
"jinja2>=3.1.6",
|
|
23
|
-
"rich>=15.0.0",
|
|
24
|
-
"tomlkit>=0.15.0",
|
|
25
|
-
"typer>=0.24.2",
|
|
26
|
-
]
|
|
27
|
-
|
|
21
|
+
"cryptography>=46.0.3",
|
|
22
|
+
"jinja2>=3.1.6",
|
|
23
|
+
"rich>=15.0.0",
|
|
24
|
+
"tomlkit>=0.15.0",
|
|
25
|
+
"typer>=0.24.2",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
28
|
[project.scripts]
|
|
29
29
|
pyarch = "pyarch.cli.app:app"
|
|
30
30
|
|
|
31
31
|
[project.urls]
|
|
32
|
-
Homepage = "https://github.com/Allcode-1/
|
|
33
|
-
Repository = "https://github.com/Allcode-1/
|
|
34
|
-
Issues = "https://github.com/Allcode-1/
|
|
35
|
-
|
|
36
|
-
[build-system]
|
|
37
|
-
requires = ["hatchling"]
|
|
38
|
-
build-backend = "hatchling.build"
|
|
39
|
-
|
|
40
|
-
[tool.hatch.build.targets.wheel]
|
|
41
|
-
packages = ["pyarch"]
|
|
32
|
+
Homepage = "https://github.com/Allcode-1/PyArch"
|
|
33
|
+
Repository = "https://github.com/Allcode-1/PyArch"
|
|
34
|
+
Issues = "https://github.com/Allcode-1/PyArch/issues"
|
|
35
|
+
|
|
36
|
+
[build-system]
|
|
37
|
+
requires = ["hatchling"]
|
|
38
|
+
build-backend = "hatchling.build"
|
|
39
|
+
|
|
40
|
+
[tool.hatch.build.targets.wheel]
|
|
41
|
+
packages = ["src/pyarch"]
|
|
42
|
+
|
|
43
|
+
[dependency-groups]
|
|
44
|
+
dev = []
|