create-win-project 1.4.0 → 2.0.0

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 (99) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +54 -147
  3. package/checks/check-compatibility.js +37 -8
  4. package/checks/check-generated-project.js +27 -3
  5. package/checks/check-library.js +13 -3
  6. package/checks/check-package.js +15 -0
  7. package/checks/classify-changes.js +5 -15
  8. package/checks/run-compatibility-shard.js +21 -0
  9. package/docs/README.md +20 -0
  10. package/docs/capabilities.md +13 -0
  11. package/docs/compatibility.md +13 -0
  12. package/docs/generated-project.md +12 -0
  13. package/docs/getting-started.md +26 -0
  14. package/docs/{ARCHITECTURE.md → maintainers/architecture.md} +3 -3
  15. package/docs/maintainers/ci-strategy.md +46 -0
  16. package/docs/{CONTRIBUTING.md → maintainers/contributing.md} +7 -7
  17. package/docs/migration-v2.md +13 -0
  18. package/docs/production-contract.md +24 -0
  19. package/library/INDEX.md +1 -1
  20. package/library/compatibility-impact.json +14 -0
  21. package/library/development-tools/devops/makefile/commands.md +11 -0
  22. package/library/development-tools/devops/makefile/definition.json +2 -2
  23. package/library/development-tools/devops/makefile/docker.md +9 -0
  24. package/library/development-tools/devops/makefile/validation.md +5 -0
  25. package/library/features/sqlalchemy-alembic.md +17 -0
  26. package/library/optional-features/concerns/zod/errors.md +5 -0
  27. package/library/optional-features/concerns/zod/testing.md +5 -0
  28. package/library/optional-features/concerns/zod/validation.md +21 -0
  29. package/library/optional-features/styling/css-modules/definition.json +3 -2
  30. package/library/optional-features/styling/css-modules/responsive.md +5 -0
  31. package/library/optional-features/styling/css-modules/theme.md +7 -0
  32. package/library/stacks/expo/definition.json +2 -2
  33. package/library/stacks/fastapi/architecture.md +40 -0
  34. package/library/stacks/fastapi/definition.json +39 -0
  35. package/library/stacks/fastapi/runtime.md +25 -0
  36. package/library/stacks/fastapi/security.md +26 -0
  37. package/library/stacks/fastapi/structure.md +27 -0
  38. package/library/stacks/fastapi/testing.md +23 -0
  39. package/library/stacks/nextjs/definition.json +2 -2
  40. package/library/stacks/no-frontend/definition.json +1 -1
  41. package/library/stacks/react-vite/definition.json +2 -2
  42. package/library/tested-versions.json +42 -2
  43. package/library/universal/coding-rules/definition.json +3 -3
  44. package/library/universal/coding-rules/hygiene.md +9 -0
  45. package/library/universal/coding-rules/naming.md +17 -0
  46. package/library/universal/git-conventions/branches.md +5 -0
  47. package/library/universal/git-conventions/commits.md +7 -0
  48. package/library/universal/git-conventions/definition.json +4 -2
  49. package/library/universal/git-conventions/workflow.md +5 -0
  50. package/library/universal/typescript/boundaries.md +13 -0
  51. package/library/universal/typescript/definition.json +3 -3
  52. package/library/universal/typescript/errors.md +5 -0
  53. package/library/universal/typescript/patterns.md +7 -0
  54. package/package.json +4 -6
  55. package/src/cli/arguments.js +11 -0
  56. package/src/cli/main.js +18 -0
  57. package/src/cli/questions.js +16 -15
  58. package/src/cli/system-check.js +22 -2
  59. package/src/engine/load-library.js +3 -2
  60. package/src/engine/project-files.js +10 -1
  61. package/src/engine/project-guidance.js +2 -1
  62. package/src/engine/project-shapes.js +4 -4
  63. package/src/engine/render-templates.js +3 -0
  64. package/src/engine/tested-versions.js +21 -2
  65. package/src/engine/upgrade-report.js +20 -0
  66. package/src/stacks/available-stacks.js +2 -0
  67. package/src/stacks/backends/fastapi/ci.js +3 -0
  68. package/src/stacks/backends/fastapi/create-files.js +874 -0
  69. package/src/stacks/backends/fastapi/docker.js +75 -0
  70. package/src/stacks/backends/fastapi/environment.js +3 -0
  71. package/src/stacks/backends/fastapi/index.js +32 -0
  72. package/src/stacks/compose-files.js +19 -1
  73. package/src/stacks/create-project.js +128 -7
  74. package/src/stacks/frontends/nextjs/index.js +1 -1
  75. package/src/stacks/frontends/react-native/create-files.js +4 -1
  76. package/src/stacks/frontends/react-native/environment.js +1 -1
  77. package/src/stacks/frontends/react-native/index.js +1 -1
  78. package/src/stacks/frontends/react-vite/environment.js +1 -1
  79. package/src/stacks/frontends/react-vite/index.js +1 -1
  80. package/src/stacks/shared/capability-packs.js +31 -0
  81. package/src/stacks/shared/environment.js +12 -4
  82. package/src/stacks/shared/javascript-package.js +6 -0
  83. package/templates/ci/fastapi.yml +62 -0
  84. package/templates/docker/compose-prod/fastapi.yml +52 -0
  85. package/templates/docker/compose-prod/springboot.yml +19 -1
  86. package/templates/docker/dockerfile/fastapi.dev.dockerfile +9 -0
  87. package/templates/docker/dockerfile/fastapi.prod.dockerfile +11 -0
  88. package/templates/docker/dockerfile/nextjs.prod.dockerfile +1 -0
  89. package/templates/docker/dockerfile/springboot.prod.dockerfile +4 -1
  90. package/templates/docker/dockerfile/vite.prod.dockerfile +2 -1
  91. package/templates/makefile/fastapi.mk +97 -0
  92. package/library/development-tools/devops/makefile/makefile.md +0 -556
  93. package/library/optional-features/concerns/zod.md +0 -174
  94. package/library/optional-features/styling/css-modules/css-modules-extensions.md +0 -267
  95. package/library/universal/coding-rules/coding-rules.md +0 -281
  96. package/library/universal/git-conventions/git-conventions.md +0 -186
  97. package/library/universal/typescript/typescript.md +0 -272
  98. /package/docs/{CONTENT_MODEL.md → maintainers/content-model.md} +0 -0
  99. /package/docs/{DEPENDENCY_MAINTENANCE.md → maintainers/dependencies.md} +0 -0
