@cubocicloide/stack-react-fastapi 13.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/LICENSE +33 -0
  2. package/README.md +66 -0
  3. package/dist/commands/lint/checks/BE/001.d.ts +6 -0
  4. package/dist/commands/lint/checks/BE/001.js +95 -0
  5. package/dist/commands/lint/checks/BE/001.js.map +1 -0
  6. package/dist/commands/lint/checks/BE/002.d.ts +6 -0
  7. package/dist/commands/lint/checks/BE/002.js +30 -0
  8. package/dist/commands/lint/checks/BE/002.js.map +1 -0
  9. package/dist/commands/lint/checks/BE/003.d.ts +11 -0
  10. package/dist/commands/lint/checks/BE/003.js +46 -0
  11. package/dist/commands/lint/checks/BE/003.js.map +1 -0
  12. package/dist/commands/lint/checks/BE/004.d.ts +6 -0
  13. package/dist/commands/lint/checks/BE/004.js +27 -0
  14. package/dist/commands/lint/checks/BE/004.js.map +1 -0
  15. package/dist/commands/lint/checks/BE/005.d.ts +6 -0
  16. package/dist/commands/lint/checks/BE/005.js +107 -0
  17. package/dist/commands/lint/checks/BE/005.js.map +1 -0
  18. package/dist/commands/lint/checks/BE/006.d.ts +6 -0
  19. package/dist/commands/lint/checks/BE/006.js +27 -0
  20. package/dist/commands/lint/checks/BE/006.js.map +1 -0
  21. package/dist/commands/lint/checks/BE/007.d.ts +31 -0
  22. package/dist/commands/lint/checks/BE/007.js +109 -0
  23. package/dist/commands/lint/checks/BE/007.js.map +1 -0
  24. package/dist/commands/lint/checks/BE/008.d.ts +12 -0
  25. package/dist/commands/lint/checks/BE/008.js +57 -0
  26. package/dist/commands/lint/checks/BE/008.js.map +1 -0
  27. package/dist/commands/lint/checks/BE/009.d.ts +12 -0
  28. package/dist/commands/lint/checks/BE/009.js +104 -0
  29. package/dist/commands/lint/checks/BE/009.js.map +1 -0
  30. package/dist/commands/lint/checks/BE/010.d.ts +12 -0
  31. package/dist/commands/lint/checks/BE/010.js +54 -0
  32. package/dist/commands/lint/checks/BE/010.js.map +1 -0
  33. package/dist/commands/lint/checks/BE/011.d.ts +16 -0
  34. package/dist/commands/lint/checks/BE/011.js +46 -0
  35. package/dist/commands/lint/checks/BE/011.js.map +1 -0
  36. package/dist/commands/lint/checks/E2E/001.d.ts +6 -0
  37. package/dist/commands/lint/checks/E2E/001.js +35 -0
  38. package/dist/commands/lint/checks/E2E/001.js.map +1 -0
  39. package/dist/commands/lint/checks/E2E/002.d.ts +6 -0
  40. package/dist/commands/lint/checks/E2E/002.js +37 -0
  41. package/dist/commands/lint/checks/E2E/002.js.map +1 -0
  42. package/dist/commands/lint/checks/E2E/003.d.ts +6 -0
  43. package/dist/commands/lint/checks/E2E/003.js +42 -0
  44. package/dist/commands/lint/checks/E2E/003.js.map +1 -0
  45. package/dist/commands/lint/checks/E2E/004.d.ts +6 -0
  46. package/dist/commands/lint/checks/E2E/004.js +37 -0
  47. package/dist/commands/lint/checks/E2E/004.js.map +1 -0
  48. package/dist/commands/lint/checks/E2E/005.d.ts +6 -0
  49. package/dist/commands/lint/checks/E2E/005.js +47 -0
  50. package/dist/commands/lint/checks/E2E/005.js.map +1 -0
  51. package/dist/commands/lint/checks/E2E/006.d.ts +6 -0
  52. package/dist/commands/lint/checks/E2E/006.js +28 -0
  53. package/dist/commands/lint/checks/E2E/006.js.map +1 -0
  54. package/dist/commands/lint/checks/E2E/007.d.ts +6 -0
  55. package/dist/commands/lint/checks/E2E/007.js +47 -0
  56. package/dist/commands/lint/checks/E2E/007.js.map +1 -0
  57. package/dist/commands/lint/checks/FE/001.d.ts +6 -0
  58. package/dist/commands/lint/checks/FE/001.js +56 -0
  59. package/dist/commands/lint/checks/FE/001.js.map +1 -0
  60. package/dist/commands/lint/checks/FE/002.d.ts +6 -0
  61. package/dist/commands/lint/checks/FE/002.js +80 -0
  62. package/dist/commands/lint/checks/FE/002.js.map +1 -0
  63. package/dist/commands/lint/checks/FE/003.d.ts +6 -0
  64. package/dist/commands/lint/checks/FE/003.js +65 -0
  65. package/dist/commands/lint/checks/FE/003.js.map +1 -0
  66. package/dist/commands/lint/checks/FE/004.d.ts +6 -0
  67. package/dist/commands/lint/checks/FE/004.js +72 -0
  68. package/dist/commands/lint/checks/FE/004.js.map +1 -0
  69. package/dist/commands/lint/checks/FE/005.d.ts +6 -0
  70. package/dist/commands/lint/checks/FE/005.js +103 -0
  71. package/dist/commands/lint/checks/FE/005.js.map +1 -0
  72. package/dist/commands/lint/checks/FE/006.d.ts +6 -0
  73. package/dist/commands/lint/checks/FE/006.js +102 -0
  74. package/dist/commands/lint/checks/FE/006.js.map +1 -0
  75. package/dist/commands/lint/checks/FE/007.d.ts +6 -0
  76. package/dist/commands/lint/checks/FE/007.js +60 -0
  77. package/dist/commands/lint/checks/FE/007.js.map +1 -0
  78. package/dist/commands/lint/checks/FE/008.d.ts +6 -0
  79. package/dist/commands/lint/checks/FE/008.js +115 -0
  80. package/dist/commands/lint/checks/FE/008.js.map +1 -0
  81. package/dist/commands/lint/checks/FE/009.d.ts +6 -0
  82. package/dist/commands/lint/checks/FE/009.js +83 -0
  83. package/dist/commands/lint/checks/FE/009.js.map +1 -0
  84. package/dist/commands/lint/checks/FE/010.d.ts +6 -0
  85. package/dist/commands/lint/checks/FE/010.js +105 -0
  86. package/dist/commands/lint/checks/FE/010.js.map +1 -0
  87. package/dist/commands/lint/checks/FE/011.d.ts +6 -0
  88. package/dist/commands/lint/checks/FE/011.js +43 -0
  89. package/dist/commands/lint/checks/FE/011.js.map +1 -0
  90. package/dist/commands/lint/checks/FE/012.d.ts +6 -0
  91. package/dist/commands/lint/checks/FE/012.js +150 -0
  92. package/dist/commands/lint/checks/FE/012.js.map +1 -0
  93. package/dist/index.d.ts +5 -0
  94. package/dist/index.js +3491 -0
  95. package/dist/index.js.map +1 -0
  96. package/dude.stack.json +7 -0
  97. package/package.json +43 -0
  98. package/templates/aws-eks/backend/Dockerfile.prod.hbs +22 -0
  99. package/templates/aws-eks/docs/docs/deploy.md.hbs +159 -0
  100. package/templates/aws-eks/frontend/Dockerfile.prod +28 -0
  101. package/templates/aws-eks/frontend/nginx.conf +19 -0
  102. package/templates/aws-eks/iac/README.md.hbs +311 -0
  103. package/templates/aws-eks/iac/_gitignore +24 -0
  104. package/templates/aws-eks/iac/helm/app/.helmignore +7 -0
  105. package/templates/aws-eks/iac/helm/app/Chart.yaml.hbs +6 -0
  106. package/templates/aws-eks/iac/helm/app/templates/NOTES.txt +23 -0
  107. package/templates/aws-eks/iac/helm/app/templates/backend-deployment.yaml +44 -0
  108. package/templates/aws-eks/iac/helm/app/templates/backend-service.yaml +16 -0
  109. package/templates/aws-eks/iac/helm/app/templates/celery-beat-deployment.yaml +34 -0
  110. package/templates/aws-eks/iac/helm/app/templates/celery-worker-deployment.yaml +31 -0
  111. package/templates/aws-eks/iac/helm/app/templates/configmap.yaml +15 -0
  112. package/templates/aws-eks/iac/helm/app/templates/flower-deployment.yaml +28 -0
  113. package/templates/aws-eks/iac/helm/app/templates/flower-service.yaml +19 -0
  114. package/templates/aws-eks/iac/helm/app/templates/frontend-deployment.yaml +34 -0
  115. package/templates/aws-eks/iac/helm/app/templates/frontend-service.yaml +16 -0
  116. package/templates/aws-eks/iac/helm/app/templates/helpers.tpl +90 -0
  117. package/templates/aws-eks/iac/helm/app/templates/hpa.yaml +23 -0
  118. package/templates/aws-eks/iac/helm/app/templates/ingress.yaml +30 -0
  119. package/templates/aws-eks/iac/helm/app/templates/migration-job.yaml +38 -0
  120. package/templates/aws-eks/iac/helm/app/templates/redis-deployment.yaml +33 -0
  121. package/templates/aws-eks/iac/helm/app/templates/redis-service.yaml +18 -0
  122. package/templates/aws-eks/iac/helm/app/templates/secret.yaml +17 -0
  123. package/templates/aws-eks/iac/helm/app/templates/serviceaccount.yaml +12 -0
  124. package/templates/aws-eks/iac/helm/app/values-dev.yaml.hbs +35 -0
  125. package/templates/aws-eks/iac/helm/app/values.yaml.hbs +130 -0
  126. package/templates/aws-eks/iac/runner/Dockerfile +53 -0
  127. package/templates/aws-eks/iac/terraform/bootstrap/main.tf.hbs +101 -0
  128. package/templates/aws-eks/iac/terraform/bootstrap/outputs.tf +19 -0
  129. package/templates/aws-eks/iac/terraform/bootstrap/variables.tf.hbs +17 -0
  130. package/templates/aws-eks/iac/terraform/environments/dev/backend.hcl.hbs +12 -0
  131. package/templates/aws-eks/iac/terraform/environments/dev/terraform.tfvars.hbs +32 -0
  132. package/templates/aws-eks/iac/terraform/main.tf.hbs +305 -0
  133. package/templates/aws-eks/iac/terraform/outputs.tf.hbs +52 -0
  134. package/templates/aws-eks/iac/terraform/providers.tf +47 -0
  135. package/templates/aws-eks/iac/terraform/variables.tf.hbs +181 -0
  136. package/templates/aws-eks/iac/terraform/versions.tf +27 -0
  137. package/templates/base/.claude/agents/issue-fixer.md +190 -0
  138. package/templates/base/.claude/agents/security-fixer.md +250 -0
  139. package/templates/base/.claude/rules/BE/001.md +25 -0
  140. package/templates/base/.claude/rules/BE/002.md +15 -0
  141. package/templates/base/.claude/rules/BE/003.md +18 -0
  142. package/templates/base/.claude/rules/BE/004.md +14 -0
  143. package/templates/base/.claude/rules/BE/005.md +15 -0
  144. package/templates/base/.claude/rules/BE/006.md +17 -0
  145. package/templates/base/.claude/rules/BE/007.md +21 -0
  146. package/templates/base/.claude/rules/BE/008.md +19 -0
  147. package/templates/base/.claude/rules/BE/009.md +27 -0
  148. package/templates/base/.claude/rules/BE/010.md +16 -0
  149. package/templates/base/.claude/rules/BE/011.md +15 -0
  150. package/templates/base/.claude/rules/E2E/001.md +13 -0
  151. package/templates/base/.claude/rules/E2E/002.md +14 -0
  152. package/templates/base/.claude/rules/E2E/003.md +10 -0
  153. package/templates/base/.claude/rules/E2E/004.md +23 -0
  154. package/templates/base/.claude/rules/E2E/005.md +15 -0
  155. package/templates/base/.claude/rules/E2E/006.md +13 -0
  156. package/templates/base/.claude/rules/E2E/007.md +18 -0
  157. package/templates/base/.claude/rules/FE/001.md +22 -0
  158. package/templates/base/.claude/rules/FE/002.md +39 -0
  159. package/templates/base/.claude/rules/FE/003.md +19 -0
  160. package/templates/base/.claude/rules/FE/004.md +21 -0
  161. package/templates/base/.claude/rules/FE/005.md +33 -0
  162. package/templates/base/.claude/rules/FE/006.md +24 -0
  163. package/templates/base/.claude/rules/FE/007.md +19 -0
  164. package/templates/base/.claude/rules/FE/008.md +26 -0
  165. package/templates/base/.claude/rules/FE/009.md +30 -0
  166. package/templates/base/.claude/rules/FE/010.md +25 -0
  167. package/templates/base/.claude/rules/FE/011.md +22 -0
  168. package/templates/base/.claude/rules/FE/012.md +32 -0
  169. package/templates/base/.claude/settings.json +53 -0
  170. package/templates/base/.claude/skills/clean-branches/SKILL.md +100 -0
  171. package/templates/base/.claude/skills/create/SKILL.md +47 -0
  172. package/templates/base/.claude/skills/create-jira-issue/SKILL.md +174 -0
  173. package/templates/base/.claude/skills/create-page/SKILL.md +195 -0
  174. package/templates/base/.claude/skills/create-route/SKILL.md +199 -0
  175. package/templates/base/.claude/skills/draft-email/SKILL.md +104 -0
  176. package/templates/base/.claude/skills/fix-issues/SKILL.md +238 -0
  177. package/templates/base/.claude/skills/security-scan/SKILL.md +297 -0
  178. package/templates/base/.claude/skills/verify-security-fixes/SKILL.md +180 -0
  179. package/templates/base/.dude/commands/README.md +85 -0
  180. package/templates/base/.dude/commands/hello.ts +34 -0
  181. package/templates/base/.dude/lint/checks/PRJ/001.ts +26 -0
  182. package/templates/base/.dude/lint/checks/README.md +69 -0
  183. package/templates/base/.vscode/tasks.json +44 -0
  184. package/templates/base/.worktreeinclude +2 -0
  185. package/templates/base/CLAUDE.md.hbs +364 -0
  186. package/templates/base/README.md.hbs +187 -0
  187. package/templates/base/_env.example.hbs +29 -0
  188. package/templates/base/_env.hbs +25 -0
  189. package/templates/base/_gitignore +31 -0
  190. package/templates/base/_npmrc +2 -0
  191. package/templates/base/backend/Dockerfile.hbs +22 -0
  192. package/templates/base/backend/README.md.hbs +74 -0
  193. package/templates/base/backend/_dockerignore +11 -0
  194. package/templates/base/backend/app/__init__.py +1 -0
  195. package/templates/base/backend/app/core/__init__.py +0 -0
  196. package/templates/base/backend/app/core/config.py.hbs +23 -0
  197. package/templates/base/backend/app/fixtures/__init__.py +0 -0
  198. package/templates/base/backend/app/main.py.hbs +41 -0
  199. package/templates/base/backend/app/management/__init__.py +0 -0
  200. package/templates/base/backend/app/models/__init__.py +0 -0
  201. package/templates/base/backend/app/queries/__init__.py +0 -0
  202. package/templates/base/backend/app/routers/__init__.py +0 -0
  203. package/templates/base/backend/app/routers/health.py +13 -0
  204. package/templates/base/backend/app/schemas/__init__.py +0 -0
  205. package/templates/base/backend/app/schemas/health.py +7 -0
  206. package/templates/base/backend/app/tasks/__init__.py +1 -0
  207. package/templates/base/backend/app/tests/__init__.py +0 -0
  208. package/templates/base/backend/app/tests/conftest.py +13 -0
  209. package/templates/base/backend/app/tests/models/__init__.py +0 -0
  210. package/templates/base/backend/app/tests/queries/__init__.py +0 -0
  211. package/templates/base/backend/app/tests/routers/__init__.py +0 -0
  212. package/templates/base/backend/app/tests/routers/test_health.py +10 -0
  213. package/templates/base/backend/app/tests/tasks/__init__.py +1 -0
  214. package/templates/base/backend/app/tests/utils/__init__.py +0 -0
  215. package/templates/base/backend/app/utils/__init__.py +0 -0
  216. package/templates/base/backend/pyproject.toml.hbs +40 -0
  217. package/templates/base/docker-compose.yml.hbs +128 -0
  218. package/templates/base/docs/docs/api.md +21 -0
  219. package/templates/base/docs/docs/dude.md.hbs +316 -0
  220. package/templates/base/docs/docs/index.md.hbs +100 -0
  221. package/templates/base/docs/docs/mkdocs.md +238 -0
  222. package/templates/base/docs/mkdocs.yml.hbs +52 -0
  223. package/templates/base/e2e/.prettierrc.json +1 -0
  224. package/templates/base/e2e/_prettierignore +3 -0
  225. package/templates/base/e2e/cucumber.js +21 -0
  226. package/templates/base/e2e/eslint.config.mjs +14 -0
  227. package/templates/base/e2e/features/example.feature +13 -0
  228. package/templates/base/e2e/package.json.hbs +30 -0
  229. package/templates/base/e2e/pages/ExamplePage.ts +16 -0
  230. package/templates/base/e2e/playwright.config.ts +27 -0
  231. package/templates/base/e2e/steps/common.steps.ts +32 -0
  232. package/templates/base/e2e/steps/example.steps.ts +4 -0
  233. package/templates/base/e2e/support/hooks.ts +72 -0
  234. package/templates/base/e2e/support/world.ts +24 -0
  235. package/templates/base/e2e/tsconfig.json +22 -0
  236. package/templates/base/frontend/.prettierrc.json +6 -0
  237. package/templates/base/frontend/Dockerfile +10 -0
  238. package/templates/base/frontend/_dockerignore +4 -0
  239. package/templates/base/frontend/eslint.config.js +32 -0
  240. package/templates/base/frontend/index.html.hbs +13 -0
  241. package/templates/base/frontend/package.json.hbs +38 -0
  242. package/templates/base/frontend/public/favicon.svg +5 -0
  243. package/templates/base/frontend/src/$components/Layout/$assets/logo.svg +5 -0
  244. package/templates/base/frontend/src/$components/Layout/constants.tsx.hbs +10 -0
  245. package/templates/base/frontend/src/$components/Layout/index.tsx +80 -0
  246. package/templates/base/frontend/src/$components/Layout/types.tsx +9 -0
  247. package/templates/base/frontend/src/$components/index.tsx +1 -0
  248. package/templates/base/frontend/src/$hooks/index.tsx +2 -0
  249. package/templates/base/frontend/src/$hooks/useCounterStore/index.tsx +28 -0
  250. package/templates/base/frontend/src/$hooks/useCounterStore/types.tsx +7 -0
  251. package/templates/base/frontend/src/$hooks/usePageTitle/index.tsx +21 -0
  252. package/templates/base/frontend/src/$types/vite-env.d.ts +10 -0
  253. package/templates/base/frontend/src/App.tsx.hbs +40 -0
  254. package/templates/base/frontend/src/main.tsx +10 -0
  255. package/templates/base/frontend/src/openapi/utils/openapi.yaml.hbs +28 -0
  256. package/templates/base/frontend/src/pages/constants.tsx +31 -0
  257. package/templates/base/frontend/src/pages/index.tsx +192 -0
  258. package/templates/base/frontend/src/pages/types.tsx +6 -0
  259. package/templates/base/frontend/src/styles.module.css +7 -0
  260. package/templates/base/frontend/src/utils/constants.tsx +11 -0
  261. package/templates/base/frontend/src/utils/formatters/index.tsx +49 -0
  262. package/templates/base/frontend/src/utils/functions.tsx +70 -0
  263. package/templates/base/frontend/src/utils/index.tsx +3 -0
  264. package/templates/base/frontend/tsconfig.json +24 -0
  265. package/templates/base/frontend/vite.config.ts +20 -0
  266. package/templates/base/package.json.hbs +11 -0
  267. package/templates/base/security/baseline.json +4 -0
  268. package/templates/celery/backend/app/tasks/__init__.py +1 -0
  269. package/templates/celery/backend/app/tasks/example.py +21 -0
  270. package/templates/celery/backend/app/tests/tasks/test_example.py +7 -0
  271. package/templates/celery/backend/app/worker.py.hbs +33 -0
  272. package/templates/celerybeat/backend/app/tasks/scheduled.py +16 -0
  273. package/templates/celerybeat/backend/app/tests/tasks/test_scheduled.py +7 -0
  274. package/templates/postgres/.dude/commands/reset.ts +76 -0
  275. package/templates/postgres/backend/alembic/env.py +55 -0
  276. package/templates/postgres/backend/alembic/script.py.mako +27 -0
  277. package/templates/postgres/backend/alembic/versions/0001_create_user_table.py +38 -0
  278. package/templates/postgres/backend/alembic.ini +42 -0
  279. package/templates/postgres/backend/app/core/database.py +15 -0
  280. package/templates/postgres/backend/app/models/__init__.py +5 -0
  281. package/templates/postgres/backend/app/models/user.py +15 -0
  282. package/templates/postgres/backend/app/queries/__init__.py +5 -0
  283. package/templates/postgres/backend/app/queries/users.py +18 -0
  284. package/templates/postgres/backend/app/routers/users.py +19 -0
  285. package/templates/postgres/backend/app/routers/users__id.py +20 -0
  286. package/templates/postgres/backend/app/tests/conftest.py +33 -0
  287. package/templates/postgres/backend/app/tests/models/test_user.py +12 -0
  288. package/templates/postgres/backend/app/tests/queries/test_users.py +12 -0
  289. package/templates/postgres/backend/app/tests/routers/test_users.py +10 -0
  290. package/templates/postgres/backend/app/tests/routers/test_users__id.py +9 -0
  291. package/templates/postgres/backend/start.sh +32 -0
  292. package/templates/postgres/frontend/src/openapi/utils/openapi.yaml.hbs +138 -0
  293. package/templates/postgres/frontend/src/pages/users/[id]/index.tsx +51 -0
  294. package/templates/postgres/frontend/src/pages/users/index.tsx +54 -0
  295. package/templates/postgres/frontend/src/pages/users/types.tsx +4 -0
