@yosr-ai/template-next-fullstack 0.0.0-stage → 0.1.0-alpha.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 (125) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +15 -2
  3. package/features/api-trpc/files/src/app/api/trpc/[trpc]/route.ts +15 -0
  4. package/features/api-trpc/files/src/app/trpc-provider.tsx +27 -0
  5. package/features/api-trpc/files/src/features/notes/components/note-form.tsx +48 -0
  6. package/features/api-trpc/files/src/server/api/context.ts +10 -0
  7. package/features/api-trpc/files/src/server/api/notes.test.ts +30 -0
  8. package/features/api-trpc/files/src/server/api/notes.ts +42 -0
  9. package/features/api-trpc/files/src/server/api/root.ts +8 -0
  10. package/features/api-trpc/files/src/server/api/trpc.ts +8 -0
  11. package/features/api-trpc/snippets/providers-imports.tsx +2 -0
  12. package/features/api-trpc/snippets/providers.tsx +1 -0
  13. package/features/auth-authjs/files/e2e/sign-in.spec.ts +10 -0
  14. package/features/auth-authjs/files/src/app/api/auth/[...nextauth]/route.ts +12 -0
  15. package/features/auth-authjs/files/src/app/auth-session-provider.tsx +8 -0
  16. package/features/auth-authjs/files/src/app/sign-in/page.tsx +19 -0
  17. package/features/auth-authjs/files/src/server/auth/config.ts +28 -0
  18. package/features/auth-authjs/files/src/server/auth/index.ts +15 -0
  19. package/features/auth-authjs/snippets/providers-imports.tsx +2 -0
  20. package/features/auth-authjs/snippets/providers.tsx +1 -0
  21. package/features/auth-authjs-drizzle/files/src/server/db/auth-tables.ts +86 -0
  22. package/features/auth-authjs-drizzle/snippets/adapter-db-imports.ts +8 -0
  23. package/features/auth-authjs-drizzle/snippets/adapter-imports.ts +1 -0
  24. package/features/auth-authjs-drizzle/snippets/adapter.ts +7 -0
  25. package/features/auth-authjs-drizzle/snippets/auth-tables.ts +7 -0
  26. package/features/auth-authjs-prisma/snippets/adapter-db-imports.ts +1 -0
  27. package/features/auth-authjs-prisma/snippets/adapter-imports.ts +1 -0
  28. package/features/auth-authjs-prisma/snippets/adapter.ts +1 -0
  29. package/features/auth-authjs-prisma/snippets/auth-models.prisma +58 -0
  30. package/features/auth-clerk/files/e2e/sign-in.spec.ts +15 -0
  31. package/features/auth-clerk/files/src/app/clerk-app-provider.tsx +13 -0
  32. package/features/auth-clerk/files/src/app/sign-in/[[...sign-in]]/page.tsx +18 -0
  33. package/features/auth-clerk/files/src/app/sign-up/[[...sign-up]]/page.tsx +18 -0
  34. package/features/auth-clerk/files/src/proxy.ts +24 -0
  35. package/features/auth-clerk/files/src/server/auth/index.ts +11 -0
  36. package/features/auth-clerk/snippets/providers-imports.tsx +2 -0
  37. package/features/auth-clerk/snippets/providers.tsx +1 -0
  38. package/features/deploy-docker/files/.dockerignore +6 -0
  39. package/features/deploy-docker/files/Dockerfile +24 -0
  40. package/features/deploy-docker/files/compose.yaml +6 -0
  41. package/features/deploy-docker-npm/files/Dockerfile +24 -0
  42. package/features/deploy-docker-postgres/snippets/postgres-service.yaml +4 -0
  43. package/features/deploy-vercel/snippets/readme-deploy.md +3 -0
  44. package/features/orm-drizzle/files/drizzle.config.ts +8 -0
  45. package/features/orm-drizzle/files/src/features/notes/notes-store.ts +21 -0
  46. package/features/orm-drizzle/files/src/server/db/index.ts +20 -0
  47. package/features/orm-drizzle/files/src/server/db/schema.ts +11 -0
  48. package/features/orm-drizzle/snippets/ci-e2e-setup.yaml +1 -0
  49. package/features/orm-drizzle/snippets/ci-job.yaml +11 -0
  50. package/features/orm-drizzle/snippets/readme-db.md +4 -0
  51. package/features/orm-prisma/files/prisma/schema.prisma +18 -0
  52. package/features/orm-prisma/files/prisma.config.ts +13 -0
  53. package/features/orm-prisma/files/src/features/notes/notes-store.ts +13 -0
  54. package/features/orm-prisma/files/src/server/db/index.ts +20 -0
  55. package/features/orm-prisma/snippets/ci-e2e-setup.yaml +1 -0
  56. package/features/orm-prisma/snippets/ci-job.yaml +11 -0
  57. package/features/orm-prisma/snippets/readme-db.md +4 -0
  58. package/features/payments-stripe/files/src/app/api/checkout/route.ts +27 -0
  59. package/features/payments-stripe/files/src/app/api/webhooks/stripe/route.ts +18 -0
  60. package/features/payments-stripe/files/src/server/billing/billing.test.ts +113 -0
  61. package/features/payments-stripe/files/src/server/billing/index.ts +102 -0
  62. package/features/payments-stripe/files/src/server/billing/stripe.ts +10 -0
  63. package/features/payments-stripe-drizzle/files/src/server/billing/store.ts +39 -0
  64. package/features/payments-stripe-drizzle/snippets/billing-tables.ts +13 -0
  65. package/features/payments-stripe-prisma/files/src/server/billing/store.ts +30 -0
  66. package/features/payments-stripe-prisma/snippets/billing-models.prisma +17 -0
  67. package/files/.env.example +1 -0
  68. package/files/.github/workflows/ci.yml +25 -0
  69. package/files/.prettierignore +7 -0
  70. package/files/.prettierrc.json +1 -0
  71. package/files/README.md +18 -0
  72. package/files/components.json +20 -0
  73. package/files/e2e/smoke.spec.ts +16 -0
  74. package/files/eslint.config.mjs +21 -0
  75. package/files/gitignore +25 -0
  76. package/files/next.config.ts +7 -0
  77. package/files/package.json +42 -0
  78. package/files/playwright.config.ts +20 -0
  79. package/files/pnpm-workspace.yaml +16 -0
  80. package/files/postcss.config.mjs +7 -0
  81. package/files/src/app/globals.css +68 -0
  82. package/files/src/app/layout.tsx +22 -0
  83. package/files/src/app/page.tsx +21 -0
  84. package/files/src/app/providers.tsx +15 -0
  85. package/files/src/components/ui/button.tsx +59 -0
  86. package/files/src/components/ui/input.tsx +21 -0
  87. package/files/src/features/notes/actions.ts +22 -0
  88. package/files/src/features/notes/components/note-form.tsx +32 -0
  89. package/files/src/features/notes/components/note-list.tsx +23 -0
  90. package/files/src/features/notes/create-note.test.ts +27 -0
  91. package/files/src/features/notes/create-note.ts +23 -0
  92. package/files/src/features/notes/note-schema.ts +13 -0
  93. package/files/src/features/notes/notes-store.ts +17 -0
  94. package/files/src/shared/utils.test.ts +13 -0
  95. package/files/src/shared/utils.ts +6 -0
  96. package/files/tsconfig.json +35 -0
  97. package/files/vitest.config.mts +9 -0
  98. package/package.json +26 -4
  99. package/rules/api-server-actions.md +1 -0
  100. package/rules/api-trpc.md +1 -0
  101. package/rules/architecture.md +11 -0
  102. package/rules/auth-authjs.md +1 -0
  103. package/rules/auth-clerk.md +1 -0
  104. package/rules/commands.md +5 -0
  105. package/rules/data-drizzle.md +1 -0
  106. package/rules/data-none.md +1 -0
  107. package/rules/data-prisma.md +1 -0
  108. package/rules/data-server-first.md +1 -0
  109. package/rules/errors-result.md +1 -0
  110. package/rules/errors-throw.md +1 -0
  111. package/rules/forms-zod.md +1 -0
  112. package/rules/layout-feature.md +5 -0
  113. package/rules/layout-flat.md +5 -0
  114. package/rules/layout-layer.md +6 -0
  115. package/rules/payments-stripe.md +1 -0
  116. package/rules/project-overview.md +5 -0
  117. package/rules/tests-colocated.md +1 -0
  118. package/rules/tests-folder.md +1 -0
  119. package/rules/tests-separate.md +1 -0
  120. package/rules/ui-shadcn.md +1 -0
  121. package/seed.template.json +1714 -0
  122. package/style/errors-result/files/src/features/notes/actions.ts +18 -0
  123. package/style/errors-result/files/src/features/notes/create-note.test.ts +30 -0
  124. package/style/errors-result/files/src/features/notes/create-note.ts +16 -0
  125. package/style/errors-result/files/src/shared/result.ts +12 -0