@@ -0,0 +1,46 @@
1
+ # CI and Branch Protection
2
+
3
+ `dev` is the integration branch and `main` is the protected release-ready branch. Use merge
4
+ commits for feature branches so contribution history remains visible.
5
+
6
+ ## Required checks
7
+
8
+ | Pull request | Required checks | Coverage |
9
+ |---|---|---|
10
+ | feature → `dev` | `quality`, `compatibility-gate` | Repository tests plus 10 current-profile smoke projects |
11
+ | `dev` → `main` | `quality`, `compatibility-gate` | Every current/previous contract plus representative native and container lanes |
12
+
13
+ Configure both branches to require pull requests, resolve conversations, reject force pushes and
14
+ deletions, and require branches to be current before merging. Restrict direct pushes to `main`.
15
+ Do not require individual matrix job names; require the stable `compatibility-gate` aggregator.
16
+
17
+ Required workflows intentionally have no path filters. A skipped workflow cannot report its check,
18
+ which can leave a required pull request waiting forever or accidentally encourage bypasses.
19
+
20
+ ## Manual verification
21
+
22
+ `Generated compatibility` can be started with `workflow_dispatch`. Choose `full` before changing a
23
+ compatibility default or investigating a release candidate; choose `smoke` for a quick diagnostic.
24
+ The pull-request base branch still determines automatic scope: `dev` gets smoke, `main` gets full.
25
+
26
+ The quality suite runs once per revision. The full matrix generates every supported combination
27
+ and checks its metadata contract. Representative risk-bearing lanes additionally install and run
28
+ native tooling; one current-profile lane per container family builds images. This avoids repeating
29
+ the same expensive installation or image build across hundreds of structurally equivalent cases.
30
+
31
+ ## Definition of done for generated behavior
32
+
33
+ Repository unit tests are necessary but are not sufficient evidence for a generator change. For
34
+ each affected stack shape, verification must generate a project in a temporary directory and use
35
+ that project's native tools to exercise the behavior users receive:
36
+
37
+ 1. Install the exact profile dependencies without weakening install-script controls.
38
+ 2. Run the generated formatter, linter, type checker, and tests.
39
+ 3. Apply migrations to the declared database, then check for migration drift.
40
+ 4. Build the application and validate Compose; build containers for full verification.
41
+ 5. Exercise each affected root layout, architecture profile, and authentication model.
42
+
43
+ A warning may be reported separately, but a failed native command is a failed implementation.
44
+ Do not approve a PR based only on generated file presence, string assertions, fixture hashes, or
45
+ the agent's completion statement. The stable `compatibility-gate` is the executable acceptance
46
+ boundary.
@@ -1,6 +1,6 @@
1
1
  # Contributing
2
2
 
3
- See `docs/ARCHITECTURE.md` for completed source ownership and `docs/DEPENDENCY_MAINTENANCE.md` for profile promotion. This file is the workflow, not the design.
3
+ See `docs/maintainers/architecture.md` for source ownership and `docs/maintainers/dependencies.md` for profile promotion. This file is the workflow, not the design.
4
4
 
5
5
  ## Quick start
6
6
 
