Skip to content

Commit a94312e

Browse files
committed
updated
1 parent bf32b1e commit a94312e

63 files changed

Lines changed: 1513 additions & 513 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/instructions/nextjs.instructions.md

Lines changed: 206 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ Always move client-only UI into a Client Component and import it directly in you
394394
- **Dynamic Segments:** Use `[param]` for dynamic API routes (e.g., `app/api/users/[id]/route.ts`).
395395
- **Validation:** Always validate and sanitize input. Use libraries like `zod` or `yup`.
396396
- **Error Handling:** Return appropriate HTTP status codes and error messages.
397-
- **Authentication:** Protect sensitive routes using middleware or server-side session checks.
397+
- **Authentication:** Protect sensitive routes using proxy or server-side session checks.
398398

399399
### StormCom API Standards (CRITICAL)
400400

@@ -1060,16 +1060,16 @@ export async function checkRateLimit(request: NextRequest) {
10601060
}
10611061
```
10621062

1063-
### Middleware Best Practices
1063+
### Proxy Best Practices (Next.js 16)
10641064

10651065
**Authentication & Tenant Isolation** (REQUIRED):
10661066
```typescript
1067-
// middleware.ts
1067+
// proxy.ts (formerly middleware.ts in Next.js 15)
10681068
import { NextResponse } from 'next/server';
10691069
import type { NextRequest } from 'next/server';
10701070
import { getToken } from 'next-auth/jwt';
10711071