@@ -0,0 +1,55 @@
1
+ """Alembic environment — PostgreSQL + SQLModel autogenerate."""
2
+
3
+ import os
4
+ from logging.config import fileConfig
5
+
6
+ from alembic import context
7
+ from app.models import * # noqa: F401, F403 — required so SQLModel registers all table metadata
8
+ from sqlalchemy import engine_from_config, pool
9
+ from sqlmodel import SQLModel
10
+
11
+ DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://postgres:postgres@postgres:5432/app")
12
+
13
+ config = context.config
14
+
15
+ if config.config_file_name is not None:
16
+ fileConfig(config.config_file_name)
17
+
18
+ config.set_main_option("sqlalchemy.url", DATABASE_URL)
19
+
20
+ target_metadata = SQLModel.metadata
21
+
22
+
23
+ def run_migrations_offline() -> None:
24
+ """Run migrations without an active DB connection (SQL output only)."""
25
+ url = config.get_main_option("sqlalchemy.url")
26
+ context.configure(
27
+ url=url,
28
+ target_metadata=target_metadata,
29
+ literal_binds=True,
30
+ dialect_opts={"paramstyle": "named"},
31
+ )
32
+ with context.begin_transaction():
33
+ context.run_migrations()
34
+
35
+
36
+ def run_migrations_online() -> None:
37
+ """Run migrations against a live DB connection."""
38
+ connectable = engine_from_config(
39
+ config.get_section(config.config_ini_section, {}),
40
+ prefix="sqlalchemy.",
41
+ poolclass=pool.NullPool,
42
+ )
43
+ with connectable.connect() as connection:
44
+ context.configure(
45
+ connection=connection,
46
+ target_metadata=target_metadata,
47
+ )
48
+ with context.begin_transaction():
49
+ context.run_migrations()
50
+
51
+
52
+ if context.is_offline_mode():
53
+ run_migrations_offline()
54
+ else:
55
+ run_migrations_online()
@@ -0,0 +1,27 @@
1
+ """${message}
2
+
3
+ Revision ID: ${up_revision}
4
+ Revises: ${down_revision | comma,n}
5
+ Create Date: ${create_date}
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+ import sqlmodel
13
+ ${imports if imports else ""}
14
+
15
+ # revision identifiers, used by Alembic.
16
+ revision: str = ${repr(up_revision)}
17
+ down_revision: Union[str, None] = ${repr(down_revision)}
18
+ branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
19
+ depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
20
+
21
+
22
+ def upgrade() -> None:
23
+ ${upgrades if upgrades else "pass"}
24
+
25
+
26
+ def downgrade() -> None:
27
+ ${downgrades if downgrades else "pass"}
@@ -0,0 +1,38 @@
1
+ """create user table
2
+
3
+ Revision ID: 0001_create_user_table
4
+ Revises:
5
+ Create Date: 2026-01-01 00:00:00.000000
6
+
7
+ """
8
+
9
+ from typing import Sequence, Union
10
+
11
+ import sqlalchemy as sa
12
+ import sqlmodel
13
+ from alembic import op
14
+
15
+ # revision identifiers, used by Alembic.
16
+ revision: str = "0001_create_user_table"
17
+ down_revision: Union[str, None] = None
18
+ branch_labels: Union[str, Sequence[str], None] = None
19
+ depends_on: Union[str, Sequence[str], None] = None
20
+
21
+
22
+ def upgrade() -> None:
23
+ op.create_table(
24
+ "user",
25
+ sa.Column("id", sa.Integer(), nullable=False),
26
+ sa.Column("email", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
27
+ sa.Column("full_name", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
28
+ sa.Column("is_active", sa.Boolean(), nullable=False),
29
+ sa.Column("created_at", sa.DateTime(), nullable=False),
30
+ sa.Column("updated_at", sa.DateTime(), nullable=False),
31
+ sa.PrimaryKeyConstraint("id"),
32
+ )
33
+ op.create_index(op.f("ix_user_email"), "user", ["email"], unique=True)
34
+
35
+
36
+ def downgrade() -> None:
37
+ op.drop_index(op.f("ix_user_email"), table_name="user")
38
+ op.drop_table("user")
@@ -0,0 +1,42 @@
1
+ # A generic, single database configuration.
2
+
3
+ [alembic]
4
+ script_location = alembic
5
+ prepend_sys_path = .
6
+ version_path_separator = os
7
+
8
+ [post_write_hooks]
9
+
10
+ [loggers]
11
+ keys = root,sqlalchemy,alembic
12
+
13
+ [handlers]
14
+ keys = console
15
+
16
+ [formatters]
17
+ keys = generic
18
+
19
+ [logger_root]
20
+ level = WARN
21
+ handlers = console
22
+ qualname =
23
+
24
+ [logger_sqlalchemy]
25
+ level = WARN
26
+ handlers =
27
+ qualname = sqlalchemy.engine
28
+
29
+ [logger_alembic]
30
+ level = INFO
31
+ handlers =
32
+ qualname = alembic
33
+
34
+ [handler_console]
35
+ class = StreamHandler
36
+ args = (sys.stderr,)
37
+ level = NOTSET
38
+ formatter = generic
39
+
40
+ [formatter_generic]
41
+ format = %(levelname)-5.5s [%(name)s] %(message)s
42
+ datefmt = %H:%M:%S
@@ -0,0 +1,15 @@
1
+ """Database engine and session dependency."""
2
+
3
+ import os
4
+
5
+ from sqlmodel import Session, create_engine
6
+
7
+ DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://postgres:postgres@postgres:5432/app")
8
+
9
+ engine = create_engine(DATABASE_URL)
10
+
11
+
12
+ def get_db():
13
+ """Yield a SQLModel session (use as a FastAPI Dependency)."""
14
+ with Session(engine) as session:
15
+ yield session
@@ -0,0 +1,5 @@
1
+ """Models package — all imports must live here so Alembic discovers every table."""
2
+
3
+ from app.models.user import User
4
+
5
+ __all__ = ["User"]
@@ -0,0 +1,15 @@
1
+ """User model."""
2
+
3
+ from datetime import UTC, datetime
4
+ from typing import Optional
5
+
6
+ from sqlmodel import Field, SQLModel
7
+
8
+
9
+ class User(SQLModel, table=True):
10
+ id: Optional[int] = Field(default=None, primary_key=True)
11
+ email: str = Field(unique=True, index=True)
12
+ full_name: Optional[str] = None
13
+ is_active: bool = Field(default=True)
14
+ created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
15
+ updated_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
@@ -0,0 +1,5 @@
1
+ """Queries package."""
2
+
3
+ from app.queries.users import UsersQueries
4
+
5
+ __all__ = ["UsersQueries"]
@@ -0,0 +1,18 @@
1
+ """User queries."""
2
+
3
+ from typing import Sequence
4
+
5
+ from sqlmodel import Session, select
6
+
7
+ from app.models.user import User
8
+
9
+
10
+ class UsersQueries:
11
+ def get_all(self, db: Session) -> Sequence[User]:
12
+ return db.exec(select(User)).all()
13
+
14
+ def get_by_id(self, db: Session, user_id: int) -> User | None:
15
+ return db.get(User, user_id)
16
+
17
+ def get_by_email(self, db: Session, email: str) -> User | None:
18
+ return db.exec(select(User).where(User.email == email)).first()
@@ -0,0 +1,19 @@
1
+ """Users list router."""
2
+
3
+ from typing import Sequence
4
+
5
+ from fastapi import APIRouter, Depends
6
+ from sqlmodel import Session
7
+
8
+ from app.core.database import get_db
9
+ from app.models.user import User
10
+ from app.queries.users import UsersQueries
11
+
12
+ router = APIRouter(tags=["users"])
13
+ _users = UsersQueries()
14
+
15
+
16
+ @router.get("/users", response_model=list[User])
17
+ def get_users(db: Session = Depends(get_db)) -> Sequence[User]:
18
+ """Return all users."""
19
+ return _users.get_all(db)
@@ -0,0 +1,20 @@
1
+ """Users by ID router."""
2
+
3
+ from fastapi import APIRouter, Depends, HTTPException
4
+ from sqlmodel import Session
5
+
6
+ from app.core.database import get_db
7
+ from app.models.user import User
8
+ from app.queries.users import UsersQueries
9
+
10
+ router = APIRouter(tags=["users"])
11
+ _users = UsersQueries()
12
+
13
+
14
+ @router.get("/users/{id}", response_model=User)
15
+ def get_users__id(id: int, db: Session = Depends(get_db)) -> User:
16
+ """Return a single user by ID."""
17
+ user = _users.get_by_id(db, id)
18
+ if user is None:
19
+ raise HTTPException(status_code=404, detail="User not found")
20
+ return user
@@ -0,0 +1,33 @@
1
+ """Pytest configuration and shared fixtures."""
2
+
3
+ import pytest
4
+ from httpx import ASGITransport, AsyncClient
5
+ from sqlmodel import Session, SQLModel, create_engine
6
+ from sqlmodel.pool import StaticPool
7
+
8
+ from app.core.database import get_db
9
+ from app.main import app as fastapi_app
10
+ from app.models import user as _user_model # noqa: F401 — registers the User table with SQLModel.metadata
11
+
12
+
13
+ @pytest.fixture(name="db")
14
+ def db_fixture():
15
+ """In-memory SQLite session for database tests."""
16
+ engine = create_engine(
17
+ "sqlite://",
18
+ connect_args={"check_same_thread": False},
19
+ poolclass=StaticPool,
20
+ )
21
+ SQLModel.metadata.create_all(engine)
22
+ with Session(engine) as session:
23
+ yield session
24
+ SQLModel.metadata.drop_all(engine)
25
+
26
+
27
+ @pytest.fixture
28
+ async def client(db: Session):
29
+ """Async HTTP client with the FastAPI app wired to the in-memory DB."""
30
+ fastapi_app.dependency_overrides[get_db] = lambda: db
31
+ async with AsyncClient(transport=ASGITransport(app=fastapi_app), base_url="http://test") as c:
32
+ yield c
33
+ fastapi_app.dependency_overrides.clear()
@@ -0,0 +1,12 @@
1
+ """Tests for models/user.py."""
2
+
3
+ import pytest
4
+
5
+ from app.models.user import User
6
+
7
+
8
+ def test_user_model_fields():
9
+ user = User(id=1, full_name="Alice", email="alice@example.com")
10
+ assert user.id == 1
11
+ assert user.full_name == "Alice"
12
+ assert user.email == "alice@example.com"
@@ -0,0 +1,12 @@
1
+ """Tests for queries/users.py."""
2
+
3
+ import pytest
4
+
5
+ from app.queries.users import UsersQueries
6
+
7
+
8
+ @pytest.mark.anyio
9
+ async def test_get_all_returns_list(db):
10
+ queries = UsersQueries()
11
+ result = queries.get_all(db)
12
+ assert isinstance(result, list)
@@ -0,0 +1,10 @@
1
+ """Tests for routers/users.py."""
2
+
3
+ import pytest
4
+
5
+
6
+ @pytest.mark.anyio
7
+ async def test_get_users(client):
8
+ response = await client.get("/api/users")
9
+ assert response.status_code == 200
10
+ assert isinstance(response.json(), list)
@@ -0,0 +1,9 @@
1
+ """Tests for routers/users__id.py."""
2
+
3
+ import pytest
4
+
5
+
6
+ @pytest.mark.anyio
7
+ async def test_get_users__id_not_found(client):
8
+ response = await client.get("/api/users/99999")
9
+ assert response.status_code == 404
@@ -0,0 +1,32 @@
1
+ #!/bin/bash
2
+ # start.sh — container entrypoint when PostgreSQL is enabled.
3
+ # 1. Waits for the DB to accept connections.
4
+ # 2. Runs Alembic migrations.
5
+ # 3. Starts uvicorn.
6
+ set -e
7
+
8
+ POSTGRES_HOST="${POSTGRES_HOST:-postgres}"
9
+ POSTGRES_PORT="${POSTGRES_PORT:-5432}"
10
+
11
+ echo "Waiting for PostgreSQL at ${POSTGRES_HOST}:${POSTGRES_PORT}..."
12
+ until python -c "
13
+ import socket, os, sys
14
+ try:
15
+ s = socket.create_connection(
16
+ (os.getenv('POSTGRES_HOST', 'postgres'), int(os.getenv('POSTGRES_PORT', '5432'))),
17
+ timeout=1,
18
+ )
19
+ s.close()
20
+ sys.exit(0)
21
+ except Exception:
22
+ sys.exit(1)
23
+ " 2>/dev/null; do
24
+ echo " Not ready — retrying in 1s..."
25
+ sleep 1
26
+ done
27
+
28
+ echo "PostgreSQL is up. Running migrations..."
29
+ uv run alembic upgrade head
30
+
31
+ echo "Starting uvicorn..."
32
+ exec uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
@@ -0,0 +1,138 @@
1
+ openapi: 3.1.0
2
+ info:
3
+ title: {{projectName}} backend
4
+ version: 0.1.0
5
+ paths:
6
+ /api/health:
7
+ get:
8
+ summary: Get Health
9
+ description: Health-check endpoint.
10
+ operationId: get_health_api_health_get
11
+ responses:
12
+ "200":
13
+ description: Successful Response
14
+ content:
15
+ application/json:
16
+ schema:
17
+ $ref: "#/components/schemas/HealthResponse"
18
+ /api/users:
19
+ get:
20
+ tags:
21
+ - users
22
+ summary: Get Users
23
+ description: Return all users.
24
+ operationId: get_users_api_users_get
25
+ responses:
26
+ "200":
27
+ description: Successful Response
28
+ content:
29
+ application/json:
30
+ schema:
31
+ items:
32
+ $ref: "#/components/schemas/User"
33
+ type: array
34
+ title: Response Get Users Api Users Get
35
+ /api/users/{id}:
36
+ get:
37
+ tags:
38
+ - users
39
+ summary: Get User By Id
40
+ description: Return a single user by ID.
41
+ operationId: get_users__id_api_users__id__get
42
+ parameters:
43
+ - name: id
44
+ in: path
45
+ required: true
46
+ schema:
47
+ type: integer
48
+ title: Id
49
+ responses:
50
+ "200":
51
+ description: Successful Response
52
+ content:
53
+ application/json:
54
+ schema:
55
+ $ref: "#/components/schemas/User"
56
+ "422":
57
+ description: Validation Error
58
+ content:
59
+ application/json:
60
+ schema:
61
+ $ref: "#/components/schemas/HTTPValidationError"
62
+ components:
63
+ schemas:
64
+ HealthResponse:
65
+ properties:
66
+ status:
67
+ type: string
68
+ title: Status
69
+ type: object
70
+ required:
71
+ - status
72
+ title: HealthResponse
73
+ HTTPValidationError:
74
+ properties:
75
+ detail:
76
+ items:
77
+ $ref: "#/components/schemas/ValidationError"
78
+ type: array
79
+ title: Detail
80
+ type: object
81
+ title: HTTPValidationError
82
+ User:
83
+ properties:
84
+ id:
85
+ anyOf:
86
+ - type: integer
87
+ - type: "null"
88
+ title: Id
89
+ email:
90
+ type: string
91
+ title: Email
92
+ full_name:
93
+ anyOf:
94
+ - type: string
95
+ - type: "null"
96
+ title: Full Name
97
+ is_active:
98
+ type: boolean
99
+ title: Is Active
100
+ default: true
101
+ created_at:
102
+ type: string
103
+ format: date-time
104
+ title: Created At
105
+ updated_at:
106
+ type: string
107
+ format: date-time
108
+ title: Updated At
109
+ type: object
110
+ required:
111
+ - email
112
+ title: User
113
+ ValidationError:
114
+ properties:
115
+ loc:
116
+ items:
117
+ anyOf:
118
+ - type: string
119
+ - type: integer
120
+ type: array
121
+ title: Location
122
+ msg:
123
+ type: string
124
+ title: Message
125
+ type:
126
+ type: string
127
+ title: Error Type
128
+ input:
129
+ title: Input
130
+ ctx:
131
+ type: object
132
+ title: Context
133
+ type: object
134
+ required:
135
+ - loc
136
+ - msg
137
+ - type
138
+ title: ValidationError
@@ -0,0 +1,51 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+ import { Alert, Button, Card, Descriptions, Spin, Tag } from 'antd'
3
+ import { ArrowLeftOutlined } from '@ant-design/icons'
4
+ import { useNavigate, useParams } from 'react-router-dom'
5
+ import { usePageTitle } from '@/$hooks'
6
+ import { formatDateTime } from '@/utils'
7
+ import { $get as getUser } from '@/openapi/api/users/[id]'
8
+
9
+ export default function UserDetailPage() {
10
+ const { id } = useParams<{ id: string }>()
11
+ usePageTitle(`User ${id ?? ''}`)
12
+ const navigate = useNavigate()
13
+
14
+ const {
15
+ data: user,
16
+ isLoading,
17
+ isError,
18
+ } = useQuery({
19
+ queryKey: ['users', id],
20
+ queryFn: () => getUser(id!),
21
+ enabled: id != null,
22
+ })
23
+
24
+ return (
25
+ <Card
26
+ title={`User ${id ?? ''}`}
27
+ extra={
28
+ <Button icon={<ArrowLeftOutlined />} onClick={() => navigate('/users')}>
29
+ Back to users
30
+ </Button>
31
+ }
32
+ >
33
+ {isLoading ? (
34
+ <Spin />
35
+ ) : isError || !user ? (
36
+ <Alert type="error" showIcon message="User not found" />
37
+ ) : (
38
+ <Descriptions column={1} bordered size="small">
39
+ <Descriptions.Item label="ID">{user.id}</Descriptions.Item>
40
+ <Descriptions.Item label="Email">{user.email}</Descriptions.Item>
41
+ <Descriptions.Item label="Full name">{user.full_name ?? '—'}</Descriptions.Item>
42
+ <Descriptions.Item label="Status">
43
+ {user.is_active ? <Tag color="green">active</Tag> : <Tag>inactive</Tag>}
44
+ </Descriptions.Item>
45
+ <Descriptions.Item label="Created">{formatDateTime(user.created_at)}</Descriptions.Item>
46
+ <Descriptions.Item label="Updated">{formatDateTime(user.updated_at)}</Descriptions.Item>
47
+ </Descriptions>
48
+ )}
49
+ </Card>
50
+ )
51
+ }
@@ -0,0 +1,54 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+ import { Alert, Card, Table, Tag, Typography } from 'antd'
3
+ import { useNavigate } from 'react-router-dom'
4
+ import { usePageTitle } from '@/$hooks'
5
+ import { formatDateTime } from '@/utils'
6
+ import { $get as getUsers } from '@/openapi/api/users'
7
+ import type { User } from './types'
8
+
9
+ const { Text } = Typography
10
+
11
+ export default function UsersPage() {
12
+ usePageTitle('Users')
13
+ const navigate = useNavigate()
14
+ const { data, isLoading, isError } = useQuery({ queryKey: ['users'], queryFn: getUsers })
15
+
16
+ if (isError) {
17
+ return <Alert type="error" showIcon message="Could not load users" />
18
+ }
19
+
20
+ return (
21
+ <Card title="Users">
22
+ <Table<User>
23
+ rowKey="id"
24
+ loading={isLoading}
25
+ dataSource={data ?? []}
26
+ onRow={(user) => ({
27
+ onClick: () => navigate(`/users/${user.id}`),
28
+ style: { cursor: 'pointer' },
29
+ })}
30
+ columns={[
31
+ { title: 'ID', dataIndex: 'id', width: 80 },
32
+ { title: 'Email', dataIndex: 'email' },
33
+ {
34
+ title: 'Full name',
35
+ dataIndex: 'full_name',
36
+ render: (value: User['full_name']) => value ?? <Text type="secondary">—</Text>,
37
+ },
38
+ {
39
+ title: 'Status',
40
+ dataIndex: 'is_active',
41
+ width: 120,
42
+ render: (value: User['is_active']) =>
43
+ value ? <Tag color="green">active</Tag> : <Tag>inactive</Tag>,
44
+ },
45
+ {
46
+ title: 'Created',
47
+ dataIndex: 'created_at',
48
+ render: (value: User['created_at']) => formatDateTime(value),
49
+ },
50
+ ]}
51
+ />
52
+ </Card>
53
+ )
54
+ }
@@ -0,0 +1,4 @@
1
+ import type { GetResponse } from '@/openapi/api/users/types'
2
+
3
+ /** One user row as returned by GET /api/users. */
4
+ export type User = GetResponse[number]