gspec 1.7.0 → 1.11.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 (72) hide show
  1. package/bin/gspec.js +275 -8
  2. package/commands/gspec.analyze.md +1 -1
  3. package/commands/gspec.implement.md +10 -8
  4. package/commands/gspec.practices.md +3 -1
  5. package/commands/gspec.stack.md +11 -6
  6. package/commands/gspec.style.md +18 -23
  7. package/dist/antigravity/gspec-analyze/SKILL.md +1 -1
  8. package/dist/antigravity/gspec-architect/SKILL.md +1 -1
  9. package/dist/antigravity/gspec-feature/SKILL.md +1 -1
  10. package/dist/antigravity/gspec-implement/SKILL.md +11 -9
  11. package/dist/antigravity/gspec-migrate/SKILL.md +5 -5
  12. package/dist/antigravity/gspec-practices/SKILL.md +4 -2
  13. package/dist/antigravity/gspec-profile/SKILL.md +1 -1
  14. package/dist/antigravity/gspec-research/SKILL.md +3 -3
  15. package/dist/antigravity/gspec-stack/SKILL.md +12 -7
  16. package/dist/antigravity/gspec-style/SKILL.md +19 -24
  17. package/dist/claude/gspec-analyze/SKILL.md +1 -1
  18. package/dist/claude/gspec-architect/SKILL.md +1 -1
  19. package/dist/claude/gspec-feature/SKILL.md +1 -1
  20. package/dist/claude/gspec-implement/SKILL.md +11 -9
  21. package/dist/claude/gspec-migrate/SKILL.md +5 -5
  22. package/dist/claude/gspec-practices/SKILL.md +4 -2
  23. package/dist/claude/gspec-profile/SKILL.md +1 -1
  24. package/dist/claude/gspec-research/SKILL.md +3 -3
  25. package/dist/claude/gspec-stack/SKILL.md +12 -7
  26. package/dist/claude/gspec-style/SKILL.md +19 -24
  27. package/dist/codex/gspec-analyze/SKILL.md +1 -1
  28. package/dist/codex/gspec-architect/SKILL.md +1 -1
  29. package/dist/codex/gspec-feature/SKILL.md +1 -1
  30. package/dist/codex/gspec-implement/SKILL.md +11 -9
  31. package/dist/codex/gspec-migrate/SKILL.md +5 -5
  32. package/dist/codex/gspec-practices/SKILL.md +4 -2
  33. package/dist/codex/gspec-profile/SKILL.md +1 -1
  34. package/dist/codex/gspec-research/SKILL.md +3 -3
  35. package/dist/codex/gspec-stack/SKILL.md +12 -7
  36. package/dist/codex/gspec-style/SKILL.md +19 -24
  37. package/dist/cursor/gspec-analyze.mdc +1 -1
  38. package/dist/cursor/gspec-architect.mdc +1 -1
  39. package/dist/cursor/gspec-feature.mdc +1 -1
  40. package/dist/cursor/gspec-implement.mdc +11 -9
  41. package/dist/cursor/gspec-migrate.mdc +5 -5
  42. package/dist/cursor/gspec-practices.mdc +4 -2
  43. package/dist/cursor/gspec-profile.mdc +1 -1
  44. package/dist/cursor/gspec-research.mdc +3 -3
  45. package/dist/cursor/gspec-stack.mdc +12 -7
  46. package/dist/cursor/gspec-style.mdc +19 -24
  47. package/dist/opencode/gspec-analyze/SKILL.md +168 -0
  48. package/dist/opencode/gspec-architect/SKILL.md +361 -0
  49. package/dist/opencode/gspec-feature/SKILL.md +204 -0
  50. package/dist/opencode/gspec-implement/SKILL.md +202 -0
  51. package/dist/opencode/gspec-migrate/SKILL.md +118 -0
  52. package/dist/opencode/gspec-practices/SKILL.md +137 -0
  53. package/dist/opencode/gspec-profile/SKILL.md +221 -0
  54. package/dist/opencode/gspec-research/SKILL.md +302 -0
  55. package/dist/opencode/gspec-stack/SKILL.md +305 -0
  56. package/dist/opencode/gspec-style/SKILL.md +224 -0
  57. package/package.json +3 -1
  58. package/starters/features/about-page.md +98 -0
  59. package/starters/features/contact-form.md +147 -0
  60. package/starters/features/contact-page.md +103 -0
  61. package/starters/features/home-page.md +103 -0
  62. package/starters/features/responsive-navbar.md +113 -0
  63. package/starters/features/services-page.md +103 -0
  64. package/starters/features/site-footer.md +121 -0
  65. package/starters/features/theme-switcher.md +124 -0
  66. package/starters/practices/tdd-pipeline-first.md +192 -0
  67. package/starters/stacks/astro-tailwind-github-pages.md +283 -0
  68. package/starters/stacks/nextjs-supabase-vercel.md +319 -0
  69. package/starters/stacks/nextjs-vercel-typescript.md +264 -0
  70. package/starters/styles/clean-professional.md +316 -0
  71. package/starters/styles/dark-minimal-developer.md +442 -0
  72. package/templates/spec-sync.md +1 -1
