# supabase-community/svelte-kanban architecture

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

- Interactive diagram: https://gitdiagram.com/supabase-community/svelte-kanban
- Repository: https://github.com/supabase-community/svelte-kanban

## Overview

##### Project type and purpose
- This is a full‑stack single-page web application (a Trello‑style Kanban board) built with SvelteKit on the front end and Supabase (PostgreSQL + Auth + Realtime) as the back end.
- The README confirms it’s a Trello clone using Supabase for storage and authentication, deployed (e.g., on Vercel).

##### File structure
- Top level:
- Static assets (static/) and index.html for hosting.
- SvelteKit config (svelte.config.js, vite.config.js, jsconfig.json).
- Supabase folder for database schema, seeds, and CLI config (supabase/config.toml, seed.sql, .branches/dump.sql).
- src/ contains SvelteKit routes and components:
– src/routes/+layout.js, +page.svelte, route files for Login, BoardList, dynamic boards/[id], and components (Header, AddForm, AddList, List, InPlaceEdit).
– src/routes/db.js configures the Supabase client.
– src/index.test.js holds tests.
- Build scripts and dependencies: package.json, pnpm‑lock.yaml, .eslintrc, .prettierrc, etc.

##### README for additional insights
- Supabase storage requires running setup.sql and seed.sql.
- Authentication flows: login route.
- Database schema creation and seeding is automated via Supabase CLI.
- The app uses Supabase client (supabase-js) on the client side for CRUD and real‑time updates.

a. Main components
- Browser / Client (SvelteKit SPA)
- SvelteKit Server (routes + page endpoints if running server‑side)
- Supabase Services
– Auth (handles sign‑in, tokens)
– Database (PostgreSQL tables: boards, lists, cards, users)
– Realtime (WebSocket channel for live updates)
- Deployment platform (e.g., Vercel, optional)
b. Relationships and interactions
1) User → Browser UI (Svelte components)
2) Browser UI ↔ Supabase Auth (login/signup API)
3) Browser UI ↔ Supabase Database (CRUD via REST / PostgREST or supabase-js client)
4) Browser UI ↔ Supabase Realtime (subscribe to changes on boards/lists/cards)
5) (Optional) Browser → SvelteKit server for server‑side rendering/load functions → Supabase
c. Architectural patterns
- SvelteKit’s File‑Based Routing for component composition and SSR/CSR hybrid.
- Separation of concerns: UI components vs. data access (db.js).
- Event‑driven updates via Supabase Realtime.
d. Key technologies
- SvelteKit (frontend + SSR)
- supabase-js (client library)
- PostgreSQL (hosted by Supabase)
- Vite (bundler)
- pnpm (package manager)

