# baranwal-meet10/magic_moment architecture

> Architecture diagram of the GitHub repository baranwal-meet10/magic_moment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/baranwal-meet10/magic_moment
- Repository: https://github.com/baranwal-meet10/magic_moment

## Overview

GiftLink lets a sender compose a themed message and optional photo, create a private share link, and lets a recipient unwrap it once to reveal the message and any image. The README documents the atomic open, metadata isolation, rate limiting, and private storage policy; sampled route excerpts show the client-side create and reveal responsibilities. Supabase RPC internals and several route details are documented but not present in the supplied source excerpts, so those boundaries are represented at the documented service level.

Main entry points: [`src/routes/create.tsx`](https://github.com/baranwal-meet10/magic_moment/blob/main/src/routes/create.tsx) (Gift authoring), [`src/routes/g.$slug.tsx`](https://github.com/baranwal-meet10/magic_moment/blob/main/src/routes/g.%24slug.tsx) (Gift reveal), [`src/integrations/supabase/client.server.ts`](https://github.com/baranwal-meet10/magic_moment/blob/main/src/integrations/supabase/client.server.ts) (Admin client), [`src/lib/gift-images.functions.ts`](https://github.com/baranwal-meet10/magic_moment/blob/main/src/lib/gift-images.functions.ts) (Signed image URLs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_journey["Gift journey"]
  node_landing["Landing page<br/>[index.tsx]"]
  node_author["Gift authoring<br/>[create.tsx]"]
  node_unwrap["Gift reveal<br/>[g.$slug.tsx]"]
end

subgraph group_presentation["Gift presentation"]
  node_theme["Theme engine<br/>[theme.ts]"]
  node_theme_picker["Theme picker<br/>[theme-drawer.tsx]"]
  node_unwrap_motion["Touch controls<br/>[mobile-touch.tsx]"]
  node_loading["Create progress"]
  node_ui_primitives["UI primitives"]
end

subgraph group_platform["Runtime platform"]
  node_client["Supabase client<br/>[client.ts]"]
  node_server_client["Admin client<br/>[client.server.ts]"]
  node_server["SSR request handler<br/>[server.ts]"]
  node_error_page["Error response page<br/>[error-page.ts]"]
end

subgraph group_operations["Security and media"]
  node_rpc["Gift RPC service"]
  node_database[("Postgres gifts")]
  node_media[("Private image storage")]
  node_image_urls["Signed image URLs"]
end

node_visitor(("Visitor"))

node_visitor -->|"opens site"| node_landing
node_visitor -->|"creates gift"| node_author
node_visitor -.->|"opens link"| node_unwrap
node_author -->|"selects theme"| node_theme_picker
node_author -->|"uses theme"| node_theme
node_author -->|"shows progress"| node_loading
node_author -->|"calls API"| node_client
node_author -->|"uploads photo"| node_media
node_author -->|"creates gift"| node_rpc
node_rpc -->|"writes gift"| node_database
node_unwrap -->|"calls API"| node_client
node_unwrap -->|"looks up and opens"| node_rpc
node_rpc -->|"reads and opens"| node_database
node_unwrap -->|"styles reveal"| node_theme
node_unwrap -->|"uses controls"| node_unwrap_motion
node_unwrap -->|"requests image URLs"| node_image_urls
node_image_urls -->|"uses admin client"| node_server_client
node_server_client -.->|"signs image access"| node_media
node_server -->|"renders on error"| node_error_page

click node_landing "https://github.com/baranwal-meet10/magic_moment/blob/main/src/routes/index.tsx"
click node_author "https://github.com/baranwal-meet10/magic_moment/blob/main/src/routes/create.tsx"
click node_unwrap "https://github.com/baranwal-meet10/magic_moment/blob/main/src/routes/g.%24slug.tsx"
click node_theme "https://github.com/baranwal-meet10/magic_moment/blob/main/src/lib/theme.ts"
click node_theme_picker "https://github.com/baranwal-meet10/magic_moment/blob/main/src/components/theme-drawer.tsx"
click node_unwrap_motion "https://github.com/baranwal-meet10/magic_moment/blob/main/src/components/mobile-touch.tsx"
click node_loading "https://github.com/baranwal-meet10/magic_moment/blob/main/src/components/wrapping-loader.tsx"
click node_ui_primitives "https://github.com/baranwal-meet10/magic_moment/tree/main/src/components"
click node_client "https://github.com/baranwal-meet10/magic_moment/blob/main/src/integrations/supabase/client.ts"
click node_server_client "https://github.com/baranwal-meet10/magic_moment/blob/main/src/integrations/supabase/client.server.ts"
click node_image_urls "https://github.com/baranwal-meet10/magic_moment/blob/main/src/lib/gift-images.functions.ts"
click node_server "https://github.com/baranwal-meet10/magic_moment/blob/main/src/server.ts"
click node_error_page "https://github.com/baranwal-meet10/magic_moment/blob/main/src/lib/error-page.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_landing,node_author,node_unwrap toneBlue
class node_theme,node_theme_picker,node_unwrap_motion,node_loading,node_ui_primitives toneAmber
class node_client,node_server_client,node_server,node_error_page toneMint
class node_rpc,node_database,node_media,node_image_urls toneRose
class node_visitor toneIndigo
```

## Components

### Gift journey

- [Landing page](https://github.com/baranwal-meet10/magic_moment/blob/main/src/routes/index.tsx): `src/routes/index.tsx`
- [Gift authoring](https://github.com/baranwal-meet10/magic_moment/blob/main/src/routes/create.tsx): `src/routes/create.tsx`
- [Gift reveal](https://github.com/baranwal-meet10/magic_moment/blob/main/src/routes/g.%24slug.tsx): `src/routes/g.$slug.tsx`

### Gift presentation

- [Theme engine](https://github.com/baranwal-meet10/magic_moment/blob/main/src/lib/theme.ts): `src/lib/theme.ts`
- [Theme picker](https://github.com/baranwal-meet10/magic_moment/blob/main/src/components/theme-drawer.tsx): `src/components/theme-drawer.tsx`
- [Touch controls](https://github.com/baranwal-meet10/magic_moment/blob/main/src/components/mobile-touch.tsx): `src/components/mobile-touch.tsx`
- [Create progress](https://github.com/baranwal-meet10/magic_moment/blob/main/src/components/wrapping-loader.tsx): `src/components/wrapping-loader.tsx`
- [UI primitives](https://github.com/baranwal-meet10/magic_moment/tree/main/src/components): `src/components`

### Runtime platform

- [Supabase client](https://github.com/baranwal-meet10/magic_moment/blob/main/src/integrations/supabase/client.ts): `src/integrations/supabase/client.ts`
- [Admin client](https://github.com/baranwal-meet10/magic_moment/blob/main/src/integrations/supabase/client.server.ts): `src/integrations/supabase/client.server.ts`
- [SSR request handler](https://github.com/baranwal-meet10/magic_moment/blob/main/src/server.ts): `src/server.ts`
- [Error response page](https://github.com/baranwal-meet10/magic_moment/blob/main/src/lib/error-page.ts): `src/lib/error-page.ts`

### Security and media

- **Gift RPC service**
- **Postgres gifts**
- **Private image storage**
- [Signed image URLs](https://github.com/baranwal-meet10/magic_moment/blob/main/src/lib/gift-images.functions.ts): `src/lib/gift-images.functions.ts`

### Other components

- **Visitor**

## Connections

- Visitor → Landing page: opens site (evidence: `src/routes/index.tsx`)
- Visitor → Gift authoring: creates gift
- Visitor → Gift reveal: opens link
- Gift authoring → Theme picker: selects theme (evidence: `src/routes/create.tsx`)
- Gift authoring → Theme engine: uses theme (evidence: `src/routes/create.tsx`)
- Gift authoring → Create progress: shows progress (evidence: `src/routes/create.tsx`)
- Gift authoring → Supabase client: calls API (evidence: `src/routes/create.tsx`)
- Gift authoring → Private image storage: uploads photo (evidence: `src/routes/create.tsx`)
- Gift authoring → Gift RPC service: creates gift (evidence: `README.md`)
- Gift RPC service → Postgres gifts: writes gift (evidence: `README.md`)
- Gift reveal → Supabase client: calls API (evidence: `src/routes/g.$slug.tsx`)
- Gift reveal → Gift RPC service: looks up and opens (evidence: `README.md`)
- Gift RPC service → Postgres gifts: reads and opens (evidence: `README.md`)
- Gift reveal → Theme engine: styles reveal (evidence: `src/routes/g.$slug.tsx`)
- Gift reveal → Touch controls: uses controls (evidence: `src/routes/g.$slug.tsx`)
- Gift reveal → Signed image URLs: requests image URLs (evidence: `src/routes/g.$slug.tsx`)
- Signed image URLs → Admin client: uses admin client (evidence: `src/lib/gift-images.functions.ts`)
- Admin client → Private image storage: signs image access (evidence: `README.md`)
- SSR request handler → Error response page: renders on error (evidence: `src/server.ts`)