@@ -0,0 +1,283 @@
1
+ ---
2
+ gspec-version: 1.8.0
3
+ description: Static documentation site with Astro, Tailwind CSS v4, and GitHub Pages deployment
4
+ ---
5
+
6
+ # Technology Stack Definition
7
+
8
+ ## 1. Overview
9
+
10
+ A **static documentation and marketing site** deployed to GitHub Pages, built with Astro.
11
+
12
+ ### Architecture Style
13
+ - Static site generated at build time with Astro. Zero server-side runtime, no API, no database.
14
+ - Content-driven architecture — pages are authored in Markdown/MDX and rendered through Astro layouts.
15
+
16
+ ### Deployment Target
17
+ - **GitHub Pages** — static hosting via GitHub Actions build-and-deploy workflow
18
+
19
+ ### Scale & Performance Requirements
20
+ - Minimal — static HTML/CSS/JS served via GitHub Pages CDN. Target: perfect Lighthouse scores.
21
+
22
+ ---
23
+
24
+ ## 2. Open Questions & Clarifications
25
+
26
+ None — all information is clear.
27
+
28
+ ---
29
+
30
+ ## 3. Core Technology Stack
31
+
32
+ ### Programming Languages
33
+
34
+ - **Astro Components (.astro)** — Astro's template syntax, compiles to static HTML
35
+ - **Markdown / MDX** — Content authoring format for documentation pages
36
+ - **JavaScript (ES Modules)** — For any client-side interactivity and Astro configuration
37
+
38
+ ### Runtime Environment
39
+
40
+ - **Node.js 20 LTS** — Used for Astro site generation. Pinned in CI via GitHub Actions `setup-node`.
41
+ - **No container runtime** — Not needed for a static site.
42
+
43
+ ---
44
+
45
+ ## 4. Frontend Stack
46
+
47
+ ### Framework
48
+
49
+ - **Astro 5.x** — Static site generator optimized for content-driven websites
50
+ - **Why Astro:**
51
+ - Zero-JS-by-default output — ideal for a documentation/marketing site
52
+ - First-class Markdown/MDX support for content pages
53
+ - Built-in GitHub Pages deployment support
54
+ - Islands architecture allows interactive components only where needed
55
+ - Excellent performance out of the box (perfect Lighthouse scores)
56
+
57
+ ### Build Tools
58
+
59
+ - **Astro's built-in Vite pipeline** — Astro uses Vite internally; no separate bundler configuration needed
60
+ - **`@astrojs/tailwind`** — Official Astro integration for Tailwind CSS
61
+
62
+ ### State Management
63
+
64
+ Not Applicable — static site with no client-side application state. Any interactivity (e.g., mobile nav toggle, copy-to-clipboard) uses vanilla JS or Astro's `<script>` tags.
65
+
66
+ ### Styling Technology
67
+
68
+ - **Tailwind CSS v4** — Utility-first CSS framework
69
+ - **Why Tailwind:**
70
+ - Astro's officially recommended CSS solution with first-class integration
71
+ - Zero runtime cost in static output — all CSS is purged and inlined at build time
72
+ - Rapid prototyping without writing custom CSS files
73
+ - Excellent responsive design utilities built in
74
+ - `@tailwindcss/typography` plugin for long-form Markdown content styling
75
+ - **Design token mapping:** Visual design values defined in `gspec/style.md` (when created) map to Tailwind's `theme.extend` configuration in `tailwind.config.mjs`. Custom colors, fonts, and spacing scales are defined there as Tailwind theme tokens rather than as raw CSS variables.
76
+
77
+ ---
78
+
79
+ ## 5. Backend Stack
80
+
81
+ Not Applicable — fully static site. Pre-rendered HTML served from GitHub Pages.
82
+
83
+ ---
84
+
85
+ ## 6. Infrastructure & DevOps
86
+
87
+ ### Cloud Provider
88
+
89
+ - **GitHub** — The sole infrastructure provider:
90
+ - **GitHub Pages** — Static site hosting
91
+ - **GitHub Actions** — CI/CD pipeline
92
+
93
+ ### Container Orchestration
94
+
95
+ Not Applicable.
96
+
97
+ ### CI/CD Pipeline
98
+
99
+ - **Platform:** GitHub Actions
100
+ - *Rationale:* Native integration with GitHub Pages deployment. No external CI service needed — hosting and CI are in the same platform.
101
+ - **Deployment trigger:** Push to main (website paths changed). Path filtering scopes the workflow so non-website changes don't trigger deploys.
102
+ - **Deployment method:** `actions/deploy-pages` for GitHub Pages.
103
+ - **Note:** Pipeline stages and structure (lint → typecheck → test → build → deploy) are defined in `gspec/practices.md`. This section defines the CI technology and deployment configuration.
104
+
105
+ ### Infrastructure as Code
106
+
107
+ Not Applicable — GitHub Pages requires no IaC. Configuration lives in `astro.config.mjs` and the GitHub Actions workflow YAML.
108
+
109
+ ---
110
+
111
+ ## 7. Data & Storage
112
+
113
+ ### File Storage
114
+
115
+ - **GitHub Pages CDN** — Serves all static assets (HTML, CSS, JS, images)
116
+
117
+ ### Data Warehouse / Analytics
118
+
119
+ Not Applicable.
120
+
121
+ ---
122
+
123
+ ## 8. Authentication & Security
124
+
125
+ Not Applicable — public static site with no user accounts, login, or protected resources.
126
+
127
+ ---
128
+
129
+ ## 9. Monitoring & Observability
130
+
131
+ Not Applicable — static site with no runtime to monitor. GitHub Pages provides basic traffic analytics if needed.
132
+
133
+ ---
134
+
135
+ ## 10. Testing Infrastructure
136
+
137
+ ### Testing Frameworks
138
+
139
+ - **Build verification:** `astro build` succeeds without errors (run in CI)
140
+ - **Lighthouse CI** (optional) — Automated performance/accessibility audits in the deploy pipeline
141
+ - **E2E testing:** Playwright or Cypress can be used for page-load and rendering verification if required by `gspec/practices.md`. Astro sites are static HTML — E2E tests verify that built pages load correctly and key elements are visible.
142
+ - **Unit testing:** Vitest can be used for testing utility functions, content collection schemas, or build-time logic if required by `gspec/practices.md`.
143
+ - **Note:** Whether and how extensively to test is defined by `gspec/practices.md`. This section defines the available tools for the Astro ecosystem.
144
+
145
+ ### Test Data Management
146
+
147
+ Not Applicable — static content site with no database.
148
+
149
+ ### Performance Testing
150
+
151
+ Not Applicable — static assets served from CDN.
152
+
153
+ ---
154
+
155
+ ## 11. Third-Party Integrations
156
+
157
+ ### External Services
158
+
159
+ - **GitHub Pages** — Website hosting
160
+ - **Formspree** — Client-side form submission service for contact forms and visitor inquiries. Accepts POST requests directly from the browser — no server-side endpoint or backend code required.
161
+ - *Rationale*: GitHub Pages is static-only with no server runtime. Formspree provides form handling without requiring a backend, keeping the architecture zero-server.
162
+ - Free tier supports up to 50 submissions per month.
163
+ - Submissions are forwarded to a configured email address.
164
+
165
+ ### API Clients
166
+
167
+ Not Applicable.
168
+
169
+ ---
170
+
171
+ ## 12. Development Tools
172
+
173
+ ### Package Management
174
+
175
+ - **Package manager:** npm
176
+ - *Rationale:* Simplest option for a static site with minimal dependencies. No need for pnpm's strict resolution or yarn's workspaces at this project scale.
177
+ - Key dependencies:
178
+ - `astro` — Static site generator
179
+ - `@astrojs/tailwind` — Tailwind CSS integration
180
+ - `tailwindcss` — Utility-first CSS framework
181
+ - `@tailwindcss/typography` — Prose styling for Markdown content
182
+
183
+ ### Project Structure
184
+
185
+ ```
186
+ src/
187
+ ├── pages/ # Astro file-based routing
188
+ ├── layouts/ # Page layouts (BaseLayout.astro, DocsLayout.astro)
189
+ ├── components/ # Reusable UI components
190
+ └── content/ # Markdown/MDX content collections
191
+ public/ # Static assets (images, favicon, etc.)
192
+ astro.config.mjs
193
+ tailwind.config.mjs
194
+ package.json
195
+ ```
196
+
197
+ ### Code Quality Tools
198
+
199
+ - **Prettier** — Consistent formatting across Astro, JS, and Markdown files (with `prettier-plugin-astro`)
200
+ - No linter needed at current project scale
201
+
202
+ ### Local Development
203
+
204
+ - `npm run dev` — Astro dev server with hot reload
205
+ - No Docker, no database, no environment variables required
206
+
207
+ ---
208
+
209
+ ## 13. Migration & Compatibility
210
+
211
+ ### Legacy System Integration
212
+
213
+ Not Applicable.
214
+
215
+ ### Upgrade Path
216
+
217
+ - **Astro:** Follow major version upgrade guides. Astro has a strong commitment to smooth upgrades.
218
+ - **Tailwind CSS:** v4 is current. Tailwind's upgrade tooling (`@tailwindcss/upgrade`) automates major version migrations.
219
+ - **Node.js:** Track LTS releases. Currently Node 20, move to Node 22 LTS when ready.
220
+
221
+ ---
222
+
223
+ ## 14. Technology Decisions & Tradeoffs
224
+
225
+ ### Key Architectural Decisions
226
+
227
+ | Decision | Rationale | Alternatives Considered |
228
+ |----------|-----------|------------------------|
229
+ | **Astro over Next.js/Docusaurus** | Zero-JS static output, first-class Markdown support, perfect for docs/marketing. No SSR or client-side routing needed. | Next.js (overkill, ships unnecessary JS), Docusaurus (opinionated, React dependency), Hugo (Go templating less flexible) |
230
+ | **Tailwind over vanilla CSS** | Rapid styling, consistent design system, excellent Astro integration, zero runtime cost after build. | Vanilla CSS (slower to prototype), UnoCSS (smaller ecosystem), Open Props (less utility coverage) |
231
+ | **Minimal dependency footprint** | Only install what the static site needs — no backend or toolchain bloat. | Monorepo with shared dependencies (unnecessary complexity for a static site) |
232
+
233
+ ### Risk Mitigation
234
+
235
+ | Risk | Mitigation |
236
+ |------|------------|
237
+ | Astro breaking changes | Pin major version, test builds in CI, upgrade intentionally |
238
+ | Tailwind v4 is relatively new | First-class Astro support, large community, easy fallback to v3 |
239
+ | GitHub Pages limitations | Static site is tiny; unlikely to hit limits. Could move to Cloudflare Pages or Netlify if needed |
240
+
241
+ ---
242
+
243
+ ## 15. Technology-Specific Practices
244
+
245
+ ### Framework Conventions & Patterns
246
+
247
+ - Use `.astro` components for all pages and layouts — avoid unnecessary framework islands (React, Vue, etc.) unless interactive behavior demands it
248
+ - Use Astro's built-in `<Content />` component for rendering Markdown content
249
+ - Use Astro's file-based routing in `src/pages/`
250
+ - Use `src/layouts/` for page layouts (e.g., `BaseLayout.astro`, `DocsLayout.astro`)
251
+ - Use `src/components/` for reusable UI components
252
+ - Prefer Astro's scoped `<style>` blocks for component-specific styles that don't map well to Tailwind utilities
253
+ - Use content collections (`src/content/`) for structured Markdown content with schema validation
254
+ - Use `getStaticPaths()` for dynamic routes when generating pages from collections
255
+
256
+ ### Library Usage Patterns
257
+
258
+ #### Tailwind CSS in Astro
259
+ - Configure design tokens in `tailwind.config.mjs` under `theme.extend` — map from `gspec/style.md` definitions
260
+ - Use `@apply` sparingly and only in Astro `<style>` blocks for repeated patterns — prefer utility classes in templates
261
+ - Use Tailwind's responsive prefixes (`sm:`, `md:`, `lg:`) rather than custom media queries
262
+ - Use `@tailwindcss/typography` with the `prose` class for all long-form Markdown content
263
+
264
+ ### Language Idioms
265
+
266
+ - **ES Modules** — Use `import`/`export` exclusively
267
+ - **`node:` prefix for built-in modules** — e.g., `import { readFileSync } from 'node:fs'`
268
+
269
+ ### Client-Side Interactivity Patterns
270
+
271
+ Features that require client-side JavaScript (e.g., theme switching, mobile navigation toggles) need special handling in Astro's zero-JS architecture:
272
+
273
+ - **Inline `<script>` tags** — For critical scripts that must run before paint (e.g., applying a saved theme preference to prevent flash-of-wrong-theme), use an inline `<script is:inline>` in the `<head>` of the base layout. This runs synchronously before the page renders.
274
+ - **Astro `<script>` tags** — For non-critical interactivity (e.g., hamburger menu toggle, copy-to-clipboard), use Astro's `<script>` tags in components. These are bundled and optimized by Astro.
275
+ - **Framework islands** — Use `client:load`, `client:visible`, or `client:idle` only for complex interactive components that require a framework (React, Vue, etc.). Most interactivity on a static site can be handled with vanilla JS.
276
+
277
+ ### Stack-Specific Anti-Patterns
278
+
279
+ - **Don't add React/Vue/Svelte islands** unless a component genuinely requires client-side interactivity — the site should ship zero JS by default
280
+ - **Don't use `client:load`** without justification — prefer `client:visible` or `client:idle` if interactivity is truly needed
281
+ - **Don't install a CSS-in-JS library** alongside Tailwind — pick one styling approach
282
+ - **Don't over-engineer navigation or routing** — Astro's file-based routing handles everything a docs site needs
283
+ - **Don't use deferred scripts for theme initialization** — theme preference must be applied in a blocking inline script to prevent flash-of-wrong-theme
@@ -0,0 +1,319 @@
1
+ ---
2
+ gspec-version: 1.8.0
3
+ description: Full-stack SaaS with Next.js App Router, Supabase (Postgres, Auth, RLS), and Vercel deployment
4
+ ---
5
+
6
+ # Technology Stack
7
+
8
+ ## 1. Overview
9
+
10
+ - **Architecture style:** Full-stack monolith — a single Next.js application handling both frontend rendering and API routes, backed by Supabase for managed database, authentication, and real-time capabilities.
11
+ - **Deployment target:** Vercel (serverless edge and Node.js runtimes). Supabase Cloud for managed Postgres and auth services.
12
+ - **Scale and performance requirements:** Early-stage SaaS supporting tens to low hundreds of concurrent users. Supabase connection pooling and Vercel's edge network handle initial scale. Architecture should support horizontal scaling without major refactoring.
13
+
14
+ ## 2. Open Questions & Clarifications
15
+
16
+ None — all critical decisions are resolved.
17
+
18
+ ## 3. Core Technology Stack
19
+
20
+ ### Programming Languages
21
+
22
+ - **Primary language:** TypeScript (strict mode enabled)
23
+ - **Rationale:** Type safety across the full stack (frontend + API routes + database queries). Reduces bugs, improves IDE support, and is the standard for modern Next.js development.
24
+ - **Language-specific tooling:**
25
+ - ESLint for linting (with `@next/eslint-plugin-next`)
26
+ - Prettier for formatting
27
+ - `typescript` compiler in strict mode (`strict: true` in `tsconfig.json`)
28
+
29
+ ### Runtime Environment
30
+
31
+ - **Runtime:** Node.js 20 LTS
32
+ - **Package manager:** pnpm
33
+ - **Rationale:** Faster installs, strict dependency resolution (prevents phantom dependencies), disk-efficient via content-addressable storage. Well-supported by Vercel.
34
+ - **Container runtime:** Not applicable — deployed as serverless functions on Vercel. Docker used only for local Supabase development via `supabase start`.
35
+
36
+ ## 4. Frontend Stack
37
+
38
+ ### Framework
39
+
40
+ - **Framework:** Next.js 15 (App Router)
41
+ - **Rationale:** React-based full-stack framework with server components, server actions, and API routes in a single project. First-class Vercel deployment support. App Router enables streaming, partial prerendering, and co-located data fetching.
42
+ - **React version:** React 19 (ships with Next.js 15)
43
+ - **Update strategy:** Stay on latest stable Next.js minor releases. Evaluate major upgrades within 2 weeks of release.
44
+
45
+ ### Build Tools
46
+
47
+ - **Bundler:** Turbopack (Next.js built-in, used in development)
48
+ - **Production builds:** Next.js built-in compiler (SWC-based)
49
+ - **No additional bundler configuration needed** — Next.js handles transpilation, code splitting, tree shaking, and minification out of the box.
50
+
51
+ ### State Management
52
+
53
+ - **Server state:** React Server Components for initial data loading. `@supabase/ssr` for authenticated server-side data fetching.
54
+ - **Client state:** React's built-in state (`useState`, `useReducer`, `useContext`) for local UI state. No external state management library needed at this stage.
55
+ - **Data fetching on the client:** Supabase client library for real-time subscriptions and client-initiated mutations. Consider adding `swr` or `@tanstack/react-query` only if caching/revalidation patterns become complex.
56
+
57
+ ### Styling Technology
58
+
59
+ - **CSS framework:** Tailwind CSS v4
60
+ - **Rationale:** Utility-first approach enables rapid UI development. Excellent tree-shaking keeps bundle size small.
61
+ - **Component library:** shadcn/ui
62
+ - **Rationale:** Copy-paste component primitives built on Radix UI. Fully customizable (not a locked dependency), accessible by default, designed for Tailwind. Components live in the codebase, not `node_modules`.
63
+ - **Design token mapping:** Tailwind's CSS custom properties (defined in `app/globals.css`) serve as the bridge between design tokens documented in `gspec/style.md` and utility classes. shadcn/ui's theming uses these same CSS variables for consistent styling.
64
+ - **Note**: Icon library choices are defined in `gspec/style.md`. The stack defines the CSS framework and component library; the style defines the icon set.
65
+
66
+ ### Progressive Web App
67
+
68
+ - **PWA implementation:** `next-pwa` (or `@serwist/next`) for service worker generation and caching.
69
+ - **Manifest:** `manifest.json` in the `public/` directory with app name, icons, theme color, and display mode (`standalone`).
70
+ - **Offline strategy:** Cache-first for static assets. Network-first for API calls with fallback to cached data where appropriate.
71
+ - **Install prompt:** Native browser install prompt. No custom install UI for MVP.
72
+
73
+ ## 5. Backend Stack
74
+
75
+ ### Framework
76
+
77
+ - **API layer:** Next.js Route Handlers (App Router `route.ts` files) for application API endpoints.
78
+ - **API style:** RESTful JSON APIs via Route Handlers. Supabase client SDK used directly in Server Components and Server Actions for database operations where no custom API logic is needed.
79
+ - **Server Actions:** Used for form mutations and simple data writes that don't need a formal API endpoint.
80
+
81
+ ### Database
82
+
83
+ - **Primary database:** Supabase Postgres (managed PostgreSQL)
84
+ - **Rationale:** Managed Postgres with built-in auth, Row Level Security, real-time subscriptions, and a generous free tier. Eliminates the need for a separate auth service and reduces infrastructure complexity.
85
+ - **ORM / query builder:** Supabase JavaScript client (`@supabase/supabase-js`) for data access. Supabase auto-generates a typed client from the database schema.
86
+ - **Type generation:** Use `supabase gen types typescript` to generate TypeScript types from the database schema. Regenerate after every migration.
87
+ - **Migration strategy:** Supabase CLI migrations (`supabase migration new`, `supabase db push`). Migrations are SQL files stored in `supabase/migrations/` and version-controlled in git.
88
+ - **Connection pooling:** Supabase's built-in Supavisor connection pooler (transaction mode) for serverless function compatibility.
89
+
90
+ ### Row Level Security (RLS)
91
+
92
+ - **RLS is mandatory on all tables.** Every table must have RLS enabled with appropriate policies before being used by the application.
93
+ - **Policy design:** Policies use `auth.uid()` to scope data access to the authenticated user's resources. Multi-tenant isolation is enforced at the database level, not the application level.
94
+ - **Service role:** The Supabase service role key is used only in server-side contexts (Route Handlers, Server Actions) when RLS bypass is explicitly needed (e.g., admin operations, background jobs). Never expose the service role key to the client.
95
+
96
+ ### Caching Layer
97
+
98
+ - **No dedicated caching service for MVP.** Leverage:
99
+ - Next.js Data Cache and `revalidatePath`/`revalidateTag` for server-side caching
100
+ - Vercel Edge Cache for static and ISR pages
101
+ - Browser caching via service worker (PWA)
102
+ - **Upgrade path:** Add Redis (Upstash) if query patterns demand it post-launch.
103
+
104
+ ### Message Queue / Event Bus
105
+
106
+ Not applicable for MVP. Background jobs (e.g., scheduled reports, data syncs) will use Vercel Cron to trigger Next.js Route Handlers on a schedule. This keeps all code in the single Next.js codebase. Upgrade to a dedicated queue if job volume or complexity warrants it.
107
+
108
+ ## 6. Infrastructure & DevOps
109
+
110
+ ### Cloud Provider
111
+
112
+ - **Primary:** Vercel for application hosting and edge network.
113
+ - **Database & Auth:** Supabase Cloud (runs on AWS under the hood).
114
+ - **Key services used:**
115
+ - Vercel: Serverless Functions, Edge Network, Preview Deployments, Analytics
116
+ - Supabase: Postgres, Auth, Realtime, Edge Functions, Storage (for file uploads if needed)
117
+
118
+ ### Container Orchestration
119
+
120
+ Not applicable — fully serverless architecture. Vercel manages function scaling and routing. Supabase manages database scaling.
121
+
122
+ ### CI/CD Pipeline
123
+
124
+ - **Platform:** GitHub Actions
125
+ - *Rationale:* Native GitHub integration for PRs and branch workflows. Pairs well with Vercel's GitHub integration for preview deployments.
126
+ - **Deployment trigger:** Merge to `main` branch.
127
+ - **Deployment method:** Vercel GitHub integration — automatic preview deploys on every PR, production deploy on merge to `main`.
128
+ - **Database migrations:** Applied manually via `supabase db push` or automated in the deploy pipeline for production.
129
+ - **Branch strategy:** Feature branches → PR → merge to `main` → auto-deploy to production.
130
+ - **Note:** Pipeline stages and structure (lint → typecheck → test → build → deploy) are defined in `gspec/practices.md`. This section defines the CI technology and deployment configuration.
131
+
132
+ ### Infrastructure as Code
133
+
134
+ - **Supabase configuration:** `supabase/config.toml` for local dev settings. SQL migrations in `supabase/migrations/` for schema changes.
135
+ - **Vercel configuration:** `vercel.json` for redirects, headers, and function configuration. Environment variables managed via Vercel dashboard and `vercel env pull` for local dev.
136
+ - **No dedicated IaC tool** (Terraform, etc.) needed at this stage — both Vercel and Supabase are fully managed.
137
+
138
+ ## 7. Data & Storage
139
+
140
+ ### File Storage
141
+
142
+ - **Object storage:** Supabase Storage for user-uploaded files (e.g., business logos, report assets).
143
+ - **CDN:** Vercel Edge Network for static assets. Supabase Storage has built-in CDN via its transformation API.
144
+ - **Asset management:** Static assets (images, fonts, icons) in `public/` directory, served via Vercel's CDN.
145
+
146
+ ### Data Warehouse / Analytics
147
+
148
+ Not applicable for MVP. Analytics via Vercel built-in analytics. Revisit when reporting features require historical data aggregation.
149
+
150
+ ## 8. Authentication & Security
151
+
152
+ ### Authentication
153
+
154
+ - **Auth provider:** Supabase Auth
155
+ - **Rationale:** Tightly integrated with Supabase Postgres and RLS. Supports email/password, magic links, and OAuth providers. Free tier is generous.
156
+ - **Authentication flow:**
157
+ - Email/password with email confirmation
158
+ - Magic link login as an alternative
159
+ - Google OAuth for quick signup
160
+ - Session management via Supabase Auth cookies (using `@supabase/ssr` for server-side session handling)
161
+ - **Custom login pages:** All auth UI is custom-built using shadcn/ui components. No Supabase-branded auth UI (`@supabase/auth-ui-react`) is used. Auth flows call `supabase.auth.signInWithPassword()`, `signUp()`, etc. directly.
162
+ - **Identity management:** Supabase Auth handles user records. Application-level user profiles stored in a `profiles` table linked to `auth.users` via foreign key.
163
+
164
+ ### Authorization
165
+
166
+ - **Pattern:** Row Level Security (RLS) at the database layer for data access control. Application-level role checks for UI and API authorization.
167
+ - **Roles:** Users belong to organizations. Roles (e.g., owner, member) are stored in a membership table and checked in RLS policies and server-side logic.
168
+ - **Permission management:** RLS policies are the primary enforcement mechanism. Server-side middleware validates session and role before processing sensitive operations.
169
+
170
+ ### Security Tools
171
+
172
+ - **Secrets management:** Environment variables stored in Vercel (production) and `.env.local` (development, git-ignored). Supabase service role key and other sensitive values never committed to source control.
173
+ - **Security headers:** Configured via `next.config.ts` security headers (CSP, HSTS, X-Frame-Options, etc.) and Vercel's built-in protections.
174
+ - **Dependency scanning:** Dependabot or Renovate for automated dependency updates. `pnpm audit` in CI pipeline.
175
+
176
+ ## 9. Monitoring & Observability
177
+
178
+ ### Application Monitoring
179
+
180
+ - **Primary:** Vercel Analytics (Web Vitals, page performance, function execution times).
181
+ - **Speed Insights:** Vercel Speed Insights for real-user Core Web Vitals monitoring.
182
+ - **Product analytics:** Google Analytics 4 (GA4) for user behavior tracking, acquisition channels, and conversion funnels. Integrated via `@next/third-parties` Google tag support for optimal Next.js compatibility (script loading, route change tracking). Measurement ID stored as a `NEXT_PUBLIC_GA_MEASUREMENT_ID` environment variable.
183
+ - **Upgrade path:** Add Sentry or Datadog if error volume or debugging complexity warrants it post-launch.
184
+
185
+ ### Logging
186
+
187
+ - **Application logs:** `console.log` / `console.error` in server functions, captured by Vercel's built-in log drain.
188
+ - **Supabase logs:** Available via Supabase Dashboard (Postgres logs, Auth logs, Edge Function logs).
189
+ - **Structured logging:** Use a lightweight structured logger (e.g., `pino`) if log volume grows and needs parsing.
190
+
191
+ ### Tracing
192
+
193
+ Not applicable for MVP — single-service architecture doesn't require distributed tracing. Vercel function logs provide request-level visibility.
194
+
195
+ ### Error Tracking
196
+
197
+ - **Primary:** Vercel's built-in error reporting for function errors and build failures.
198
+ - **Client-side:** React Error Boundaries for graceful UI error handling. Errors logged to console and visible in Vercel logs.
199
+ - **Upgrade path:** Add Sentry for structured error tracking with stack traces and release correlation.
200
+
201
+ ## 10. Testing Infrastructure
202
+
203
+ ### Testing Frameworks
204
+
205
+ - **Unit & integration testing:** Vitest
206
+ - **Rationale:** Fast, Vite-native, excellent TypeScript support, Jest-compatible API. Runs significantly faster than Jest for modern TypeScript projects.
207
+ - **E2E testing:** Playwright
208
+ - **Rationale:** Cross-browser support, reliable auto-waiting, excellent developer tooling (codegen, trace viewer). Runs against actual Vercel preview deployments.
209
+ - **Component testing:** Vitest with `@testing-library/react` for testing React components in isolation.
210
+
211
+ ### Test Data Management
212
+
213
+ - **Test database:** Local Supabase instance via `supabase start` (Docker-based) for integration tests.
214
+ - **Fixtures:** SQL seed files in `supabase/seed.sql` for consistent test data.
215
+ - **Mocking:** Vitest's built-in mocking for unit tests. MSW (Mock Service Worker) for mocking external API calls in integration tests.
216
+
217
+ ### Performance Testing
218
+
219
+ Not applicable for MVP. Add load testing (k6 or similar) when approaching production scale.
220
+
221
+ ## 11. Third-Party Integrations
222
+
223
+ ### External Services
224
+
225
+ ### API Clients
226
+
227
+ - **HTTP client:** Native `fetch` API (available in Node.js 20+ and Next.js server contexts). No Axios dependency needed.
228
+ - **SDK usage:** Use official SDKs where available (e.g., Google APIs client library). Fall back to `fetch` for APIs without official TypeScript SDKs.
229
+ - **API versioning:** Pin external API versions where possible. Abstract third-party API calls behind internal service modules to isolate breaking changes.
230
+
231
+ ## 12. Development Tools
232
+
233
+ ### Package Management
234
+
235
+ - **Package manager:** pnpm (v9+)
236
+ - **Dependency strategy:** Pin exact versions in `pnpm-lock.yaml`. Use `pnpm up --latest` for controlled upgrades. Automated dependency PRs via Dependabot or Renovate.
237
+ - **Private registry:** Not applicable.
238
+
239
+ ### Code Quality Tools
240
+
241
+ - **Linter:** ESLint with `@next/eslint-plugin-next`, `eslint-plugin-react-hooks`, and `typescript-eslint`
242
+ - **Formatter:** Prettier (integrated with ESLint via `eslint-config-prettier`)
243
+ - **Pre-commit hooks:** `lint-staged` + `husky` for running lint and format checks on staged files before commit
244
+
245
+ ### Local Development
246
+
247
+ - **Local environment:**
248
+ - `pnpm dev` — Next.js dev server with Turbopack
249
+ - `supabase start` — Local Supabase stack (Postgres, Auth, Storage, Realtime) via Docker
250
+ - `.env.local` — Local environment variables (Supabase URL, anon key, etc.)
251
+ - **Database GUI:** Supabase Studio (included with `supabase start`, available at `localhost:54323`)
252
+ - **Hot reload:** Turbopack provides fast refresh for frontend changes. Server-side changes auto-restart.
253
+
254
+ ## 13. Migration & Compatibility
255
+
256
+ ### Legacy System Integration
257
+
258
+ Not applicable — greenfield project with no legacy systems.
259
+
260
+ ### Upgrade Path
261
+
262
+ - **Next.js:** Follow Vercel's upgrade guides for major versions. Canary testing on preview branches before upgrading production.
263
+ - **Supabase:** Managed upgrades handled by Supabase Cloud. Test migration compatibility against local Supabase instance before applying to production.
264
+ - **Breaking change management:** Automated dependency update PRs. CI pipeline catches regressions before merge.
265
+
266
+ ## 14. Technology Decisions & Tradeoffs
267
+
268
+ ### Key Architectural Decisions
269
+
270
+ | Decision | Rationale | Alternative Considered | Tradeoff |
271
+ |---|---|---|---|
272
+ | **Next.js App Router** | Server components, streaming, co-located data fetching. Vercel-optimized. | Pages Router | App Router is newer with some rough edges, but is the future of Next.js |
273
+ | **Supabase over custom backend** | Managed Postgres + Auth + Realtime eliminates boilerplate. RLS provides multi-tenant security at the DB layer. | Separate API server + Auth0 + managed Postgres | Less flexibility in auth flows and background job processing, but dramatically faster to ship |
274
+ | **shadcn/ui over a component library** | Components live in the codebase, fully customizable. No version lock-in. | MUI, Chakra, Mantine | More initial setup than a batteries-included library, but better long-term control |
275
+ | **Custom auth pages over Supabase Auth UI** | Full brand control, no Supabase branding, custom UX | `@supabase/auth-ui-react` | More code to maintain, but necessary for professional SaaS appearance |
276
+ | **Vercel over self-hosted** | Zero-config deploys, preview environments, edge network, analytics. | AWS (ECS/Lambda), Fly.io | Vendor lock-in to Vercel, higher costs at scale. Acceptable for early stage. |
277
+ | **RLS over application-level authorization** | Security enforced at DB layer — no way to accidentally bypass in application code | Middleware-only auth checks | RLS policies are harder to debug and test. Worth it for multi-tenant data isolation. |
278
+
279
+ ### Risk Mitigation
280
+
281
+ - **Vercel vendor lock-in:** Next.js is open source and can be self-hosted. Migration path exists if Vercel costs become prohibitive.
282
+ - **Supabase availability:** Supabase is backed by standard Postgres. Data can be migrated to any Postgres host. Auth can be replaced with a custom solution or another provider.
283
+ - **Serverless cold starts:** Vercel's edge runtime and function warm-up mitigate most cold start issues. Monitor function execution times via Vercel Analytics.
284
+
285
+ ## 15. Technology-Specific Practices
286
+
287
+ ### Framework Conventions & Patterns
288
+
289
+ - **App Router structure:** Use the `app/` directory with route groups for logical organization (e.g., `(auth)` for login/signup, `(dashboard)` for authenticated pages, `(marketing)` for public pages).
290
+ - **Server vs Client Components:** Default to Server Components. Add `"use client"` only when the component needs browser APIs, event handlers, or React hooks (`useState`, `useEffect`).
291
+ - **Data fetching:** Fetch data in Server Components or Server Actions. Avoid `useEffect` for data fetching on the client. Use Supabase's real-time subscriptions for live updates on the client.
292
+ - **Route Handlers:** Use `app/api/` route handlers only for webhook endpoints, external API integrations, or operations that need explicit HTTP method handling. Prefer Server Actions for form mutations.
293
+ - **Loading and error states:** Use `loading.tsx` and `error.tsx` files at appropriate route levels for streaming UI and error boundaries.
294
+
295
+ ### Library Usage Patterns
296
+
297
+ - **Supabase client initialization:**
298
+ - Server Components / Server Actions: Create a Supabase client per-request using `@supabase/ssr` with cookie-based session handling
299
+ - Client Components: Create a browser client using `createBrowserClient` from `@supabase/ssr`
300
+ - Route Handlers: Create a server client with cookie access
301
+ - Never instantiate the service role client on the client side
302
+ - **shadcn/ui usage:** Components installed into `components/ui/`. Customize via the CSS variables in `globals.css`, not by modifying component internals directly unless necessary. Compose complex UI from shadcn primitives.
303
+ - **Tailwind conventions:** Use Tailwind utility classes directly in JSX. Avoid `@apply` except in `globals.css` for base styles. Use `cn()` utility (from shadcn) for conditional class merging. Follow mobile-first responsive design (`sm:`, `md:`, `lg:` breakpoints).
304
+
305
+ ### Language Idioms
306
+
307
+ - **TypeScript strict mode:** `strict: true` in `tsconfig.json`. No `any` types except in genuinely dynamic contexts. Use `unknown` and narrow with type guards.
308
+ - **Import organization:** Group imports in order: (1) React/Next.js, (2) third-party libraries, (3) internal modules, (4) relative imports. Enforce with ESLint import ordering rules.
309
+ - **Path aliases:** Use `@/` alias (configured in `tsconfig.json`) for imports from the project root. Example: `import { Button } from "@/components/ui/button"`.
310
+ - **Async patterns:** Use `async/await` consistently. Avoid `.then()` chains. Handle errors with try/catch in Server Actions and Route Handlers.
311
+
312
+ ### Stack-Specific Anti-Patterns
313
+
314
+ - **Do not use the Supabase service role key in Client Components or expose it via environment variables prefixed with `NEXT_PUBLIC_`.** This bypasses RLS and is a critical security vulnerability.
315
+ - **Do not disable RLS on tables**, even temporarily. Create permissive policies for development if needed, but never turn RLS off.
316
+ - **Do not use `useEffect` for data fetching** when a Server Component or Server Action can do the same work. This leads to client-side waterfalls and loading spinners.
317
+ - **Do not import server-only modules in Client Components.** Use the `server-only` package to enforce boundaries.
318
+ - **Do not store Supabase sessions in localStorage.** Use `@supabase/ssr` cookie-based session handling for secure, server-compatible auth.
319
+ - **Avoid excessive `"use client"` directives.** Push interactivity to leaf components and keep parent layouts as Server Components for better performance and smaller client bundles.