@yosr-ai/template-next-fullstack 0.0.0-stage → 0.1.0-alpha.1
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.
- package/CHANGELOG.md +15 -0
- package/README.md +15 -2
- package/features/api-trpc/files/src/app/api/trpc/[trpc]/route.ts +15 -0
- package/features/api-trpc/files/src/app/trpc-provider.tsx +27 -0
- package/features/api-trpc/files/src/features/notes/components/note-form.tsx +48 -0
- package/features/api-trpc/files/src/server/api/context.ts +8 -0
- package/features/api-trpc/files/src/server/api/notes.test.ts +30 -0
- package/features/api-trpc/files/src/server/api/notes.ts +42 -0
- package/features/api-trpc/files/src/server/api/root.ts +8 -0
- package/features/api-trpc/files/src/server/api/trpc.ts +8 -0
- package/features/api-trpc/snippets/providers-imports.tsx +2 -0
- package/features/api-trpc/snippets/providers.tsx +1 -0
- package/features/auth-authjs/files/e2e/sign-in.spec.ts +10 -0
- package/features/auth-authjs/files/src/app/api/auth/[...nextauth]/route.ts +13 -0
- package/features/auth-authjs/files/src/app/auth-session-provider.tsx +8 -0
- package/features/auth-authjs/files/src/app/sign-in/page.tsx +19 -0
- package/features/auth-authjs/files/src/server/auth/config.ts +28 -0
- package/features/auth-authjs/files/src/server/auth/index.ts +15 -0
- package/features/auth-authjs/snippets/providers-imports.tsx +2 -0
- package/features/auth-authjs/snippets/providers.tsx +1 -0
- package/features/auth-authjs-drizzle/files/src/server/db/auth-tables.ts +86 -0
- package/features/auth-authjs-drizzle/snippets/adapter-db-imports.ts +8 -0
- package/features/auth-authjs-drizzle/snippets/adapter-imports.ts +1 -0
- package/features/auth-authjs-drizzle/snippets/adapter.ts +7 -0
- package/features/auth-authjs-drizzle/snippets/auth-tables.ts +7 -0
- package/features/auth-authjs-prisma/snippets/adapter-db-imports.ts +1 -0
- package/features/auth-authjs-prisma/snippets/adapter-imports.ts +1 -0
- package/features/auth-authjs-prisma/snippets/adapter.ts +1 -0
- package/features/auth-authjs-prisma/snippets/auth-models.prisma +58 -0
- package/features/auth-clerk/files/e2e/sign-in.spec.ts +15 -0
- package/features/auth-clerk/files/src/app/clerk-app-provider.tsx +13 -0
- package/features/auth-clerk/files/src/app/sign-in/[[...sign-in]]/page.tsx +18 -0
- package/features/auth-clerk/files/src/app/sign-up/[[...sign-up]]/page.tsx +18 -0
- package/features/auth-clerk/files/src/proxy.ts +24 -0
- package/features/auth-clerk/files/src/server/auth/index.ts +11 -0
- package/features/auth-clerk/snippets/providers-imports.tsx +2 -0
- package/features/auth-clerk/snippets/providers.tsx +1 -0
- package/features/deploy-docker/files/.dockerignore +6 -0
- package/features/deploy-docker/files/Dockerfile +26 -0
- package/features/deploy-docker/files/compose.yaml +6 -0
- package/features/deploy-docker-npm/files/Dockerfile +26 -0
- package/features/deploy-docker-postgres/snippets/postgres-service.yaml +4 -0
- package/features/deploy-vercel/snippets/readme-deploy.md +3 -0
- package/features/orm-drizzle/files/drizzle.config.ts +8 -0
- package/features/orm-drizzle/files/src/features/notes/notes-store.ts +21 -0
- package/features/orm-drizzle/files/src/server/db/index.ts +20 -0
- package/features/orm-drizzle/files/src/server/db/schema.ts +11 -0
- package/features/orm-drizzle/snippets/ci-e2e-setup.yaml +1 -0
- package/features/orm-drizzle/snippets/ci-job.yaml +11 -0
- package/features/orm-drizzle/snippets/readme-db.md +4 -0
- package/features/orm-prisma/files/prisma/schema.prisma +18 -0
- package/features/orm-prisma/files/prisma.config.ts +13 -0
- package/features/orm-prisma/files/src/features/notes/notes-store.ts +13 -0
- package/features/orm-prisma/files/src/server/db/index.ts +20 -0
- package/features/orm-prisma/snippets/ci-e2e-setup.yaml +1 -0
- package/features/orm-prisma/snippets/ci-job.yaml +11 -0
- package/features/orm-prisma/snippets/readme-db.md +4 -0
- package/features/payments-stripe/files/src/app/api/checkout/route.ts +27 -0
- package/features/payments-stripe/files/src/app/api/webhooks/stripe/route.ts +18 -0
- package/features/payments-stripe/files/src/server/billing/billing.test.ts +113 -0
- package/features/payments-stripe/files/src/server/billing/index.ts +99 -0
- package/features/payments-stripe/files/src/server/billing/stripe.ts +10 -0
- package/features/payments-stripe-drizzle/files/src/server/billing/store.ts +39 -0
- package/features/payments-stripe-drizzle/snippets/billing-tables.ts +13 -0
- package/features/payments-stripe-prisma/files/src/server/billing/store.ts +30 -0
- package/features/payments-stripe-prisma/snippets/billing-models.prisma +17 -0
- package/files/.env.example +1 -0
- package/files/.github/workflows/ci.yml +25 -0
- package/files/.prettierignore +7 -0
- package/files/.prettierrc.json +1 -0
- package/files/README.md +18 -0
- package/files/components.json +20 -0
- package/files/e2e/smoke.spec.ts +16 -0
- package/files/eslint.config.mjs +21 -0
- package/files/gitignore +25 -0
- package/files/next.config.ts +7 -0
- package/files/package.json +42 -0
- package/files/playwright.config.ts +20 -0
- package/files/pnpm-workspace.yaml +16 -0
- package/files/postcss.config.mjs +7 -0
- package/files/src/app/globals.css +68 -0
- package/files/src/app/layout.tsx +22 -0
- package/files/src/app/page.tsx +21 -0
- package/files/src/app/providers.tsx +15 -0
- package/files/src/components/ui/button.tsx +59 -0
- package/files/src/components/ui/input.tsx +21 -0
- package/files/src/features/notes/actions.ts +22 -0
- package/files/src/features/notes/components/note-form.tsx +32 -0
- package/files/src/features/notes/components/note-list.tsx +23 -0
- package/files/src/features/notes/create-note.test.ts +27 -0
- package/files/src/features/notes/create-note.ts +23 -0
- package/files/src/features/notes/note-schema.ts +13 -0
- package/files/src/features/notes/notes-store.ts +17 -0
- package/files/src/shared/utils.test.ts +13 -0
- package/files/src/shared/utils.ts +6 -0
- package/files/tsconfig.json +35 -0
- package/files/vitest.config.mts +9 -0
- package/package.json +26 -4
- package/rules/api-server-actions.md +1 -0
- package/rules/api-trpc.md +1 -0
- package/rules/architecture.md +11 -0
- package/rules/auth-authjs.md +1 -0
- package/rules/auth-clerk.md +1 -0
- package/rules/commands.md +5 -0
- package/rules/data-drizzle.md +1 -0
- package/rules/data-none.md +1 -0
- package/rules/data-prisma.md +1 -0
- package/rules/data-server-first.md +1 -0
- package/rules/errors-result.md +1 -0
- package/rules/errors-throw.md +1 -0
- package/rules/forms-zod.md +1 -0
- package/rules/layout-feature.md +5 -0
- package/rules/layout-flat.md +5 -0
- package/rules/layout-layer.md +6 -0
- package/rules/payments-stripe.md +1 -0
- package/rules/project-overview.md +5 -0
- package/rules/tests-colocated.md +1 -0
- package/rules/tests-folder.md +1 -0
- package/rules/tests-separate.md +1 -0
- package/rules/ui-shadcn.md +1 -0
- package/seed.template.json +1721 -0
- package/style/errors-result/files/src/features/notes/actions.ts +18 -0
- package/style/errors-result/files/src/features/notes/create-note.test.ts +30 -0
- package/style/errors-result/files/src/features/notes/create-note.ts +16 -0
- 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.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
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__/`.
|
|
5
|
+
- Routes in `src/app/` stay thin: they compose feature components and call feature functions.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
**Flat** means one folder per area under `src/lib/` and `src/components/`, no deeper nesting.
|
|
2
|
+
|
|
3
|
+
- Notes logic is `src/lib/notes/`. Shared helpers are `src/lib/shared/`. Feature UI is `src/components/notes/`. shadcn/ui stays in `src/components/ui/`.
|
|
4
|
+
- Routes stay in `src/app/`.
|
|
5
|
+
- `src/lib/server/` is the server-infrastructure area. It has one level for `db/` and `auth/` (`src/lib/server/db/`, `src/lib/server/auth/`). Don't add a folder inside any other area, and don't nest further under `db/` or `auth/`.
|
|
@@ -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/`.
|
|
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: __seed_api__.
|
|
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` (__seed_aliasList__).
|
|
5
|
+
- `.seed/` is a record of what Yosr Seed generated. The app never reads it. It is not edited by hand. It can drift from the project after later changes such as adding a database.
|
|
@@ -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`.
|