# arthurbonetti/nextwatch architecture

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

- Interactive diagram: https://gitdiagram.com/arthurbonetti/nextwatch
- Repository: https://github.com/arthurbonetti/nextwatch

## Overview

NextWatch helps users discover streaming titles from their active subscriptions, choose what to watch, and manage subscription costs. Its main flow loads a provider-filtered catalog, supports roulette selection and title details, and records saved titles or viewing decisions. Separate branches cover account access and subscription finances. The README describes offline local persistence and authenticated Supabase synchronization; sampled excerpts show some context-to-service calls, but not every screen or storage operation.

Main entry points: [`services/authApi.ts`](https://github.com/arthurbonetti/nextwatch/blob/main/services/authApi.ts) (Auth client), [`contexts/CatalogContext.tsx`](https://github.com/arthurbonetti/nextwatch/blob/main/contexts/CatalogContext.tsx) (Catalog state), [`app/(tabs)/index.tsx`](https://github.com/arthurbonetti/nextwatch/blob/main/app/(tabs)/index.tsx) (Home and roulette), [`contexts/SubscriptionsContext.tsx`](https://github.com/arthurbonetti/nextwatch/blob/main/contexts/SubscriptionsContext.tsx) (Subscription state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Discovery and viewing"]
  node_home["Home and roulette<br/>[index.tsx]"]
  node_explore["Catalog search<br/>[tab2.tsx]"]
  node_title["Title details<br/>[&#91;id&#93;.tsx]"]
  node_list["My List<br/>[my-list.tsx]"]
  node_history["Draw history<br/>[draw-history.tsx]"]
  node_catalog["Catalog state<br/>[CatalogContext.tsx]"]
  node_catalog_data["Static catalog<br/>[catalog.ts]"]
  node_roulette["Roulette flow<br/>[DrawFlowModal.tsx]"]
end

subgraph group_state["User data and sync"]
  node_subscriptions_screen["Subscription dashboard<br/>[subscriptions.tsx]"]
  node_subscriptions["Subscription state"]
  node_mylist_state["Saved titles<br/>[MyListContext.tsx]"]
  node_draw_state["Decision history"]
  node_progress["Series progress"]
end

subgraph group_identity["Authentication"]
  node_login["Login and registration<br/>[login.tsx]"]
  node_auth["Auth state<br/>[AuthContext.tsx]"]
  node_auth_api["Auth client<br/>[authApi.ts]"]
  node_secure_store[("Secure session store<br/>[secureStore.ts]")]
end

subgraph group_services["External services"]
  node_tmdb["Catalog service<br/>[tmdb.ts]"]
  node_proxy["TMDB proxy<br/>[index.ts]"]
  node_tmdb_api{{"TMDB"}}
  node_supabase[("Supabase Auth and data")]
end

subgraph group_presentation["Interface components"]
  node_details_ui["Title detail sections"]
  node_subscription_editor["Subscription editor"]
end

node_user(("Viewer"))

node_user -->|"opens"| node_home
node_user -->|"searches"| node_explore
node_user -->|"signs in"| node_login
node_user -->|"manages"| node_subscriptions_screen
node_home -->|"reads catalog"| node_catalog
node_home -->|"reads providers"| node_subscriptions
node_home -->|"opens"| node_roulette
node_home -->|"records decisions"| node_draw_state
node_home -->|"opens details"| node_title
node_explore -->|"searches"| node_catalog
node_explore -->|"filters by providers"| node_subscriptions
node_title -->|"renders"| node_details_ui
node_title -->|"reads title data"| node_catalog
node_title -->|"saves title"| node_mylist_state
node_list -->|"reads saved titles"| node_mylist_state
node_list -->|"resolves title data"| node_catalog
node_history -->|"reads decisions"| node_draw_state
node_catalog -->|"uses fallback"| node_catalog_data
node_catalog -->|"uses active providers"| node_subscriptions
node_catalog -->|"fetches and searches"| node_tmdb
node_subscriptions_screen -->|"reads and updates"| node_subscriptions
node_subscriptions_screen -->|"opens editor"| node_subscription_editor
node_subscriptions -->|"gets session"| node_auth
node_subscriptions -->|"syncs subscriptions"| node_auth_api
node_mylist_state -->|"syncs saved titles"| node_auth_api
node_draw_state -->|"syncs decisions"| node_auth_api
node_progress -->|"syncs progress"| node_auth_api
node_login -->|"submits credentials"| node_auth
node_auth -->|"authenticates"| node_auth_api
node_auth_api -->|"stores session"| node_secure_store
node_auth_api -->|"auth and data requests"| node_supabase
node_tmdb -->|"requests catalog data"| node_proxy
node_proxy -->|"forwards requests"| node_tmdb_api
node_tmdb -->|"uses authenticated requests"| node_auth_api
node_details_ui -->|"loads detail data"| node_tmdb

click node_home "https://github.com/arthurbonetti/nextwatch/blob/main/app/(tabs)/index.tsx"
click node_explore "https://github.com/arthurbonetti/nextwatch/blob/main/app/(tabs)/tab2.tsx"
click node_title "https://github.com/arthurbonetti/nextwatch/blob/main/app/title/%5Bid%5D.tsx"
click node_list "https://github.com/arthurbonetti/nextwatch/blob/main/app/my-list.tsx"
click node_history "https://github.com/arthurbonetti/nextwatch/blob/main/app/draw-history.tsx"
click node_catalog "https://github.com/arthurbonetti/nextwatch/blob/main/contexts/CatalogContext.tsx"
click node_catalog_data "https://github.com/arthurbonetti/nextwatch/blob/main/constants/catalog.ts"
click node_roulette "https://github.com/arthurbonetti/nextwatch/blob/main/components/organisms/DrawModal/DrawFlowModal.tsx"
click node_subscriptions_screen "https://github.com/arthurbonetti/nextwatch/blob/main/app/subscriptions.tsx"
click node_subscriptions "https://github.com/arthurbonetti/nextwatch/blob/main/contexts/SubscriptionsContext.tsx"
click node_mylist_state "https://github.com/arthurbonetti/nextwatch/blob/main/contexts/MyListContext.tsx"
click node_draw_state "https://github.com/arthurbonetti/nextwatch/blob/main/contexts/DrawHistoryContext.tsx"
click node_progress "https://github.com/arthurbonetti/nextwatch/blob/main/hooks/useSeriesProgress.ts"
click node_login "https://github.com/arthurbonetti/nextwatch/blob/main/app/(auth)/login.tsx"
click node_auth "https://github.com/arthurbonetti/nextwatch/blob/main/contexts/AuthContext.tsx"
click node_auth_api "https://github.com/arthurbonetti/nextwatch/blob/main/services/authApi.ts"
click node_secure_store "https://github.com/arthurbonetti/nextwatch/blob/main/services/secureStore.ts"
click node_tmdb "https://github.com/arthurbonetti/nextwatch/blob/main/services/tmdb.ts"
click node_proxy "https://github.com/arthurbonetti/nextwatch/blob/main/supabase/functions/tmdb-proxy/index.ts"
click node_details_ui "https://github.com/arthurbonetti/nextwatch/tree/main/components/organisms/TitleDetails"
click node_subscription_editor "https://github.com/arthurbonetti/nextwatch/blob/main/components/organisms/SubscriptionEditorModal.tsx"

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_home,node_explore,node_title,node_list,node_history,node_catalog,node_catalog_data,node_roulette,node_user toneBlue
class node_subscriptions_screen,node_subscriptions,node_mylist_state,node_draw_state,node_progress toneAmber
class node_login,node_auth,node_auth_api,node_secure_store toneMint
class node_tmdb,node_proxy,node_tmdb_api,node_supabase toneRose
class node_details_ui,node_subscription_editor toneIndigo
```

## Components

### Discovery and viewing

- [Home and roulette](https://github.com/arthurbonetti/nextwatch/blob/main/app/(tabs)/index.tsx): `app/(tabs)/index.tsx`
- [Catalog search](https://github.com/arthurbonetti/nextwatch/blob/main/app/(tabs)/tab2.tsx): `app/(tabs)/tab2.tsx`
- [Title details](https://github.com/arthurbonetti/nextwatch/blob/main/app/title/%5Bid%5D.tsx): `app/title/[id].tsx`
- [My List](https://github.com/arthurbonetti/nextwatch/blob/main/app/my-list.tsx): `app/my-list.tsx`
- [Draw history](https://github.com/arthurbonetti/nextwatch/blob/main/app/draw-history.tsx): `app/draw-history.tsx`
- [Catalog state](https://github.com/arthurbonetti/nextwatch/blob/main/contexts/CatalogContext.tsx): `contexts/CatalogContext.tsx`
- [Static catalog](https://github.com/arthurbonetti/nextwatch/blob/main/constants/catalog.ts): `constants/catalog.ts`
- [Roulette flow](https://github.com/arthurbonetti/nextwatch/blob/main/components/organisms/DrawModal/DrawFlowModal.tsx): `components/organisms/DrawModal/DrawFlowModal.tsx`

### User data and sync

- [Subscription dashboard](https://github.com/arthurbonetti/nextwatch/blob/main/app/subscriptions.tsx): `app/subscriptions.tsx`
- [Subscription state](https://github.com/arthurbonetti/nextwatch/blob/main/contexts/SubscriptionsContext.tsx): `contexts/SubscriptionsContext.tsx`
- [Saved titles](https://github.com/arthurbonetti/nextwatch/blob/main/contexts/MyListContext.tsx): `contexts/MyListContext.tsx`
- [Decision history](https://github.com/arthurbonetti/nextwatch/blob/main/contexts/DrawHistoryContext.tsx): `contexts/DrawHistoryContext.tsx`
- [Series progress](https://github.com/arthurbonetti/nextwatch/blob/main/hooks/useSeriesProgress.ts): `hooks/useSeriesProgress.ts`

### Authentication

- [Login and registration](https://github.com/arthurbonetti/nextwatch/blob/main/app/(auth)/login.tsx): `app/(auth)/login.tsx`
- [Auth state](https://github.com/arthurbonetti/nextwatch/blob/main/contexts/AuthContext.tsx): `contexts/AuthContext.tsx`
- [Auth client](https://github.com/arthurbonetti/nextwatch/blob/main/services/authApi.ts): `services/authApi.ts`
- [Secure session store](https://github.com/arthurbonetti/nextwatch/blob/main/services/secureStore.ts): `services/secureStore.ts`

### External services

- [Catalog service](https://github.com/arthurbonetti/nextwatch/blob/main/services/tmdb.ts): `services/tmdb.ts`
- [TMDB proxy](https://github.com/arthurbonetti/nextwatch/blob/main/supabase/functions/tmdb-proxy/index.ts): `supabase/functions/tmdb-proxy/index.ts`
- **TMDB**
- **Supabase Auth and data**

### Interface components

- [Title detail sections](https://github.com/arthurbonetti/nextwatch/tree/main/components/organisms/TitleDetails): `components/organisms/TitleDetails`
- [Subscription editor](https://github.com/arthurbonetti/nextwatch/blob/main/components/organisms/SubscriptionEditorModal.tsx): `components/organisms/SubscriptionEditorModal.tsx`

### Other components

- **Viewer**

## Connections

- Viewer → Home and roulette: opens (evidence: `README.md`)
- Viewer → Catalog search: searches (evidence: `README.md`)
- Viewer → Login and registration: signs in (evidence: `README.md`)
- Viewer → Subscription dashboard: manages (evidence: `README.md`)
- Home and roulette → Catalog state: reads catalog (evidence: `app/(tabs)/index.tsx`)
- Home and roulette → Subscription state: reads providers (evidence: `app/(tabs)/index.tsx`)
- Home and roulette → Roulette flow: opens (evidence: `app/(tabs)/index.tsx`)
- Home and roulette → Decision history: records decisions (evidence: `app/(tabs)/index.tsx`)
- Home and roulette → Title details: opens details (evidence: `app/(tabs)/index.tsx`)
- Catalog search → Catalog state: searches (evidence: `app/(tabs)/tab2.tsx`)
- Catalog search → Subscription state: filters by providers (evidence: `app/(tabs)/tab2.tsx`)
- Title details → Title detail sections: renders (evidence: `app/title/[id].tsx`)
- Title details → Catalog state: reads title data (evidence: `app/title/[id].tsx`)
- Title details → Saved titles: saves title (evidence: `app/title/[id].tsx`)
- My List → Saved titles: reads saved titles (evidence: `app/my-list.tsx`)
- My List → Catalog state: resolves title data (evidence: `app/my-list.tsx`)
- Draw history → Decision history: reads decisions (evidence: `README.md`)
- Catalog state → Static catalog: uses fallback (evidence: `contexts/CatalogContext.tsx`)
- Catalog state → Subscription state: uses active providers (evidence: `contexts/CatalogContext.tsx`)
- Catalog state → Catalog service: fetches and searches (evidence: `contexts/CatalogContext.tsx`)
- Subscription dashboard → Subscription state: reads and updates (evidence: `app/subscriptions.tsx`)
- Subscription dashboard → Subscription editor: opens editor (evidence: `app/subscriptions.tsx`)
- Subscription state → Auth state: gets session (evidence: `contexts/SubscriptionsContext.tsx`)
- Subscription state → Auth client: syncs subscriptions (evidence: `contexts/SubscriptionsContext.tsx`)
- Saved titles → Auth client: syncs saved titles (evidence: `contexts/MyListContext.tsx`)
- Decision history → Auth client: syncs decisions (evidence: `contexts/DrawHistoryContext.tsx`)
- Series progress → Auth client: syncs progress (evidence: `hooks/useSeriesProgress.ts`)
- Login and registration → Auth state: submits credentials
- Auth state → Auth client: authenticates (evidence: `contexts/AuthContext.tsx`)
- Auth client → Secure session store: stores session (evidence: `services/authApi.ts`)
- Auth client → Supabase Auth and data: auth and data requests (evidence: `README.md`)
- Catalog service → TMDB proxy: requests catalog data (evidence: `README.md`)
- TMDB proxy → TMDB: forwards requests (evidence: `README.md`)
- Catalog service → Auth client: uses authenticated requests (evidence: `services/tmdb.ts`)
- Title detail sections → Catalog service: loads detail data (evidence: `app/title/[id].tsx`)
