# dudusotero/octane-supabase-todo architecture

> Architecture diagram of the GitHub repository dudusotero/octane-supabase-todo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dudusotero/octane-supabase-todo
- Repository: https://github.com/dudusotero/octane-supabase-todo

## Overview

#### Purpose and Runtime

This is a Vite-served Octane client application for authenticated, per-user todo management with Supabase-backed realtime synchronization and avatar storage. It runs against a local Supabase Docker stack; browser code calls `@supabase/supabase-js` directly.

Entry points:
- `index.html`
- `src/main.ts`
- `src/App.tsrx`

#### Application Shell and Session Gate

`src/main.ts` mounts the Octane application and imports global styling. `src/App.tsrx` is the top-level control boundary: it consumes auth state and selects either the authentication UI or authenticated todo/avatar functionality.

Auth state is modeled as an external store rather than isolated component state:
- `src/App.tsrx`
- `src/lib/session.ts`
- `src/lib/supabase.ts`

This allows session changes from Supabase auth events to propagate consistently across the UI.

#### Supabase Client Boundary

The repository centralizes Supabase client construction in:
- `src/lib/supabase.ts`
- `.env`
- `src/lib/database.types.ts`

`supabase.ts` is the sole `createClient` location. Generated database types constrain client queries and mutations. Environment values target the local Supabase stack, while `.env.local` can override them.

#### Authentication Flow

`src/Auth.tsrx` implements email/password sign-up, sign-in, and sign-out through the shared Supabase client. Successful auth transitions update the session store, which causes `App` to replace the auth screen with the authenticated application.

Core paths:
- `src/Auth.tsrx`
- `src/lib/session.ts`
- `src/lib/supabase.ts`

#### Todo Data Access and Realtime Flow

All todo reads and writes are centralized in `src/lib/queries.ts`; UI components do not define independent database access patterns. `src/TodoList.tsrx` loads the current user’s todos, invokes query-layer mutations, and subscribes to Supabase Realtime INSERT, UPDATE, and DELETE events.

Core paths:
- `src/TodoList.tsrx`
- `src/lib/queries.ts`
- `src/lib/supabase.ts`

The important boundary is server-enforced ownership: client filtering is not the security mechanism. Realtime updates also cover writes originating outside the current browser.

#### Avatar Storage Flow

`src/AvatarUpload.tsrx` uploads a user avatar through Supabase Storage and renders its resulting public URL. Storage policy is enforced server-side, including image-type acceptance and a 2 MB cap.

Core paths:
- `src/AvatarUpload.tsrx`
- `src/lib/supabase.ts`
- `supabase/migrations/20260811000000_todos_and_avatars.sql`

#### Database, Authorization, and Local Infrastructure

The Supabase migration is the backend contract. It defines the `todos` schema, row-level security and grants, Realtime publication setup, storage bucket configuration, and storage policies/limits:
- `supabase/migrations/20260811000000_todos_and_avatars.sql`
- `supabase/config.toml`
- `src/lib/database.types.ts`

Operationally, `npx supabase start` launches the local Docker-backed services; Vite serves the frontend. Resetting the database reapplies the migration, keeping schema, policies, and local behavior reproducible.