package/package.json CHANGED
@@ -1,6 +1,28 @@
1
1
  {
2
2
  "name": "@yosr-ai/template-next-fullstack",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "Yosr Seed next-fullstack template.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/getyosr/yosr-seed.git",
9
+ "directory": "packages/template-next-fullstack"
10
+ },
11
+ "type": "module",
12
+ "exports": {
13
+ "./package.json": "./package.json",
14
+ "./seed.template.json": "./seed.template.json"
15
+ },
16
+ "files": [
17
+ "README.md",
18
+ "CHANGELOG.md",
19
+ "seed.template.json",
20
+ "files",
21
+ "features",
22
+ "style",
23
+ "rules"
24
+ ],
25
+ "engines": {
26
+ "node": ">=24"
27
+ }
28
+ }
@@ -0,0 +1 @@
1
+ Mutations go through **server actions** (`"use server"` files such as `actions.ts`). Actions validate input with zod, call feature functions, and `revalidatePath` what changed. No ad-hoc API routes for app data.
@@ -0,0 +1 @@
1
+ App data mutations go through tRPC procedures under `__seed_serverDir__/api`. The HTTP handler is `src/app/api/trpc/[trpc]/route.ts`. The notes form calls `notes.create`, which calls `createNote` from `@domain/notes`. Do not call `db()` at module scope.
@@ -0,0 +1,11 @@
1
+ # Architecture: __seed_projectName__
2
+
3
+ Generated by Yosr Seed from `__seed_templateName__@__seed_templateVersion__`. This note is for humans and AI agents; keep it current when the structure changes.
4
+
5
+ ## Stack
6
+
7
+ Next.js (App Router) + TypeScript, Tailwind CSS v4 + shadcn/ui, Vitest (unit) + Playwright (e2e smoke), package manager `__seed_packageManager__`. Data: __seed_storageLabel__. Deploy target: __seed_deploy__.
8
+
9
+ ## Request flow
10
+
11
+ `src/app/page.tsx` (Server Component) reads notes through the feature store, renders `NoteForm` (client) and `NoteList` (server). The form posts to a server action, which validates with zod, stores the note and revalidates the page.
@@ -0,0 +1 @@
1
+ Sign-in is GitHub OAuth and Google OAuth only. No email, magic link, or credentials. Sessions are stored in Postgres (`session.strategy: "database"`). The route is `src/app/api/auth/[...nextauth]/route.ts`. Read the server session with `auth()` from `@server/auth`. Stripe checkout uses `sessionEmail()` from the same module. Do not call `db()` at module scope; the adapter calls it from `authOptions()`. Auth tables live in the active ORM schema (`__seed_serverDir__/db/schema.ts` for Drizzle, `prisma/schema.prisma` for Prisma). After changing them, run `__seed_pmRun__ db:push`.
@@ -0,0 +1 @@
1
+ Sign-in is Clerk. It works with or without a database. The provider is `ClerkAppProvider` in `src/app/providers.tsx`. The request gate is `src/proxy.ts`, which calls `clerkMiddleware` from `@clerk/nextjs/server` only when `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` and `CLERK_SECRET_KEY` are both set. Sign-in is `src/app/sign-in/[[...sign-in]]/page.tsx`. Sign-up is `src/app/sign-up/[[...sign-up]]/page.tsx`. When the publishable key is unset, those pages render local markup and do not call Clerk. `sessionEmail()` in `__seed_serverDir__/auth/index.ts` calls `currentUser()` only when checkout runs.
@@ -0,0 +1,5 @@
1
+ Use the project's package manager (`__seed_packageManager__`):
2
+
3
+ - `__seed_pmRun__ lint`, `__seed_pmRun__ typecheck`, `__seed_pmRun__ build`, `__seed_pmRun__ test` must all pass before you finish a change.
4
+ - `__seed_pmRun__ format` formats with Prettier; don't hand-format.
5
+ - `__seed_pmRun__ test:e2e` runs the Playwright smoke test (builds and starts the app).
@@ -0,0 +1 @@
1
+ Postgres via Drizzle. Tables are defined in `__seed_serverDir__/db/schema.ts`; get the client with `db()` from `@server/db`. Database access belongs in the feature's store module (see the notes store), not in components or routes. After changing the schema run `__seed_pmExec__ drizzle-kit push` (dev) or generate a migration with `__seed_pmRun__ db:generate`.
@@ -0,0 +1 @@
1
+ There is **no database**. The example store keeps data in memory and resets on restart. If the app needs persistence, add a database deliberately (ask first); don't write to the filesystem as a substitute.
@@ -0,0 +1 @@
1
+ Postgres via Prisma. The schema is `prisma/schema.prisma`; get the client with `db()` from `@server/db`. Database access belongs in the feature's store module (see the notes store), not in components or routes. After changing the schema run `__seed_pmRun__ db:push` (dev) or regenerate the client with `__seed_pmRun__ db:generate`.
@@ -0,0 +1 @@
1
+ Fetch data on the server: in Server Components or server functions. Use client components only for interactivity (forms, state), and mutate through server actions.
@@ -0,0 +1 @@
1
+ Expected failures **return a `Result`** from `@shared/result` (`ok(value)` / `err(message)`) instead of throwing. Callers must check `result.ok`. Only unexpected failures (bugs, outages) throw.
@@ -0,0 +1 @@
1
+ Expected failures (bad input, not found) **throw** a named `Error` subclass (see `NoteValidationError`). Server actions catch those and return a user-facing message; anything else is re-thrown.
@@ -0,0 +1 @@
1
+ Validate every input with a zod schema in the feature folder (the example is the notes schema module). The same schema types the data (`z.infer`) and validates it on the server.
@@ -0,0 +1,5 @@
1
+ Code is grouped **by feature**:
2
+
3
+ - `__seed_domainDir__/<feature>/` holds that feature's server functions, server actions, zod schemas, and tests. Feature UI lives in `__seed_featureUiDir__/` (on the default tree, the `components/` folder inside the feature).
4
+ - Code shared by several features goes in `__seed_sharedDir__/`. Server-only infrastructure (database client) goes in `__seed_serverDir__/`.
5
+ - Routes in `src/app/` stay thin: they compose feature components and call feature functions.
@@ -0,0 +1,5 @@
1
+ The structure is **flat** on purpose:
2
+
3
+ - Logic and helpers live in `__seed_domainDir__/` (one folder per area is fine, no deeper).
4
+ - Feature UI lives in `__seed_featureUiDir__/`. Routes stay in `src/app/`.
5
+ - Don't add new top-level folders without a reason.
@@ -0,0 +1,6 @@
1
+ Code is grouped **by technical layer**:
2
+
3
+ - Domain logic lives in `__seed_domainDir__/<area>/` (server functions, actions, schemas).
4
+ - Feature UI lives in `__seed_featureUiDir__/`.
5
+ - Shared helpers go in `__seed_sharedDir__/`; shadcn/ui stays in `src/components/ui/`; server-only infrastructure in `__seed_serverDir__/`.
6
+ - Routes in `src/app/` stay thin.
@@ -0,0 +1 @@
1
+ Payments use Stripe Checkout. Create the client with `stripeClient()` in `__seed_serverDir__/billing/stripe.ts` inside the request that needs it. Do not construct Stripe at module scope. Checkout is `src/app/api/checkout/route.ts`. It reads `sessionEmail()` from `@server/auth`. Auth.js and Clerk each provide that function for the active auth feature. The webhook is `src/app/api/webhooks/stripe/route.ts`. It checks `STRIPE_WEBHOOK_SECRET` and the `stripe-signature` header, then `webhooks.constructEvent`, before writing a billing row. Leave `STRIPE_SECRET_KEY` and `STRIPE_WEBHOOK_SECRET` empty in `.env.example`.
@@ -0,0 +1,5 @@
1
+ `__seed_projectName__` is a Next.js (App Router) + TypeScript app with Tailwind CSS and shadcn/ui, generated by Yosr Seed from `__seed_templateName__@__seed_templateVersion__`. Data: __seed_storageLabel__. API style: server actions.
2
+
3
+ - Read `docs/architecture.md` before larger changes; it lists the folder map and where new code goes.
4
+ - Import across folders through the path aliases in `tsconfig.json` (`@/`, `@domain/`, `@shared/`, `@server/`, `@ui/`).
5
+ - Don't edit `.seed/`; it records how the project was generated.
@@ -0,0 +1 @@
1
+ Unit tests (Vitest) sit **next to the code**: `create-note.ts` → `create-note` plus the applied unit-test suffix. Import the unit under test through its alias. Every new server function gets a test.
@@ -0,0 +1 @@
1
+ Unit tests (Vitest) live in a **`__tests__/` folder next to the code**: `<area>/<file>.ts` → `<area>/__tests__/<file>` plus the applied unit-test suffix. Import the unit under test through its alias. Every new server function gets a test.
@@ -0,0 +1 @@
1
+ Unit tests (Vitest) live under **`tests/unit/`**, mirroring `src/`. Import the unit under test through its alias. Every new server function gets a test.
@@ -0,0 +1 @@
1
+ UI uses Tailwind CSS v4 and shadcn/ui components in `src/components/ui/` (add more with `__seed_pmExec__ shadcn add <name>`). Don't edit generated shadcn files for one-off styling; pass `className` instead. Merge classes with `cn()` from `@shared/utils`.