# profitble/glow architecture

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

- Interactive diagram: https://gitdiagram.com/profitble/glow
- Repository: https://github.com/profitble/glow

## Overview

##### Project Type & Purpose
- This is a full-stack mobile application (“UMAX Clone”), built with Expo/React Native on the client side and Supabase + serverless functions on the backend.
- Purpose: a “for-women” wellness/self-care app with user profiles, AI-driven recommendations, real-time updates, and subscription monetization.

##### File Structure
- Top level:
- .gitignore, README.md
- assets/ (fonts, images)
- The lack of a “src/” folder in the tree is an artifact of the excerpt; most app source lives under the Expo project root.
- Key indicators: React Native app (Expo), static assets separated, no custom backend code here (it relies on Supabase and Vercel).

##### README for Additional Insights
- Tech stack: Expo/React Native, Supabase (Auth, Storage, Realtime, PostgreSQL), Vercel Edge Functions, OpenAI API, RevenueCat, TypeScript, Sentry, EAS.

##### Main Components & Their Roles
a. Frontend (Mobile Client)
- Expo/React Native app with routing (Expo Router), state (Zustand), offline persistence.
- Error boundaries, asset upload/download.
b. Backend as a Service (Supabase)
- GoTrue Auth + RLS policies (user management & security).
- PostgreSQL database (persistent storage).
- Storage bucket (user photos, other assets).
- Real-time subscriptions (live UI updates).
c. API Proxy Layer (Vercel Edge Functions)
- Secure “AI” and other third-party integrations.
- Origin validation, rate limiting, secret injection.
d. External Services
- OpenAI API (AI features)
- RevenueCat API (subscription state & monetization)
e. Monitoring & CI/CD
- Sentry for error monitoring.
- Expo Application Services (EAS) for builds, OTA updates, and CI/CD.

##### Relationships & Data Flows
- Mobile → Secure API calls → Supabase Auth & Database
- Mobile ↔ Realtime Subscriptions ↔ Supabase
- Mobile → Asset Operations → Supabase Storage
- Mobile → Edge Function → OpenAI → Edge Function → Mobile
- Mobile → RevenueCat → Mobile (entitlements)

##### Architectural Patterns & Principles
- BaaS (“Backend for Frontend”) with Supabase
- Serverless compute for custom logic (Edge Functions)
- RLS for zero-trust data access
- Real-time, event-driven updates
- Offline-first & graceful error handling on client
- Zero client-side API keys (all secrets held in server/proxy)
- Separation of concerns: UI vs. data vs. compute vs. external integrations

##### Technologies & Frameworks to Call Out
- Expo/React Native, TypeScript, Zustand, React Error Boundary
- Supabase (Auth, Storage, Realtime, PostgreSQL)
- Vercel Edge Functions, OpenAI API, RevenueCat SDK
- EAS (build/deploy), Sentry (monitoring)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        MobileClient["Mobile Client<br/>(Expo/React Native)"]:::frontend
        assetsStatic["Static Assets"]:::frontend
        fonts["Fonts"]:::frontend
        images["Images"]:::frontend
    end

    %% BaaS Layer
    subgraph "BaaS Layer"
        direction TB
        SupabaseAuth["Auth (GoTrue)"]:::baas
        SupabaseDB["PostgreSQL DB"]:::db
        SupabaseStorage["Storage Bucket"]:::db
        SupabaseRealtime["Realtime"]:::baas
    end

    %% Serverless Layer
    subgraph "Serverless Layer"
        direction TB
        EdgeAPI["Edge Functions<br/>(API Proxy)"]:::serverless
    end

    %% External Services
    subgraph "External Services"
        direction TB
        OpenAI["OpenAI API"]:::external
        RevenueCat["RevenueCat API"]:::external
    end

    %% Documentation
    subgraph "Project Docs"
        direction TB
        readme["README.md"]:::external
        gitignore[".gitignore"]:::external
    end

    %% Connections
    MobileClient -->|"Auth"| SupabaseAuth
    MobileClient -->|"RLS-protected DB Ops"| SupabaseDB
    MobileClient -->|"Asset Operations"| SupabaseStorage
    MobileClient <-->|"Realtime Subscriptions"| SupabaseRealtime
    MobileClient -->|"AI Request/Response"| EdgeAPI
    EdgeAPI -->|"OpenAI Request"| OpenAI
    OpenAI -->|"Response"| EdgeAPI
    MobileClient -->|"Subscription Check"| RevenueCat

    %% Click Events
    click assetsStatic "https://github.com/profitble/glow/tree/main/assets/"
    click fonts "https://github.com/profitble/glow/tree/main/assets/fonts/"
    click images "https://github.com/profitble/glow/tree/main/assets/images/"
    click readme "https://github.com/profitble/glow/blob/main/README.md"
    click gitignore "https://github.com/profitble/glow/blob/main/.gitignore"

    %% Styles
    classDef frontend fill:#D8B4FE,stroke:#7C3AED,stroke-width:2px
    classDef baas fill:#BFDBFE,stroke:#1E3A8A,stroke-width:2px
    classDef serverless fill:#BBF7D0,stroke:#15803D,stroke-width:2px
    classDef db fill:#FECACA,stroke:#B91C1C,stroke-width:2px
    classDef external fill:#FCF3CF,stroke:#B7950B,stroke-width:2px
```
