# gomezsergio3002-afk/mimo-gift architecture

> Architecture diagram of the GitHub repository gomezsergio3002-afk/mimo-gift, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gomezsergio3002-afk/mimo-gift
- Repository: https://github.com/gomezsergio3002-afk/mimo-gift

## Overview

#### Purpose and Runtime
A Next.js 15 TypeScript application combining a SaaS subscription starter with a personalized gift-creation experience. It runs as a React/Next App Router service, styled with Tailwind and shadcn/ui, and is intended for Vercel deployment. Global application composition begins at `src/app/layout.tsx`; request/session handling is centralized in `src/middleware.ts`.

#### Route Domains and Entry Points
Public marketing routes use the site group: `src/app/(site)/page.tsx` and `src/app/(site)/pricing/page.tsx`. Authentication is isolated under `src/app/(auth)/login/page.tsx`, with Supabase callback completion at `src/app/(auth)/auth/callback/route.ts`. Signed-in account functionality is under `src/app/(account)/account/page.tsx`. Gift creation and rendering are separately entered through `src/app/gift-wizard/page.tsx` and `src/app/gift-preview/page.tsx`.

#### Authentication and Account Boundary
Supabase provides authentication and Postgres persistence. Server, admin, and middleware-scoped clients are deliberately separated in `src/libs/supabase/supabase-server-client.ts`, `src/libs/supabase/supabase-admin.ts`, and `src/libs/supabase/supabase-middleware-client.ts`. Account controllers encapsulate user/session/customer/subscription lookup and persistence, especially `src/features/account/controllers/get-session.ts`, `src/features/account/controllers/get-subscription.ts`, and `src/features/account/controllers/upsert-user-subscription.ts`.

#### Billing and Stripe Synchronization
Pricing UI obtains locally synchronized products, then invokes a checkout server action: `src/features/pricing/controllers/get-products.ts`, `src/features/pricing/actions/create-checkout-action.ts`, and `src/features/pricing/components/pricing-section.tsx`. Stripe integration is privileged behind `src/libs/stripe/stripe-admin.ts`. Stripe events enter through `src/app/api/webhooks/route.ts`, which is the critical external trust boundary: verified webhook payloads synchronize products, prices, customers, and subscription state into Supabase. The customer portal is exposed by `src/app/(account)/manage-subscription/route.ts`.

#### Gift Authoring and Presentation
The gift feature is a client-facing multi-step authoring flow. `src/features/gift/wizard/wizard.tsx` coordinates steps, navigation, preview, and publication-oriented UI; individual content stages live in paths such as `src/features/gift/wizard/steps/step-fotos.tsx` and `src/features/gift/wizard/steps/step-musica.tsx`. Shared gift state shape/defaults are defined by `src/features/gift/models/gift-schema.ts` and `src/features/gift/models/defaults.ts`. Final presentation is composed from sectional components through `src/features/gift/components/gift-page.tsx`, including photos, music, messages, activities, vouchers, and wheel content.

#### Persistence and Schema Ownership
Database schema is owned through Supabase migrations, beginning with `supabase/migrations/20240115041359_init.sql`; local bootstrap data is in `supabase/seed.sql`. Stripe catalog bootstrap is externalized in `stripe-fixtures.json`, then converges into Supabase via webhook processing. Feature controllers, rather than route components, should remain the boundary for database and Stripe-side mutations.

#### Supporting External Services
Resend is the transactional email provider, accessed through `src/libs/resend/resend-client.ts`; email templates are feature-owned, e.g. `src/features/emails/welcome.tsx`. Required runtime secrets cover Supabase public/service credentials, Stripe publishable/secret/webhook credentials, and Resend API access, documented by `.env.local.example`.

