shaapi 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.
- shaapi-0.1.0/.gitignore +170 -0
- shaapi-0.1.0/LICENCE +21 -0
- shaapi-0.1.0/PKG-INFO +92 -0
- shaapi-0.1.0/README.md +73 -0
- shaapi-0.1.0/docs/README.md +30 -0
- shaapi-0.1.0/examples/todolist/README.md +92 -0
- shaapi-0.1.0/pyproject.toml +38 -0
- shaapi-0.1.0/src/shaapi/__init__.py +3 -0
- shaapi-0.1.0/src/shaapi/cli.py +97 -0
- shaapi-0.1.0/src/shaapi/generator.py +114 -0
- shaapi-0.1.0/src/shaapi/template/.dockerignore +37 -0
- shaapi-0.1.0/src/shaapi/template/.env.template +59 -0
- shaapi-0.1.0/src/shaapi/template/.gitattributes +12 -0
- shaapi-0.1.0/src/shaapi/template/.gitignore +170 -0
- shaapi-0.1.0/src/shaapi/template/.gitlab-ci.yml +89 -0
- shaapi-0.1.0/src/shaapi/template/Dockerfile +59 -0
- shaapi-0.1.0/src/shaapi/template/LICENSE +21 -0
- shaapi-0.1.0/src/shaapi/template/README.md +206 -0
- shaapi-0.1.0/src/shaapi/template/backend/.gitignore +164 -0
- shaapi-0.1.0/src/shaapi/template/backend/__init__.py +0 -0
- shaapi-0.1.0/src/shaapi/template/backend/alembic/README +1 -0
- shaapi-0.1.0/src/shaapi/template/backend/alembic/env.py +102 -0
- shaapi-0.1.0/src/shaapi/template/backend/alembic/script.py.mako +26 -0
- shaapi-0.1.0/src/shaapi/template/backend/alembic/versions/2026_06_08_1024-64524c63b666_initial.py +143 -0
- shaapi-0.1.0/src/shaapi/template/backend/alembic.ini +117 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/__init__.py +55 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/__init__.py +1 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/api/v1/__init__.py +0 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/api/v1/auth.py +59 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/api/v1/casbin.py +218 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/api/v1/login_log.py +63 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/api/v1/opera_log.py +61 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/api/v1/role.py +108 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/api/v1/user.py +47 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/schema/casbin_rule.py +45 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/schema/login_log.py +36 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/schema/opera_log.py +43 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/schema/role.py +36 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/schema/sso.py +37 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/schema/token.py +74 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/schema/user.py +93 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/service/auth_service.py +233 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/service/casbin_service.py +135 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/service/login_log_service.py +62 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/service/opera_log_service.py +31 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/service/role_service.py +79 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/service/secure_token_service.py +60 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/admin/service/user_service.py +153 -0
- shaapi-0.1.0/src/shaapi/template/backend/app/api.py +11 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/__init__.py +0 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/cloud_storage/__init__.py +11 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/cloud_storage/cloud_storage.py +180 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/dataclasses.py +52 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/email_conf/email.py +105 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/enums.py +144 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/exception/__init__.py +0 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/exception/errors.py +87 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/exception/exception_handler.py +280 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/log.py +123 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/model.py +68 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/pagination.py +83 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/response/__init__.py +0 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/response/response_code.py +158 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/response/response_schema.py +110 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/schema.py +144 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/security/jwt.py +203 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/security/rbac.py +98 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/security/sec_token.py +6 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/socketio/action.py +11 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/socketio/server.py +50 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/sso/base.py +69 -0
- shaapi-0.1.0/src/shaapi/template/backend/common/sso/google.py +127 -0
- shaapi-0.1.0/src/shaapi/template/backend/core/conf.py +208 -0
- shaapi-0.1.0/src/shaapi/template/backend/core/path_conf.py +24 -0
- shaapi-0.1.0/src/shaapi/template/backend/core/registrar.py +195 -0
- shaapi-0.1.0/src/shaapi/template/backend/crud/__init__.py +1 -0
- shaapi-0.1.0/src/shaapi/template/backend/crud/crud_base.py +35 -0
- shaapi-0.1.0/src/shaapi/template/backend/crud/crud_casbin.py +46 -0
- shaapi-0.1.0/src/shaapi/template/backend/crud/crud_login_log.py +58 -0
- shaapi-0.1.0/src/shaapi/template/backend/crud/crud_opera_log.py +58 -0
- shaapi-0.1.0/src/shaapi/template/backend/crud/crud_role.py +128 -0
- shaapi-0.1.0/src/shaapi/template/backend/crud/crud_user.py +267 -0
- shaapi-0.1.0/src/shaapi/template/backend/database/__init__.py +0 -0
- shaapi-0.1.0/src/shaapi/template/backend/database/db_postgres.py +125 -0
- shaapi-0.1.0/src/shaapi/template/backend/database/db_redis.py +62 -0
- shaapi-0.1.0/src/shaapi/template/backend/entrypoint-api.sh +19 -0
- shaapi-0.1.0/src/shaapi/template/backend/lang/en/app.py +18 -0
- shaapi-0.1.0/src/shaapi/template/backend/lang/en/auth.py +10 -0
- shaapi-0.1.0/src/shaapi/template/backend/lang/fr/app.py +18 -0
- shaapi-0.1.0/src/shaapi/template/backend/lang/fr/auth.py +10 -0
- shaapi-0.1.0/src/shaapi/template/backend/main.py +54 -0
- shaapi-0.1.0/src/shaapi/template/backend/middleware/__init__.py +1 -0
- shaapi-0.1.0/src/shaapi/template/backend/middleware/access_middleware.py +19 -0
- shaapi-0.1.0/src/shaapi/template/backend/middleware/i18n_middleware.py +19 -0
- shaapi-0.1.0/src/shaapi/template/backend/middleware/jwt_auth_middleware.py +73 -0
- shaapi-0.1.0/src/shaapi/template/backend/middleware/opera_log_middleware.py +179 -0
- shaapi-0.1.0/src/shaapi/template/backend/middleware/state_middleware.py +26 -0
- shaapi-0.1.0/src/shaapi/template/backend/models/__init__.py +10 -0
- shaapi-0.1.0/src/shaapi/template/backend/models/associations.py +20 -0
- shaapi-0.1.0/src/shaapi/template/backend/models/casbin_rule.py +30 -0
- shaapi-0.1.0/src/shaapi/template/backend/models/login_log.py +28 -0
- shaapi-0.1.0/src/shaapi/template/backend/models/opera_log.py +36 -0
- shaapi-0.1.0/src/shaapi/template/backend/models/role.py +27 -0
- shaapi-0.1.0/src/shaapi/template/backend/models/user.py +30 -0
- shaapi-0.1.0/src/shaapi/template/backend/seeder/json/admin.json +15 -0
- shaapi-0.1.0/src/shaapi/template/backend/seeder/json/user.json +15 -0
- shaapi-0.1.0/src/shaapi/template/backend/seeder/run.py +34 -0
- shaapi-0.1.0/src/shaapi/template/backend/static/ip2region.xdb +0 -0
- shaapi-0.1.0/src/shaapi/template/backend/templates/build/meet.html +169 -0
- shaapi-0.1.0/src/shaapi/template/backend/templates/build/new_account.html +373 -0
- shaapi-0.1.0/src/shaapi/template/backend/templates/build/reset-password.html +170 -0
- shaapi-0.1.0/src/shaapi/template/backend/templates/build/test_email.html +25 -0
- shaapi-0.1.0/src/shaapi/template/backend/templates/build/welcome-one-1.html +160 -0
- shaapi-0.1.0/src/shaapi/template/backend/templates/build/welcome-one.html +178 -0
- shaapi-0.1.0/src/shaapi/template/backend/templates/build/welcome-two.html +234 -0
- shaapi-0.1.0/src/shaapi/template/backend/templates/index.html +0 -0
- shaapi-0.1.0/src/shaapi/template/backend/templates/src/new_account.mjml +15 -0
- shaapi-0.1.0/src/shaapi/template/backend/templates/src/reset_password.mjml +19 -0
- shaapi-0.1.0/src/shaapi/template/backend/templates/src/test_email.mjml +11 -0
- shaapi-0.1.0/src/shaapi/template/backend/templates/ws/ws.html +70 -0
- shaapi-0.1.0/src/shaapi/template/backend/utils/demo_site.py +18 -0
- shaapi-0.1.0/src/shaapi/template/backend/utils/encrypt.py +108 -0
- shaapi-0.1.0/src/shaapi/template/backend/utils/health_check.py +34 -0
- shaapi-0.1.0/src/shaapi/template/backend/utils/prometheus.py +135 -0
- shaapi-0.1.0/src/shaapi/template/backend/utils/request_parse.py +110 -0
- shaapi-0.1.0/src/shaapi/template/backend/utils/serializers.py +75 -0
- shaapi-0.1.0/src/shaapi/template/backend/utils/timezone.py +51 -0
- shaapi-0.1.0/src/shaapi/template/backend/utils/trace_id.py +7 -0
- shaapi-0.1.0/src/shaapi/template/backend/utils/translator.py +28 -0
- shaapi-0.1.0/src/shaapi/template/devops/scripts/deploy.sh +7 -0
- shaapi-0.1.0/src/shaapi/template/devops/scripts/setup_env.sh +62 -0
- shaapi-0.1.0/src/shaapi/template/docker-compose.monitoring.yml +63 -0
- shaapi-0.1.0/src/shaapi/template/docker-compose.override.yml +12 -0
- shaapi-0.1.0/src/shaapi/template/docker-compose.yml +90 -0
- shaapi-0.1.0/src/shaapi/template/docker-run.sh +99 -0
- shaapi-0.1.0/src/shaapi/template/etc/dashboards/fastapi-observability.json +1044 -0
- shaapi-0.1.0/src/shaapi/template/etc/dashboards.yaml +10 -0
- shaapi-0.1.0/src/shaapi/template/etc/grafana/datasource.yml +79 -0
- shaapi-0.1.0/src/shaapi/template/etc/prometheus/prometheus.yml +52 -0
- shaapi-0.1.0/src/shaapi/template/package-lock.json +2102 -0
- shaapi-0.1.0/src/shaapi/template/package.json +16 -0
- shaapi-0.1.0/src/shaapi/template/pyproject.toml +78 -0
- shaapi-0.1.0/src/shaapi/template/uv.lock +2866 -0
shaapi-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
.env.elastic
|
|
9
|
+
|
|
10
|
+
# Distribution / packaging
|
|
11
|
+
.Python
|
|
12
|
+
# build/
|
|
13
|
+
develop-eggs/
|
|
14
|
+
dist/
|
|
15
|
+
downloads/
|
|
16
|
+
/node_modules
|
|
17
|
+
eggs/
|
|
18
|
+
.eggs/
|
|
19
|
+
lib/
|
|
20
|
+
lib64/
|
|
21
|
+
parts/
|
|
22
|
+
sdist/
|
|
23
|
+
var/
|
|
24
|
+
wheels/
|
|
25
|
+
share/python-wheels/
|
|
26
|
+
*.egg-info/
|
|
27
|
+
.installed.cfg
|
|
28
|
+
*.egg
|
|
29
|
+
MANIFEST
|
|
30
|
+
|
|
31
|
+
# private_key.pem
|
|
32
|
+
# public_key.pem
|
|
33
|
+
|
|
34
|
+
# PyInstaller
|
|
35
|
+
# Usually these files are written by a python script from a template
|
|
36
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
37
|
+
*.manifest
|
|
38
|
+
*.spec
|
|
39
|
+
|
|
40
|
+
# Installer logs
|
|
41
|
+
pip-log.txt
|
|
42
|
+
pip-delete-this-directory.txt
|
|
43
|
+
|
|
44
|
+
# Unit test / coverage reports
|
|
45
|
+
htmlcov/
|
|
46
|
+
.tox/
|
|
47
|
+
.nox/
|
|
48
|
+
.coverage
|
|
49
|
+
.coverage.*
|
|
50
|
+
.cache
|
|
51
|
+
nosetests.xml
|
|
52
|
+
coverage.xml
|
|
53
|
+
*.cover
|
|
54
|
+
*.py,cover
|
|
55
|
+
.hypothesis/
|
|
56
|
+
.pytest_cache/
|
|
57
|
+
cover/
|
|
58
|
+
|
|
59
|
+
# Translations
|
|
60
|
+
*.mo
|
|
61
|
+
*.pot
|
|
62
|
+
|
|
63
|
+
# Django stuff:
|
|
64
|
+
*.log
|
|
65
|
+
local_settings.py
|
|
66
|
+
db.sqlite3
|
|
67
|
+
db.sqlite3-journal
|
|
68
|
+
|
|
69
|
+
# Flask stuff:
|
|
70
|
+
instance/
|
|
71
|
+
.webassets-cache
|
|
72
|
+
|
|
73
|
+
# Scrapy stuff:
|
|
74
|
+
.scrapy
|
|
75
|
+
|
|
76
|
+
# Sphinx documentation
|
|
77
|
+
docs/_build/
|
|
78
|
+
|
|
79
|
+
# PyBuilder
|
|
80
|
+
.pybuilder/
|
|
81
|
+
target/
|
|
82
|
+
|
|
83
|
+
# Jupyter Notebook
|
|
84
|
+
.ipynb_checkpoints
|
|
85
|
+
|
|
86
|
+
# IPython
|
|
87
|
+
profile_default/
|
|
88
|
+
ipython_config.py
|
|
89
|
+
|
|
90
|
+
# pyenv
|
|
91
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
92
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
93
|
+
# .python-version
|
|
94
|
+
|
|
95
|
+
# pipenv
|
|
96
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
97
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
98
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
99
|
+
# install all needed dependencies.
|
|
100
|
+
#Pipfile.lock
|
|
101
|
+
|
|
102
|
+
# poetry
|
|
103
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
104
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
105
|
+
# commonly ignored for libraries.
|
|
106
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
107
|
+
#poetry.lock
|
|
108
|
+
|
|
109
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
110
|
+
__pypackages__/
|
|
111
|
+
|
|
112
|
+
# Celery stuff
|
|
113
|
+
celerybeat-schedule
|
|
114
|
+
celerybeat.pid
|
|
115
|
+
|
|
116
|
+
# SageMath parsed files
|
|
117
|
+
*.sage.py
|
|
118
|
+
|
|
119
|
+
# Environments
|
|
120
|
+
.env
|
|
121
|
+
.env.elastic
|
|
122
|
+
.venv
|
|
123
|
+
env/
|
|
124
|
+
venv/
|
|
125
|
+
ENV/
|
|
126
|
+
env.bak/
|
|
127
|
+
venv.bak/
|
|
128
|
+
fastapi-boilerplate-venv/
|
|
129
|
+
|
|
130
|
+
# Spyder project settings
|
|
131
|
+
.spyderproject
|
|
132
|
+
.spyproject
|
|
133
|
+
|
|
134
|
+
# Rope project settings
|
|
135
|
+
.ropeproject
|
|
136
|
+
|
|
137
|
+
# mkdocs documentation
|
|
138
|
+
/site
|
|
139
|
+
|
|
140
|
+
# mypy
|
|
141
|
+
.mypy_cache/
|
|
142
|
+
.dmypy.json
|
|
143
|
+
dmypy.json
|
|
144
|
+
|
|
145
|
+
# Pyre type checker
|
|
146
|
+
.pyre/
|
|
147
|
+
|
|
148
|
+
# pytype static type analyzer
|
|
149
|
+
.pytype/
|
|
150
|
+
|
|
151
|
+
# Cython debug symbols
|
|
152
|
+
cython_debug/
|
|
153
|
+
/boilerplate-venv
|
|
154
|
+
|
|
155
|
+
# PyCharm
|
|
156
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
157
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
158
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
159
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
160
|
+
#.idea/
|
|
161
|
+
.history/
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
changelog.config.js
|
|
165
|
+
|
|
166
|
+
# macOS
|
|
167
|
+
.DS_Store
|
|
168
|
+
|
|
169
|
+
# uv (commit uv.lock for reproducibility)
|
|
170
|
+
.venv/
|
shaapi-0.1.0/LICENCE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Shalom Tehe
|
|
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.
|
shaapi-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: shaapi
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Scaffold lean, batteries-included FastAPI backends — like django-admin, for FastAPI.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Shalom-302/shaapi
|
|
6
|
+
Project-URL: Repository, https://github.com/Shalom-302/shaapi
|
|
7
|
+
Author-email: Shalom <shalomtehe219@gmail.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENCE
|
|
10
|
+
Keywords: backend,boilerplate,cli,fastapi,scaffold,starter
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Framework :: FastAPI
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Requires-Dist: rich>=13
|
|
17
|
+
Requires-Dist: typer>=0.12
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# shaapi
|
|
21
|
+
|
|
22
|
+
**Scaffold lean, batteries-included FastAPI backends — like `django-admin`, for FastAPI.**
|
|
23
|
+
|
|
24
|
+
Beginners shouldn't have to architect a production backend from scratch. `shaapi`
|
|
25
|
+
gives you a clean, opinionated FastAPI project — async SQLAlchemy + Alembic,
|
|
26
|
+
Postgres, Redis, JWT auth, Casbin RBAC, file storage, and a one-command Docker
|
|
27
|
+
workflow — generated in seconds.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install shaapi
|
|
31
|
+
shaapi create-project "my api"
|
|
32
|
+
cd my_api
|
|
33
|
+
./docker-run.sh up
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
→ API live at `http://localhost:8000`, Swagger at `http://localhost:8000/admin/api/v1/docs`.
|
|
37
|
+
|
|
38
|
+
## What you get
|
|
39
|
+
|
|
40
|
+
- **FastAPI** (async) with a clean layered architecture (`app/`, `common/`, `core/`, `crud/`, `models/`, `schemas/`)
|
|
41
|
+
- **SQLAlchemy 2 + Alembic** migrations, **Postgres** (auto-create in dev, migrations in prod)
|
|
42
|
+
- **Redis** cache + rate limiting
|
|
43
|
+
- **JWT auth** + **Casbin RBAC** (users, roles, permissions)
|
|
44
|
+
- **File storage** (MinIO / S3 / GCS)
|
|
45
|
+
- **Docker**: multi-stage slim image built with [uv], hot-reload in dev (source bind-mount), `docker-run.sh` orchestration
|
|
46
|
+
- **Opt-in observability** (`--monitoring`): Prometheus, Grafana, Tempo, Loki
|
|
47
|
+
|
|
48
|
+
## CLI
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
shaapi create-project "my api" # interactive
|
|
52
|
+
shaapi create-project "my api" -y # accept defaults
|
|
53
|
+
shaapi create-project "my api" --monitoring --no-git
|
|
54
|
+
shaapi --version
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## In your generated project
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
./docker-run.sh up # build + start everything (dev: hot-reload)
|
|
61
|
+
./docker-run.sh up --monitoring
|
|
62
|
+
./docker-run.sh logs # tail logs
|
|
63
|
+
./docker-run.sh migrate # alembic upgrade head
|
|
64
|
+
./docker-run.sh makemigrations "add posts table"
|
|
65
|
+
./docker-run.sh down
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Documentation
|
|
69
|
+
|
|
70
|
+
Full docs in **English** and **French** under [`docs/`](docs/):
|
|
71
|
+
|
|
72
|
+
| | English | Français |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| Getting started | [getting-started](docs/en/getting-started.md) | [démarrage](docs/fr/demarrage.md) |
|
|
75
|
+
| Architecture | [architecture](docs/en/architecture.md) | [architecture](docs/fr/architecture.md) |
|
|
76
|
+
| Create a feature | [create-a-feature](docs/en/create-a-feature.md) | [créer une fonctionnalité](docs/fr/creer-une-fonctionnalite.md) |
|
|
77
|
+
| Deployment | [deployment](docs/en/deployment.md) | [déploiement](docs/fr/deploiement.md) |
|
|
78
|
+
|
|
79
|
+
## Example
|
|
80
|
+
|
|
81
|
+
[`examples/todolist`](examples/todolist) — a complete authenticated Todo API
|
|
82
|
+
(JWT, per-user ownership, admin-only endpoint) built on top of shaapi in 5 files.
|
|
83
|
+
|
|
84
|
+
## Status
|
|
85
|
+
|
|
86
|
+
Alpha. See the repo for roadmap and contribution guidelines.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
|
91
|
+
|
|
92
|
+
[uv]: https://github.com/astral-sh/uv
|
shaapi-0.1.0/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# shaapi
|
|
2
|
+
|
|
3
|
+
**Scaffold lean, batteries-included FastAPI backends — like `django-admin`, for FastAPI.**
|
|
4
|
+
|
|
5
|
+
Beginners shouldn't have to architect a production backend from scratch. `shaapi`
|
|
6
|
+
gives you a clean, opinionated FastAPI project — async SQLAlchemy + Alembic,
|
|
7
|
+
Postgres, Redis, JWT auth, Casbin RBAC, file storage, and a one-command Docker
|
|
8
|
+
workflow — generated in seconds.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install shaapi
|
|
12
|
+
shaapi create-project "my api"
|
|
13
|
+
cd my_api
|
|
14
|
+
./docker-run.sh up
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
→ API live at `http://localhost:8000`, Swagger at `http://localhost:8000/admin/api/v1/docs`.
|
|
18
|
+
|
|
19
|
+
## What you get
|
|
20
|
+
|
|
21
|
+
- **FastAPI** (async) with a clean layered architecture (`app/`, `common/`, `core/`, `crud/`, `models/`, `schemas/`)
|
|
22
|
+
- **SQLAlchemy 2 + Alembic** migrations, **Postgres** (auto-create in dev, migrations in prod)
|
|
23
|
+
- **Redis** cache + rate limiting
|
|
24
|
+
- **JWT auth** + **Casbin RBAC** (users, roles, permissions)
|
|
25
|
+
- **File storage** (MinIO / S3 / GCS)
|
|
26
|
+
- **Docker**: multi-stage slim image built with [uv], hot-reload in dev (source bind-mount), `docker-run.sh` orchestration
|
|
27
|
+
- **Opt-in observability** (`--monitoring`): Prometheus, Grafana, Tempo, Loki
|
|
28
|
+
|
|
29
|
+
## CLI
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
shaapi create-project "my api" # interactive
|
|
33
|
+
shaapi create-project "my api" -y # accept defaults
|
|
34
|
+
shaapi create-project "my api" --monitoring --no-git
|
|
35
|
+
shaapi --version
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## In your generated project
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
./docker-run.sh up # build + start everything (dev: hot-reload)
|
|
42
|
+
./docker-run.sh up --monitoring
|
|
43
|
+
./docker-run.sh logs # tail logs
|
|
44
|
+
./docker-run.sh migrate # alembic upgrade head
|
|
45
|
+
./docker-run.sh makemigrations "add posts table"
|
|
46
|
+
./docker-run.sh down
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Documentation
|
|
50
|
+
|
|
51
|
+
Full docs in **English** and **French** under [`docs/`](docs/):
|
|
52
|
+
|
|
53
|
+
| | English | Français |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| Getting started | [getting-started](docs/en/getting-started.md) | [démarrage](docs/fr/demarrage.md) |
|
|
56
|
+
| Architecture | [architecture](docs/en/architecture.md) | [architecture](docs/fr/architecture.md) |
|
|
57
|
+
| Create a feature | [create-a-feature](docs/en/create-a-feature.md) | [créer une fonctionnalité](docs/fr/creer-une-fonctionnalite.md) |
|
|
58
|
+
| Deployment | [deployment](docs/en/deployment.md) | [déploiement](docs/fr/deploiement.md) |
|
|
59
|
+
|
|
60
|
+
## Example
|
|
61
|
+
|
|
62
|
+
[`examples/todolist`](examples/todolist) — a complete authenticated Todo API
|
|
63
|
+
(JWT, per-user ownership, admin-only endpoint) built on top of shaapi in 5 files.
|
|
64
|
+
|
|
65
|
+
## Status
|
|
66
|
+
|
|
67
|
+
Alpha. See the repo for roadmap and contribution guidelines.
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
MIT
|
|
72
|
+
|
|
73
|
+
[uv]: https://github.com/astral-sh/uv
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# shaapi documentation
|
|
2
|
+
|
|
3
|
+
**Scaffold lean, batteries-included FastAPI backends — like `django-admin`, for FastAPI.**
|
|
4
|
+
|
|
5
|
+
Choose your language / Choisissez votre langue :
|
|
6
|
+
|
|
7
|
+
### 🇬🇧 English
|
|
8
|
+
- [Getting started](en/getting-started.md)
|
|
9
|
+
- [Architecture](en/architecture.md)
|
|
10
|
+
- [Create a feature (Todo tutorial)](en/create-a-feature.md)
|
|
11
|
+
- [Deployment](en/deployment.md)
|
|
12
|
+
|
|
13
|
+
### 🇫🇷 Français
|
|
14
|
+
- [Démarrage rapide](fr/demarrage.md)
|
|
15
|
+
- [Architecture](fr/architecture.md)
|
|
16
|
+
- [Créer une fonctionnalité (tutoriel Todo)](fr/creer-une-fonctionnalite.md)
|
|
17
|
+
- [Déploiement](fr/deploiement.md)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## TL;DR
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install shaapi
|
|
25
|
+
shaapi create-project "my api"
|
|
26
|
+
cd my_api
|
|
27
|
+
./docker-run.sh up
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
API → `http://localhost:8000` · Swagger → `http://localhost:8000/admin/api/v1/docs`
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Example: a Todo API with auth (admin + user)
|
|
2
|
+
|
|
3
|
+
This example shows how little it takes to build a real, authenticated feature on
|
|
4
|
+
top of a shaapi project: a per-user todo list with ownership rules and an
|
|
5
|
+
admin-only "see everything" endpoint.
|
|
6
|
+
|
|
7
|
+
*Cet exemple montre à quel point il est simple de bâtir une vraie fonctionnalité
|
|
8
|
+
authentifiée sur shaapi : une todolist par utilisateur, avec règles de propriété
|
|
9
|
+
et un endpoint réservé aux admins.*
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## What it demonstrates / Ce que ça démontre
|
|
14
|
+
|
|
15
|
+
- **JWT auth** — register / login, protected routes (`DependsJwtAuth`)
|
|
16
|
+
- **Per-user data** — each user only sees and edits their own todos
|
|
17
|
+
- **Ownership enforcement** — accessing someone else's todo returns `403`
|
|
18
|
+
- **Role-based access** — only users with the `admin` role can `GET /todo/all`
|
|
19
|
+
|
|
20
|
+
All of it on **FastAPI + async SQLAlchemy + Pydantic v2**, with zero extra
|
|
21
|
+
plumbing — shaapi already provides the auth, DB session, RBAC and response layer.
|
|
22
|
+
|
|
23
|
+
## The whole feature = 5 files + 1 line
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
backend/
|
|
27
|
+
├── models/todo.py # SQLAlchemy model
|
|
28
|
+
├── app/admin/schema/todo.py # Pydantic schemas
|
|
29
|
+
├── crud/crud_todo.py # data access (CRUDBase)
|
|
30
|
+
├── app/admin/service/todo_service.py # business logic
|
|
31
|
+
└── app/admin/api/v1/todo.py # router (auto-discovered)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The router is **auto-discovered** — dropping `todo.py` into `app/admin/api/v1/`
|
|
35
|
+
is enough to expose its endpoints. No central registry to edit.
|
|
36
|
+
|
|
37
|
+
## Install into a shaapi project / Installer dans un projet shaapi
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# 1. Create a project
|
|
41
|
+
pip install shaapi
|
|
42
|
+
shaapi create-project "todoapp"
|
|
43
|
+
|
|
44
|
+
# 2. Copy this feature on top of it
|
|
45
|
+
cp -r examples/todolist/backend/. todoapp/backend/
|
|
46
|
+
|
|
47
|
+
# 3. Register the model (one line) in todoapp/backend/models/__init__.py
|
|
48
|
+
# from backend.models.todo import Todo
|
|
49
|
+
|
|
50
|
+
# 4. Run
|
|
51
|
+
cd todoapp
|
|
52
|
+
./docker-run.sh up
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
In development the table is auto-created on startup. For production, generate a
|
|
56
|
+
migration: `./docker-run.sh makemigrations "add todo table"`.
|
|
57
|
+
|
|
58
|
+
## Endpoints
|
|
59
|
+
|
|
60
|
+
| Method | Path | Who | Description |
|
|
61
|
+
|--------|------------------------------|----------------|-----------------------------|
|
|
62
|
+
| POST | `/admin/api/v1/auth/register`| public | Create an account |
|
|
63
|
+
| POST | `/admin/api/v1/auth/login` | public | Get an access token |
|
|
64
|
+
| POST | `/admin/api/v1/todo/` | any user | Create a todo |
|
|
65
|
+
| GET | `/admin/api/v1/todo/` | any user | List **my** todos (paged) |
|
|
66
|
+
| GET | `/admin/api/v1/todo/{id}` | owner/admin | Get one todo |
|
|
67
|
+
| PUT | `/admin/api/v1/todo/{id}` | owner/admin | Update a todo |
|
|
68
|
+
| DELETE | `/admin/api/v1/todo/{id}` | owner/admin | Delete a todo |
|
|
69
|
+
| GET | `/admin/api/v1/todo/all` | **admin only** | List every user's todos |
|
|
70
|
+
|
|
71
|
+
Authenticated calls send `Authorization: Bearer <access_token>`.
|
|
72
|
+
|
|
73
|
+
## Make a user an admin / Donner le rôle admin
|
|
74
|
+
|
|
75
|
+
```sql
|
|
76
|
+
INSERT INTO role (x_id, name, status, remark, created_time)
|
|
77
|
+
VALUES ('admin0000000000000000000001', 'admin', 1, '', now());
|
|
78
|
+
INSERT INTO user_role (user_id, role_id)
|
|
79
|
+
SELECT <USER_ID>, id FROM role WHERE name = 'admin';
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Reproduce the proof / Reproduire la preuve
|
|
83
|
+
|
|
84
|
+
With the stack running, from the repo root:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
python examples/todolist/smoke_test.py
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Expected output: registration, per-user CRUD, a `403` when a user touches
|
|
91
|
+
another user's todo, a `403` on `/todo/all` for a normal user, and `200` once
|
|
92
|
+
the user is granted the `admin` role.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "shaapi"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Scaffold lean, batteries-included FastAPI backends — like django-admin, for FastAPI."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
license = { text = "MIT" }
|
|
8
|
+
authors = [{ name = "Shalom", email = "shalomtehe219@gmail.com" }]
|
|
9
|
+
keywords = ["fastapi", "boilerplate", "scaffold", "backend", "starter", "cli"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 3 - Alpha",
|
|
12
|
+
"Framework :: FastAPI",
|
|
13
|
+
"Programming Language :: Python :: 3.11",
|
|
14
|
+
"License :: OSI Approved :: MIT License",
|
|
15
|
+
]
|
|
16
|
+
dependencies = [
|
|
17
|
+
"typer>=0.12",
|
|
18
|
+
"rich>=13",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/Shalom-302/shaapi"
|
|
23
|
+
Repository = "https://github.com/Shalom-302/shaapi"
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
shaapi = "shaapi.cli:app"
|
|
27
|
+
|
|
28
|
+
[build-system]
|
|
29
|
+
requires = ["hatchling"]
|
|
30
|
+
build-backend = "hatchling.build"
|
|
31
|
+
|
|
32
|
+
# packages=["src/shaapi"] already bundles the whole template (incl. non-python
|
|
33
|
+
# files and dotfiles), so no force-include is needed.
|
|
34
|
+
[tool.hatch.build.targets.wheel]
|
|
35
|
+
packages = ["src/shaapi"]
|
|
36
|
+
|
|
37
|
+
[tool.hatch.build.targets.sdist]
|
|
38
|
+
include = ["src/shaapi", "README.md", "LICENCE"]
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""shaapi command-line interface."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Optional
|
|
7
|
+
|
|
8
|
+
import typer
|
|
9
|
+
from rich.console import Console
|
|
10
|
+
from rich.panel import Panel
|
|
11
|
+
|
|
12
|
+
from shaapi import __version__
|
|
13
|
+
from shaapi.generator import create_project, slugify
|
|
14
|
+
|
|
15
|
+
# Make output robust on Windows consoles (cp1252) and when piped.
|
|
16
|
+
for _stream in (sys.stdout, sys.stderr):
|
|
17
|
+
try:
|
|
18
|
+
_stream.reconfigure(encoding="utf-8") # type: ignore[union-attr]
|
|
19
|
+
except (AttributeError, ValueError):
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
app = typer.Typer(
|
|
23
|
+
add_completion=False,
|
|
24
|
+
no_args_is_help=True,
|
|
25
|
+
help="shaapi - scaffold lean, batteries-included FastAPI backends.",
|
|
26
|
+
)
|
|
27
|
+
console = Console()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@app.command("create-project")
|
|
31
|
+
def create_project_command(
|
|
32
|
+
name: str = typer.Argument(..., help='Project name, e.g. "my api".'),
|
|
33
|
+
path: Path = typer.Option(Path("."), "--path", "-p", help="Where to create the project."),
|
|
34
|
+
monitoring: Optional[bool] = typer.Option(
|
|
35
|
+
None, "--monitoring/--no-monitoring", help="Include the Prometheus/Grafana stack."
|
|
36
|
+
),
|
|
37
|
+
git: Optional[bool] = typer.Option(
|
|
38
|
+
None, "--git/--no-git", help="Initialize a git repository."
|
|
39
|
+
),
|
|
40
|
+
yes: bool = typer.Option(False, "--yes", "-y", help="Accept defaults, skip prompts."),
|
|
41
|
+
):
|
|
42
|
+
"""Create a new shaapi project."""
|
|
43
|
+
slug = slugify(name)
|
|
44
|
+
console.print(f"\n[bold cyan]shaapi[/] creating project [bold]{slug}[/]\n")
|
|
45
|
+
|
|
46
|
+
if monitoring is None:
|
|
47
|
+
monitoring = (
|
|
48
|
+
False if yes
|
|
49
|
+
else typer.confirm("Include monitoring (Prometheus/Grafana/Tempo/Loki)?", default=False)
|
|
50
|
+
)
|
|
51
|
+
if git is None:
|
|
52
|
+
git = True if yes else typer.confirm("Initialize a git repository?", default=True)
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
dest = create_project(name, path, monitoring=monitoring, git_init=git)
|
|
56
|
+
except (FileExistsError, ValueError, RuntimeError) as exc:
|
|
57
|
+
console.print(f"[bold red]Error:[/] {exc}")
|
|
58
|
+
raise typer.Exit(code=1)
|
|
59
|
+
|
|
60
|
+
up_cmd = "./docker-run.sh up" + (" --monitoring" if monitoring else "")
|
|
61
|
+
console.print(
|
|
62
|
+
Panel.fit(
|
|
63
|
+
f"[green][OK][/] Project created at [bold]{dest}[/]\n\n"
|
|
64
|
+
f"[bold]Next steps[/]\n"
|
|
65
|
+
f" cd {dest.name}\n"
|
|
66
|
+
f" {up_cmd}\n\n"
|
|
67
|
+
f"Then open [cyan]http://localhost:8000/admin/api/v1/docs[/]",
|
|
68
|
+
title="Done",
|
|
69
|
+
border_style="cyan",
|
|
70
|
+
)
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _version_callback(value: bool) -> None:
|
|
75
|
+
if value:
|
|
76
|
+
console.print(f"shaapi {__version__}")
|
|
77
|
+
raise typer.Exit()
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@app.command()
|
|
81
|
+
def version() -> None:
|
|
82
|
+
"""Show the shaapi version."""
|
|
83
|
+
console.print(f"shaapi {__version__}")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@app.callback()
|
|
87
|
+
def main(
|
|
88
|
+
_version: Optional[bool] = typer.Option(
|
|
89
|
+
None, "--version", "-V", callback=_version_callback, is_eager=True,
|
|
90
|
+
help="Show the version and exit.",
|
|
91
|
+
),
|
|
92
|
+
) -> None:
|
|
93
|
+
"""shaapi CLI."""
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
if __name__ == "__main__":
|
|
97
|
+
app()
|