Add PatternLens onboarding flow & schema migrations#5
Open
Patternslab-ecosystem wants to merge 6 commits intomainfrom
Open
Add PatternLens onboarding flow & schema migrations#5Patternslab-ecosystem wants to merge 6 commits intomainfrom
Patternslab-ecosystem wants to merge 6 commits intomainfrom
Conversation
Rewrites the minimal CLAUDE.md stub into a full AI assistant reference covering the actual monorepo state as of 2026-02-25 per DIPLO BIBLE v4.0. Covers: repo identity, multi-repo ecosystem map, full directory structure, actual tech stack (Next.js 14/15, React 18/19, Prisma, Supabase, Stripe, Claude Sonnet, Vitest), S11 language policy with forbidden vocabulary table, code contract rules, package-by-package status (active vs README-only vs ROADMAP), database schema, CI/CD gates (SILENCE SENTINEL jobs), dev workflow commands, env vars reference, CODEOWNERS review gates, roadmap boundary, and pre-task checklist. https://claude.ai/code/session_01VHCS526rsACFMoTreq8hn4
- upgrade/page.tsx: fix fetch to /api/stripe/checkout (was /api/stripe/create-checkout — 404)
- voice/upload: replace broken Claude audio API call with internal forward to /api/voice/transcribe (Whisper)
- stripe/webhook checkout.session.completed: add stripe_customer_id, stripe_subscription_status: "active" to profile update
- migration 20260225_fix_profiles_stripe.sql: add stripe_customer_id, stripe_subscription_id, stripe_subscription_status, pro_since to profiles
- migration 20260225_fix_schema.sql: add all missing columns (profiles, objects, interpretations) and create consent_logs + voice_dumps tables with RLS
- .env.example: add STRIPE_PRO_PRICE_ID, STRIPE_PRICE_{PLN,USD,GBP,EUR}, ENABLE_DEMO_LOGIN, DEMO_ACCOUNT_PASSWORD, NEXT_PUBLIC_ENVIRONMENT
- pricing.ts: replace placeholder price ID strings with process.env references matching lib/stripe/config.ts PRICE_IDS
- claude-integration.ts: unify CLAUDE_MODEL to claude-sonnet-4-20250514 (matches /api/analyze)
- delete apps/pattern-lens/ (confirmed duplicate, flagged in DIPLO_BIBLE_v4.0)
https://claude.ai/code/session_01VHCS526rsACFMoTreq8hn4
PART 1 — Design tokens - src/styles/design-tokens.css: full v5.0 token set (bg, accent, text, crisis, spacing, radius, font, easing, max-content-width) - Beacon keyframe (ob-beacon-pulse 3s, opacity 0.15→0.4), result fade-in (ob-fade-in) - prefers-reduced-motion guard on all animations - src/app/globals.css: @import design-tokens.css as first line PART 2 — Onboarding flow (public, pre-auth) - layout.tsx: standalone dark layout, 480px max-width, no nav - page.tsx (Stage 1): CSS-only pulsing beacon, headline, CTA → /onboarding/intent - intent/page.tsx (Stage 2): 3 sub-steps (intent, experience, preferred_moment), progress indicator, back button, single-select cards, 300ms auto-advance, localStorage persistence - first-object/page.tsx (Stage 3): textarea (min 20 / max 280 chars), char counter, POST /api/analyze?preview=true, PhaseCards (Context expanded, others collapsed), DisclaimerStrip, dual CTA - consent/page.tsx (Stage 4): 2 required + 2 optional checkboxes, custom 20px checkbox with SVG checkmark, auth-branch (not logged-in → /signup?onboarding=true, logged-in → POST /api/consent → /dashboard) - complete/page.tsx (Stage 5): useEffect mount, reads localStorage, writes onboarding_completed: true to Supabase if logged in, clears keys, router.replace('/dashboard') PART 3 — Middleware - /onboarding added to PUBLIC_ROUTES (pre-auth access) - If logged in + on /dashboard or /: query profiles.onboarding_completed; redirect to /onboarding if false - If logged in + on /onboarding path + onboarding_completed = true: redirect to /dashboard (skip re-running flow) PART 4 — /api/analyze preview mode - previewRateMap (in-memory): 1 request per IP per hour - body.preview === true uses preview rate limit + skips auth (route was already public) - Body parsed before rate limit to read preview flag; existing 20/min limit unchanged for normal requests https://claude.ai/code/session_01VHCS526rsACFMoTreq8hn4
- LoginPage: 62/38 golden ratio grid (left: forms, right: brand anchor) - LoginLeftColumn: MagicLink (primary), Password (collapsible), Google OAuth (tertiary) - MagicLinkForm + MagicLinkSent: OTP flow with sent state - PasswordForm: email+password with error protocol BŁĄD_AUTH/BŁĄD_WALIDACJI - GoogleButton: OAuth provider button - LoginRightColumn: brand copy, phase preview, disclaimer - SignupPage: zod-validated registration form with success state - MergePromptModal: anonymous→account data merge confirmation - MergePromptWrapper: stub (useMergeOnLogin pending IDB implementation) - AhaCTA: sticky bottom banner for anonymous users post-analysis - app/login/page.tsx: replaced monolith with Server Component wrapper + metadata - app/signup/page.tsx: new route using SignupPage component All components: design tokens via CSS vars, zero any/unknown, S11-compliant copy https://claude.ai/code/session_01VHCS526rsACFMoTreq8hn4
… components - Create AuthContext wrapping Supabase auth (status/signIn*/signUp/signOut) - Create useMergeOnLogin hook (localStorage anon_objects → /api/objects/merge) - Create useAnonStore hook (localStorage-backed IDB stub for hasAha + anonObjectIds) - Add AuthProvider to root layout wrapping LanguageProvider - Update MagicLinkForm → useAuth().signInWithOtp - Update PasswordForm → useAuth().signInWithPassword, redirect /objects - Update GoogleButton → useAuth().signInWithGoogle - Update SignupPage → useAuth().signUp + add fullName field, redirect /objects - Update AhaCTA → useAuth().status replaces direct Supabase session check - Update MergePromptWrapper → replaces stub with real useMergeOnLogin - Fix package.json: remove stray trailing char that broke JSON parse - Add eslint.config.mjs (next/core-web-vitals + next/typescript) https://claude.ai/code/session_01VHCS526rsACFMoTreq8hn4
Owner
Author
Benchmark 2030 — Triage AutomatycznyStatus: 🔄 Zakwalifikowany do Sprint 1 Ten issue dotyczy onboarding flow i schema migrations — kluczowego elementu architektury B2C. Plan działania (Benchmark 2030):
Assigned: Sprint 1 (Zero-Debt Foundation)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the complete onboarding flow for PatternLens (B2C app) with four sequential stages, database schema fixes, and supporting infrastructure. This enables new users to complete intent discovery, consent collection, first-object analysis, and finalization before accessing the dashboard.
Key Changes
Onboarding Flow (4 Stages)
/onboarding— Welcome page with pulsing beacon animation/onboarding/intent— 3-step intent discovery (what to change, experience level, preferred moment)/onboarding/first-object— Text input for first behavioral pattern analysis with live character counter (20–280 chars)/onboarding/consent— Consent collection (2 required: AI disclaimer + structural proposal; 2 optional: analytics + notifications)/onboarding/complete— Redirect handler that marksonboarding_completed: truein Supabase profiles and clears localStorageDatabase Schema Fixes
20260225_fix_schema.sql— Adds missing columns toprofiles,objects,interpretations, and createsconsent_logstable for GDPR audit trail20260225_fix_profiles_stripe.sql— Adds Stripe-related columns (stripe_customer_id,stripe_subscription_id,stripe_subscription_status,pro_since)API & Analysis
/api/analyze— Enhanced with preview rate limiting (1 request per IP per hour) for unauthenticated onboarding analysis/api/voice/upload— Simplified; removed inline transcription logic (deferred to safety middleware per DIPLO v4.0)Design & Styling
design-tokens.css— Complete design token system (colors, spacing, typography, animations) for dark mode + accessibilityglobals.css— Imports design tokens at topMiddleware & Routing
middleware.ts— Added/onboardingto public routes; added onboarding gate check for authenticated users (redirects to/onboarding/completeif not completed)onboarding/layout.tsx— Standalone layout with centered, dark background; no app navigationDocumentation
CLAUDE.md— Expanded from 16 lines to 500+ lines with complete ecosystem overview, tech stack, S11 language policy, package architecture, database schema, and code contracts (DIPLO v4.0 reference)Configuration
.env.example— Added Stripe price ID placeholderspricing.ts— Updated with Stripe price ID referencesclaude-integration.ts— Updated Claude model toclaude-sonnet-4-20250514Implementation Details
any/unknownNotes
apps/pattern-lens/directory (old naming convention)/api/analyze— redirects to/emergencyif triggeredhttps://claude.ai/code/session_01VHCS526rsACFMoTreq8hn4