1072-
export async function middleware(request: NextRequest) {
1072+
export async function proxy(request: NextRequest) {
10731073
const { pathname } = request.nextUrl;
10741074

10751075
// 1. Rate limiting for API routes
@@ -1136,7 +1136,7 @@ When building features for StormCom, ensure:
11361136
- [ ] All database queries filter by `storeId`
11371137
- [ ] Prisma middleware auto-injects `storeId`
11381138
- [ ] Session includes `storeId` for tenant context
1139-
- [ ] Middleware validates tenant access
1139+
- [ ] Proxy validates tenant access
11401140

11411141
### ✅ Database (Prisma)
11421142
- [ ] Use Prisma Client (NO raw SQL)
@@ -1189,6 +1189,206 @@ When building features for StormCom, ensure:
11891189

11901190
---
11911191

1192+
## Next.js 16 Migration Guide (Critical Changes)
1193+
1194+
**REQUIRED**: StormCom uses Next.js 16.0.0+ with breaking changes from v15. Follow this migration checklist:
1195+
1196+
### 1. Proxy (Formerly Middleware)
1197+
1198+
**Breaking Change**: `middleware.ts` renamed to `proxy.ts` with new terminology.
1199+
1200+
```typescript
1201+
// ❌ DEPRECATED (Next.js 15):
1202+
// middleware.ts
1203+
export default function middleware(request: NextRequest) {
1204+
return NextResponse.next();
1205+
}
1206+
1207+
// ✅ REQUIRED (Next.js 16):
1208+
// proxy.ts (at project root or in src/)
1209+
export default function proxy(request: NextRequest) {
1210+
return NextResponse.next();
1211+
}
1212+
```
1213+
1214+
**Migration**:
1215+
```bash
1216+
# Use automated codemod
1217+
npx @next/codemod@canary middleware-to-proxy .
1218+
1219+
# Or manually:
1220+
# 1. Rename middleware.ts → proxy.ts
1221+
# 2. Rename function: middleware → proxy
1222+
# 3. Update all references in codebase
1223+
```
1224+
1225+
**Why**: Clarifies network boundary and aligns with proxy pattern. Only ONE proxy file per project allowed.
1226+
1227+
**Documentation**: https://nextjs.org/docs/app/api-reference/file-conventions/proxy
1228+
1229+
### 2. Async Route Parameters
1230+
1231+
**Breaking Change**: `params` and `searchParams` are now Promises.
1232+
1233+
```typescript
1234+
// ❌ DEPRECATED (Next.js 15):
1235+
export default function Page({ params, searchParams }: Props) {
1236+
const { id } = params; // Synchronous access
1237+
const query = searchParams.q;
1238+
}
1239+
1240+
// ✅ REQUIRED (Next.js 16):
1241+
export default async function Page({ params, searchParams }: Props) {
1242+
const { id } = await params; // Must await
1243+
const { q: query } = await searchParams; // Must await
1244+
}
1245+
```
1246+
1247+
**Applies to**:
1248+
- Page components (`page.tsx`)
1249+
- Layout components (`layout.tsx`)
1250+
- Route handlers (`route.ts`)
1251+
- `generateMetadata()` functions
1252+
1253+
### 3. Server-Only Functions Now Async
1254+
1255+
**Breaking Change**: `cookies()`, `headers()`, `draftMode()` now return Promises.
1256+
1257+
```typescript
1258+
// ❌ DEPRECATED (Next.js 15):
1259+
import { cookies } from 'next/headers';
1260+
const cookieStore = cookies();
1261+
1262+
// ✅ REQUIRED (Next.js 16):
1263+
import { cookies } from 'next/headers';
1264+
const cookieStore = await cookies();
1265+
```
1266+
1267+
### 4. Image Component Defaults
1268+
1269+
**Breaking Change**: Default quality changed, minimum cache TTL increased.
1270+
1271+
```typescript
1272+
// Next.js 15 defaults:
1273+
// - quality: 75
1274+
// - minimumCacheTTL: 60 seconds
1275+
// - imageSizes: [16, 32, 48, 64, 96, 128, 256, 384]
1276+
1277+
// Next.js 16 defaults:
1278+
// - quality: 75 (unchanged)
1279+
// - minimumCacheTTL: 14400 seconds (4 hours)
1280+
// - imageSizes: [32, 48, 64, 96, 128, 256, 384] (removed 16)
1281+
```
1282+
1283+
**If you relied on 16px size**:
1284+
```typescript
1285+
// next.config.ts
1286+
export default {
1287+
images: {
1288+
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
1289+
},
1290+
};
1291+
```
1292+
1293+
### 5. Turbopack Now Default
1294+
1295+
**Breaking Change**: Turbopack is now the default bundler (2-5x faster builds).
1296+
1297+
```bash
1298+
# Use webpack if needed (custom webpack config)
1299+
next dev --webpack
1300+
next build --webpack
1301+
1302+
# Or in package.json
1303+
{
1304+
"scripts": {
1305+
"dev": "next dev --webpack",
1306+
"build": "next build --webpack"
1307+
}
1308+
}
1309+
```
1310+
1311+
### 6. Caching Model Changes
1312+
1313+
**Breaking Change**: Explicit opt-in caching with `"use cache"` directive.
1314+
1315+
```typescript
1316+
// Next.js 15: Implicit caching (fetch auto-cached)
1317+
async function getData() {
1318+
const res = await fetch('https://api.example.com/data');
1319+
return res.json();
1320+
}
1321+
1322+
// Next.js 16: Explicit caching required
1323+
"use cache";
1324+
async function getData() {
1325+
const res = await fetch('https://api.example.com/data');
1326+
return res.json();
1327+
}
1328+
```
1329+
1330+
**Enable Cache Components** (Optional):
1331+
```typescript
1332+
// next.config.ts
1333+
export default {
1334+
cacheComponents: true, // Opt-in to new caching model
1335+
};
1336+
```
1337+
1338+
### 7. revalidateTag() Signature Change
1339+
1340+
**Breaking Change**: Requires `cacheLife` profile as second argument.
1341+
1342+
```typescript
1343+
// ❌ DEPRECATED (Next.js 15):
1344+
revalidateTag('blog-posts');
1345+
1346+
// ✅ REQUIRED (Next.js 16):
1347+
revalidateTag('blog-posts', 'max'); // Use cacheLife profile
1348+
1349+
// Or with custom revalidate time:
1350+
revalidateTag('products', { revalidate: 3600 });
1351+
```
1352+
1353+
### 8. Parallel Routes Require default.js
1354+
1355+
**Breaking Change**: All parallel route slots MUST have `default.js`.
1356+
1357+
```typescript
1358+
// app/
1359+
// ├── @modal/
1360+
// │ ├── default.tsx // ✅ REQUIRED (was optional in v15)
1361+
// │ └── photo/
1362+
// │ └── page.tsx
1363+
// └── page.tsx
1364+
1365+
// default.tsx
1366+
export default function Default() {
1367+
return null; // or call notFound()
1368+
}
1369+
```
1370+
1371+
### Migration Checklist
1372+
1373+
- [ ] Rename `middleware.ts``proxy.ts`
1374+
- [ ] Update function name: `middleware``proxy`
1375+
- [ ] Add `await` to all `params` and `searchParams` usage
1376+
- [ ] Add `await` to `cookies()`, `headers()`, `draftMode()`
1377+
- [ ] Update `revalidateTag()` calls to include second argument
1378+
- [ ] Add `default.js` to all parallel route slots
1379+
- [ ] Test with Turbopack (or opt into webpack if needed)
1380+
- [ ] Consider enabling `cacheComponents` for explicit caching
1381+
- [ ] Update image component usage if relying on 16px size
1382+
- [ ] Run type-check: `npm run type-check`
1383+
- [ ] Run build: `npm run build`
1384+
1385+
**Resources**:
1386+
- [Next.js 16 Upgrade Guide](https://nextjs.org/docs/app/guides/upgrading/version-16)
1387+
- [Next.js 16 Blog Post](https://nextjs.org/blog/next-16)
1388+
- [Proxy Documentation](https://nextjs.org/docs/app/api-reference/file-conventions/proxy)
1389+
1390+
---
1391+
11921392
## Next.js MCP Server Integration (REQUIRED)
11931393

11941394
**CRITICAL**: Next.js 16.0.0+ includes built-in Model Context Protocol (MCP) server support for AI-assisted development. StormCom REQUIRES both MCP servers for optimal Copilot agent experience.
@@ -1297,7 +1497,7 @@ npm run dev
12971497

12981498
**Benefits for StormCom Development**:
12991499
- **Context-Aware Suggestions**: Agent recommends features based on existing structure
1300-
- **Live Application State**: Query current routes, middleware, errors during development
1500+
- **Live Application State**: Query current routes, proxy configuration, errors during development
13011501
- **Multi-Tenant Awareness**: Agent understands route groups and tenant isolation patterns
13021502
- **Performance Insights**: Get recommendations based on actual performance metrics
13031503
- **Accurate Implementations**: Generate code following StormCom patterns and conventions

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ dist/
3434
*.test.ts.snap
3535

3636
# Prisma
37-
# /prisma/*.db
38-
# /prisma/*.db-journal
37+
/prisma/*.db
38+
/prisma/*.db-journal
3939
/prisma/prisma/*.db
4040
# /prisma/prisma/dev.db
4141

.specify/memory/constitution.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
# Sync Impact Report
2+
<!--
3+
Version change: 1.1.0 → 1.2.0
4+
5+
Modified principles:
6+
- Required Technologies: replaced "Custom Auth System" note with a pinned NextAuth.js requirement (NextAuth.js v4.24.13).
7+
- Authentication & Authorization: pinned to NextAuth.js v4.24.13 and added compatibility guidance for Next.js v16.0.1.
8+
9+
Added / Removed sections:
10+
- Removed: explicit note recommending a custom auth system due to NextAuth v5 incompatibility.
11+
12+
Templates & files checked and sync status:
13+
- .specify/memory/constitution.md — ✅ updated
14+
- specs/001-multi-tenant-ecommerce/plan.md — ✅ updated to reference NextAuth.js v4.24.13
15+
- specs/001-multi-tenant-ecommerce/tasks.md — ✅ updated to reinstate T022 for NextAuth.js v4.24.13
16+
- .specify/templates/plan-template.md — ✅ reviewed (no changes required)
17+
- .specify/templates/spec-template.md — ✅ reviewed (no changes required)
18+
- .specify/templates/tasks-template.md — ✅ reviewed (no changes required)
19+
20+
Follow-up TODOs:
21+
- Verify `package.json` pins or allows `next-auth@4.24.13` and `next@16.0.1`. If not, propose dependency update and run `npm install`.
22+
- Run full test suite (Vitest + Playwright) to validate NextAuth integration and resolve any auth-related test mocks.
23+
- Remove or migrate any legacy custom-auth code paths once NextAuth integration is fully validated.
24+
-->
25+
126
# StormCom Constitution
227

328
## Core Principles
@@ -159,7 +184,7 @@ Performance is a priority. All features must meet defined performance budgets: p
159184
-**PostgreSQL** (production on Vercel Postgres).
160185
-**Tailwind CSS** `4.1.14+` (utility-first styling).
161186
-**Radix UI** + **shadcn/ui** (accessible component library).
162-
-**Custom Auth System** (JWT + Vercel KV session storage) - **NOTE**: NextAuth.js v5 incompatible with Next.js 16; custom implementation used instead (see plan.md, tasks.md).
187+
-**NextAuth.js** `v4.24.13` - Official authentication framework configured for Next.js `v16.0.1`. Use NextAuth.js v4.24.13 for session management (JWT sessions), provider integrations, and optional 2FA/TOTP flows. In production, session state SHOULD be stored in Vercel KV or another secure session store. This replaces the prior custom-auth note: NextAuth v4.x is the supported authentication system for the project and is verified compatible with Next.js 16.0.1.
163188
-**Zod** (runtime validation).
164189
-**React Hook Form** (form state management).
165190
-**Vitest** `3.2.4+` (unit/integration testing).
@@ -275,7 +300,7 @@ Performance is a priority. All features must meet defined performance budgets: p
275300
Ensure all user data is encrypted at rest and in transit. Follow industry best practices for authentication and authorization, including HTTPS, secure cookies, and role-based access control.
276301

277302
**Authentication & Authorization**
278-
- Use NextAuth.js v4+ for authentication.
303+
- Use NextAuth.js `v4.24.13` (compatible with Next.js `v16.0.1`) for authentication. Configure providers, JWT session handling, and optional 2FA/TOTP via NextAuth integrations where applicable. Session cookies MUST be HTTP-only and SameSite=Lax; store session state in Vercel KV in production.
279304
- Implement JWT sessions with HTTP-only cookies (SameSite=Lax).
280305
- Hash passwords with bcrypt (cost factor: 12).
281306
- Enforce Role-Based Access Control (RBAC) with granular permissions.
@@ -309,4 +334,4 @@ Ensure compliance with GDPR, CCPA, and other relevant data protection regulation
309334

310335
This constitution supersedes all other practices. Amendments require documentation, approval, and a migration plan. All pull requests and reviews must verify compliance with the principles outlined in this document. Complexity must be justified, and runtime development guidance must be followed as outlined in the project documentation.
311336

312-
**Version**: 1.1.0 | **Ratified**: 2025-10-17 | **Last Amended**: 2025-10-17
337+
**Version**: 1.2.0 | **Ratified**: 2025-10-17 | **Last Amended**: 2025-11-08

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,3 +728,9 @@ MIT License - see [LICENSE](LICENSE) file
728728
---
729729
730730
**Built with ❤️ using Next.js 16 (Including), TypeScript 5.9, Prisma, and Spec-Driven Development**
731+
732+
## Login credentials:
733+
- Super Admin: admin@stormcom.io / Admin@123
734+
- TechHub Admin: admin@techhub.example.com / Admin@123
735+
- StyleStreet Admin: admin@stylestreet.example.com / Admin@123
736+
- CozyHome Admin: admin@cozyhome.example.com / Admin@123
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)