Main entry points: [`src/lib/supabase.ts`](https://github.com/dudusotero/octane-supabase-todo/blob/main/src/lib/supabase.ts) (Supabase client), [`src/App.tsrx`](https://github.com/dudusotero/octane-supabase-todo/blob/main/src/App.tsrx) (Session gate), [`src/TodoList.tsrx`](https://github.com/dudusotero/octane-supabase-todo/blob/main/src/TodoList.tsrx) (Todo list), [`supabase/config.toml`](https://github.com/dudusotero/octane-supabase-todo/blob/main/supabase/config.toml) (Supabase services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Octane client"]
  node_vite["Vite host<br/>frontend runtime<br/>[index.html]"]
  node_main["Application mount<br/>Octane entry<br/>[main.ts]"]
  node_app["Session gate<br/>top-level UI<br/>[App.tsrx]"]
  node_auth["Authentication UI<br/>auth component<br/>[Auth.tsrx]"]
  node_session["Session store<br/>external auth state<br/>[session.ts]"]
  node_todos["Todo list<br/>realtime UI<br/>[TodoList.tsrx]"]
  node_avatar["Avatar upload<br/>storage UI<br/>[AvatarUpload.tsrx]"]
  node_queries["Todo query layer<br/>data access<br/>[queries.ts]"]
  node_client{{"Supabase client<br/>client boundary<br/>[supabase.ts]"}}
  node_types["Database types<br/>generated types<br/>[database.types.ts]"]
  node_env["Environment settings<br/>local connection config<br/>[.env]"]
end

subgraph group_supabase["Local Supabase stack"]
  node_supabase[("Supabase services<br/>local Docker backend<br/>[config.toml]")]
  node_migration["Schema and policy contract<br/>SQL migration"]
end

node_vite -->|"serves"| node_main
node_main -->|"mounts"| node_app
node_app -->|"consumes"| node_session
node_app -->|"shows when signed out"| node_auth
node_app -->|"shows when signed in"| node_todos
node_app -->|"shows when signed in"| node_avatar
node_auth -->|"signs in, signs up, signs out"| node_client
node_client -->|"auth events update"| node_session
node_todos -->|"loads and mutates"| node_queries
node_todos -->|"subscribes to Realtime"| node_client
node_queries -->|"queries todos"| node_client
node_avatar -->|"uploads avatar"| node_client
node_client -->|"typed by"| node_types
node_env -.->|"configures local endpoint"| node_client
node_client -->|"browser API calls"| node_supabase
node_migration -->|"provisions schema and policies"| node_supabase
node_supabase -.->|"realtime changes"| node_todos

click node_vite "https://github.com/dudusotero/octane-supabase-todo/blob/main/index.html"
click node_main "https://github.com/dudusotero/octane-supabase-todo/blob/main/src/main.ts"
click node_app "https://github.com/dudusotero/octane-supabase-todo/blob/main/src/App.tsrx"
click node_auth "https://github.com/dudusotero/octane-supabase-todo/blob/main/src/Auth.tsrx"
click node_session "https://github.com/dudusotero/octane-supabase-todo/blob/main/src/lib/session.ts"
click node_todos "https://github.com/dudusotero/octane-supabase-todo/blob/main/src/TodoList.tsrx"
click node_avatar "https://github.com/dudusotero/octane-supabase-todo/blob/main/src/AvatarUpload.tsrx"
click node_queries "https://github.com/dudusotero/octane-supabase-todo/blob/main/src/lib/queries.ts"
click node_client "https://github.com/dudusotero/octane-supabase-todo/blob/main/src/lib/supabase.ts"
click node_types "https://github.com/dudusotero/octane-supabase-todo/blob/main/src/lib/database.types.ts"
click node_env "https://github.com/dudusotero/octane-supabase-todo/blob/main/.env"
click node_supabase "https://github.com/dudusotero/octane-supabase-todo/blob/main/supabase/config.toml"
click node_migration "https://github.com/dudusotero/octane-supabase-todo/blob/main/supabase/migrations/20260811000000_todos_and_avatars.sql"

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_vite,node_main,node_app,node_auth,node_session,node_todos,node_avatar,node_queries,node_client,node_types,node_env toneBlue
class node_supabase,node_migration toneAmber
```

## Components

### Octane client

- [Vite host](https://github.com/dudusotero/octane-supabase-todo/blob/main/index.html): frontend runtime · `index.html`
- [Application mount](https://github.com/dudusotero/octane-supabase-todo/blob/main/src/main.ts): Octane entry · `src/main.ts`
- [Session gate](https://github.com/dudusotero/octane-supabase-todo/blob/main/src/App.tsrx): top-level UI · Selects unauthenticated or authenticated UI. · `src/App.tsrx`
- [Authentication UI](https://github.com/dudusotero/octane-supabase-todo/blob/main/src/Auth.tsrx): auth component · `src/Auth.tsrx`
- [Session store](https://github.com/dudusotero/octane-supabase-todo/blob/main/src/lib/session.ts): external auth state · Propagates Supabase auth events across the UI. · `src/lib/session.ts`
- [Todo list](https://github.com/dudusotero/octane-supabase-todo/blob/main/src/TodoList.tsrx): realtime UI · Loads user todos and subscribes to change events. · `src/TodoList.tsrx`
- [Avatar upload](https://github.com/dudusotero/octane-supabase-todo/blob/main/src/AvatarUpload.tsrx): storage UI · `src/AvatarUpload.tsrx`
- [Todo query layer](https://github.com/dudusotero/octane-supabase-todo/blob/main/src/lib/queries.ts): data access · Centralizes todo reads and mutations. · `src/lib/queries.ts`
- [Supabase client](https://github.com/dudusotero/octane-supabase-todo/blob/main/src/lib/supabase.ts): client boundary · Sole createClient location. · `src/lib/supabase.ts`
- [Database types](https://github.com/dudusotero/octane-supabase-todo/blob/main/src/lib/database.types.ts): generated types · `src/lib/database.types.ts`
- [Environment settings](https://github.com/dudusotero/octane-supabase-todo/blob/main/.env): local connection config · `.env`

### Local Supabase stack

- [Supabase services](https://github.com/dudusotero/octane-supabase-todo/blob/main/supabase/config.toml): local Docker backend · Provides Auth, Postgres, Realtime, and Storage. · `supabase/config.toml`
- [Schema and policy contract](https://github.com/dudusotero/octane-supabase-todo/blob/main/supabase/migrations/20260811000000_todos_and_avatars.sql): SQL migration · Defines todos, RLS, Realtime publication, avatar bucket, and storage policies. · `supabase/migrations/20260811000000_todos_and_avatars.sql`

## Connections

- Vite host → Application mount: serves
- Application mount → Session gate: mounts
- Session gate → Session store: consumes
- Session gate → Authentication UI: shows when signed out
- Session gate → Todo list: shows when signed in
- Session gate → Avatar upload: shows when signed in
- Authentication UI → Supabase client: signs in, signs up, signs out
- Supabase client → Session store: auth events update
- Todo list → Todo query layer: loads and mutates
- Todo list → Supabase client: subscribes to Realtime
- Todo query layer → Supabase client: queries todos
- Avatar upload → Supabase client: uploads avatar
- Supabase client → Database types: typed by
- Environment settings → Supabase client: configures local endpoint
- Supabase client → Supabase services: browser API calls
- Schema and policy contract → Supabase services: provisions schema and policies
- Supabase services → Todo list: realtime changes · Includes writes from other clients.