@@ -60,7 +60,7 @@ If a new stack needs a runtime (`node`, `java`, `php`), add its version to `libr
60
60
  - `deps`/`devDeps` are **names only** — never versions or ranges. Exact versions live only in `library/tested-versions.json`.
61
61
  - `env` are semantic names (`DATABASE_URL`); `clientEnv` subset gets the frontend prefix (`NEXT_PUBLIC_`, `VITE_`, `EXPO_PUBLIC_`).
62
62
 
63
- - Add `playbooks/stack/<id>/{architecture,structure,runtime,security,testing}.md` — the five facets. Keep each file focused; route concerns via definition `concerns[]`, not duplication. Check `docs/CONTENT_MODEL.md` — every concern section must match a Markdown heading (numbered headings normalized).
63
+ - Add `playbooks/stack/<id>/{architecture,structure,runtime,security,testing}.md` — the five facets. Keep each file focused; route concerns via definition `concerns[]`, not duplication. Check `docs/maintainers/content-model.md` — every concern section must match a Markdown heading (numbered headings normalized).
64
64
 
65
65
  - Run: `node checks/check-library.js` — catches duplicate ids, unknown dep names, `clientEnv` not in `env`, missing labels, heading mismatches.
66
66
 
@@ -124,15 +124,15 @@ npm run verify:generated -- --profile=$(jq -r .defaultProfile library/tested-ver
124
124
 
125
125
  - `verify:generated` compares byte-identical output via `generateProject` vs legacy shim for your new stack.
126
126
  - Run `npm run matrix:smoke` (10 smoke projects) before any `feature -> dev` PR.
127
- - Full matrix `npm run matrix:full` (every profile x stack x arch x auth, with install/build/Maven/Expo/Compose checks) is only required on `dev -> main` promotion per `docs/CI_STRATEGY.md`.
127
+ - Full matrix `npm run matrix:full` (every profile x stack x arch x auth, with install/build/Maven/Expo/Compose checks) is only required on `dev -> main` promotion per `docs/maintainers/ci-strategy.md`.
128
128
 
129
129
  ### 6. Docs (only if ownership changed)
130
130
 
131
- Update `docs/ARCHITECTURE.md` only if source ownership or the generation pipeline changed — not for every stack. If you added concerns/playbooks, verify `docs/CONTENT_MODEL.md` checklist (concern has one home, `RULES.md` sections resolve).
131
+ Update `docs/maintainers/architecture.md` only if source ownership or the generation pipeline changed — not for every stack. If you added concerns/playbooks, verify `docs/maintainers/content-model.md` checklist (concern has one home, `RULES.md` sections resolve).
132
132
 
133
133
  ## Testing and PRs
134
134
 
135
- - Required checks per `docs/CI_STRATEGY.md`:
135
+ - Required checks per `docs/maintainers/ci-strategy.md`:
136
136
  - `feature -> dev`: `quality` + `compatibility-gate` (repository tests + 10 smoke projects)
137
137
  - `dev -> main`: `quality` + `compatibility-gate` (every profile x stack x arch x applicable auth)
138
138
 
@@ -142,7 +142,7 @@ Update `docs/ARCHITECTURE.md` only if source ownership or the generation pipelin
142
142
 
143
143
  ## Version ownership
144
144
 
145
- Exact versions belong only to `library/tested-versions.json`. Never add a version to a `definition.json` or a `create-files.js`. `packageVersion(profile, name, capability)` and `composerPackageVersion(profile, name)` are the only version sources; they reject ranges and unknown package requests. See `docs/DEPENDENCY_MAINTENANCE.md` for current/previous profile promotion and Renovate flow.
145
+ Exact versions belong only to `library/tested-versions.json`. Never add a version to a `definition.json` or a `create-files.js`. `packageVersion(profile, name, capability)` and `composerPackageVersion(profile, name)` are the only version sources; they reject ranges and unknown package requests. See `docs/maintainers/dependencies.md` for current/previous profile promotion and Renovate flow.
146
146
 
147
147
  ## Docs workflow
148
148
 
@@ -151,4 +151,4 @@ Exact versions belong only to `library/tested-versions.json`. Never add a versio
151
151
  - `playbooks/` — reusable standards; add the five facets per stack (`architecture.md`, `structure.md`, `runtime.md`, `security.md`, `testing.md`).
152
152
  - `docs/guides/` inside generated projects — architecture, API, setup, deployment for *this* product.
153
153
 
154
- Do not advertise a capability solely because a playbook mentions it. A generated capability must have executable configuration and contract coverage. For questions, read `docs/ARCHITECTURE.md` first, then this file.
154
+ Do not advertise a capability solely because a playbook mentions it. A generated capability must have executable configuration and contract coverage. For questions, read `docs/maintainers/architecture.md` first, then this file.
@@ -0,0 +1,13 @@
1
+ # Migrating from 1.x to 2.0
2
+
3
+ Version 2 never overwrites or automatically upgrades an existing project. Commit or back up the project first, generate a new version-2 project with equivalent stack choices, and compare it with the existing application.
4
+
5
+ 1. Run `create-win-project upgrade-report .` when a profile exists; otherwise inventory runtimes, direct dependencies, authentication, CI, deployment, and operations manually.
6
+ 2. Adopt `create-win-project.profile.json` schema 2 and record the stack, dated compatibility profile, production baseline, and capabilities.
7
+ 3. Replace optional/no-test paths with the stack default: full web coverage (including Playwright) or Jest plus React Native Testing Library for Expo.
8
+ 4. Install exact direct versions in a clean working tree and commit the package-manager lockfile. Review resolved transitive and peer changes.
9
+ 5. Port hardened production artifacts and operations guidance. Keep development Docker optional.
10
+ 6. Select uploads, queues, or mobile offline behavior only when required; do not infer them from 1.x advisory concerns.
11
+ 7. Run lint, typecheck, tests, production builds/exports, Compose parsing, and relevant container/database/capability checks before replacing the old baseline.
12
+
13
+ Treat generated files as reference implementations during migration. Merge application-specific behavior deliberately and record approved architecture, provider, authentication, data, or major dependency deviations in `CONTEXT.md`.
@@ -0,0 +1,24 @@
1
+ # Version 2 production contract
2
+
3
+ Version 2 generates a tested, stack-appropriate production baseline. It guarantees deterministic files for the recorded schema-v2 profile, exact tested direct dependency requests, standard tests and CI, production builds, security rules, operations guidance, and cloud-neutral Docker artifacts for deployable web stacks. Expo projects receive an EAS-ready baseline, not automatic store submission.
4
+
5
+ The guarantee is a starting contract, not a claim that an unfinished product is safe to launch. Teams still own domain authorization, infrastructure sizing, secrets, observability targets, data classification, compliance, external-provider configuration, device verification, deployment, backups, and restore drills.
6
+
7
+ ## Dependency ownership
8
+
9
+ `library/tested-versions.json` owns exact direct npm and Composer versions for current and retained profiles. npm and Composer validate peer ranges, resolve transitive packages, and create lockfiles during installation. Generated projects own and commit those lockfiles; the generator does not freeze or silently upgrade their transitive graph.
10
+
11
+ ## Standard baseline
12
+
13
+ - Tests, lint/type checks, production builds, CI, security rules, environment validation, and operations documentation are standard.
14
+ - Vite production uses non-root nginx with SPA fallback, security headers, safe cache policy, and API `no-store`; Next.js retains framework-native caching.
15
+ - Server/database stacks document readiness, graceful shutdown, pooling, migration preflight, encrypted backups, restore verification, retention, deployment, and rollback.
16
+ - Development Docker remains optional. Shared Redis caching, queues, object storage, offline synchronization, and malware scanning appear only for a supported explicit requirement.
17
+
18
+ ## Conditional capabilities
19
+
20
+ Private uploads define authorization, size/signature checks, generated names, quarantine/scanning, cleanup, and rejection tests. Queues define bounded retry, idempotency, timeouts, failed-job handling, correlation, and replay. Mobile cache/sync defines ownership, key namespaces, TTL, invalidation, privacy, reconnect states, and conflict handling. Unsupported combinations fail before any destination is written.
21
+
22
+ ## Support and recovery
23
+
24
+ The current and previous dated profiles are supported through their catalog dates. Run `create-win-project upgrade-report [path]` for a read-only comparison; it never modifies an existing project. Major deviations require approval and a decision record in generated `CONTEXT.md`.
package/library/INDEX.md CHANGED
@@ -55,4 +55,4 @@ Manifests compose capabilities; `lib/scaffold.js` owns their executable minimum.
55
55
  - `playbooks/`: only selected reusable guidance.
56
56
  - `docs/`: setup, API, architecture, auth, and deployment for the generated product.
57
57
 
58
- See `docs/CONTENT_MODEL.md` for authoring and deduplication rules and `docs/ARCHITECTURE.md` for the generation pipeline.
58
+ See `docs/maintainers/content-model.md` for authoring and deduplication rules and `docs/maintainers/architecture.md` for the generation pipeline.
@@ -0,0 +1,14 @@
1
+ {
2
+ "stacks": {
3
+ "nextjs": ["src/stacks/frontends/nextjs/", "library/stacks/nextjs/", "templates/agents/nextjs.", "templates/ci/nextjs."],
4
+ "react": ["src/stacks/frontends/react-vite/", "library/stacks/react-vite/", "templates/agents/react-vite.", "templates/ci/vite."],
5
+ "react-native": ["src/stacks/frontends/react-native/", "library/stacks/expo/", "templates/agents/react-native.", "templates/ci/expo."],
6
+ "springboot": ["src/stacks/backends/springboot/", "library/stacks/springboot/", "library/features/flyway/", "templates/ci/springboot."],
7
+ "fastapi": ["src/stacks/backends/fastapi/", "library/stacks/fastapi/", "library/features/sqlalchemy-alembic.md", "templates/ci/fastapi."],
8
+ "laravel": ["src/stacks/backends/laravel/", "library/stacks/laravel/", "library/features/laravel", "templates/ci/laravel."],
9
+ "supabase": ["src/stacks/backends/supabase/", "library/features/supabase/"],
10
+ "postgres": ["src/stacks/backends/postgres/", "library/features/postgresql/", "library/features/prisma/"],
11
+ "none": ["src/stacks/backends/none/"]
12
+ },
13
+ "shared": ["library/tested-versions.json", "lib/", "src/engine/", "src/stacks/shared/", "templates/docker/", "templates/gitignore/", "templates/makefile/", "checks/check-compatibility.js", "checks/check-generated-project.js"]
14
+ }
@@ -0,0 +1,11 @@
1
+ # Make commands
2
+
3
+ ## Core Rules
4
+
5
+ - Targets wrap documented project commands; they do not hide different behavior.
6
+ - Declare non-file targets with `.PHONY`.
7
+ - Use tabs for recipes and `$(VARIABLE)` for configurable values.
8
+ - Keep the default target safe and read-only; `help` or `check` is preferred.
9
+ - Fail on command errors and preserve the underlying exit status.
10
+
11
+ Use small targets such as `install`, `dev`, `lint`, `test`, `build`, and `check`. Compose them instead of duplicating recipes.
@@ -2,10 +2,10 @@
2
2
  "id": "makefile",
3
3
  "kind": "devops",
4
4
  "label": "Makefile",
5
- "file": "devops/makefile.md",
5
+ "playbooks": ["capabilities/devops/makefile/commands.md", "capabilities/devops/makefile/docker.md", "capabilities/devops/makefile/validation.md"],
6
6
  "required": false,
7
7
  "folders": [],
8
8
  "concerns": [
9
- { "id": "makefile", "required": true, "sections": ["Core Rules"] }
9
+ { "id": "makefile", "required": true, "playbook": "capabilities/devops/makefile/commands.md", "sections": ["Core Rules"] }
10
10
  ]
11
11
  }
@@ -0,0 +1,9 @@
1
+ # Make and Docker
2
+
3
+ ## Docker Targets
4
+
5
+ - Keep image building separate from container startup.
6
+ - `build` may run `docker compose build`; `run` must not rebuild implicitly.
7
+ - Use the generated Compose file as the source of service names and profiles.
8
+ - Never interpolate secrets into command output.
9
+ - Destructive volume or database targets require explicit names and confirmation.
@@ -0,0 +1,5 @@
1
+ # Make validation
2
+
3
+ ## Validation Targets
4
+
5
+ `check` should compose the same lint, typecheck, test, and build commands used by CI. Keep focused targets independently runnable, and avoid suppressing failures with leading `-`, `|| true`, or unconditional success messages.
@@ -0,0 +1,17 @@
1
+ # SQLAlchemy and Alembic
2
+
3
+ ## Session Ownership
4
+
5
+ Use SQLAlchemy 2 async sessions with `asyncpg`. Services own session and transaction
6
+ boundaries spanning multiple writes or read-modify-write behavior. Routers never manage
7
+ sessions directly; they receive a session dependency from shared core infrastructure.
8
+
9
+ Database unique/check/foreign-key constraints are the final concurrency boundary; map
10
+ expected constraint conflicts to stable application errors.
11
+
12
+ ## Migrations
13
+
14
+ Alembic owns all schema changes. Generate revisions explicitly and apply them with
15
+ `alembic upgrade head` from the backend directory. Application startup must not
16
+ automatically migrate production databases. Verify migration configuration and upgrade
17
+ checks in CI before container builds.
@@ -0,0 +1,5 @@
1
+ # Zod validation errors
2
+
3
+ ## Safe Validation Errors
4
+
5
+ Convert issues to stable field/code structures at the boundary. Do not expose internal paths, secrets, provider payloads, or raw exception text. Log diagnostic context server-side with request correlation and privacy filtering.
@@ -0,0 +1,5 @@
1
+ # Testing Zod schemas
2
+
3
+ ## Schema Tests
4
+
5
+ Test valid boundaries, missing required values, wrong types, limits, unknown keys, and security-sensitive malformed input. Prefer small representative fixtures and assert stable error codes rather than complete library messages.
@@ -0,0 +1,21 @@
1
+ # Runtime validation with Zod
2
+
3
+ ## Agent Quick Reference
4
+
5
+ Parse untrusted values once at their owning boundary, use the inferred type internally, and return safe structured errors.
6
+
7
+ ## Schema First, Always
8
+
9
+ Define the runtime contract before consuming external data. Use strict schemas for requests, environment variables, persisted data, and provider responses. Apply coercion only when the transport contract explicitly permits it.
10
+
11
+ ## Zod Schema Placement
12
+
13
+ Place a schema at the boundary that owns the contract. Feature schemas stay with the feature; shared protocol schemas live in a dependency-neutral contract module. Export inferred types rather than duplicating shapes.
14
+
15
+ ## Web Form (React Hook Form)
16
+
17
+ Use the schema resolver at submission boundaries, show field errors accessibly, and validate again on the server. Client validation improves feedback but never establishes trust.
18
+
19
+ ## React Native Form (React Hook Form + Controller)
20
+
21
+ Wrap controlled native inputs with `Controller`, preserve accessible labels and errors, and validate the same transport contract again at the trusted server boundary.
@@ -2,10 +2,11 @@
2
2
  "id": "css-modules",
3
3
  "kind": "styling",
4
4
  "label": "CSS Modules",
5
- "file": "styling/css-modules-extensions.md",
5
+ "playbooks": ["styling/css-modules/theme.md", "styling/css-modules/responsive.md"],
6
6
  "required": false,
7
7
  "folders": [],
8
8
  "concerns": [
9
- { "id": "styling", "required": true, "sections": ["Dark Mode with CSS Variables", "Responsive in Module File"] }
9
+ { "id": "styling-theme", "required": true, "playbook": "styling/css-modules/theme.md", "sections": ["Dark Mode with CSS Variables"] },
10
+ { "id": "styling-responsive", "required": true, "playbook": "styling/css-modules/responsive.md", "sections": ["Responsive in Module File"] }
10
11
  ]
11
12
  }
@@ -0,0 +1,5 @@
1
+ # CSS Modules responsive layout
2
+
3
+ ## Responsive in Module File
4
+
5
+ Keep component breakpoints beside the component styles. Start with the narrow layout, add only measured breakpoints, and prefer container-aware layout when the component is reusable. Avoid global selectors and viewport assumptions inside modules.
@@ -0,0 +1,7 @@
1
+ # CSS Modules theming
2
+
3
+ ## Dark Mode with CSS Variables
4
+
5
+ Define semantic color and spacing variables at the application theme boundary. Switch variable values through the selected theme mechanism; components consume semantic tokens and must not duplicate light/dark selectors.
6
+
7
+ Respect system preference by default, preserve explicit user choice, and maintain accessible contrast in every supported theme.
@@ -4,7 +4,7 @@
4
4
  "label": "React Native (Expo)",
5
5
  "language": "TypeScript",
6
6
  "platform": "mobile",
7
- "appliesTo": { "backend": ["supabase", "springboot", "laravel", "none"] },
7
+ "appliesTo": { "backend": ["supabase", "springboot", "laravel", "none", "fastapi"] },
8
8
  "port": 8081,
9
9
  "needsDocker": false,
10
10
  "frontendDir": "",
@@ -44,6 +44,6 @@
44
44
  { "id": "http-client", "required": false, "when": "The app adopts Axios for a REST API", "playbook": "concerns/axios.md", "sections": ["One Shared Client", "Service Calls apiClient, Hook Calls Service"] },
45
45
  { "id": "query", "required": false, "when": "The app needs cached remote server state", "playbook": "concerns/tanstack-query.md", "sections": ["Read Hook", "Mutation Hook", "QueryClient Setup"] },
46
46
  { "id": "state", "required": false, "when": "Shared state across multiple screens", "playbook": "concerns/zustand.md", "sections": ["Store Setup", "Auth Store Pattern"] },
47
- { "id": "validation", "required": false, "when": "Project has forms", "playbook": "concerns/zod.md", "sections": ["Schema First, Always", "React Native Form (React Hook Form + Controller)"] }
47
+ { "id": "validation", "required": false, "when": "Project has forms", "playbook": "concerns/zod/validation.md", "sections": ["Schema First, Always", "React Native Form (React Hook Form + Controller)"] }
48
48
  ]
49
49
  }
@@ -0,0 +1,40 @@
1
+ # FastAPI Architecture
2
+
3
+ ## Profiles
4
+
5
+ ### Small
6
+
7
+ Use a compact application package with configuration, database, security, and route
8
+ modules. Do not add service/repository layers that have only one caller or split a
9
+ simple operation into ceremonial layers.
10
+
11
+ ```text
12
+ HTTP → Router → Service function → AsyncSession → PostgreSQL
13
+ ```
14
+
15
+ ### Medium (default)
16
+
17
+ Keep feature-oriented routers, services, repositories, schemas, and shared core
18
+ infrastructure explicit. Services own transaction boundaries and reusable operations.
19
+ Features communicate through clear service APIs rather than reaching into repositories.
20
+
21
+ ### Large
22
+
23
+ Build bounded feature modules with explicit public module interfaces. A feature exposes
24
+ a small router/service API and keeps repository and schema implementation internal.
25
+ Verify no cycles, no access to internals, and only declared module dependencies with
26
+ the generated architecture-boundary tests. Large does not mean microservices.
27
+
28
+ ## Dependency Direction
29
+
30
+ ```text
31
+ web/API → application operation → domain policy → persistence/external adapter
32
+ ```
33
+
34
+ - Routers translate HTTP and never touch the database session directly.
35
+ - Services do not return HTTP responses or depend on route details.
36
+ - Repositories contain persistence queries, not application policy.
37
+ - Cross-feature work calls a public operation or publishes a deliberate event.
38
+ - External side effects are not assumed successful merely because a transaction commits.
39
+
40
+ Start at the selected project baseline and let each feature create only the files it uses.
@@ -0,0 +1,39 @@
1
+ {
2
+ "id": "fastapi",
3
+ "kind": "backend",
4
+ "label": "FastAPI",
5
+ "language": "Python",
6
+ "appliesTo": { "frontend": ["nextjs", "react", "react-native", "no-frontend"] },
7
+ "port": 8000,
8
+ "needsDocker": true,
9
+ "architectureProfiles": ["small", "medium", "large"],
10
+ "playbooks": [
11
+ "stack/fastapi/architecture.md",
12
+ "stack/fastapi/structure.md",
13
+ "stack/fastapi/runtime.md",
14
+ "stack/fastapi/security.md",
15
+ "stack/fastapi/testing.md",
16
+ "capabilities/sqlalchemy-alembic.md",
17
+ { "file": "capabilities/auth/oidc-resource-server.md", "appliesWhen": { "authentication": "oidc" } }
18
+ ],
19
+ "makefileTemplate": "fastapi",
20
+ "folders": [],
21
+ "deps": [],
22
+ "devDeps": [],
23
+ "env": ["API_URL", "DATABASE_URL", "POSTGRES_USER", "POSTGRES_PASSWORD", "POSTGRES_DB", "OIDC_ISSUER", "OIDC_AUDIENCE", "OIDC_ALGORITHMS", "OIDC_JWKS_URL", "CORS_ALLOWED_ORIGINS"],
24
+ "clientEnv": ["API_URL"],
25
+ "constraints": [
26
+ "FastAPI owns server-side business logic, authorization, and data access",
27
+ "Security starts deny-by-default; add authentication through OIDC bearer validation rather than hand-rolled token code",
28
+ "Application startup must not automatically migrate production databases"
29
+ ],
30
+ "concerns": [
31
+ { "id": "architecture", "required": true, "playbook": "stack/fastapi/architecture.md", "sections": ["Profiles", "Dependency Direction"] },
32
+ { "id": "structure", "required": true, "playbook": "stack/fastapi/structure.md", "sections": ["Package by Feature"] },
33
+ { "id": "runtime", "required": true, "playbook": "stack/fastapi/runtime.md", "sections": ["Configuration and Lifecycle", "Errors and Observability"] },
34
+ { "id": "stack-security", "required": true, "playbook": "stack/fastapi/security.md", "sections": ["Authentication Models", "Authorization"] },
35
+ { "id": "stack-testing", "required": true, "playbook": "stack/fastapi/testing.md", "sections": ["Test Layers"] },
36
+ { "id": "persistence", "required": true, "playbook": "capabilities/sqlalchemy-alembic.md", "sections": ["Session Ownership", "Migrations"] },
37
+ { "id": "oidc-auth", "required": true, "appliesWhen": { "authentication": "oidc" }, "playbook": "capabilities/auth/oidc-resource-server.md", "sections": ["Provider and API Responsibilities", "Required Tests"] }
38
+ ]
39
+ }
@@ -0,0 +1,25 @@
1
+ # FastAPI Runtime
2
+
3
+ ## Configuration and Lifecycle
4
+
5
+ Configuration comes from validated Pydantic Settings and environment-specific deployment
6
+ values. The application exposes public `GET /health` and dependency-aware `GET /ready`
7
+ readiness separately. Readiness verifies dependencies required to serve traffic.
8
+
9
+ Manage dependencies with uv and a frozen lockfile (`uv sync --frozen`). Run with
10
+ Uvicorn. Keep schema changes owned by Alembic migrations invoked explicitly via
11
+ `alembic upgrade head`; application startup must not automatically migrate production
12
+ databases.
13
+
14
+ ## Errors and Observability
15
+
16
+ Services raise typed application exceptions with stable error codes and no HTTP types.
17
+ Exception handlers map them to RFC 9457 problem details. Include a safe code and
18
+ trace ID; never expose stack traces, SQL, internal hosts, credentials, or sensitive fields.
19
+
20
+ Use structured PII-safe events. Do not log whole requests, passwords, tokens, cookies, or
21
+ email addresses by default.
22
+
23
+ Configure exact-origin CORS from `CORS_ALLOWED_ORIGINS`. Store uploads outside the
24
+ application tree under generated object keys; validate size and content and route
25
+ untrusted files through the product's scanning/quarantine process.
@@ -0,0 +1,26 @@
1
+ # FastAPI Security
2
+
3
+ ## Authentication Models
4
+
5
+ The generated authentication choice is authoritative:
6
+
7
+ - `public`: no user accounts; generated application endpoints are intentionally public.
8
+ - `undecided`: health is public and every other endpoint is denied until auth is designed.
9
+ - `oidc`: an external identity provider owns login, refresh, rotation, and revocation;
10
+ FastAPI validates bearer issuer, audience, algorithm, JWKS signature, expiry, and claims
11
+ on every protected API request. Session authentication is not offered.
12
+
13
+ Never turn the API into a home-grown authorization server from a short JWT example.
14
+
15
+ ## Authorization
16
+
17
+ Route dependencies provide a broad baseline. Enforce feature permissions and resource
18
+ ownership at the application operation or protected data boundary with explicit
19
+ dependencies. Test unauthenticated, authenticated-but-forbidden, and allowed cases.
20
+
21
+ - Keep public health endpoints separate from protected API routes.
22
+ - Configure OIDC issuer, audience, allowed algorithms, JWKS retrieval, and claim
23
+ validation from environment; deny by default.
24
+ - Configure exact-origin CORS. Never combine credentials with wildcard origin.
25
+ - Rate limit login, recovery, and other abuse-sensitive operations.
26
+ - Treat role claims as inputs to server policy, not proof of resource ownership.
@@ -0,0 +1,27 @@
1
+ # FastAPI Structure
2
+
3
+ ## Package by Feature
4
+
5
+ Place the application entrypoint in the `app` package. Organize business code below it by
6
+ feature, never in one global router/service/repository layer.
7
+
8
+ ```text
9
+ app/
10
+ ├── main.py
11
+ ├── core/ settings, database, security, logging (Medium/Large)
12
+ ├── modules/status/ router, service, repository, schemas (Large)
13
+ ├── features/status/ router, service, repository, schemas (Medium)
14
+ └── routes_health.py public health/readiness (Small)
15
+ ```
16
+
17
+ Small may keep the few feature modules directly under `app/`. Medium uses the named
18
+ `features/` packages when multiple files make ownership clearer. Large exposes types in
19
+ the module base/`__init__.py` public interface and places implementation in submodules
20
+ as required by the generated boundary tests.
21
+
22
+ Backend-only projects live at the repository root. Paired backends live under `backend/`.
23
+
24
+ - Use explicit imports; re-export only the public module interface from `__init__.py`.
25
+ - Prefer Pydantic v2 models for transport schemas; keep ORM models persistence-only.
26
+ - Do not invent users, products, or other business entities in the baseline.
27
+ - Use database-native identity types and constraints deliberately.
@@ -0,0 +1,23 @@
1
+ # FastAPI Testing
2
+
3
+ ## Test Layers
4
+
5
+ | Risk | Test |
6
+ |---|---|
7
+ | Pure policy/value object | pytest unit test |
8
+ | Service orchestration/error code | Focused unit test with boundary fakes |
9
+ | Router validation/error/security | HTTPX async test without a database |
10
+ | Custom repository/Alembic/constraints | PostgreSQL integration test |
11
+ | Feature module | Module integration test |
12
+ | Large boundaries | Generated boundary test (no internal imports) |
13
+
14
+ Do not use SQLite as proof that PostgreSQL queries or migrations work. Standard CRUD
15
+ methods need no dedicated test, but custom queries, constraints, locking, and migrations do.
16
+
17
+ Test behavior and risk rather than every public function or mock call. Authentication tests
18
+ cover missing bearer tokens and invalid issuer, audience, signature, expiry, and required
19
+ claims. Authorization tests include resource ownership, not roles alone.
20
+
21
+ Every profile runs `ruff check`, `ruff format --check`, `mypy`, and `pytest`. Full testing
22
+ runs PostgreSQL integration tests; Large additionally fails on cycles and access to
23
+ module internals.
@@ -4,7 +4,7 @@
4
4
  "label": "Next.js",
5
5
  "language": "TypeScript",
6
6
  "platform": "web",
7
- "appliesTo": { "backend": ["none", "supabase", "springboot", "postgres", "laravel"] },
7
+ "appliesTo": { "backend": ["none", "supabase", "springboot", "postgres", "laravel", "fastapi"] },
8
8
  "port": 3000,
9
9
  "needsDocker": false,
10
10
  "frontendDir": "",
@@ -38,7 +38,7 @@
38
38
  { "id": "runtime", "required": true, "playbook": "stack/nextjs/runtime.md", "sections": ["Server and Client", "Caching and Mutations"] },
39
39
  { "id": "stack-security", "required": true, "playbook": "stack/nextjs/security.md", "sections": ["Authorization", "Sessions"] },
40
40
  { "id": "stack-testing", "required": true, "playbook": "stack/nextjs/testing.md", "sections": ["Test Layers"] },
41
- { "id": "validation", "required": false, "when": "Project has forms / runtime input", "playbook": "concerns/zod.md", "sections": ["Schema First, Always", "Zod Schema Placement"] },
41
+ { "id": "validation", "required": false, "when": "Project has forms / runtime input", "playbook": "concerns/zod/validation.md", "sections": ["Schema First, Always", "Zod Schema Placement"] },
42
42
  { "id": "query", "required": false, "when": "Client needs cached server state", "playbook": "concerns/tanstack-query.md", "sections": ["Read Hook", "Mutation Hook"] },
43
43
  { "id": "state", "required": false, "when": "Shared non-server UI state", "playbook": "concerns/zustand.md", "sections": ["Store Setup"] },
44
44
  { "id": "env", "required": false, "when": "Validating env vars at build time", "playbook": "concerns/t3-env.md", "sections": ["Setup"] },
@@ -3,7 +3,7 @@
3
3
  "kind": "frontend",
4
4
  "label": "No frontend",
5
5
  "platform": "api",
6
- "appliesTo": { "backend": ["springboot", "laravel"] },
6
+ "appliesTo": { "backend": ["springboot", "laravel", "fastapi"] },
7
7
  "port": 0,
8
8
  "needsDocker": false,
9
9
  "frontendDir": "",
@@ -4,7 +4,7 @@
4
4
  "label": "React + Vite",
5
5
  "language": "TypeScript",
6
6
  "platform": "web",
7
- "appliesTo": { "backend": ["none", "supabase", "springboot", "laravel"] },
7
+ "appliesTo": { "backend": ["none", "supabase", "springboot", "laravel", "fastapi"] },
8
8
  "port": 5173,
9
9
  "needsDocker": false,
10
10
  "frontendDir": "frontend",
@@ -39,7 +39,7 @@
39
39
  { "id": "stack-security", "required": true, "playbook": "stack/react-vite/security.md", "sections": ["Browser Trust Boundary"] },
40
40
  { "id": "stack-testing", "required": true, "playbook": "stack/react-vite/testing.md", "sections": ["Test Layers"] },
41
41
  { "id": "http-client", "required": false, "when": "The app adopts Axios instead of the native fetch client", "playbook": "concerns/axios.md", "sections": ["One Shared Client", "Service Calls apiClient, Hook Calls Service"] },
42
- { "id": "validation", "required": false, "when": "Project has forms / runtime input", "playbook": "concerns/zod.md", "sections": ["Schema First, Always", "Web Form (React Hook Form)"] },
42
+ { "id": "validation", "required": false, "when": "Project has forms / runtime input", "playbook": "concerns/zod/validation.md", "sections": ["Schema First, Always", "Web Form (React Hook Form)"] },
43
43
  { "id": "query", "required": false, "when": "Client needs cached server state", "playbook": "concerns/tanstack-query.md", "sections": ["Read Hook", "Mutation Hook"] },
44
44
  { "id": "state", "required": false, "when": "Shared UI state across pages", "playbook": "concerns/zustand.md", "sections": ["Store Setup"] }
45
45
  ]