# sabowaryan/loventy architecture

> Architecture diagram of the GitHub repository sabowaryan/loventy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sabowaryan/loventy
- Repository: https://github.com/sabowaryan/loventy

## Overview

##### Project type and purpose
- Loventy is a full-stack, mobile-first web application for digital wedding invitations and guest management.
- Frontend: React + Vite + TypeScript
- Backend: Supabase (Auth, Database, Storage, Realtime) + Stripe for billing + optional local check-in via WASM

##### File-structure analysis
- Top level
- src/                 ← React app
- supabase/            ← SQL migrations for Postgres + Storage buckets
- lib/stripe.ts        ← Stripe client wrappers
- lib/supabase.ts      ← Supabase client initialization
- src/components/, src/pages/ show an SPA with routes for auth, dashboard, editor, guests, invitations, settings
- Hooks under src/hooks call supabase or stripe clients
- Configuration: vite.config.ts, tailwind.config.js, postcss.config.js

##### Key insights from README
- Real-time RSVP tracking and QR check-in
- Secure, temporary tokens (Supabase Auth + RLS)
- Multi-language + multi-event support
- Payment plans handled by Stripe

##### Main components
A. Clients
1. Guest’s Browser (view invitation, RSVP, QR check-in)
2. Host’s Browser / Admin App (create events, manage guests, edit invitations)
3. Offline Check-in Tablet (WASM-based fallback)
B. Frontend
- React SPA served via CDN/Netlify (index.html + JS bundle)
- Routes: /auth, /dashboard, /editor, /invitation/:id
- UI components, context providers (AuthContext, StripeProvider)
C. Backend & Services
1. Supabase
– Auth service (email/password, time-limited tokens)
– Postgres Database (guests, events, invitations, usage, settings)
– RLS Policies (row-level security per event/token)
– Storage bucket for media (wedding photos, audio)
– Realtime subscription for RSVP updates
2. Stripe
– Billing plans, webhooks for plan changes
3. CDN / Hosting
– Static assets (public/) delivered via CDN
– _redirects rules for SPA routing
D. External Integrations
- Email/SMS (via Supabase or 3rd party) for confirmation links
- QR code generator library (client-side)
- Analytics (optional)
- AI suggestions (future)

##### Relationships & data flow
1. Client ←→ CDN hosting SPA bundle
2. SPA ←→ Supabase Auth (login/register, token issuance)
3. SPA ←→ Supabase Database & Storage (CRUD event/guest/invitation)
4. SPA ←→ Supabase Realtime (listen for RSVP status changes)
5. SPA ←→ Stripe API (subscribe/unsubscribe, get plan info)
6. Offline device loads WASM SQL engine + exports a subset of guest data → local check-in → sync back when online

##### Architectural patterns & principles
- Client-side routed SPA (Vite + React Router)
- BFF-less architecture: frontend calls 3rd-party APIs directly (supabase-js, stripe-js)
- Event-driven updates via WebSockets (Supabase Realtime)
- Security by design: RLS policies isolate each event’s data
- Offline-first check-in via WASM + local SQL (in public/wasm/sql-wasm.wasm)

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Clients" 
        GuestApp["Guest's Browser"]:::client
        HostApp["Host's Browser / Admin App"]:::client
        Tablet["Offline Check-in Tablet (WASM)"]:::client
    end

    subgraph "CDN / Hosting" 
        CDN["CDN / Netlify<br/>Static Hosting"]:::cdn
    end

    subgraph "Frontend App" 
        ReactSPA["React SPA"]:::frontend
    end

    subgraph "Supabase Services" 
        Auth["Auth Service"]:::supabase
        DB["Postgres Database"]:::supabase
        Storage["Storage Bucket"]:::supabase
        Realtime["Realtime Service"]:::supabase
    end

    Stripe["Stripe Billing"]:::stripe

    subgraph "External Integrations"
        EmailSMS["Email / SMS Service"]:::external
        QRLib["QR Code Generator"]:::external
        Analytics["Analytics"]:::external
    end

    GuestApp -->|"load SPA"| CDN
    HostApp -->|"load SPA"| CDN
    Tablet -->|"load WASM"| CDN

    CDN -->|"serve index.html & JS bundle"| ReactSPA

    ReactSPA -->|"login/register"| Auth
    ReactSPA -->|"CRUD events/guests/invitations"| DB
    ReactSPA -->|"upload/download media"| Storage
    ReactSPA -->|"subscribe to RSVP updates"| Realtime
    ReactSPA -->|"subscribe/unsubscribe"| Stripe
    ReactSPA -->|"send confirmations"| EmailSMS
    ReactSPA -->|"generate QR codes"| QRLib
    ReactSPA -->|"track usage"| Analytics

    Tablet -->|"local SQL operations"| Tablet
    Tablet -->|"sync data when online"| DB

    classDef client fill:#D0E6FF,stroke:#3399FF,color:#000;
    classDef cdn fill:#F0F0F0,stroke:#888888,color:#000;
    classDef frontend fill:#E6F7FF,stroke:#3399FF,color:#000;
    classDef supabase fill:#E6FFE6,stroke:#33CC33,color:#000;
    classDef stripe fill:#FFE6CC,stroke:#FF9933,color:#000;
    classDef external fill:#F5F5F5,stroke:#AAAAAA,color:#000;

    click ReactSPA "https://github.com/sabowaryan/loventy/blob/main/src/main.tsx"
    click Auth "https://github.com/sabowaryan/loventy/blob/main/src/lib/supabase.ts"
    click DB "https://github.com/sabowaryan/loventy/tree/main/supabase/migrations/"
    click Storage "https://github.com/sabowaryan/loventy/blob/main/supabase/migrations/20250705000000_create_wedding_media_bucket.sql"
    click Stripe "https://github.com/sabowaryan/loventy/blob/main/src/lib/stripe.ts"
    click Tablet "https://github.com/sabowaryan/loventy/blob/main/public/wasm/sql-wasm.wasm"
    click CDN "https://github.com/sabowaryan/loventy/tree/main/public/"
```
