# mjcaelum-oss/lucky-mate architecture

> Architecture diagram of the GitHub repository mjcaelum-oss/lucky-mate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mjcaelum-oss/lucky-mate
- Repository: https://github.com/mjcaelum-oss/lucky-mate

## Overview

Lucky Mate is a mobile fortune service entered through an NFC keyring or a direct link. The user selects a fortune category, receives a daily result, and can revisit or share that result. The main runtime flow is represented alongside analytics, image sharing, and editorial content management. The README documents the optional Kakao and device-sharing behaviors; the sampled sources show the API, server, domain, and image-generation responsibilities. Database details are represented at the documented migration path.

Main entry points: [`components/experience.tsx`](https://github.com/mjcaelum-oss/lucky-mate/blob/main/components/experience.tsx) (Fortune experience), [`lib/server.ts`](https://github.com/mjcaelum-oss/lucky-mate/blob/main/lib/server.ts) (Fortune services), [`app/api/[action]/route.ts`](https://github.com/mjcaelum-oss/lucky-mate/blob/main/app/api/%5Baction%5D/route.ts) (Action API), [`app/[[...path]]/page.tsx`](https://github.com/mjcaelum-oss/lucky-mate/blob/main/app/%5B%5B...path%5D%5D/page.tsx) (Page entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_experience_ui["Fortune experience<br/>[experience.tsx]"]
  node_page_route["Page entry<br/>[page.tsx]"]
  node_image_sharing["Share card generator<br/>[sharing.ts]"]
end

subgraph group_runtime["Fortune runtime"]
  node_api["Action API<br/>[route.ts]"]
  node_domain["Domain rules<br/>[domain.ts]"]
  node_server["Fortune services<br/>[server.ts]"]
end

subgraph group_state["Persistence and analytics"]
  node_supabase[("Supabase database<br/>[001_initial.sql]")]
  node_local_store[("Demo file store<br/>[server.ts]")]
  node_event_logs["Event logging<br/>[server.ts]"]
end

subgraph group_content["Content management"]
  node_editorial_content["Draft fortunes<br/>[content.ts]"]
  node_fortune_csv["Fortune CSV"]
  node_csv_sync["Content import<br/>[fortune-csv.ts]"]
end

node_visitor(("Keyring visitor"))
node_kakao["Kakao sharing"]
node_device_share["Device sharing"]
node_purchase["Purchase destination"]

node_visitor -->|"opens route"| node_page_route
node_page_route -->|"renders"| node_experience_ui
node_experience_ui -->|"requests actions"| node_api
node_api -->|"validates inputs"| node_domain
node_api -->|"calls services"| node_server
node_server -->|"uses types and rules"| node_domain
node_server -->|"reads draft content"| node_editorial_content
node_server -->|"reads and writes"| node_supabase
node_server -->|"reads and writes"| node_local_store
node_api -->|"records events"| node_event_logs
node_server -->|"persists events"| node_event_logs
node_experience_ui -->|"generates share image"| node_image_sharing
node_experience_ui -.->|"shares via SDK"| node_kakao
node_experience_ui -.->|"offers device sharing"| node_device_share
node_experience_ui -.->|"opens purchase link"| node_purchase
node_fortune_csv -.->|"provides content"| node_csv_sync
node_csv_sync -->|"syncs content"| node_supabase

click node_experience_ui "https://github.com/mjcaelum-oss/lucky-mate/blob/main/components/experience.tsx"
click node_page_route "https://github.com/mjcaelum-oss/lucky-mate/blob/main/app/%5B%5B...path%5D%5D/page.tsx"
click node_api "https://github.com/mjcaelum-oss/lucky-mate/blob/main/app/api/%5Baction%5D/route.ts"
click node_domain "https://github.com/mjcaelum-oss/lucky-mate/blob/main/lib/domain.ts"
click node_server "https://github.com/mjcaelum-oss/lucky-mate/blob/main/lib/server.ts"
click node_editorial_content "https://github.com/mjcaelum-oss/lucky-mate/blob/main/lib/content.ts"
click node_image_sharing "https://github.com/mjcaelum-oss/lucky-mate/blob/main/lib/sharing.ts"
click node_supabase "https://github.com/mjcaelum-oss/lucky-mate/blob/main/supabase/migrations/001_initial.sql"
click node_local_store "https://github.com/mjcaelum-oss/lucky-mate/blob/main/lib/server.ts"
click node_event_logs "https://github.com/mjcaelum-oss/lucky-mate/blob/main/lib/server.ts"
click node_fortune_csv "https://github.com/mjcaelum-oss/lucky-mate/blob/main/supabase/seed/fortune_contents.csv"
click node_csv_sync "https://github.com/mjcaelum-oss/lucky-mate/blob/main/scripts/fortune-csv.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_experience_ui,node_page_route,node_image_sharing toneBlue
class node_api,node_domain,node_server toneAmber
class node_supabase,node_local_store,node_event_logs toneMint
class node_editorial_content,node_fortune_csv,node_csv_sync toneRose
class node_visitor,node_kakao,node_device_share,node_purchase toneIndigo
```

## Components

### User experience

- [Fortune experience](https://github.com/mjcaelum-oss/lucky-mate/blob/main/components/experience.tsx): `components/experience.tsx`
- [Page entry](https://github.com/mjcaelum-oss/lucky-mate/blob/main/app/%5B%5B...path%5D%5D/page.tsx): `app/[[...path]]/page.tsx`
- [Share card generator](https://github.com/mjcaelum-oss/lucky-mate/blob/main/lib/sharing.ts): `lib/sharing.ts`

### Fortune runtime

- [Action API](https://github.com/mjcaelum-oss/lucky-mate/blob/main/app/api/%5Baction%5D/route.ts): `app/api/[action]/route.ts`
- [Domain rules](https://github.com/mjcaelum-oss/lucky-mate/blob/main/lib/domain.ts): `lib/domain.ts`
- [Fortune services](https://github.com/mjcaelum-oss/lucky-mate/blob/main/lib/server.ts): `lib/server.ts`

### Persistence and analytics

- [Supabase database](https://github.com/mjcaelum-oss/lucky-mate/blob/main/supabase/migrations/001_initial.sql): `supabase/migrations/001_initial.sql`
- [Demo file store](https://github.com/mjcaelum-oss/lucky-mate/blob/main/lib/server.ts): `lib/server.ts`
- [Event logging](https://github.com/mjcaelum-oss/lucky-mate/blob/main/lib/server.ts): `lib/server.ts`

### Content management

- [Draft fortunes](https://github.com/mjcaelum-oss/lucky-mate/blob/main/lib/content.ts): `lib/content.ts`
- [Fortune CSV](https://github.com/mjcaelum-oss/lucky-mate/blob/main/supabase/seed/fortune_contents.csv): `supabase/seed/fortune_contents.csv`
- [Content import](https://github.com/mjcaelum-oss/lucky-mate/blob/main/scripts/fortune-csv.ts): `scripts/fortune-csv.ts`

### Other components

- **Keyring visitor**
- **Kakao sharing**
- **Device sharing**
- **Purchase destination**

## Connections

- Keyring visitor → Page entry: opens route (evidence: `README.md`)
- Page entry → Fortune experience: renders (evidence: `app/[[...path]]/page.tsx`)
- Fortune experience → Action API: requests actions (evidence: `README.md`)
- Action API → Domain rules: validates inputs (evidence: `app/api/[action]/route.ts`)
- Action API → Fortune services: calls services (evidence: `app/api/[action]/route.ts`)
- Fortune services → Domain rules: uses types and rules (evidence: `lib/server.ts`)
- Fortune services → Draft fortunes: reads draft content (evidence: `lib/server.ts`)
- Fortune services → Supabase database: reads and writes (evidence: `lib/server.ts`)
- Fortune services → Demo file store: reads and writes (evidence: `lib/server.ts`)
- Action API → Event logging: records events (evidence: `app/api/[action]/route.ts`)
- Fortune services → Event logging: persists events (evidence: `lib/server.ts`)
- Fortune experience → Share card generator: generates share image (evidence: `components/experience.tsx`)
- Fortune experience → Kakao sharing: shares via SDK (evidence: `README.md`)
- Fortune experience → Device sharing: offers device sharing (evidence: `README.md`)
- Fortune experience → Purchase destination: opens purchase link (evidence: `README.md`)
- Fortune CSV → Content import: provides content (evidence: `README.md`)
- Content import → Supabase database: syncs content (evidence: `scripts/fortune-csv.ts`)