##### Essential details to capture
- File‑based routing → show mapping between URL paths and Svelte components (e.g., /boards/[id] → BoardDetail component).
- db.js as the single Supabase client instantiation (central data access module).
- Supabase CLI artifacts (seed.sql, setup.sql) illustrating database provisioning.
- Real‑time update mechanism for collaborative editing.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        LayoutJs["+layout.js"]:::frontend
        PageSvelte["+page.svelte"]:::frontend
        Header["Header.svelte"]:::frontend
        BoardList["BoardList.svelte"]:::frontend
        Login["Login.svelte"]:::frontend
        BoardPage["+page.svelte (boards/[id])"]:::frontend
        AddForm["AddForm.svelte"]:::frontend
        AddList["AddList.svelte"]:::frontend
        InPlaceEdit["InPlaceEdit.svelte"]:::frontend
        ListComp["List.svelte"]:::frontend
    end

    %% Server/API Layer
    subgraph "Server/API Layer"
        direction TB
        LayoutLoad["+layout.js load()"]:::server
        BoardLoad["+page.js load()"]:::server
        DBClient["db.js (Supabase Client)"]:::server
    end

    %% Supabase Services
    subgraph "Supabase Services"
        direction TB
        Auth["Auth Service"]:::service
        Database["PostgreSQL Database"]:::service
        Realtime["Realtime Service"]:::service
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        direction TB
        SetupSQL["setup.sql"]:::db
        ConfigToml["supabase/config.toml"]:::db
        SeedSQL["supabase/seed.sql"]:::db
        DumpSQL["supabase/.branches/main/dump.sql"]:::db
    end

    %% Static & Tooling
    subgraph "Static & Hosting"
        direction TB
        IndexHtml["index.html"]:::infra
        GlobalCSS["static/global.css"]:::infra
        Robots["static/robots.txt"]:::infra
    end

    subgraph "Build & Tooling"
        direction TB
        SvelteConfig["svelte.config.js"]:::infra
        ViteConfig["vite.config.js"]:::infra
        JsConfig["jsconfig.json"]:::infra
        PackageJson["package.json"]:::infra
        LockFile["pnpm-lock.yaml"]:::infra
    end

    subgraph "Testing"
        direction TB
        Tests["src/index.test.js"]:::infra
    end

    %% Connections
    Login -->|"calls Auth API"| DBClient
    DBClient -->|"POST /login"| Auth
    PageSvelte -->|"CRUD ops"| DBClient
    BoardList -->|"SELECT boards"| DBClient
    BoardPage -->|"SELECT/UPDATE board"| DBClient
    AddForm -->|"INSERT card"| DBClient
    AddList -->|"INSERT list"| DBClient
    InPlaceEdit -->|"UPDATE item"| DBClient
    ListComp -->|"SELECT cards"| DBClient

    DBClient -->|"REST/Realtime"| Database
    DBClient -->|"subscribe()"| Realtime

    LayoutLoad -->|"SSR load()"| DBClient
    BoardLoad -->|"SSR load()"| DBClient

    Auth -->|"stores users"| Database
    Realtime -->|"listens changes"| Database

    %% Click Events
    click LayoutJs "https://github.com/supabase-community/svelte-kanban/blob/main/src/routes/+layout.js"
    click PageSvelte "https://github.com/supabase-community/svelte-kanban/blob/main/src/routes/+page.svelte"
    click Header "https://github.com/supabase-community/svelte-kanban/blob/main/src/routes/Header.svelte"
    click BoardList "https://github.com/supabase-community/svelte-kanban/blob/main/src/routes/BoardList.svelte"
    click Login "https://github.com/supabase-community/svelte-kanban/blob/main/src/routes/Login.svelte"
    click BoardPage "https://github.com/supabase-community/svelte-kanban/blob/main/src/routes/boards/[id]/+page.svelte"
    click AddForm "https://github.com/supabase-community/svelte-kanban/blob/main/src/routes/boards/[id]/AddForm.svelte"
    click AddList "https://github.com/supabase-community/svelte-kanban/blob/main/src/routes/boards/[id]/AddList.svelte"
    click InPlaceEdit "https://github.com/supabase-community/svelte-kanban/blob/main/src/routes/boards/[id]/InPlaceEdit.svelte"
    click ListComp "https://github.com/supabase-community/svelte-kanban/blob/main/src/routes/boards/[id]/List.svelte"
    click LayoutLoad "https://github.com/supabase-community/svelte-kanban/blob/main/src/routes/+layout.js"
    click BoardLoad "https://github.com/supabase-community/svelte-kanban/blob/main/src/routes/boards/[id]/+page.js"
    click DBClient "https://github.com/supabase-community/svelte-kanban/blob/main/src/routes/db.js"
    click SetupSQL "https://github.com/supabase-community/svelte-kanban/blob/main/setup.sql"
    click ConfigToml "https://github.com/supabase-community/svelte-kanban/blob/main/supabase/config.toml"
    click SeedSQL "https://github.com/supabase-community/svelte-kanban/blob/main/supabase/seed.sql"
    click DumpSQL "https://github.com/supabase-community/svelte-kanban/blob/main/supabase/.branches/main/dump.sql"
    click IndexHtml "https://github.com/supabase-community/svelte-kanban/blob/main/index.html"
    click GlobalCSS "https://github.com/supabase-community/svelte-kanban/blob/main/static/global.css"
    click Robots "https://github.com/supabase-community/svelte-kanban/blob/main/static/robots.txt"
    click SvelteConfig "https://github.com/supabase-community/svelte-kanban/blob/main/svelte.config.js"
    click ViteConfig "https://github.com/supabase-community/svelte-kanban/blob/main/vite.config.js"
    click JsConfig "https://github.com/supabase-community/svelte-kanban/blob/main/jsconfig.json"
    click PackageJson "https://github.com/supabase-community/svelte-kanban/blob/main/package.json"
    click LockFile "https://github.com/supabase-community/svelte-kanban/blob/main/pnpm-lock.yaml"
    click Tests "https://github.com/supabase-community/svelte-kanban/blob/main/src/index.test.js"

    %% Styles
    classDef frontend fill:#e0f7fa,stroke:#006064,color:#004d40
    classDef server fill:#e8f5e9,stroke:#1b5e20,color:#2e7d32
    classDef service fill:#fff3e0,stroke:#e65100,color:#bf360c
    classDef db fill:#ede7f6,stroke:#4527a0,color:#311b92
    classDef infra fill:#f5f5f5,stroke:#424242,color:#212121
```
