# openfrenchfries/supasveltekit architecture

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

- Interactive diagram: https://gitdiagram.com/openfrenchfries/supasveltekit
- Repository: https://github.com/openfrenchfries/supasveltekit

## Overview

##### Main Components Identification

a. Core Integration Layer:
- SupabaseApp (root component that initializes the integration)
- Supabase SDK Store (manages the Supabase client instance)

b. Feature Modules:
- Authentication Module
- Database Module
- Realtime Module
- Storage Module
- Functions Module

**┌─────────────────────────────────────────────────┐**
- SvelteKit App                   │
- ┘
- ↓
**┌─────────────────────────────────────────────────┐**
- SupaSvelteKit Layer               │
- ┘
- ↓
**┌─────────────────────────────────────────────────┐**
- Supabase Backend                 │
- ┘

##### Component Details

a. Authentication Components:
- Authenticated.svelte
- Unauthenticated.svelte
- Session Store

b. Database Components:
- Collection.svelte
- Item.svelte
- Database Store

c. Realtime Components:
- BroadcastChannel.svelte
- DbChanges.svelte
- RealtimePresence.svelte
- Associated Stores

d. Storage Components:
- BucketContext.svelte
- BucketFilesList.svelte
- BucketsList.svelte
- Uploader.svelte
- Storage Stores

e. Functions Components:
- FunctionCall.svelte
- DelayedFunctionCall.svelte
- IntervalFunctionCall.svelte
- ScheduledFunctionCall.svelte

##### Data Flow Representation

→ Regular data flow
⇢ Reactive updates
⇄ Two-way binding
⇉ Realtime communications

##### Integration Points

Integration points with external services:
- Supabase Client initialization
- Authentication providers
- Database connections
- Storage buckets
- Edge Functions

##### Store Management

Store relationships:
- Session store connections
- Database stores
- Realtime presence stores
- Broadcast channel stores
- Storage bucket stores

##### Component Hierarchy

**┌─ SupabaseApp ─────────────────────┐**
- Authentication               │
- Authenticated            │
- Unauthenticated         │
- Database                    │
- Collection              │
- Item                    │
- ...                        │
- ┘

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Layers
    subgraph SvelteKit["SvelteKit Application"]
        App["SupabaseApp"]:::core
        click App "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/SupabaseApp.svelte"
    end

    subgraph Integration["SupaSvelteKit Integration Layer"]
        SDK["Supabase SDK Store"]:::core
        click SDK "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/stores/supabase-sdk.ts"

        subgraph Auth["Authentication Module"]
            AuthComp["Authenticated"]:::auth
            UnAuthComp["Unauthenticated"]:::auth
            SessionStore["Session Store"]:::store
            click AuthComp "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/auth/Authenticated.svelte"
            click UnAuthComp "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/auth/Unauthenticated.svelte"
            click SessionStore "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/stores/session.ts"
        end

        subgraph DB["Database Module"]
            Collection["Collection"]:::db
            Item["Item"]:::db
            DBStore["Database Store"]:::store
            click Collection "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/database/Collection.svelte"
            click Item "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/database/Item.svelte"
            click DBStore "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/stores/database.ts"
        end

        subgraph RT["Realtime Module"]
            Broadcast["BroadcastChannel"]:::realtime
            DbChanges["DbChanges"]:::realtime
            Presence["RealtimePresence"]:::realtime
            BroadcastStore["Broadcast Store"]:::store
            ChangesStore["Changes Store"]:::store
            PresenceStore["Presence Store"]:::store
            click Broadcast "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/realtime/BroadcastChannel.svelte"
            click DbChanges "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/realtime/DbChanges.svelte"
            click Presence "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/realtime/RealtimePresence.svelte"
            click BroadcastStore "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/stores/broadcast-channel.ts"
            click ChangesStore "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/stores/db-changes-channel.ts"
            click PresenceStore "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/stores/presence-channel.ts"
        end

        subgraph Storage["Storage Module"]
            BucketCtx["BucketContext"]:::storage
            FilesList["BucketFilesList"]:::storage
            BucketsList["BucketsList"]:::storage
            Uploader["Uploader"]:::storage
            BucketStore["Bucket Store"]:::store
            click BucketCtx "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/storage/BucketContext.svelte"
            click FilesList "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/storage/BucketFilesList.svelte"
            click BucketsList "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/storage/BucketsList.svelte"
            click Uploader "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/storage/Uploader.svelte"
            click BucketStore "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/stores/bucket.ts"
        end

        subgraph Func["Functions Module"]
            FuncCall["FunctionCall"]:::function
            DelayedCall["DelayedFunctionCall"]:::function
            IntervalCall["IntervalFunctionCall"]:::function
            ScheduledCall["ScheduledFunctionCall"]:::function
            FuncStore["Function Store"]:::store
            click FuncCall "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/function/FunctionCall.svelte"
            click DelayedCall "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/function/DelayedFunctionCall.svelte"
            click IntervalCall "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/function/IntervalFunctionCall.svelte"
            click ScheduledCall "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/components/function/ScheduledFunctionCall.svelte"
            click FuncStore "https://github.com/OpenFrenchFries/supasveltekit/blob/main/src/lib/stores/function.ts"
        end
    end

    subgraph Backend["Supabase Backend"]
        SupaAuth["Authentication Service"]
        SupaDB["Database Service"]
        SupaRT["Realtime Service"]
        SupaStorage["Storage Service"]
        SupaFunc["Edge Functions"]
    end

    %% Connections
    App --> SDK
    SDK --> Auth & DB & RT & Storage & Func
    Auth --> SupaAuth
    DB --> SupaDB
    RT --> SupaRT
    Storage --> SupaStorage
    Func --> SupaFunc

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef auth fill:#2ecc71,stroke:#27ae60,color:white
    classDef db fill:#f1c40f,stroke:#f39c12,color:black
    classDef realtime fill:#9b59b6,stroke:#8e44ad,color:white
    classDef storage fill:#795548,stroke:#5d4037,color:white
    classDef function fill:#e67e22,stroke:#d35400,color:white
    classDef store fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Authentication"]:::auth
        L3["Database"]:::db
        L4["Realtime"]:::realtime
        L5["Storage"]:::storage
        L6["Functions"]:::function
        L7["Stores"]:::store
    end
```
