PyArch-CLI 0.2.1__tar.gz → 0.4.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.
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/.gitignore +15 -12
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/.python-version +1 -1
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/PKG-INFO +115 -30
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/README.md +391 -304
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/assets/Dockerfile.vhs +11 -11
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/assets/pyarch-demo.tape +37 -37
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/assets/vhs-uv +17 -17
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/pyproject.toml +48 -48
- pyarch_cli-0.4.0/src/pyarch/__init__.py +1 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/cli/__init__.py +1 -1
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/cli/add.py +18 -1
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/cli/app.py +36 -36
- pyarch_cli-0.4.0/src/pyarch/cli/common.py +85 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/cli/db.py +48 -47
- pyarch_cli-0.4.0/src/pyarch/cli/generate.py +58 -0
- pyarch_cli-0.4.0/src/pyarch/cli/init.py +65 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/config/__init__.py +1 -1
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/config/manifest.py +201 -164
- pyarch_cli-0.4.0/src/pyarch/config/models.py +94 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/generators/__init__.py +1 -1
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/generators/common/__init__.py +1 -1
- pyarch_cli-0.4.0/src/pyarch/generators/common/commands.py +30 -0
- pyarch_cli-0.4.0/src/pyarch/generators/common/compose_edit.py +252 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/generators/common/filesystem.py +79 -93
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/generators/common/renderer.py +31 -31
- pyarch_cli-0.4.0/src/pyarch/generators/common/source_edit.py +322 -0
- pyarch_cli-0.4.0/src/pyarch/generators/integration/auth.py +266 -0
- pyarch_cli-0.4.0/src/pyarch/generators/integration/redis.py +237 -0
- pyarch_cli-0.4.0/src/pyarch/generators/integration/registry.py +22 -0
- pyarch_cli-0.4.0/src/pyarch/generators/integration/spec.py +15 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/generators/module/__init__.py +1 -1
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/generators/module/layered.py +230 -167
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/generators/project/__init__.py +1 -1
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/generators/project/base.py +52 -11
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/generators/project/layered.py +190 -158
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/main.py +9 -9
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/services/__init__.py +1 -1
- pyarch_cli-0.4.0/src/pyarch/services/add_integration.py +40 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/services/create_module.py +12 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/services/create_project.py +41 -37
- pyarch_cli-0.4.0/src/pyarch/services/database.py +228 -0
- pyarch_cli-0.4.0/src/pyarch/services/dry_run.py +131 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/alembic_env.py.j2 +57 -57
- pyarch_cli-0.4.0/src/pyarch/templates/layered/auth/config.py.j2 +13 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/auth/dependencies.py.j2 +5 -5
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/auth/refresh_session_model.py.j2 +6 -1
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/auth/routes.py.j2 +16 -16
- pyarch_cli-0.4.0/src/pyarch/templates/layered/auth/schemas.py.j2 +55 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/auth/service.py.j2 +56 -40
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/auth/test_auth.py.j2 +195 -117
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/auth/test_helpers.py.j2 +47 -47
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/auth/tokens.py.j2 +5 -5
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/auth/user_model.py.j2 +3 -3
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/auth/utils.py.j2 +4 -6
- pyarch_cli-0.4.0/src/pyarch/templates/layered/config.py.j2 +43 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/env.example.j2 +17 -16
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/errors.py.j2 +5 -6
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/exception_handlers.py.j2 +13 -13
- pyarch_cli-0.4.0/src/pyarch/templates/layered/infra/redis/cache.py.j2 +87 -0
- pyarch_cli-0.4.0/src/pyarch/templates/layered/infra/redis/config.py.j2 +8 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/models_init.py.j2 +5 -4
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/module/module_model.py.j2 +13 -13
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/module/module_repo.py.j2 +63 -57
- pyarch_cli-0.4.0/src/pyarch/templates/layered/module/module_router.py.j2 +90 -0
- pyarch_cli-0.4.0/src/pyarch/templates/layered/module/module_router_protected.py.j2 +94 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/module/module_schema.py.j2 +23 -23
- pyarch_cli-0.4.0/src/pyarch/templates/layered/module/module_service.py.j2 +116 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/module/module_test.py.j2 +70 -43
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/module/module_test_protected.py.j2 +110 -70
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/pagination.py.j2 +22 -22
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/router.py.j2 +7 -7
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/layered/session.py.j2 +33 -33
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/project/base/Dockerfile.j2 +2 -2
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/project/base/README.md.j2 +39 -39
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/project/base/ci.yml.j2 +26 -26
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/project/base/conftest.py.j2 +73 -49
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/project/base/docker-compose.postgres.yml.j2 +46 -43
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/project/base/docker-compose.sqlite.yml.j2 +6 -6
- pyarch_cli-0.4.0/src/pyarch/templates/project/base/dockerignore.j2 +14 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/templates/project/base/main.py.j2 +8 -8
- pyarch_cli-0.4.0/src/pyarch/templates/project/base/ruff.toml.j2 +16 -0
- pyarch_cli-0.4.0/tests/integration/test_generated_project.py +97 -0
- pyarch_cli-0.4.0/tests/integration/test_project_generation.py +203 -0
- pyarch_cli-0.4.0/tests/unit/test_add_integration.py +189 -0
- pyarch_cli-0.4.0/tests/unit/test_auth_integration.py +172 -0
- pyarch_cli-0.4.0/tests/unit/test_compose_edit.py +340 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/tests/unit/test_database_cli.py +57 -57
- pyarch_cli-0.4.0/tests/unit/test_database_service.py +380 -0
- pyarch_cli-0.4.0/tests/unit/test_dry_run.py +95 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/tests/unit/test_filesystem.py +30 -30
- pyarch_cli-0.4.0/tests/unit/test_generate_cli.py +65 -0
- pyarch_cli-0.4.0/tests/unit/test_manifest.py +183 -0
- pyarch_cli-0.4.0/tests/unit/test_module_generator.py +256 -0
- pyarch_cli-0.4.0/tests/unit/test_redis_integration.py +118 -0
- pyarch_cli-0.4.0/tests/unit/test_source_edit.py +558 -0
- pyarch_cli-0.4.0/tests/unit/test_templates.py +292 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/uv.lock +9 -7
- pyarch_cli-0.2.1/src/pyarch/__init__.py +0 -1
- pyarch_cli-0.2.1/src/pyarch/cli/common.py +0 -26
- pyarch_cli-0.2.1/src/pyarch/cli/generate.py +0 -32
- pyarch_cli-0.2.1/src/pyarch/cli/init.py +0 -34
- pyarch_cli-0.2.1/src/pyarch/config/models.py +0 -50
- pyarch_cli-0.2.1/src/pyarch/generators/common/commands.py +0 -6
- pyarch_cli-0.2.1/src/pyarch/generators/integration/auth.py +0 -157
- pyarch_cli-0.2.1/src/pyarch/services/add_integration.py +0 -65
- pyarch_cli-0.2.1/src/pyarch/services/database.py +0 -110
- pyarch_cli-0.2.1/src/pyarch/templates/layered/auth/config.py.j2 +0 -35
- pyarch_cli-0.2.1/src/pyarch/templates/layered/auth/schemas.py.j2 +0 -31
- pyarch_cli-0.2.1/src/pyarch/templates/layered/config.py.j2 +0 -22
- pyarch_cli-0.2.1/src/pyarch/templates/layered/module/module_router.py.j2 +0 -59
- pyarch_cli-0.2.1/src/pyarch/templates/layered/module/module_router_protected.py.j2 +0 -73
- pyarch_cli-0.2.1/src/pyarch/templates/layered/module/module_service.py.j2 +0 -65
- pyarch_cli-0.2.1/src/pyarch/templates/project/base/dockerignore.j2 +0 -12
- pyarch_cli-0.2.1/src/pyarch/templates/project/base/ruff.toml.j2 +0 -8
- pyarch_cli-0.2.1/tests/integration/test_generated_project.py +0 -68
- pyarch_cli-0.2.1/tests/integration/test_project_generation.py +0 -97
- pyarch_cli-0.2.1/tests/unit/test_database_service.py +0 -162
- pyarch_cli-0.2.1/tests/unit/test_manifest.py +0 -29
- pyarch_cli-0.2.1/tests/unit/test_module_generator.py +0 -43
- pyarch_cli-0.2.1/tests/unit/test_templates.py +0 -79
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/.github/workflows/ci.yml +0 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/LICENSE +0 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/assets/pyarch-demo.gif +0 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/cli/info.py +0 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/generators/common/gitignore.py +0 -0
- {pyarch_cli-0.2.1 → pyarch_cli-0.4.0}/src/pyarch/generators/integration/__init__.py +0 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
# Python-generated files
|
|
2
|
-
__pycache__/
|
|
3
|
-
*.py[oc]
|
|
4
|
-
build/
|
|
5
|
-
*dist
|
|
6
|
-
dist/
|
|
7
|
-
wheels/
|
|
8
|
-
*.egg-info
|
|
9
|
-
*_cache
|
|
10
|
-
|
|
11
|
-
# Virtual environments
|
|
12
|
-
.venv
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
*dist
|
|
6
|
+
dist/
|
|
7
|
+
wheels/
|
|
8
|
+
*.egg-info
|
|
9
|
+
*_cache
|
|
10
|
+
|
|
11
|
+
# Virtual environments
|
|
12
|
+
.venv
|
|
13
|
+
|
|
14
|
+
# OMP agent workspace
|
|
15
|
+
.omp/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
3.13
|
|
1
|
+
3.13
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: PyArch-CLI
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Stateful CLI generator for Layered FastAPI projects
|
|
5
5
|
Project-URL: Homepage, https://github.com/Allcode-1/PyArch
|
|
6
6
|
Project-URL: Repository, https://github.com/Allcode-1/PyArch
|
|
@@ -19,9 +19,7 @@ Classifier: Topic :: Software Development :: Code Generators
|
|
|
19
19
|
Requires-Python: >=3.13
|
|
20
20
|
Requires-Dist: cryptography>=46.0.3
|
|
21
21
|
Requires-Dist: jinja2>=3.1.6
|
|
22
|
-
Requires-Dist: mypy>=2.3.0
|
|
23
22
|
Requires-Dist: rich>=15.0.0
|
|
24
|
-
Requires-Dist: ruff>=0.16.1
|
|
25
23
|
Requires-Dist: tomlkit>=0.15.0
|
|
26
24
|
Requires-Dist: typer>=0.24.2
|
|
27
25
|
Description-Content-Type: text/markdown
|
|
@@ -34,7 +32,7 @@ Description-Content-Type: text/markdown
|
|
|
34
32
|

