# sharone-12/sofascore-scraper architecture

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

- Interactive diagram: https://gitdiagram.com/sharone-12/sofascore-scraper
- Repository: https://github.com/sharone-12/sofascore-scraper

## Overview

This is a football analytics and live-match companion web app. Users browse fixtures, scores, player/team statistics, predictions, comparisons and squad leaders; live-watch views discover and match streams to fixtures. The graph separates analytics, match data, and stream discovery/integrations, with Supabase as the shared data service. Relationship evidence is limited to the supplied excerpts and SOURCE INDEX references; unsampled implementations are represented at their existing paths, without inferring undocumented calls.

Main entry points: [`lib/supabase.ts`](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/supabase.ts) (Supabase client), [`app/api/streams/active/route.ts`](https://github.com/sharone-12/sofascore-scraper/blob/main/app/api/streams/active/route.ts) (Stream discovery API), [`app/api/ask/route.ts`](https://github.com/sharone-12/sofascore-scraper/blob/main/app/api/ask/route.ts) (Ask analytics), [`app/page.tsx`](https://github.com/sharone-12/sofascore-scraper/blob/main/app/page.tsx) (Home dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analytics["Football analytics"]
  node_home["Home dashboard<br/>[page.tsx]"]
  node_player["Player profile<br/>[page.tsx]"]
  node_signals["Player signals<br/>[page.tsx]"]
  node_squad["Squad view<br/>[page.tsx]"]
  node_leaders["Squad leaders<br/>[page.tsx]"]
  node_teams["Team rankings<br/>[page.tsx]"]
  node_compare["Player comparison<br/>[content.tsx]"]
  node_teamcompare["Team comparison<br/>[content.tsx]"]
  node_ask["Ask analytics<br/>[route.ts]"]
  node_rank["Player ranking<br/>[rank.ts]"]
  node_stats["Player statistics<br/>[stats.ts]"]
  node_teamlogic["Team calculations<br/>[teams.ts]"]
end

subgraph group_match["Matches and predictions"]
  node_matchpages["Live match centre<br/>[page.tsx]"]
  node_scoreapi["Live scores API<br/>[route.ts]"]
  node_scorelogic["Score resolution<br/>[livescores.ts]"]
  node_predictions["Predictions<br/>[page.tsx]"]
  node_matchprediction["Match prediction<br/>[page.tsx]"]
  node_predictionlogic["Prediction engine<br/>[predictions.ts]"]
end

subgraph group_streaming["Live streaming"]
  node_livewatch["Watch live<br/>[page.tsx]"]
  node_streamapi["Stream discovery API<br/>[route.ts]"]
  node_streamresolve["Stream resolution<br/>[resolve.ts]"]
  node_providerregistry["Provider registry<br/>[registry.ts]"]
  node_streamfree["StreamFree provider<br/>[client.ts]"]
  node_zlive["ZLive provider<br/>[client.ts]"]
  node_daddy["DaddyLive provider<br/>[client.ts]"]
end

subgraph group_platform["Shared platform"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
  node_database[("Supabase data store")]
  node_seasoncomp["Season and competition scope<br/>[competition.ts]"]
  node_season["Season defaults<br/>[seasons.ts]"]
  node_auth["Live access control<br/>[auth.ts]"]
end

node_visitor(("Football fan"))

node_visitor -->|"opens dashboard"| node_home
node_visitor -->|"views predictions"| node_predictions
node_visitor -->|"watches matches"| node_livewatch
node_home -->|"queries data"| node_supabase
node_home -->|"scopes display"| node_seasoncomp
node_player -->|"loads profile"| node_supabase
node_player -->|"uses statistics"| node_stats
node_signals -->|"queries data"| node_supabase
node_signals -->|"ranks players"| node_rank
node_squad -->|"loads squad"| node_supabase
node_squad -->|"uses team data"| node_teamlogic
node_leaders -->|"loads players"| node_supabase
node_leaders -->|"ranks leaders"| node_rank
node_teams -->|"queries data"| node_supabase
node_teams -->|"builds rankings"| node_teamlogic
node_compare -->|"loads comparison"| node_supabase
node_teamcompare -->|"loads comparison"| node_supabase
node_ask -->|"queries player data"| node_supabase
node_ask -->|"ranks results"| node_rank
node_ask -->|"applies scope"| node_seasoncomp
node_predictions -->|"loads match data"| node_supabase
node_predictions -->|"uses predictions"| node_predictionlogic
node_matchprediction -->|"loads prediction"| node_predictionlogic
node_matchprediction -->|"loads match data"| node_supabase
node_scoreapi -->|"resolves scores"| node_scorelogic
node_scorelogic -->|"reads match data"| node_supabase
node_matchpages -.->|"requests scores"| node_scoreapi
node_livewatch -.->|"requests streams"| node_streamapi
node_streamapi -->|"loads fixtures"| node_supabase
node_streamapi -.->|"resolves candidates"| node_streamresolve
node_streamapi -.->|"selects providers"| node_providerregistry
node_streamapi -.->|"fetches and matches"| node_streamfree
node_streamapi -.->|"fetches and matches"| node_zlive
node_streamapi -.->|"fetches provider data"| node_daddy
node_streamfree -.->|"fetches external streams"| node_visitor
node_zlive -.->|"fetches channel manifest"| node_visitor
node_supabase -->|"connects to"| node_database
node_auth -.->|"gates access"| node_livewatch
node_seasoncomp -->|"uses default season"| node_season

click node_home "https://github.com/sharone-12/sofascore-scraper/blob/main/app/page.tsx"
click node_player "https://github.com/sharone-12/sofascore-scraper/blob/main/app/player/%5Bslug%5D/page.tsx"
click node_signals "https://github.com/sharone-12/sofascore-scraper/blob/main/app/signals/page.tsx"
click node_squad "https://github.com/sharone-12/sofascore-scraper/blob/main/app/squad/page.tsx"
click node_leaders "https://github.com/sharone-12/sofascore-scraper/blob/main/app/squad/leaders/page.tsx"
click node_teams "https://github.com/sharone-12/sofascore-scraper/blob/main/app/teams/page.tsx"
click node_compare "https://github.com/sharone-12/sofascore-scraper/blob/main/app/compare/content.tsx"
click node_teamcompare "https://github.com/sharone-12/sofascore-scraper/blob/main/app/teams/compare/content.tsx"
click node_ask "https://github.com/sharone-12/sofascore-scraper/blob/main/app/api/ask/route.ts"
click node_rank "https://github.com/sharone-12/sofascore-scraper/blob/main/lib/rank.ts"
click node_stats "https://github.com/sharone-12/sofascore-scraper/blob/main/lib/stats.ts"
click node_teamlogic "https://github.com/sharone-12/sofascore-scraper/blob/main/lib/teams.ts"
click node_matchpages "https://github.com/sharone-12/sofascore-scraper/blob/main/app/live/page.tsx"
click node_scoreapi "https://github.com/sharone-12/sofascore-scraper/blob/main/app/api/livescores/route.ts"
click node_scorelogic "https://github.com/sharone-12/sofascore-scraper/blob/main/lib/livescores.ts"
click node_predictions "https://github.com/sharone-12/sofascore-scraper/blob/main/app/predictions/page.tsx"
click node_matchprediction "https://github.com/sharone-12/sofascore-scraper/blob/main/app/predictions/match/page.tsx"
click node_predictionlogic "https://github.com/sharone-12/sofascore-scraper/blob/main/lib/predictions.ts"
click node_livewatch "https://github.com/sharone-12/sofascore-scraper/blob/main/app/live/watch/page.tsx"
click node_streamapi "https://github.com/sharone-12/sofascore-scraper/blob/main/app/api/streams/active/route.ts"
click node_streamresolve "https://github.com/sharone-12/sofascore-scraper/blob/main/lib/streaming/resolve.ts"
click node_providerregistry "https://github.com/sharone-12/sofascore-scraper/blob/main/lib/providers/registry.ts"
click node_streamfree "https://github.com/sharone-12/sofascore-scraper/blob/main/lib/streamfree/client.ts"
click node_zlive "https://github.com/sharone-12/sofascore-scraper/blob/main/lib/zlive/client.ts"
click node_daddy "https://github.com/sharone-12/sofascore-scraper/blob/main/lib/daddylive/client.ts"
click node_supabase "https://github.com/sharone-12/sofascore-scraper/blob/main/lib/supabase.ts"
click node_seasoncomp "https://github.com/sharone-12/sofascore-scraper/blob/main/lib/competition.ts"
click node_season "https://github.com/sharone-12/sofascore-scraper/blob/main/lib/seasons.ts"
click node_auth "https://github.com/sharone-12/sofascore-scraper/blob/main/lib/live/auth.ts"

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_player,node_signals,node_squad,node_leaders,node_teams,node_compare,node_teamcompare,node_ask,node_rank,node_stats,node_teamlogic toneBlue
class node_matchpages,node_scoreapi,node_scorelogic,node_predictions,node_matchprediction,node_predictionlogic toneAmber
class node_livewatch,node_streamapi,node_streamresolve,node_providerregistry,node_streamfree,node_zlive,node_daddy toneMint
class node_supabase,node_database,node_seasoncomp,node_season,node_auth toneRose
class node_visitor toneIndigo
```

## Components

### Football analytics

- [Home dashboard](https://github.com/sharone-12/sofascore-scraper/blob/main/app/page.tsx): `app/page.tsx`
- [Player profile](https://github.com/sharone-12/sofascore-scraper/blob/main/app/player/%5Bslug%5D/page.tsx): `app/player/[slug]/page.tsx`
- [Player signals](https://github.com/sharone-12/sofascore-scraper/blob/main/app/signals/page.tsx): `app/signals/page.tsx`
- [Squad view](https://github.com/sharone-12/sofascore-scraper/blob/main/app/squad/page.tsx): `app/squad/page.tsx`
- [Squad leaders](https://github.com/sharone-12/sofascore-scraper/blob/main/app/squad/leaders/page.tsx): `app/squad/leaders/page.tsx`
- [Team rankings](https://github.com/sharone-12/sofascore-scraper/blob/main/app/teams/page.tsx): `app/teams/page.tsx`
- [Player comparison](https://github.com/sharone-12/sofascore-scraper/blob/main/app/compare/content.tsx): `app/compare/content.tsx`
- [Team comparison](https://github.com/sharone-12/sofascore-scraper/blob/main/app/teams/compare/content.tsx): `app/teams/compare/content.tsx`
- [Ask analytics](https://github.com/sharone-12/sofascore-scraper/blob/main/app/api/ask/route.ts): `app/api/ask/route.ts`
- [Player ranking](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/rank.ts): `lib/rank.ts`
- [Player statistics](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/stats.ts): `lib/stats.ts`
- [Team calculations](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/teams.ts): `lib/teams.ts`

### Matches and predictions

- [Live match centre](https://github.com/sharone-12/sofascore-scraper/blob/main/app/live/page.tsx): `app/live/page.tsx`
- [Live scores API](https://github.com/sharone-12/sofascore-scraper/blob/main/app/api/livescores/route.ts): `app/api/livescores/route.ts`
- [Score resolution](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/livescores.ts): `lib/livescores.ts`
- [Predictions](https://github.com/sharone-12/sofascore-scraper/blob/main/app/predictions/page.tsx): `app/predictions/page.tsx`
- [Match prediction](https://github.com/sharone-12/sofascore-scraper/blob/main/app/predictions/match/page.tsx): `app/predictions/match/page.tsx`
- [Prediction engine](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/predictions.ts): `lib/predictions.ts`

### Live streaming

- [Watch live](https://github.com/sharone-12/sofascore-scraper/blob/main/app/live/watch/page.tsx): `app/live/watch/page.tsx`
- [Stream discovery API](https://github.com/sharone-12/sofascore-scraper/blob/main/app/api/streams/active/route.ts): `app/api/streams/active/route.ts`
- [Stream resolution](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/streaming/resolve.ts): `lib/streaming/resolve.ts`
- [Provider registry](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/providers/registry.ts): `lib/providers/registry.ts`
- [StreamFree provider](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/streamfree/client.ts): `lib/streamfree/client.ts`
- [ZLive provider](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/zlive/client.ts): `lib/zlive/client.ts`
- [DaddyLive provider](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/daddylive/client.ts): `lib/daddylive/client.ts`

### Shared platform

- [Supabase client](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/supabase.ts): `lib/supabase.ts`
- **Supabase data store**
- [Season and competition scope](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/competition.ts): `lib/competition.ts`
- [Season defaults](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/seasons.ts): `lib/seasons.ts`
- [Live access control](https://github.com/sharone-12/sofascore-scraper/blob/main/lib/live/auth.ts): `lib/live/auth.ts`

### Other components

- **Football fan**

## Connections

- Football fan → Home dashboard: opens dashboard (evidence: `app/page.tsx`)
- Football fan → Predictions: views predictions (evidence: `app/predictions/page.tsx`)
- Football fan → Watch live: watches matches
- Home dashboard → Supabase client: queries data (evidence: `app/page.tsx`)
- Home dashboard → Season and competition scope: scopes display (evidence: `app/page.tsx`)
- Player profile → Supabase client: loads profile (evidence: `app/player/[slug]/page.tsx`)
- Player profile → Player statistics: uses statistics (evidence: `app/player/[slug]/page.tsx`)
- Player signals → Supabase client: queries data (evidence: `app/signals/page.tsx`)
- Player signals → Player ranking: ranks players (evidence: `app/signals/page.tsx`)
- Squad view → Supabase client: loads squad (evidence: `app/squad/page.tsx`)
- Squad view → Team calculations: uses team data (evidence: `app/squad/page.tsx`)
- Squad leaders → Supabase client: loads players (evidence: `app/squad/leaders/page.tsx`)
- Squad leaders → Player ranking: ranks leaders (evidence: `app/squad/leaders/page.tsx`)
- Team rankings → Supabase client: queries data (evidence: `app/teams/page.tsx`)
- Team rankings → Team calculations: builds rankings (evidence: `app/teams/page.tsx`)
- Player comparison → Supabase client: loads comparison
- Team comparison → Supabase client: loads comparison
- Ask analytics → Supabase client: queries player data (evidence: `app/api/ask/route.ts`)
- Ask analytics → Player ranking: ranks results (evidence: `app/api/ask/route.ts`)
- Ask analytics → Season and competition scope: applies scope (evidence: `app/api/ask/route.ts`)
- Predictions → Supabase client: loads match data (evidence: `app/predictions/page.tsx`)
- Predictions → Prediction engine: uses predictions (evidence: `app/predictions/page.tsx`)
- Match prediction → Prediction engine: loads prediction (evidence: `app/predictions/match/page.tsx`)
- Match prediction → Supabase client: loads match data (evidence: `app/predictions/match/page.tsx`)
- Live scores API → Score resolution: resolves scores (evidence: `app/api/livescores/route.ts`)
- Score resolution → Supabase client: reads match data
- Live match centre → Live scores API: requests scores
- Watch live → Stream discovery API: requests streams
- Stream discovery API → Supabase client: loads fixtures (evidence: `app/api/streams/active/route.ts`)
- Stream discovery API → Stream resolution: resolves candidates
- Stream discovery API → Provider registry: selects providers
- Stream discovery API → StreamFree provider: fetches and matches (evidence: `app/api/streams/active/route.ts`)
- Stream discovery API → ZLive provider: fetches and matches (evidence: `app/api/streams/active/route.ts`)
- Stream discovery API → DaddyLive provider: fetches provider data (evidence: `app/api/streams/active/route.ts`)
- StreamFree provider → Football fan: fetches external streams
- ZLive provider → Football fan: fetches channel manifest
- Supabase client → Supabase data store: connects to (evidence: `lib/supabase.ts`)
- Live access control → Watch live: gates access
- Season and competition scope → Season defaults: uses default season (evidence: `lib/competition.ts`)
