# jadevit/fight-canon-db architecture

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

- Interactive diagram: https://gitdiagram.com/jadevit/fight-canon-db
- Repository: https://github.com/jadevit/fight-canon-db

## Overview

Fight Canon is an MMA data product: source-specific collection and matching build a canonical SQLite database, which is published as downloadable data and supports a browsing website. The main domain stages are source acquisition, identity and bout reconciliation, database updates, and user-facing browsing/querying. The README documents the source coverage and site data formats; sampled source excerpts show selected loader, matching, and browser interactions, so unsampled integrations are not expanded into unsupported call chains.

Main entry points: [`canon_db/matching.py`](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/matching.py) (Bout Matching), [`site/js/router.js`](https://github.com/jadevit/fight-canon-db/blob/main/site/js/router.js) (Page Router), [`canon_db/db.py`](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/db.py) (SQLite Database), [`canon_db/sources/sherdog/write.py`](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/sherdog/write.py) (Sherdog Writes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Source Collection"]
  node_updater["Update Runner<br/>[__main__.py]"]
  node_http["HTTP Fetcher<br/>[http.py]"]
  node_ufc["UFC Stats<br/>[load.py]"]
  node_sherdogcards["Sherdog Cards<br/>[cards.py]"]
  node_sherdogfighters["Sherdog Fighter Records<br/>[load.py]"]
  node_pfl["PFL Stats<br/>[load.py]"]
  node_oktagon["Oktagon Stats<br/>[load.py]"]
  node_sofascore["Sofascore Stats<br/>[load.py]"]
  node_decisions["MMA Decisions<br/>[load.py]"]
  node_odds["BestFightOdds<br/>[load.py]"]
end

subgraph group_reconcile["Canonicalization"]
  node_matching["Bout Matching<br/>[matching.py]"]
  node_ids["Canonical IDs<br/>[ids.py]"]
  node_sherdogwrite["Sherdog Writes<br/>[write.py]"]
  node_promotions["Promotion Mapping<br/>[promotions.py]"]
end

subgraph group_storage["Database"]
  node_database[("SQLite Database<br/>[db.py]")]
end

subgraph group_delivery["Data Delivery"]
  node_publisher["JSON Publishing<br/>[site_json.py]"]
  node_parquet["Parquet Export<br/>[export_parquet.py]"]
end

subgraph group_website["Website"]
  node_router["Page Router<br/>[router.js]"]
  node_fighterpages["Fighter Pages<br/>[fighters.js]"]
  node_fightpage["Fight Pages<br/>[fight.js]"]
  node_search["Site Search<br/>[search.js]"]
  node_querypage["SQL Query Page<br/>[query.js]"]
  node_duckdb["DuckDB-WASM<br/>[duck.js]"]
end

node_siteuser(("Website Visitor"))

node_updater -->|"updates"| node_database
node_ufc -->|"fetches through"| node_http
node_pfl -->|"fetches through"| node_http
node_sherdogcards -.->|"fetches through"| node_http
node_sherdogcards -->|"matches bouts"| node_matching
node_sherdogcards -->|"writes cards"| node_sherdogwrite
node_sherdogfighters -.->|"writes records"| node_sherdogwrite
node_pfl -->|"matches bouts"| node_matching
node_pfl -->|"fetches through"| node_http
node_oktagon -->|"matches bouts"| node_matching
node_sofascore -->|"matches bouts"| node_matching
node_decisions -->|"matches bouts"| node_matching
node_odds -->|"matches bouts"| node_matching
node_ufc -->|"resolves IDs"| node_ids
node_sherdogwrite -->|"uses canonical IDs"| node_ids
node_matching -->|"reads fights"| node_database
node_ids -->|"writes aliases"| node_database
node_sherdogwrite -->|"maps promotions"| node_promotions
node_publisher -.->|"reads database"| node_database
node_parquet -.->|"exports database"| node_database
node_siteuser -->|"opens pages"| node_router
node_router -->|"routes fighters"| node_fighterpages
node_router -->|"routes fights"| node_fightpage
node_router -->|"uses search"| node_search
node_router -->|"routes queries"| node_querypage
node_querypage -->|"runs SQL"| node_duckdb
node_duckdb -.->|"reads exported data"| node_parquet

click node_updater "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/__main__.py"
click node_http "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/http.py"
click node_ufc "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/ufcstats/load.py"
click node_sherdogcards "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/sherdog/cards.py"
click node_sherdogfighters "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/sherdog/load.py"
click node_pfl "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/pfl/load.py"
click node_oktagon "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/oktagon/load.py"
click node_sofascore "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/sofascore/load.py"
click node_decisions "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/mmadecisions/load.py"
click node_odds "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/bestfightodds/load.py"
click node_matching "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/matching.py"
click node_ids "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/ids.py"
click node_sherdogwrite "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/sherdog/write.py"
click node_database "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/db.py"
click node_promotions "https://github.com/jadevit/fight-canon-db/blob/main/canon_db/promotions.py"
click node_publisher "https://github.com/jadevit/fight-canon-db/blob/main/scripts/site_json.py"
click node_parquet "https://github.com/jadevit/fight-canon-db/blob/main/scripts/export_parquet.py"
click node_router "https://github.com/jadevit/fight-canon-db/blob/main/site/js/router.js"
click node_fighterpages "https://github.com/jadevit/fight-canon-db/blob/main/site/js/fighters.js"
click node_fightpage "https://github.com/jadevit/fight-canon-db/blob/main/site/js/fight.js"
click node_search "https://github.com/jadevit/fight-canon-db/blob/main/site/js/search.js"
click node_querypage "https://github.com/jadevit/fight-canon-db/blob/main/site/js/query.js"
click node_duckdb "https://github.com/jadevit/fight-canon-db/blob/main/site/js/duck.js"

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_updater,node_http,node_ufc,node_sherdogcards,node_sherdogfighters,node_pfl,node_oktagon,node_sofascore,node_decisions,node_odds toneBlue
class node_matching,node_ids,node_sherdogwrite,node_promotions toneAmber
class node_database toneMint
class node_publisher,node_parquet toneRose
class node_router,node_fighterpages,node_fightpage,node_search,node_querypage,node_duckdb,node_siteuser toneIndigo
```

## Components

### Source Collection

- [Update Runner](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/__main__.py): `canon_db/__main__.py`
- [HTTP Fetcher](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/http.py): `canon_db/http.py`
- [UFC Stats](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/ufcstats/load.py): `canon_db/sources/ufcstats/load.py`
- [Sherdog Cards](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/sherdog/cards.py): `canon_db/sources/sherdog/cards.py`
- [Sherdog Fighter Records](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/sherdog/load.py): `canon_db/sources/sherdog/load.py`
- [PFL Stats](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/pfl/load.py): `canon_db/sources/pfl/load.py`
- [Oktagon Stats](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/oktagon/load.py): `canon_db/sources/oktagon/load.py`
- [Sofascore Stats](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/sofascore/load.py): `canon_db/sources/sofascore/load.py`
- [MMA Decisions](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/mmadecisions/load.py): `canon_db/sources/mmadecisions/load.py`
- [BestFightOdds](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/bestfightodds/load.py): `canon_db/sources/bestfightodds/load.py`

### Canonicalization

- [Bout Matching](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/matching.py): `canon_db/matching.py`
- [Canonical IDs](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/ids.py): `canon_db/ids.py`
- [Sherdog Writes](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/sources/sherdog/write.py): `canon_db/sources/sherdog/write.py`
- [Promotion Mapping](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/promotions.py): `canon_db/promotions.py`

### Database

- [SQLite Database](https://github.com/jadevit/fight-canon-db/blob/main/canon_db/db.py): `canon_db/db.py`

### Data Delivery

- [JSON Publishing](https://github.com/jadevit/fight-canon-db/blob/main/scripts/site_json.py): `scripts/site_json.py`
- [Parquet Export](https://github.com/jadevit/fight-canon-db/blob/main/scripts/export_parquet.py): `scripts/export_parquet.py`

### Website

- [Page Router](https://github.com/jadevit/fight-canon-db/blob/main/site/js/router.js): `site/js/router.js`
- [Fighter Pages](https://github.com/jadevit/fight-canon-db/blob/main/site/js/fighters.js): `site/js/fighters.js`
- [Fight Pages](https://github.com/jadevit/fight-canon-db/blob/main/site/js/fight.js): `site/js/fight.js`
- [Site Search](https://github.com/jadevit/fight-canon-db/blob/main/site/js/search.js): `site/js/search.js`
- [SQL Query Page](https://github.com/jadevit/fight-canon-db/blob/main/site/js/query.js): `site/js/query.js`
- [DuckDB-WASM](https://github.com/jadevit/fight-canon-db/blob/main/site/js/duck.js): `site/js/duck.js`

### Other components

- **Website Visitor**

## Connections

- Update Runner → SQLite Database: updates (evidence: `canon_db/__main__.py`)
- UFC Stats → HTTP Fetcher: fetches through (evidence: `canon_db/sources/ufcstats/load.py`)
- PFL Stats → HTTP Fetcher: fetches through (evidence: `canon_db/sources/pfl/load.py`)
- Sherdog Cards → HTTP Fetcher: fetches through (evidence: `canon_db/sources/sherdog/cards.py`)
- Sherdog Cards → Bout Matching: matches bouts (evidence: `canon_db/sources/sherdog/cards.py`)
- Sherdog Cards → Sherdog Writes: writes cards (evidence: `canon_db/sources/sherdog/cards.py`)
- Sherdog Fighter Records → Sherdog Writes: writes records
- PFL Stats → Bout Matching: matches bouts (evidence: `canon_db/sources/pfl/load.py`)
- PFL Stats → HTTP Fetcher: fetches through (evidence: `canon_db/sources/pfl/load.py`)
- Oktagon Stats → Bout Matching: matches bouts (evidence: `canon_db/sources/oktagon/load.py`)
- Sofascore Stats → Bout Matching: matches bouts (evidence: `canon_db/sources/sofascore/load.py`)
- MMA Decisions → Bout Matching: matches bouts (evidence: `canon_db/sources/mmadecisions/load.py`)
- BestFightOdds → Bout Matching: matches bouts (evidence: `canon_db/sources/bestfightodds/load.py`)
- UFC Stats → Canonical IDs: resolves IDs (evidence: `canon_db/sources/ufcstats/load.py`)
- Sherdog Writes → Canonical IDs: uses canonical IDs (evidence: `canon_db/sources/sherdog/write.py`)
- Bout Matching → SQLite Database: reads fights (evidence: `canon_db/matching.py`)
- Canonical IDs → SQLite Database: writes aliases (evidence: `canon_db/ids.py`)
- Sherdog Writes → Promotion Mapping: maps promotions (evidence: `canon_db/sources/sherdog/write.py`)
- JSON Publishing → SQLite Database: reads database
- Parquet Export → SQLite Database: exports database
- Website Visitor → Page Router: opens pages (evidence: `site/js/router.js`)
- Page Router → Fighter Pages: routes fighters (evidence: `site/js/router.js`)
- Page Router → Fight Pages: routes fights (evidence: `site/js/router.js`)
- Page Router → Site Search: uses search (evidence: `site/js/router.js`)
- Page Router → SQL Query Page: routes queries (evidence: `site/js/router.js`)
- SQL Query Page → DuckDB-WASM: runs SQL (evidence: `site/js/query.js`)
- DuckDB-WASM → Parquet Export: reads exported data