Main entry points: [`src/libs/supabase/supabase-server-client.ts`](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/libs/supabase/supabase-server-client.ts) (Supabase client boundary), [`src/features/account/controllers/get-session.ts`](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/account/controllers/get-session.ts) (Account controllers), [`src/app/(account)/account/page.tsx`](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/app/(account)/account/page.tsx) (Account area), [`src/features/gift/wizard/wizard.tsx`](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/gift/wizard/wizard.tsx) (Gift wizard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Next.js runtime"]
  node_app_layout["App composition<br/>Next.js layout<br/>[layout.tsx]"]
  node_middleware["Session middleware<br/>Next.js middleware<br/>[middleware.ts]"]
  node_account_controllers["Account controllers<br/>Feature controllers<br/>[get-session.ts]"]
end

subgraph group_routes["Route domains"]
  node_public_routes["Marketing &amp; auth<br/>App Router pages<br/>[page.tsx]"]
  node_account_routes["Account area<br/>Protected routes<br/>[page.tsx]"]
  node_gift_routes["Gift routes<br/>App Router pages<br/>[page.tsx]"]
  node_auth_callback["Auth callback<br/>Route handler<br/>[route.ts]"]
end

subgraph group_billing["Billing"]
  node_pricing_ui["Pricing section<br/>Feature UI"]
  node_checkout_action["Checkout action<br/>Server action"]
  node_stripe_webhook{{"Stripe webhook<br/>Route handler<br/>[route.ts]"}}
  node_stripe_client["Stripe admin<br/>Privileged client<br/>[stripe-admin.ts]"]
end

subgraph group_gift["Gift experience"]
  node_gift_wizard["Gift wizard<br/>Client flow<br/>[wizard.tsx]"]
  node_gift_steps["Gift content steps<br/>Wizard stages<br/>[step-fotos.tsx]"]
  node_gift_model["Gift state model<br/>Schema &amp; defaults<br/>[gift-schema.ts]"]
  node_gift_page["Gift presentation<br/>Section composer<br/>[gift-page.tsx]"]
end

subgraph group_data["Data &amp; external services"]
  node_supabase_clients["Supabase client boundary<br/>Scoped clients"]
  node_supabase_db[("Supabase Auth &amp; Postgres<br/>Managed backend")]
  node_stripe[("Stripe<br/>Payment platform")]
  node_email["Transactional email<br/>Resend integration<br/>[resend-client.ts]"]
end

node_app_layout -->|"composes"| node_public_routes
node_middleware -->|"refreshes session"| node_supabase_clients
node_middleware -->|"guards"| node_account_routes
node_auth_callback -->|"completes auth"| node_supabase_clients
node_account_routes -->|"uses"| node_account_controllers
node_account_controllers -->|"queries via"| node_supabase_clients
node_supabase_clients -->|"auth &amp; persistence"| node_supabase_db
node_public_routes -->|"renders"| node_pricing_ui
node_pricing_ui -->|"starts checkout"| node_checkout_action
node_checkout_action -->|"creates session"| node_stripe_client
node_stripe_client -->|"API access"| node_stripe
node_stripe -->|"signed events"| node_stripe_webhook
node_stripe_webhook -->|"syncs catalog &amp; subscriptions"| node_supabase_db
node_account_routes -->|"customer portal"| node_stripe_client
node_gift_routes -->|"authors"| node_gift_wizard
node_gift_wizard -->|"drives"| node_gift_steps
node_gift_steps -->|"updates"| node_gift_model
node_gift_wizard -->|"previews"| node_gift_page
node_gift_model -->|"supplies content"| node_gift_page
node_account_controllers -.->|"triggers transactional mail"| node_email

click node_app_layout "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/app/layout.tsx"
click node_middleware "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/middleware.ts"
click node_public_routes "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/app/(site)/page.tsx"
click node_account_routes "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/app/(account)/account/page.tsx"
click node_gift_routes "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/app/gift-wizard/page.tsx"
click node_auth_callback "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/app/(auth)/auth/callback/route.ts"
click node_account_controllers "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/account/controllers/get-session.ts"
click node_pricing_ui "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/pricing/components/pricing-section.tsx"
click node_checkout_action "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/pricing/actions/create-checkout-action.ts"
click node_stripe_webhook "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/app/api/webhooks/route.ts"
click node_stripe_client "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/libs/stripe/stripe-admin.ts"
click node_gift_wizard "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/gift/wizard/wizard.tsx"
click node_gift_steps "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/gift/wizard/steps/step-fotos.tsx"
click node_gift_model "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/gift/models/gift-schema.ts"
click node_gift_page "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/gift/components/gift-page.tsx"
click node_supabase_clients "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/libs/supabase/supabase-server-client.ts"
click node_supabase_db "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/supabase/migrations/20240115041359_init.sql"
click node_stripe "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/stripe-fixtures.json"
click node_email "https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/libs/resend/resend-client.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_layout,node_middleware,node_account_controllers toneBlue
class node_public_routes,node_account_routes,node_gift_routes,node_auth_callback toneAmber
class node_pricing_ui,node_checkout_action,node_stripe_webhook,node_stripe_client toneMint
class node_gift_wizard,node_gift_steps,node_gift_model,node_gift_page toneRose
class node_supabase_clients,node_supabase_db,node_stripe,node_email toneIndigo
```

## Components

### Next.js runtime

- [App composition](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/app/layout.tsx): Next.js layout · `src/app/layout.tsx`
- [Session middleware](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/middleware.ts): Next.js middleware · `src/middleware.ts`
- [Account controllers](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/account/controllers/get-session.ts): Feature controllers · Session, customer, and subscription persistence boundary. · `src/features/account/controllers/get-session.ts`

### Route domains

- [Marketing & auth](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/app/(site)/page.tsx): App Router pages · Site, pricing, and login entry points. · `src/app/(site)/page.tsx`
- [Account area](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/app/(account)/account/page.tsx): Protected routes · Account page and subscription management endpoint. · `src/app/(account)/account/page.tsx`
- [Gift routes](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/app/gift-wizard/page.tsx): App Router pages · Wizard and final preview entry points. · `src/app/gift-wizard/page.tsx`
- [Auth callback](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/app/(auth)/auth/callback/route.ts): Route handler · `src/app/(auth)/auth/callback/route.ts`

### Billing

- [Pricing section](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/pricing/components/pricing-section.tsx): Feature UI · `src/features/pricing/components/pricing-section.tsx`
- [Checkout action](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/pricing/actions/create-checkout-action.ts): Server action · `src/features/pricing/actions/create-checkout-action.ts`
- [Stripe webhook](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/app/api/webhooks/route.ts): Route handler · Verified external event trust boundary. · `src/app/api/webhooks/route.ts`
- [Stripe admin](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/libs/stripe/stripe-admin.ts): Privileged client · `src/libs/stripe/stripe-admin.ts`

### Gift experience

- [Gift wizard](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/gift/wizard/wizard.tsx): Client flow · Coordinates multi-step authoring, preview, and publication UI. · `src/features/gift/wizard/wizard.tsx`
- [Gift content steps](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/gift/wizard/steps/step-fotos.tsx): Wizard stages · Photo and music stages represent authoring inputs. · `src/features/gift/wizard/steps/step-fotos.tsx`
- [Gift state model](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/gift/models/gift-schema.ts): Schema & defaults · `src/features/gift/models/gift-schema.ts`
- [Gift presentation](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/features/gift/components/gift-page.tsx): Section composer · Renders photos, music, messages, activities, vouchers, and wheel. · `src/features/gift/components/gift-page.tsx`

### Data & external services

- [Supabase client boundary](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/libs/supabase/supabase-server-client.ts): Scoped clients · Separate server, admin, and middleware clients. · `src/libs/supabase/supabase-server-client.ts`
- [Supabase Auth & Postgres](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/supabase/migrations/20240115041359_init.sql): Managed backend · `supabase/migrations/20240115041359_init.sql`
- [Stripe](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/stripe-fixtures.json): Payment platform · `stripe-fixtures.json`
- [Transactional email](https://github.com/gomezsergio3002-afk/mimo-gift/blob/main/src/libs/resend/resend-client.ts): Resend integration · Feature-owned templates send through Resend. · `src/libs/resend/resend-client.ts`

## Connections

- App composition → Marketing & auth: composes
- Session middleware → Supabase client boundary: refreshes session
- Session middleware → Account area: guards
- Auth callback → Supabase client boundary: completes auth
- Account area → Account controllers: uses
- Account controllers → Supabase client boundary: queries via
- Supabase client boundary → Supabase Auth & Postgres: auth & persistence
- Marketing & auth → Pricing section: renders
- Pricing section → Checkout action: starts checkout
- Checkout action → Stripe admin: creates session
- Stripe admin → Stripe: API access
- Stripe → Stripe webhook: signed events
- Stripe webhook → Supabase Auth & Postgres: syncs catalog & subscriptions
- Account area → Stripe admin: customer portal
- Gift routes → Gift wizard: authors
- Gift wizard → Gift content steps: drives
- Gift content steps → Gift state model: updates
- Gift wizard → Gift presentation: previews
- Gift state model → Gift presentation: supplies content
- Account controllers → Transactional email: triggers transactional mail