|
|
35
33
|

|
|
36
34
|

|
|
37
|
-

|
|
38
36
|
|
|
39
37
|
PyArch is a CLI for creating and extending Layered FastAPI projects. It sets up
|
|
40
38
|
the application structure, database, tests and Alembic, then lets you add CRUD
|
|
@@ -65,13 +63,20 @@ ready to change.
|
|
|
65
63
|
- Project-aware generation through `pyarch.toml`
|
|
66
64
|
- Atomic project creation and rollback for failed extensions
|
|
67
65
|
|
|
68
|
-
## v0.
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
|
|
72
|
-
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
## v0.4.0 Highlights
|
|
67
|
+
|
|
68
|
+
- Redis integration: `pyarch add integration redis` adds the client, settings,
|
|
69
|
+
cache helpers, a Compose service and a `fakeredis` test fixture
|
|
70
|
+
- Opt-in cache-aside for CRUD modules: `pyarch generate module <name> --cache`
|
|
71
|
+
caches single-item reads and invalidates them after update and delete; Redis
|
|
72
|
+
outages fall back to the database instead of failing requests
|
|
73
|
+
- The generated `core/config.py` is split into settings sections
|
|
74
|
+
(`settings.database.url`, `settings.pagination`, integration sections)
|
|
75
|
+
- Integrations are described by a shared registry used by auth and Redis
|
|
76
|
+
- `--dry-run` and `--diff` for `generate module` and `add integration` preview
|
|
77
|
+
file changes and dependency commands without touching the project
|
|
78
|
+
- Already plural module names are no longer pluralized twice
|
|
79
|
+
(`books` → `/books`, not `/bookses`)
|
|
75
80
|
|
|
76
81
|
## Quick Start
|
|
77
82
|
|
|
@@ -91,8 +96,12 @@ pyarch init my_project --database postgres
|
|
|
91
96
|
cd my_project
|
|
92
97
|
```
|
|
93
98
|
|
|
94
|
-
|
|
95
|
-
PostgreSQL
|
|
99
|
+
`pyarch init` creates a ready-to-run `.env` from `.env.example` (local
|
|
100
|
+
PostgreSQL credentials `postgres`/`postgres`, database `app`). If host ports
|
|
101
|
+
5432 or 8000 are taken, change `POSTGRES_PORT` / `API_PORT` in `.env` (and the
|
|
102
|
+
port in `DATABASE_URL` / `TEST_DATABASE_URL`). The test suite creates the
|
|
103
|
+
`app_test` database on the same server automatically. For a PostgreSQL
|
|
104
|
+
project, initialize the database schema before starting the app:
|
|
96
105
|
|
|
97
106
|
```bash
|
|
98
107
|
pyarch db init
|
|
@@ -111,10 +120,15 @@ revision and restart the application with:
|
|
|
111
120
|
pyarch db upgrade --message "describe schema change"
|
|
112
121
|
```
|
|
113
122
|
|
|
114
|
-
Without `--message`, PyArch prompts for one.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
123
|
+
Without `--message`, PyArch prompts for one. Only the API service is stopped
|
|
124
|
+
and rebuilt; the database service keeps running. PyArch detects both Compose
|
|
125
|
+
service names from `docker compose config` (the service with a `build` key and
|
|
126
|
+
the one running a `postgres` image), so renaming them is fine; when detection
|
|
127
|
+
is ambiguous, pin the names in `pyarch.toml` with
|
|
128
|
+
`[compose] api_service = "..."` / `db_service = "..."`. When Alembic finds no
|
|
129
|
+
metadata changes, `db upgrade` restarts the API service but creates no empty
|
|
130
|
+
revision. Compose never runs migrations implicitly; migration files remain
|
|
131
|
+
source code and should be reviewed and committed.
|
|
118
132
|
|
|
119
133
|
## Safe Generation
|
|
120
134
|
|
|
@@ -124,6 +138,13 @@ removed. `generate module` and `add integration` track every affected file and
|
|
|
124
138
|
restore the previous state if a generation step fails, including the manifest
|
|
125
139
|
and dependency files.
|
|
126
140
|
|
|
141
|
+
`generate module` and `add integration` accept `--dry-run`: the command runs on
|
|
142
|
+
a temporary copy of the project and prints the files it would create or modify
|
|
143
|
+
plus the dependency commands it would run (`uv add ...`). Nothing is written to
|
|
144
|
+
the project and no commands are executed; validation errors are reported exactly
|
|
145
|
+
as in a real run. Add `--diff` to print the full unified diff. `pyarch init`
|
|
146
|
+
has no dry-run mode: it only creates a new directory.
|
|
147
|
+
|
|
127
148
|
Open `http://127.0.0.1:8000/docs` to use the generated Swagger UI.
|
|
128
149
|
|
|
129
150
|
You can now extend the project:
|
|
@@ -132,12 +153,15 @@ You can now extend the project:
|
|
|
132
153
|
pyarch generate module user
|
|
133
154
|
pyarch add integration auth
|
|
134
155
|
pyarch generate module task --protected
|
|
156
|
+
pyarch add integration redis
|
|
157
|
+
pyarch generate module note --cache
|
|
135
158
|
pyarch info
|
|
136
159
|
```
|
|
137
160
|
|
|
138
|
-
Module names
|
|
139
|
-
route names from them:
|
|
140
|
-
|
|
161
|
+
Module names should be singular identifiers. PyArch derives the plural table and
|
|
162
|
+
route names from them: `user` generates `/users` and the `users` table. Names
|
|
163
|
+
that already look plural (`books`, `people`, `news`) are kept as-is instead of
|
|
164
|
+
being pluralized twice.
|
|
141
165
|
|
|
142
166
|
## What Gets Generated
|
|
143
167
|
|
|
@@ -158,6 +182,7 @@ my_project/
|
|
|
158
182
|
│ └── main.py
|
|
159
183
|
├── tests/
|
|
160
184
|
├── alembic/ # PostgreSQL and SQLite only
|
|
185
|
+
├── .env # created from .env.example, git-ignored
|
|
161
186
|
├── .env.example
|
|
162
187
|
├── pyarch.toml
|
|
163
188
|
└── pyproject.toml
|
|
@@ -172,15 +197,60 @@ Each generated CRUD module adds:
|
|
|
172
197
|
- CRUD tests;
|
|
173
198
|
- model and router registration in the existing application.
|
|
174
199
|
|
|
200
|
+
Integrations add their infrastructure under `app/infra/` (for example
|
|
201
|
+
`app/infra/redis/`) only when they are enabled; `app/db/` stays the base
|
|
202
|
+
database layer and auth keeps living in `app/auth/`.
|
|
203
|
+
|
|
204
|
+
## Settings
|
|
205
|
+
|
|
206
|
+
`app/core/config.py` groups settings by section instead of keeping one flat
|
|
207
|
+
class: `settings.database.url`, `settings.pagination.default_limit`,
|
|
208
|
+
`settings.auth_jwt.*`, `settings.redis.*`. The database URL is still read from
|
|
209
|
+
`DATABASE_URL`; integration sections use the nested `__` delimiter, e.g.
|
|
210
|
+
`AUTH_JWT__ALGORITHM` or `REDIS__URL`.
|
|
211
|
+
|
|
212
|
+
## Redis Cache
|
|
213
|
+
|
|
214
|
+
`pyarch add integration redis` installs `redis` (and `fakeredis` as a dev
|
|
215
|
+
dependency), generates `app/infra/redis/{config,cache}.py`, registers
|
|
216
|
+
`RedisSettings` in `Settings`, adds `REDIS__URL` to `.env.example`/`.env` and,
|
|
217
|
+
for PostgreSQL projects, a `redis` service to `docker-compose.yml` with
|
|
218
|
+
`REDIS__URL=redis://redis:6379/0` for the API container. Generated tests replace
|
|
219
|
+
the cache with an in-memory `fakeredis` instance through an autouse fixture.
|
|
220
|
+
|
|
221
|
+
`pyarch generate module <name> --cache` (requires the redis integration,
|
|
222
|
+
combinable with `--protected`) generates a cache-aside service:
|
|
223
|
+
|
|
224
|
+
- `GET /<items>/{id}` reads `<prefix>:<module>:<id>` from Redis and falls back
|
|
225
|
+
to the database on a miss, then stores the response schema as JSON with the
|
|
226
|
+
configured TTL (`REDIS__TTL_SECONDS`, 300 by default);
|
|
227
|
+
- `PATCH` and `DELETE` invalidate the key after a successful commit;
|
|
228
|
+
`404` responses are never cached;
|
|
229
|
+
- an entry that no longer matches the response schema (for example after a
|
|
230
|
+
schema change) is dropped and reloaded from the database;
|
|
231
|
+
- Redis errors never fail a request: reads and writes degrade to a cache miss
|
|
232
|
+
and are logged, failed invalidations are logged as errors.
|
|
233
|
+
|
|
234
|
+
Known limits: list endpoints are not cached; a read that loads a row before a
|
|
235
|
+
concurrent update commits can store the old value after the invalidation, so
|
|
236
|
+
it stays cached until the TTL expires; data changed outside the generated
|
|
237
|
+
service is not invalidated; caching can not yet be enabled for an already
|
|
238
|
+
generated module.
|
|
239
|
+
|
|
175
240
|
## Commands
|
|
176
241
|
|
|
177
242
|
| Command | Description |
|
|
178
243
|
| ------------------------------------------- | ------------------------------------------------ |
|
|
179
244
|
| `pyarch init <name>` | Create a Layered FastAPI project |
|
|
180
245
|
| `pyarch init <name> --database <engine>` | Select PostgreSQL or SQLite |
|
|
246
|
+
| `pyarch init <name> --app-dir <pkg> --tests-dir <pkg> --migrations-dir <path>` | Custom application package, tests package and Alembic directory |
|
|
181
247
|
| `pyarch generate module <singular-name>` | Add a CRUD module to the current project |
|
|
182
248
|
| `pyarch add integration auth` | Add JWT authentication and user management |
|
|
183
249
|
| `pyarch generate module <singular-name> --protected` | Generate protected CRUD routes |
|
|
250
|
+
| `pyarch add integration redis` | Add Redis client, settings and cache helpers |
|
|
251
|
+
| `pyarch generate module <singular-name> --cache` | Cache single-item reads in Redis |
|
|
252
|
+
| `pyarch generate module <singular-name> --dry-run [--diff]` | Preview module changes without writing |
|
|
253
|
+
| `pyarch add integration <name> --dry-run [--diff]` | Preview integration changes without writing |
|
|
184
254
|
| `pyarch info` | Show the current project configuration |
|
|
185
255
|
| `pyarch --help` | Show CLI help |
|
|
186
256
|
|
|
@@ -283,8 +353,10 @@ not have to guess the architecture, database or enabled features.
|
|
|
283
353
|
<summary>Why marker-based registration?</summary>
|
|
284
354
|
|
|
285
355
|
PyArch modifies files it generated itself. Explicit markers provide stable and
|
|
286
|
-
readable insertion points for model and
|
|
287
|
-
|
|
356
|
+
readable insertion points for model, router and settings registration. When a
|
|
357
|
+
marker is missing, PyArch falls back to the Python syntax tree: imports go after
|
|
358
|
+
the last import, settings fields into the `Settings` class, model names into
|
|
359
|
+
`__all__` and router includes to the end of the router module.
|
|
288
360
|
|
|
289
361
|
</details>
|
|
290
362
|
|
|
@@ -299,7 +371,26 @@ instead of producing incomplete files.
|
|
|
299
371
|
|
|
300
372
|
## Roadmap
|
|
301
373
|
|
|
302
|
-
### v0.
|
|
374
|
+
### v0.4.0 (current)
|
|
375
|
+
|
|
376
|
+
- Redis integration foundation (`pyarch add integration redis`);
|
|
377
|
+
- opt-in cache-aside generation for CRUD modules (`--cache`);
|
|
378
|
+
- sectioned settings classes in the generated `core/config.py`;
|
|
379
|
+
- integration registry shared by auth and Redis;
|
|
380
|
+
- dry-run mode for `generate module` and `add integration` (`--dry-run`, `--diff`);
|
|
381
|
+
- no double pluralization of plural module names.
|
|
382
|
+
|
|
383
|
+
### v0.3.0
|
|
384
|
+
|
|
385
|
+
- dev-only linting and type-checking dependencies for the CLI itself;
|
|
386
|
+
- auth settings registration that preserves the core config;
|
|
387
|
+
- marker-free fallback registration via the Python syntax tree;
|
|
388
|
+
- password policy and refresh-token family revocation on reuse;
|
|
389
|
+
- configurable project paths honored by every generator;
|
|
390
|
+
- API-only restart with auto-detected Compose service names;
|
|
391
|
+
- ready-to-run `.env`, configurable host ports, auto-created test database.
|
|
392
|
+
|
|
393
|
+
### v0.2.1
|
|
303
394
|
|
|
304
395
|
- singular module-name contract and corrected SQLite workflow documentation;
|
|
305
396
|
- generated GitHub Actions workflow for linting and tests;
|
|
@@ -312,12 +403,6 @@ instead of producing incomplete files.
|
|
|
312
403
|
- PostgreSQL Compose template and SQLite local setup;
|
|
313
404
|
- self-test suite and generated-project integration coverage.
|
|
314
405
|
|
|
315
|
-
### v0.3
|
|
316
|
-
|
|
317
|
-
- Redis integration foundation;
|
|
318
|
-
- opt-in cache-aside generation for CRUD modules;
|
|
319
|
-
- dry-run mode.
|
|
320
|
-
|
|
321
406
|
### Later
|
|
322
407
|
|
|
323
408
|
- scheduler integration;
|
|
@@ -327,6 +412,6 @@ instead of producing incomplete files.
|
|
|
327
412
|
|
|
328
413
|
## Status
|
|
329
414
|
|
|
330
|
-
PyArch v0.
|
|
415
|
+
PyArch v0.4.0 is an early alpha release. The main workflow is usable, but
|
|
331
416
|
commands, templates, generated code and the manifest may still change before a
|
|
332
417
|
stable release.
|