spaps-server-quickstart 0.2.0__tar.gz → 0.2.2__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.
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/.gitignore +4 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/PKG-INFO +126 -3
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/README.md +124 -2
- spaps_server_quickstart-0.2.2/coverage.xml +1589 -0
- spaps_server_quickstart-0.2.2/diff/plan.md +115 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/docs/MIGRATION_GUIDE.md +96 -9
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/docs/TDD_PLAN.md +3 -0
- spaps_server_quickstart-0.2.2/docs/messaging-broker-plan.md +73 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/pyproject.toml +31 -2
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/__init__.py +5 -1
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/api/dependencies.py +75 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/api/health.py +197 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/app_factory.py +12 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/auth/__init__.py +105 -4
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/auth_channels.py +110 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/db/session.py +9 -10
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/local_mode/__init__.py +35 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/local_mode/middleware.py +98 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/local_mode/personas.py +119 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/seeds/__init__.py +26 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/seeds/cli.py +87 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/seeds/schemas.py +56 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/seeds/validator.py +85 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/settings.py +23 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/startup.py +130 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/.pre-commit-config.yaml +32 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/alembic/env.py +125 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/alembic/script.py.mako +26 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/alembic/versions/.gitkeep +1 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/alembic.ini +58 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/docs/templates/API_DOCUMENTATION_TEMPLATE.md +126 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/docs/templates/DEBUG_REPORT_TEMPLATE.md +154 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/docs/templates/OPERATIONS_PLAYBOOK_TEMPLATE.md +215 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/domains/auth/local_routes.py +142 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/domains/users/__init__.py +8 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/domains/users/models.py +50 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/domains/users/repository.py +79 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/domains/users/router.py +183 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/domains/users/schemas.py +53 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/domains/users/service.py +51 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/operations/.github/workflows/deploy.yml +159 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/operations/.github/workflows/rollback.yml +136 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/templates/operations/Makefile +15 -1
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2/src/spaps_server_quickstart}/templates/operations/deploy/deploy.sh +39 -5
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/operations/deploy/docker-compose.migration.yml +44 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/operations/deploy/post-deploy-verify.sh +343 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/operations/deploy/pre-deploy-checks.sh +292 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/operations/scripts/dev/await_db.py +98 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/operations/scripts/dev/local-debug-loop.sh +376 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/operations/scripts/dev/start-db.sh +54 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/operations/scripts/dev/stop-db.sh +29 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/templates/operations/scripts/prepush.sh +28 -44
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/scripts/__init__.py +1 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/scripts/seeds/__init__.py +1 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/scripts/seeds/data/users.yaml +48 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/scripts/seeds/schemas/__init__.py +1 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/scripts/seeds/schemas/users.py +88 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/README.md +93 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/__init__.py +1 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/api/__init__.py +1 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/api/test_health.py +28 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/api/test_users_auth.py +211 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/conftest.py +634 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/domains/__init__.py +1 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/domains/example/__init__.py +1 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/domains/example/conftest.py +48 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/domains/users/__init__.py +1 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/domains/users/conftest.py +154 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/integration/__init__.py +1 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/integration/test_db_connectivity.py +38 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/unit/__init__.py +1 -0
- spaps_server_quickstart-0.2.2/src/spaps_server_quickstart/templates/tests/unit/test_settings.py +35 -0
- spaps_server_quickstart-0.2.2/templates/Makefile +71 -0
- spaps_server_quickstart-0.2.2/templates/docker-compose.yml +94 -0
- spaps_server_quickstart-0.2.2/templates/operations/.github/workflows/deploy.yml +158 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/templates/operations/Makefile +15 -1
- {spaps_server_quickstart-0.2.0/src/spaps_server_quickstart → spaps_server_quickstart-0.2.2}/templates/operations/deploy/deploy.sh +39 -5
- spaps_server_quickstart-0.2.2/templates/operations/deploy/post-deploy-verify.sh +343 -0
- spaps_server_quickstart-0.2.2/templates/operations/deploy/pre-deploy-checks.sh +292 -0
- spaps_server_quickstart-0.2.2/templates/operations/deploy/reverse-proxy/README.md +6 -0
- spaps_server_quickstart-0.2.2/templates/operations/docker-compose.dev.yml +16 -0
- spaps_server_quickstart-0.2.2/templates/operations/scripts/dev/await_db.py +98 -0
- spaps_server_quickstart-0.2.2/templates/operations/scripts/dev/local-debug-loop.sh +376 -0
- spaps_server_quickstart-0.2.2/templates/operations/scripts/dev/start-db.sh +54 -0
- spaps_server_quickstart-0.2.2/templates/operations/scripts/dev/stop-db.sh +29 -0
- spaps_server_quickstart-0.2.2/templates/tests/conftest.py +614 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_auth.py +49 -3
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_db_session.py +15 -5
- spaps_server_quickstart-0.2.2/tests/test_local_mode.py +340 -0
- spaps_server_quickstart-0.2.2/tests/test_operations_templates.py +569 -0
- spaps_server_quickstart-0.2.2/tests/test_seed_validation.py +356 -0
- spaps_server_quickstart-0.2.2/tests/test_startup_validation.py +311 -0
- spaps_server_quickstart-0.2.0/src/spaps_server_quickstart/api/health.py +0 -98
- spaps_server_quickstart-0.2.0/src/spaps_server_quickstart/templates/domains/users/router.py +0 -23
- spaps_server_quickstart-0.2.0/templates/operations/deploy/reverse-proxy/README.md +0 -1
- spaps_server_quickstart-0.2.0/tests/test_operations_templates.py +0 -58
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/CHANGELOG.md +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/docs/UPGRADING.md +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/scripts/release.sh +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/alembic/__init__.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/alembic/naming.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/api/__init__.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/api/router.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/auth/cookies.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/auth/dependencies.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/db/__init__.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/db/alembic_status.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/db/migration_runner.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/logging.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/middleware.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/rbac/__init__.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/schemas/__init__.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/schemas/health.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/secure_messaging.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/tasks/__init__.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/tasks/celery_factory.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/tasks/health.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/tasks/notifications.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/templates/__init__.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/templates/domains/__init__.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/templates/domains/admin/router.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/templates/operations/.env.production.example +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/templates/operations/.githooks/pre-push +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/templates/operations/docker-compose.prod.yml +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/templates/operations/scripts/backup-db.sh +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/templates/operations/scripts/new-migration.sh +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/src/spaps_server_quickstart/templates/operations/scripts/restore-db.sh +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/templates/operations/.env.production.example +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/templates/operations/deploy/reverse-proxy/certs/.gitkeep +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/templates/operations/deploy/reverse-proxy/docker-compose.yml +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/templates/operations/deploy/reverse-proxy/nginx.conf +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/templates/operations/deploy/reverse-proxy/sites-available/.gitkeep +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/templates/operations/deploy/reverse-proxy/sites-enabled/.gitkeep +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/templates/operations/deploy/reverse-proxy/static/.gitkeep +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/templates/operations/deploy/reverse-proxy/up.sh +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/templates/operations/docker-compose.prod.yml +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_alembic_naming.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_api_router.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_app_factory.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_auth_channels.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_auth_cookies.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_auth_dependencies.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_health_router.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_imports.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_logging.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_middleware.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_migration_runner.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_migration_status.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_rbac.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_secure_messaging.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_settings.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/tests/test_tasks.py +0 -0
- {spaps_server_quickstart-0.2.0 → spaps_server_quickstart-0.2.2}/todo.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spaps-server-quickstart
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Shared FastAPI/Celery scaffolding for Sweet Potato service backends.
|
|
5
5
|
Project-URL: Repository, https://github.com/sweet-potato/spaps
|
|
6
6
|
Author-email: buildooor <buildooor@gmail.com>
|
|
@@ -32,6 +32,7 @@ Requires-Dist: pytest-asyncio<0.24,>=0.23.0; extra == 'dev'
|
|
|
32
32
|
Requires-Dist: pytest-cov<6.0,>=5.0.0; extra == 'dev'
|
|
33
33
|
Requires-Dist: pytest<9.0,>=8.2.0; extra == 'dev'
|
|
34
34
|
Requires-Dist: ruff<0.5,>=0.4.1; extra == 'dev'
|
|
35
|
+
Requires-Dist: types-pyyaml<7.0,>=6.0.0; extra == 'dev'
|
|
35
36
|
Provides-Extra: release
|
|
36
37
|
Requires-Dist: build<2.0,>=1.2.1; extra == 'release'
|
|
37
38
|
Requires-Dist: twine<6.0,>=5.0.0; extra == 'release'
|
|
@@ -67,6 +68,48 @@ poetry run -C packages/python-server-quickstart pytest
|
|
|
67
68
|
The shared modules are designed to be imported by individual service packages. Tests live
|
|
68
69
|
alongside the shared code to guard the common behaviour.
|
|
69
70
|
|
|
71
|
+
### Local Auth Bypass Mode
|
|
72
|
+
|
|
73
|
+
For local development without external auth services, enable local mode by setting
|
|
74
|
+
`DEVELOPMENT_ENVIRONMENT=local`. This provides pre-configured personas (admin/user)
|
|
75
|
+
that bypass SPAPS authentication.
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from spaps_server_quickstart.settings import BaseServiceSettings
|
|
79
|
+
from spaps_server_quickstart.local_mode import (
|
|
80
|
+
LocalAuthMiddleware,
|
|
81
|
+
get_default_registry,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
settings = BaseServiceSettings(development_environment="local")
|
|
85
|
+
|
|
86
|
+
if settings.is_local_development:
|
|
87
|
+
app.add_middleware(LocalAuthMiddleware, registry=get_default_registry())
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Available personas:**
|
|
91
|
+
|
|
92
|
+
| Persona | Token | Roles |
|
|
93
|
+
| --- | --- | --- |
|
|
94
|
+
| Admin | `local-admin` | `admin`, `user` |
|
|
95
|
+
| User | `local-user` | `user` |
|
|
96
|
+
|
|
97
|
+
Use the token in your Authorization header: `Authorization: Bearer local-admin`
|
|
98
|
+
|
|
99
|
+
Optional local auth routes are available under `spaps_server_quickstart.templates.domains.auth.local_routes`:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from spaps_server_quickstart.templates.domains.auth.local_routes import router as local_auth_router
|
|
103
|
+
|
|
104
|
+
if settings.is_local_development:
|
|
105
|
+
app.include_router(local_auth_router, prefix="/v1/auth", tags=["local-auth"])
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
This adds:
|
|
109
|
+
- `GET /v1/auth/local-personas` - List available personas
|
|
110
|
+
- `POST /v1/auth/local-login` - Login with persona code or token
|
|
111
|
+
- `GET /v1/auth/local-me` - Get current persona from Authorization header
|
|
112
|
+
|
|
70
113
|
## Operational Templates
|
|
71
114
|
|
|
72
115
|
For infrastructure parity with live SPAPS services, the directory
|
|
@@ -74,15 +117,94 @@ For infrastructure parity with live SPAPS services, the directory
|
|
|
74
117
|
|
|
75
118
|
- Makefile with lint/test/deploy shortcuts
|
|
76
119
|
- Production `.env.production.example`
|
|
77
|
-
- Docker Compose + reverse-proxy stubs
|
|
78
|
-
- Deploy script that
|
|
120
|
+
- Docker Compose + reverse-proxy stubs (pre-configured with Docker DNS resolver support)
|
|
121
|
+
- Deploy script that reloads the shared proxy in-place after each rollout
|
|
122
|
+
- **Pre/post deployment checks** (`pre-deploy-checks.sh`, `post-deploy-verify.sh`)
|
|
79
123
|
- Database maintenance scripts (`backup-db.sh`, `restore-db.sh`, `new-migration.sh`)
|
|
80
124
|
- Pre-push hook + `scripts/prepush.sh` matching live automation
|
|
125
|
+
- Local Postgres helpers under `scripts/dev/` (`start-db.sh`, `stop-db.sh`, `await_db.py`) for pgvector-backed test runs
|
|
126
|
+
|
|
127
|
+
### Deployment Checks
|
|
128
|
+
|
|
129
|
+
The deployment scripts include automated validation:
|
|
130
|
+
|
|
131
|
+
**Pre-deployment (`pre-deploy-checks.sh`):**
|
|
132
|
+
- Docker availability and daemon status
|
|
133
|
+
- Port availability for required services
|
|
134
|
+
- Disk space validation (configurable minimum)
|
|
135
|
+
- Required environment variable validation
|
|
136
|
+
- Dev container conflict detection
|
|
137
|
+
- Docker network verification
|
|
138
|
+
|
|
139
|
+
**Post-deployment (`post-deploy-verify.sh`):**
|
|
140
|
+
- Container running status
|
|
141
|
+
- Health endpoint validation with exponential backoff
|
|
142
|
+
- Image version verification
|
|
143
|
+
- Migration status check (optional)
|
|
144
|
+
- Docker healthcheck status
|
|
145
|
+
- Service connectivity (Redis, database)
|
|
146
|
+
|
|
147
|
+
Configuration via environment variables:
|
|
148
|
+
|
|
149
|
+
| Variable | Description | Default |
|
|
150
|
+
| --- | --- | --- |
|
|
151
|
+
| `SERVICE_NAME` | Service identifier for checks | `quickstart` |
|
|
152
|
+
| `REQUIRED_PORTS` | Comma-separated ports to check | `8000` |
|
|
153
|
+
| `MIN_DISK_SPACE_GB` | Minimum disk space required | `5` |
|
|
154
|
+
| `REQUIRED_ENV_VARS` | Required environment variables | `` |
|
|
155
|
+
| `HEALTH_ENDPOINT` | URL for health check | `http://localhost:8000/health` |
|
|
156
|
+
| `MAX_HEALTH_WAIT` | Max seconds to wait for health | `60` |
|
|
157
|
+
| `SKIP_PRE_CHECKS` | Skip pre-deployment checks | `0` |
|
|
158
|
+
| `SKIP_POST_CHECKS` | Skip post-deployment checks | `0` |
|
|
159
|
+
|
|
160
|
+
### Database Caching for Local Development
|
|
161
|
+
|
|
162
|
+
The `local-debug-loop.sh` script caches seeded database state to speed up `make local-up`:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# First run: seeds database and creates cache
|
|
166
|
+
make local-up
|
|
167
|
+
|
|
168
|
+
# Subsequent runs: restores from cache if seeds/migrations unchanged
|
|
169
|
+
make local-up
|
|
170
|
+
|
|
171
|
+
# Force full reseed (ignores cache)
|
|
172
|
+
make local-up-seed
|
|
173
|
+
|
|
174
|
+
# Watch mode: auto-reseeds when files change
|
|
175
|
+
make local-up-watch
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**How it works:**
|
|
179
|
+
1. Computes SHA256 hash of `alembic/`, `scripts/seeds/`, `fixtures/` directories
|
|
180
|
+
2. If hash matches cached version, restores database from `pg_dump` cache
|
|
181
|
+
3. If hash differs, runs full migrations + seeds, then saves new cache
|
|
182
|
+
4. Cache stored at `~/.cache/${SERVICE_NAME}/db/seeded.sql.gz`
|
|
183
|
+
|
|
184
|
+
**Configuration:**
|
|
185
|
+
|
|
186
|
+
| Variable | Description | Default |
|
|
187
|
+
| --- | --- | --- |
|
|
188
|
+
| `SERVICE_NAME` | Service name for cache paths | `quickstart` |
|
|
189
|
+
| `CACHE_ROOT` | Base cache directory | `~/.cache/${SERVICE_NAME}` |
|
|
190
|
+
| `FORCE_RESEED` | Force full reseed ignoring cache | `0` |
|
|
191
|
+
| `SKIP_DB_CACHE` | Disable caching entirely | `0` |
|
|
192
|
+
| `CACHE_TARGETS` | Directories to include in hash | `alembic scripts/seeds fixtures` |
|
|
193
|
+
| `LOCAL_WATCH` | Enable watch mode for auto-reseed | `0` |
|
|
81
194
|
|
|
82
195
|
Copy the folder into a service repository when adopting the quickstart so CI/CD, GHCR pulls, backup automation,
|
|
83
196
|
and the shared reverse proxy follow the same playbook used by Ingredient, HTMA, and Sweet Potato. Update the provided
|
|
84
197
|
environment variables (`PROJECT_SLUG`, `DB_SERVICE`, etc.) after copying to match the new service naming.
|
|
85
198
|
|
|
199
|
+
The reverse proxy template adds `resolver 127.0.0.11 ipv6=off valid=30s;` and marks upstream servers with `resolve`
|
|
200
|
+
so nginx re-resolves Docker service names whenever containers cycle. During deployment the helper issues
|
|
201
|
+
`docker exec shared-reverse-proxy nginx -s reload` (falling back to the legacy `./up.sh` script) so configuration
|
|
202
|
+
changes take effect without bouncing the proxy container.
|
|
203
|
+
|
|
204
|
+
When developing locally, start the database with `scripts/dev/start-db.sh` before running `scripts/prepush.sh` or
|
|
205
|
+
pytest. The helper waits for a pgvector-enabled Postgres on port 5433 and seeds `PYTEST_DATABASE_URL`,
|
|
206
|
+
`DATABASE_URL`, and `SYNC_DATABASE_URL` with sensible defaults. Shut it down with `scripts/dev/stop-db.sh`.
|
|
207
|
+
|
|
86
208
|
## RBAC Helpers & Sample Routers
|
|
87
209
|
|
|
88
210
|
- Use `spaps_server_quickstart.rbac.require_roles` as a FastAPI dependency to guard admin/staff-only
|
|
@@ -130,6 +252,7 @@ plumbing. All list-like settings accept comma-separated environment variables fo
|
|
|
130
252
|
|
|
131
253
|
| Variable | Description | Notes |
|
|
132
254
|
| --- | --- | --- |
|
|
255
|
+
| `DEVELOPMENT_ENVIRONMENT` | Set to `local` to enable local auth bypass | Defaults to `None` |
|
|
133
256
|
| `SPAPS_API_URL` | Base URL for SPAPS API requests | Defaults to `https://api.sweetpotato.dev` |
|
|
134
257
|
| `SPAPS_API_KEY` | Service API key used for auth + channel helpers | Required when `spaps_auth_enabled` is true |
|
|
135
258
|
| `SPAPS_APPLICATION_ID` | Application identifier enforced during session validation | Required when `spaps_auth_enabled` is true |
|
|
@@ -28,6 +28,48 @@ poetry run -C packages/python-server-quickstart pytest
|
|
|
28
28
|
The shared modules are designed to be imported by individual service packages. Tests live
|
|
29
29
|
alongside the shared code to guard the common behaviour.
|
|
30
30
|
|
|
31
|
+
### Local Auth Bypass Mode
|
|
32
|
+
|
|
33
|
+
For local development without external auth services, enable local mode by setting
|
|
34
|
+
`DEVELOPMENT_ENVIRONMENT=local`. This provides pre-configured personas (admin/user)
|
|
35
|
+
that bypass SPAPS authentication.
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from spaps_server_quickstart.settings import BaseServiceSettings
|
|
39
|
+
from spaps_server_quickstart.local_mode import (
|
|
40
|
+
LocalAuthMiddleware,
|
|
41
|
+
get_default_registry,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
settings = BaseServiceSettings(development_environment="local")
|
|
45
|
+
|
|
46
|
+
if settings.is_local_development:
|
|
47
|
+
app.add_middleware(LocalAuthMiddleware, registry=get_default_registry())
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Available personas:**
|
|
51
|
+
|
|
52
|
+
| Persona | Token | Roles |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| Admin | `local-admin` | `admin`, `user` |
|
|
55
|
+
| User | `local-user` | `user` |
|
|
56
|
+
|
|
57
|
+
Use the token in your Authorization header: `Authorization: Bearer local-admin`
|
|
58
|
+
|
|
59
|
+
Optional local auth routes are available under `spaps_server_quickstart.templates.domains.auth.local_routes`:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from spaps_server_quickstart.templates.domains.auth.local_routes import router as local_auth_router
|
|
63
|
+
|
|
64
|
+
if settings.is_local_development:
|
|
65
|
+
app.include_router(local_auth_router, prefix="/v1/auth", tags=["local-auth"])
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
This adds:
|
|
69
|
+
- `GET /v1/auth/local-personas` - List available personas
|
|
70
|
+
- `POST /v1/auth/local-login` - Login with persona code or token
|
|
71
|
+
- `GET /v1/auth/local-me` - Get current persona from Authorization header
|
|
72
|
+
|
|
31
73
|
## Operational Templates
|
|
32
74
|
|
|
33
75
|
For infrastructure parity with live SPAPS services, the directory
|
|
@@ -35,15 +77,94 @@ For infrastructure parity with live SPAPS services, the directory
|
|
|
35
77
|
|
|
36
78
|
- Makefile with lint/test/deploy shortcuts
|
|
37
79
|
- Production `.env.production.example`
|
|
38
|
-
- Docker Compose + reverse-proxy stubs
|
|
39
|
-
- Deploy script that
|
|
80
|
+
- Docker Compose + reverse-proxy stubs (pre-configured with Docker DNS resolver support)
|
|
81
|
+
- Deploy script that reloads the shared proxy in-place after each rollout
|
|
82
|
+
- **Pre/post deployment checks** (`pre-deploy-checks.sh`, `post-deploy-verify.sh`)
|
|
40
83
|
- Database maintenance scripts (`backup-db.sh`, `restore-db.sh`, `new-migration.sh`)
|
|
41
84
|
- Pre-push hook + `scripts/prepush.sh` matching live automation
|
|
85
|
+
- Local Postgres helpers under `scripts/dev/` (`start-db.sh`, `stop-db.sh`, `await_db.py`) for pgvector-backed test runs
|
|
86
|
+
|
|
87
|
+
### Deployment Checks
|
|
88
|
+
|
|
89
|
+
The deployment scripts include automated validation:
|
|
90
|
+
|
|
91
|
+
**Pre-deployment (`pre-deploy-checks.sh`):**
|
|
92
|
+
- Docker availability and daemon status
|
|
93
|
+
- Port availability for required services
|
|
94
|
+
- Disk space validation (configurable minimum)
|
|
95
|
+
- Required environment variable validation
|
|
96
|
+
- Dev container conflict detection
|
|
97
|
+
- Docker network verification
|
|
98
|
+
|
|
99
|
+
**Post-deployment (`post-deploy-verify.sh`):**
|
|
100
|
+
- Container running status
|
|
101
|
+
- Health endpoint validation with exponential backoff
|
|
102
|
+
- Image version verification
|
|
103
|
+
- Migration status check (optional)
|
|
104
|
+
- Docker healthcheck status
|
|
105
|
+
- Service connectivity (Redis, database)
|
|
106
|
+
|
|
107
|
+
Configuration via environment variables:
|
|
108
|
+
|
|
109
|
+
| Variable | Description | Default |
|
|
110
|
+
| --- | --- | --- |
|
|
111
|
+
| `SERVICE_NAME` | Service identifier for checks | `quickstart` |
|
|
112
|
+
| `REQUIRED_PORTS` | Comma-separated ports to check | `8000` |
|
|
113
|
+
| `MIN_DISK_SPACE_GB` | Minimum disk space required | `5` |
|
|
114
|
+
| `REQUIRED_ENV_VARS` | Required environment variables | `` |
|
|
115
|
+
| `HEALTH_ENDPOINT` | URL for health check | `http://localhost:8000/health` |
|
|
116
|
+
| `MAX_HEALTH_WAIT` | Max seconds to wait for health | `60` |
|
|
117
|
+
| `SKIP_PRE_CHECKS` | Skip pre-deployment checks | `0` |
|
|
118
|
+
| `SKIP_POST_CHECKS` | Skip post-deployment checks | `0` |
|
|
119
|
+
|
|
120
|
+
### Database Caching for Local Development
|
|
121
|
+
|
|
122
|
+
The `local-debug-loop.sh` script caches seeded database state to speed up `make local-up`:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# First run: seeds database and creates cache
|
|
126
|
+
make local-up
|
|
127
|
+
|
|
128
|
+
# Subsequent runs: restores from cache if seeds/migrations unchanged
|
|
129
|
+
make local-up
|
|
130
|
+
|
|
131
|
+
# Force full reseed (ignores cache)
|
|
132
|
+
make local-up-seed
|
|
133
|
+
|
|
134
|
+
# Watch mode: auto-reseeds when files change
|
|
135
|
+
make local-up-watch
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**How it works:**
|
|
139
|
+
1. Computes SHA256 hash of `alembic/`, `scripts/seeds/`, `fixtures/` directories
|
|
140
|
+
2. If hash matches cached version, restores database from `pg_dump` cache
|
|
141
|
+
3. If hash differs, runs full migrations + seeds, then saves new cache
|
|
142
|
+
4. Cache stored at `~/.cache/${SERVICE_NAME}/db/seeded.sql.gz`
|
|
143
|
+
|
|
144
|
+
**Configuration:**
|
|
145
|
+
|
|
146
|
+
| Variable | Description | Default |
|
|
147
|
+
| --- | --- | --- |
|
|
148
|
+
| `SERVICE_NAME` | Service name for cache paths | `quickstart` |
|
|
149
|
+
| `CACHE_ROOT` | Base cache directory | `~/.cache/${SERVICE_NAME}` |
|
|
150
|
+
| `FORCE_RESEED` | Force full reseed ignoring cache | `0` |
|
|
151
|
+
| `SKIP_DB_CACHE` | Disable caching entirely | `0` |
|
|
152
|
+
| `CACHE_TARGETS` | Directories to include in hash | `alembic scripts/seeds fixtures` |
|
|
153
|
+
| `LOCAL_WATCH` | Enable watch mode for auto-reseed | `0` |
|
|
42
154
|
|
|
43
155
|
Copy the folder into a service repository when adopting the quickstart so CI/CD, GHCR pulls, backup automation,
|
|
44
156
|
and the shared reverse proxy follow the same playbook used by Ingredient, HTMA, and Sweet Potato. Update the provided
|
|
45
157
|
environment variables (`PROJECT_SLUG`, `DB_SERVICE`, etc.) after copying to match the new service naming.
|
|
46
158
|
|
|
159
|
+
The reverse proxy template adds `resolver 127.0.0.11 ipv6=off valid=30s;` and marks upstream servers with `resolve`
|
|
160
|
+
so nginx re-resolves Docker service names whenever containers cycle. During deployment the helper issues
|
|
161
|
+
`docker exec shared-reverse-proxy nginx -s reload` (falling back to the legacy `./up.sh` script) so configuration
|
|
162
|
+
changes take effect without bouncing the proxy container.
|
|
163
|
+
|
|
164
|
+
When developing locally, start the database with `scripts/dev/start-db.sh` before running `scripts/prepush.sh` or
|
|
165
|
+
pytest. The helper waits for a pgvector-enabled Postgres on port 5433 and seeds `PYTEST_DATABASE_URL`,
|
|
166
|
+
`DATABASE_URL`, and `SYNC_DATABASE_URL` with sensible defaults. Shut it down with `scripts/dev/stop-db.sh`.
|
|
167
|
+
|
|
47
168
|
## RBAC Helpers & Sample Routers
|
|
48
169
|
|
|
49
170
|
- Use `spaps_server_quickstart.rbac.require_roles` as a FastAPI dependency to guard admin/staff-only
|
|
@@ -91,6 +212,7 @@ plumbing. All list-like settings accept comma-separated environment variables fo
|
|
|
91
212
|
|
|
92
213
|
| Variable | Description | Notes |
|
|
93
214
|
| --- | --- | --- |
|
|
215
|
+
| `DEVELOPMENT_ENVIRONMENT` | Set to `local` to enable local auth bypass | Defaults to `None` |
|
|
94
216
|
| `SPAPS_API_URL` | Base URL for SPAPS API requests | Defaults to `https://api.sweetpotato.dev` |
|
|
95
217
|
| `SPAPS_API_KEY` | Service API key used for auth + channel helpers | Required when `spaps_auth_enabled` is true |
|
|
96
218
|
| `SPAPS_APPLICATION_ID` | Application identifier enforced during session validation | Required when `spaps_auth_enabled` is true |
|