How hugowelk/norte-v1 works
1. What this repo is
- A React + TypeScript single-page app built with Vite and Tailwind/shadcn UI.
- It is not just a marketing site: the app contains a guided quiz, a paywall, an asynchronous report-generation backend, and an admin area.
2. Main runtime boundary
- The browser hosts the entire interactive frontend.
- Supabase is the server-side boundary: it provides the database, edge functions, and generated report storage/status.
- The frontend talks to Supabase through src/integrations/supabase/client.ts; backend logic lives under supabase/functions and schema/history under supabase/migrations.
3. Primary user journey
- The core flow is a multi-step quiz experience in src/components/quiz driven by src/components/QuizFlow.tsx.
- The quiz collects preferences and inputs, then moves through tradeoff, reflection, and results screens.
- NameEmailCapture.tsx indicates the handoff from anonymous quiz completion to a known user/session before report generation.
4. Scoring and recommendation layer
- src/lib/algorithm.ts, src/lib/values.ts, and src/lib/valueExplanations.ts form the client-side logic for interpreting quiz answers.
- These files likely produce the user’s “value compass,” chosen values, and narrative explanations shown in the results and report UI.
- This is the domain logic that converts raw quiz answers into personalized output.
5. Paywall and post-paywall flow
- The app has an explicit monetization boundary, with dedicated components in src/components/quiz/Paywall.tsx and src/components/post-paywall/*.
- src/lib/postPaywallStore.ts and src/lib/pendingSession.ts suggest the app persists state so users can recover after leaving the paywall or coming back later.
- SessionRecovery.tsx indicates abandoned or interrupted sessions are a first-class case, not an edge case.
6. Report generation and delivery
- Report creation is asynchronous and backend-assisted.
- supabase/functions/generate-report contains locale-specific prompt templates (prompt.en.ts, prompt.pt-BR.ts), so generated report content is language-aware.
- check-report-status suggests the client polls or refreshes status until the report is ready, then renders it through the report page.
7. Report presentation layer
- src/pages/ReportPage.tsx is the end-user destination for generated results.
- The report is composed from focused sections in src/components/report, including the hero, gap visualization, markdown content, actions, privacy notice, and a not-found state.
- ReportMarkdown.tsx implies the generated content is stored or delivered as markdown and rendered in the client.
8. Admin subsystem
- There is a separate admin area in src/pages/Admin.tsx and src/pages/AdminTranslations.tsx.
- Supabase edge functions admin-list and admin-delete-report provide admin-only report operations.
- src/components/admin/ReportsChart.tsx shows the admin side includes reporting/analytics visualization, not just CRUD.
9. Internationalization and locale-aware content
- The app supports at least en and pt-BR via src/i18n/locales/*.
- src/i18n/index.ts, useLang.ts, and helpers in src/lib/i18nHelpers.ts coordinate language selection and content completeness.
- LanguagePicker.tsx makes locale a user-facing part of the product, and the backend prompt templates mirror those locales.
10. Cross-cutting client services
- src/lib/analytics.ts centralizes event tracking for the funnel.
- src/lib/reportOwnership.ts likely ensures only the correct user can access a report.
- src/lib/useDocumentMeta.ts and the localized metadata files under src/i18n/locales/*/meta.json indicate SEO/title/description are managed per route and language.
11. UI foundation
- src/components/ui/* is a generated/shared component library layer used across quiz, report, admin, and navigation screens.
- This separates reusable primitives from product-specific flows, which is helpful when drawing the architecture: shared UI at the bottom, flow-specific composites above it.
12. Build, deploy, and operational shape
- Vite builds the frontend; Supabase migrations/functions define the backend runtime.
- Tests exist via Vitest (vitest.config.ts, src/test/*), but the architecture is centered on runtime separation between static client and Supabase services.
- public/robots.txt, sitemap.xml, and llms.txt suggest the app is also optimized for discoverability and content indexing.
Main entry points: QuizFlow.tsx Quiz Flow · client.ts Supabase Client · App.tsx App Shell · quiz Quiz Steps
Components 22
Client App
Browser-hosted React frontend and user-facing flows.
- Bootstrap · Vite/React application bootstrap and root wiring.
src/main.tsx - App Shell · Top-level app composition and route selection.
src/App.tsx - Landing · Public entry page and main funnel starting point.
src/pages/Index.tsx - Quiz Flow · Orchestrates the guided quiz experience across multiple stages.
src/components/QuizFlow.tsx - Quiz Steps · Core quiz screens for values, tradeoffs, reflection, capture, and results.
src/components/quiz - Paywall · Payment gate and recovery-aware handoff into post-paywall flow.
src/components/quiz/Paywall.tsx - Post-Paywall · Deferred content and continuation screens shown after payment.
src/components/post-paywall - Session Recovery · Resumes interrupted or abandoned quiz/report sessions.
src/components/SessionRecovery.tsx - Report Page · End-user destination for generated personalized reports.
src/pages/ReportPage.tsx - Report Sections · Hero, gap visualization, markdown, actions, privacy, and empty-state report UI.
src/components/report - Admin Area · Administrative report management and translation oversight.
src/pages/Admin.tsx - Admin Tools · Admin navigation and analytics/charting components.
src/components/admin
Supabase
Server-side database, edge functions, and generated report storage/status.
- Supabase Client · Frontend gateway to Supabase services.
src/integrations/supabase/client.ts - Generate Report · Async report generation with locale-specific prompt templates.
supabase/functions/generate-report/index.ts - Check Status · Polls report readiness and delivery status.
supabase/functions/check-report-status/index.ts - Admin APIs · Admin-only list and delete operations for reports.
supabase/functions/admin-list/index.ts - Migrations · Database schema and policy evolution for report/session storage.
supabase/migrations
Shared Layers
Reusable client services, UI primitives, and locale/content foundations.
- UI Library · Reusable shadcn-style UI primitives shared across the app.
src/components/ui - Value Logic · Client-side scoring, value selection, and narrative explanation logic.
src/lib/algorithm.ts - Analytics · Centralized funnel/event tracking utilities.
src/lib/analytics.ts - i18n · Language selection, completeness checks, and locale-aware metadata/content helpers.
src/i18n/index.ts - Locale Content · Localized strings and metadata for supported languages.
src/i18n/locales/en/common.json
Connections 27
- Bootstrap → App Shell: bootstraps · Root rendering mounts the app shell.
- App Shell → Landing: routes · App shell routes into the public landing and funnel entry.
- App Shell → Quiz Flow: hosts · Main app shell embeds the guided quiz experience.
- Quiz Flow → Quiz Steps: orchestrates · Flow controller advances through quiz stages.
- Quiz Flow → Paywall: gates · Quiz completion can lead into the monetization boundary.
- Paywall → Post-Paywall: hands off · Paid users continue into deferred post-paywall content.
- Quiz Flow → Session Recovery: recovers · Interrupted sessions can be resumed mid-funnel.
- Quiz Steps → Value Logic: uses · Quiz answers are scored and translated into value outcomes.
- Quiz Steps → Analytics: tracks · Key funnel steps emit analytics events.
- Quiz Steps → i18n: localizes · Quiz copy and labels are language-aware.
- Post-Paywall → Supabase Client: loads · Deferred screens fetch or confirm backend state through the client.
- Supabase Client → Generate Report: calls · Frontend requests asynchronous report creation.
- Supabase Client → Check Status: polls · Frontend checks report readiness until completion.
- Supabase Client → Admin APIs: admin ops · Admin screens reach report management functions.
- Generate Report → Migrations: persists · Generated reports rely on database/storage schema and policies.
- Check Status → Migrations: reads · Status checks depend on persisted backend records.
- Report Page → Report Sections: composes · Report page assembles the presentation sections.
- Report Sections → Supabase Client: fetches · Report content/status is loaded from backend services.
- Report Sections → Value Logic: renders · Generated outcomes are presented using the same domain model.
- Admin Area → Admin Tools: uses · Admin routes embed navigation and analytics views.
- Admin Tools → Admin APIs: queries · Admin charts and lists are backed by admin edge functions.
- i18n → Locale Content: sources · Language selection resolves to locale-specific copy and metadata.
- Report Page → i18n: localizes · Report presentation adapts to the selected language.
- App Shell → UI Library: uses · Product flows are built from shared UI primitives.
- Quiz Flow → UI Library: uses · Quiz screens depend on common UI components.
- Report Sections → UI Library: uses · Report presentation is assembled from shared primitives.
- Admin Tools → UI Library: uses · Admin screens reuse the same component library.