Context
Org practice is DDD + monorepo whenever FE and BE ship together. Add a --layout monorepo (default flat) that, when a backend is selected, emits a pnpm-workspace monorepo instead of a colocated single package.
Chosen shape (pragmatic layered)
<name>/
package.json # private workspace root: scripts + packageManager
pnpm-workspace.yaml # apps/*, packages/*
apps/
web/ # the current frontend scaffold + its package.json
api/ # backend (hono/elysia + orm/db) + its package.json [only if --backend]
packages/
domain/ # shared contract: zod schemas + types (workspace:* dep)
- Tooling: pnpm workspaces (matches default PM).
packages/domain is the shared kernel; when --validation zod it ships an example schema, otherwise plain TS types. Both apps depend on it via workspace:*.
Scope
pkg/config.go: Layout enum + field (flat|monorepo), default flat
cmd/create.go: --layout flag + validation
pkg/scaffold.go: layout-aware roots — FE → apps/web, backend/orm → apps/api, plus root workspace files + packages/domain
pkg/packagejson.go: split package.json generation (web / api / domain / root); FE build skips backend/orm deps in monorepo mode
config/templates/monorepo/*: root package.json, pnpm-workspace.yaml, domain package, api tsconfig
- Tests
Notes / out of scope
Context
Org practice is DDD + monorepo whenever FE and BE ship together. Add a
--layout monorepo(defaultflat) that, when a backend is selected, emits a pnpm-workspace monorepo instead of a colocated single package.Chosen shape (pragmatic layered)
packages/domainis the shared kernel; when--validation zodit ships an example schema, otherwise plain TS types. Both apps depend on it viaworkspace:*.Scope
pkg/config.go:Layoutenum + field (flat|monorepo), default flatcmd/create.go:--layoutflag + validationpkg/scaffold.go: layout-aware roots — FE → apps/web, backend/orm → apps/api, plus root workspace files + packages/domainpkg/packagejson.go: split package.json generation (web / api / domain / root); FE build skips backend/orm deps in monorepo modeconfig/templates/monorepo/*: root package.json, pnpm-workspace.yaml, domain package, api tsconfigNotes / out of scope
main.--backendis set — deferred.