# bravinevans/petrovest architecture

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

- Interactive diagram: https://gitdiagram.com/bravinevans/petrovest
- Repository: https://github.com/bravinevans/petrovest

## Overview

Petrovest is a web streaming discovery and playback platform. The user browses or searches movie/TV catalogs, opens title details, then selects a player source; signed-in users can save library items and playback history. The graph preserves the documented discovery, detail, playback, account, library, history, and download capabilities. Sampled excerpts establish several API, action, and history links; page-to-component wiring and some unsampled feature details are represented only where documented or left unlinked.

Main entry points: [`src/actions/histories.ts`](https://github.com/bravinevans/petrovest/blob/master/src/actions/histories.ts) (Watch history actions), [`src/api/tmdb-client.ts`](https://github.com/bravinevans/petrovest/blob/master/src/api/tmdb-client.ts) (Catalog client), [`src/hooks/usePlayerEvents.ts`](https://github.com/bravinevans/petrovest/blob/master/src/hooks/usePlayerEvents.ts) (Player event tracking), [`src/utils/supabase/server.ts`](https://github.com/bravinevans/petrovest/blob/master/src/utils/supabase/server.ts) (Supabase client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_catalog["Catalog discovery"]
  node_home["Home browsing<br/>[page.tsx]"]
  node_discover["Filtered discovery<br/>[page.tsx]"]
  node_filters["Discovery filters"]
  node_search["Title search<br/>[page.tsx]"]
  node_details["Movie and TV details<br/>[page.tsx]"]
end

subgraph group_playback["Title playback"]
  node_movieplayer["Movie player<br/>[Player.tsx]"]
  node_tvplayer["TV player<br/>[Player.tsx]"]
  node_player_events["Player event tracking<br/>[usePlayerEvents.ts]"]
  node_downloads["Download options<br/>[page.tsx]"]
end

subgraph group_account["Accounts and personal data"]
  node_auth["Account actions<br/>[auth.ts]"]
  node_authcallback["Auth callback<br/>[route.ts]"]
  node_library["Saved library<br/>[library.ts]"]
  node_libraryview["Library view<br/>[List.tsx]"]
  node_history["Watch history actions<br/>[histories.ts]"]
  node_historyapi["History save endpoint<br/>[route.ts]"]
  node_homehistory["Continue watching"]
end

subgraph group_platform["Application services"]
  node_tmdbclient["Catalog client<br/>[tmdb-client.ts]"]
  node_tmdbproxy["TMDB API proxy<br/>[route.ts]"]
  node_downloadapi["Torrent lookup API<br/>[route.ts]"]
  node_supabase["Supabase client<br/>[server.ts]"]
end

node_viewer(("Viewer"))
node_tmdb["TMDB service"]
node_torrent_services["Torrent providers"]

node_viewer -->|"browses"| node_home
node_viewer -->|"filters titles"| node_discover
node_viewer -->|"searches"| node_search
node_viewer -->|"reviews details"| node_details
node_viewer -->|"watches movies"| node_movieplayer
node_viewer -->|"watches episodes"| node_tvplayer
node_viewer -->|"views downloads"| node_downloads
node_viewer -->|"opens library"| node_libraryview
node_discover -.->|"uses filters"| node_filters
node_tmdbclient -->|"fetches catalog"| node_tmdbproxy
node_tmdbproxy -->|"requests data"| node_tmdb
node_search -.->|"searches titles"| node_tmdbclient
node_home -.->|"loads listings"| node_tmdbclient
node_details -.->|"loads title data"| node_tmdbclient
node_movieplayer -.->|"tracks playback"| node_player_events
node_tvplayer -.->|"tracks playback"| node_player_events
node_player_events -->|"syncs progress"| node_history
node_player_events -->|"sends beacon"| node_historyapi
node_historyapi -->|"routes save"| node_history
node_history -->|"reads and writes"| node_supabase
node_history -.->|"fetches metadata"| node_tmdbclient
node_homehistory -->|"loads history"| node_history
node_libraryview -->|"loads library"| node_library
node_library -->|"reads and writes"| node_supabase
node_authcallback -->|"exchanges session"| node_supabase
node_auth -->|"uses account data"| node_supabase
node_downloads -->|"requests options"| node_downloadapi
node_downloadapi -->|"queries releases"| node_torrent_services

click node_home "https://github.com/bravinevans/petrovest/blob/master/src/app/page.tsx"
click node_discover "https://github.com/bravinevans/petrovest/blob/master/src/app/discover/page.tsx"
click node_filters "https://github.com/bravinevans/petrovest/blob/master/src/hooks/useDiscoverFilters.ts"
click node_search "https://github.com/bravinevans/petrovest/blob/master/src/app/search/page.tsx"
click node_details "https://github.com/bravinevans/petrovest/blob/master/src/app/movie/%5Bid%5D/page.tsx"
click node_tmdbclient "https://github.com/bravinevans/petrovest/blob/master/src/api/tmdb-client.ts"
click node_tmdbproxy "https://github.com/bravinevans/petrovest/blob/master/src/app/api/tmdb/%5B...path%5D/route.ts"
click node_movieplayer "https://github.com/bravinevans/petrovest/blob/master/src/components/sections/Movie/Player/Player.tsx"
click node_tvplayer "https://github.com/bravinevans/petrovest/blob/master/src/components/sections/TV/Player/Player.tsx"
click node_player_events "https://github.com/bravinevans/petrovest/blob/master/src/hooks/usePlayerEvents.ts"
click node_downloads "https://github.com/bravinevans/petrovest/blob/master/src/app/downloads/page.tsx"
click node_downloadapi "https://github.com/bravinevans/petrovest/blob/master/src/app/api/downloads/route.ts"
click node_auth "https://github.com/bravinevans/petrovest/blob/master/src/actions/auth.ts"
click node_authcallback "https://github.com/bravinevans/petrovest/blob/master/src/app/api/auth/callback/route.ts"
click node_supabase "https://github.com/bravinevans/petrovest/blob/master/src/utils/supabase/server.ts"
click node_library "https://github.com/bravinevans/petrovest/blob/master/src/actions/library.ts"
click node_libraryview "https://github.com/bravinevans/petrovest/blob/master/src/components/sections/Library/List.tsx"
click node_history "https://github.com/bravinevans/petrovest/blob/master/src/actions/histories.ts"
click node_historyapi "https://github.com/bravinevans/petrovest/blob/master/src/app/api/player/save-history/route.ts"
click node_homehistory "https://github.com/bravinevans/petrovest/blob/master/src/components/sections/Home/ContinueWatching.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_discover,node_filters,node_search,node_details,node_viewer toneBlue
class node_movieplayer,node_tvplayer,node_player_events,node_downloads toneAmber
class node_auth,node_authcallback,node_library,node_libraryview,node_history,node_historyapi,node_homehistory toneMint
class node_tmdbclient,node_tmdbproxy,node_downloadapi,node_supabase toneRose
class node_tmdb,node_torrent_services toneIndigo
```

## Components

### Catalog discovery

- [Home browsing](https://github.com/bravinevans/petrovest/blob/master/src/app/page.tsx): `src/app/page.tsx`
- [Filtered discovery](https://github.com/bravinevans/petrovest/blob/master/src/app/discover/page.tsx): `src/app/discover/page.tsx`
- [Discovery filters](https://github.com/bravinevans/petrovest/blob/master/src/hooks/useDiscoverFilters.ts): `src/hooks/useDiscoverFilters.ts`
- [Title search](https://github.com/bravinevans/petrovest/blob/master/src/app/search/page.tsx): `src/app/search/page.tsx`
- [Movie and TV details](https://github.com/bravinevans/petrovest/blob/master/src/app/movie/%5Bid%5D/page.tsx): `src/app/movie/[id]/page.tsx`

### Title playback

- [Movie player](https://github.com/bravinevans/petrovest/blob/master/src/components/sections/Movie/Player/Player.tsx): `src/components/sections/Movie/Player/Player.tsx`
- [TV player](https://github.com/bravinevans/petrovest/blob/master/src/components/sections/TV/Player/Player.tsx): `src/components/sections/TV/Player/Player.tsx`
- [Player event tracking](https://github.com/bravinevans/petrovest/blob/master/src/hooks/usePlayerEvents.ts): `src/hooks/usePlayerEvents.ts`
- [Download options](https://github.com/bravinevans/petrovest/blob/master/src/app/downloads/page.tsx): `src/app/downloads/page.tsx`

### Accounts and personal data

- [Account actions](https://github.com/bravinevans/petrovest/blob/master/src/actions/auth.ts): `src/actions/auth.ts`
- [Auth callback](https://github.com/bravinevans/petrovest/blob/master/src/app/api/auth/callback/route.ts): `src/app/api/auth/callback/route.ts`
- [Saved library](https://github.com/bravinevans/petrovest/blob/master/src/actions/library.ts): `src/actions/library.ts`
- [Library view](https://github.com/bravinevans/petrovest/blob/master/src/components/sections/Library/List.tsx): `src/components/sections/Library/List.tsx`
- [Watch history actions](https://github.com/bravinevans/petrovest/blob/master/src/actions/histories.ts): `src/actions/histories.ts`
- [History save endpoint](https://github.com/bravinevans/petrovest/blob/master/src/app/api/player/save-history/route.ts): `src/app/api/player/save-history/route.ts`
- [Continue watching](https://github.com/bravinevans/petrovest/blob/master/src/components/sections/Home/ContinueWatching.tsx): `src/components/sections/Home/ContinueWatching.tsx`

### Application services

- [Catalog client](https://github.com/bravinevans/petrovest/blob/master/src/api/tmdb-client.ts): `src/api/tmdb-client.ts`
- [TMDB API proxy](https://github.com/bravinevans/petrovest/blob/master/src/app/api/tmdb/%5B...path%5D/route.ts): `src/app/api/tmdb/[...path]/route.ts`
- [Torrent lookup API](https://github.com/bravinevans/petrovest/blob/master/src/app/api/downloads/route.ts): `src/app/api/downloads/route.ts`
- [Supabase client](https://github.com/bravinevans/petrovest/blob/master/src/utils/supabase/server.ts): `src/utils/supabase/server.ts`

### Other components

- **Viewer**
- **TMDB service**
- **Torrent providers**

## Connections

- Viewer → Home browsing: browses (evidence: `README.md`)
- Viewer → Filtered discovery: filters titles (evidence: `README.md`)
- Viewer → Title search: searches (evidence: `README.md`)
- Viewer → Movie and TV details: reviews details (evidence: `README.md`)
- Viewer → Movie player: watches movies (evidence: `README.md`)
- Viewer → TV player: watches episodes (evidence: `README.md`)
- Viewer → Download options: views downloads
- Viewer → Library view: opens library
- Filtered discovery → Discovery filters: uses filters
- Catalog client → TMDB API proxy: fetches catalog (evidence: `src/api/tmdb-client.ts`)
- TMDB API proxy → TMDB service: requests data (evidence: `src/app/api/tmdb/[...path]/route.ts`)
- Title search → Catalog client: searches titles
- Home browsing → Catalog client: loads listings
- Movie and TV details → Catalog client: loads title data
- Movie player → Player event tracking: tracks playback
- TV player → Player event tracking: tracks playback
- Player event tracking → Watch history actions: syncs progress (evidence: `src/hooks/usePlayerEvents.ts`)
- Player event tracking → History save endpoint: sends beacon (evidence: `src/hooks/usePlayerEvents.ts`)
- History save endpoint → Watch history actions: routes save (evidence: `src/app/api/player/save-history/route.ts`)
- Watch history actions → Supabase client: reads and writes (evidence: `src/actions/histories.ts`)
- Watch history actions → Catalog client: fetches metadata
- Continue watching → Watch history actions: loads history (evidence: `src/components/sections/Home/ContinueWatching.tsx`)
- Library view → Saved library: loads library (evidence: `src/components/sections/Library/List.tsx`)
- Saved library → Supabase client: reads and writes (evidence: `src/actions/library.ts`)
- Auth callback → Supabase client: exchanges session (evidence: `src/app/api/auth/callback/route.ts`)
- Account actions → Supabase client: uses account data (evidence: `src/actions/auth.ts`)
- Download options → Torrent lookup API: requests options
- Torrent lookup API → Torrent providers: queries releases (evidence: `src/app/api/downloads/route.ts`)
