# hermesfu/cpbl-fantasy architecture

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

- Interactive diagram: https://gitdiagram.com/hermesfu/cpbl-fantasy
- Repository: https://github.com/hermesfu/cpbl-fantasy

## Overview

CPBL Fantasy is a web fantasy-baseball application for managing leagues, teams, rosters, player data, and matchups. Users enter through the React app, navigate to player, team, and matchup views, and those views call Flask endpoints that read or update MongoDB-backed records. Matchup totals are calculated by the matchup endpoint using player search results. The excerpts establish several UI-to-API and backend relationships; scraper behavior and some route wiring are not shown, so those links are omitted.

Main entry points: [`backend/routes/__init__.py`](https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/__init__.py) (Blueprint registration), [`frontend/src/App.jsx`](https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/App.jsx) (Page routing), [`backend/routes/player.py`](https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/player.py) (Player search and data), [`frontend/src/pages/Players.jsx`](https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/pages/Players.jsx) (Player search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_frontend["React app<br/>[main.jsx]"]
  node_routes["Page routing<br/>[App.jsx]"]
  node_login["Login view<br/>[Login.jsx]"]
  node_register["Registration view<br/>[Register.jsx]"]
  node_success["Success view<br/>[Success.jsx]"]
  node_playersview["Player search<br/>[Players.jsx]"]
  node_teamview["Team roster view<br/>[Team.jsx]"]
  node_matchupview["Matchup view<br/>[Matchup.jsx]"]
end

subgraph group_league["League and teams"]
  node_server["Flask server<br/>[server.py]"]
  node_registry["Blueprint registration<br/>[__init__.py]"]
  node_users["User endpoints<br/>[user.py]"]
  node_leagues["League settings<br/>[league.py]"]
  node_teams["Team operations<br/>[team.py]"]
  node_requirements["Roster requirements<br/>[requirement.py]"]
end

subgraph group_players["Players and rosters"]
  node_rosters["Roster operations<br/>[roster.py]"]
  node_playerapi["Player search and data<br/>[player.py]"]
  node_matchups["Matchup totals<br/>[matchup.py]"]
end

subgraph group_data["Player data ingestion"]
  node_batter_scraper["Batter scraper<br/>[scrape_batter.py]"]
  node_pitcher_scraper["Pitcher scraper<br/>[scrape_pitcher.py]"]
end

node_user(("Fantasy user"))
node_mongodb[("MongoDB")]

node_user -->|"uses"| node_frontend
node_frontend -->|"renders"| node_routes
node_routes -->|"routes to"| node_login
node_routes -->|"routes to"| node_register
node_routes -->|"routes to"| node_success
node_routes -->|"routes to"| node_playersview
node_routes -->|"routes to"| node_teamview
node_routes -->|"routes to"| node_matchupview
node_server -->|"registers"| node_registry
node_registry -->|"registers"| node_users
node_registry -->|"registers"| node_playerapi
node_registry -->|"registers"| node_leagues
node_registry -->|"registers"| node_teams
node_registry -->|"registers"| node_requirements
node_registry -->|"registers"| node_rosters
node_registry -->|"registers"| node_matchups
node_playersview -->|"requests data"| node_playerapi
node_playersview -->|"requests settings"| node_leagues
node_playersview -->|"requests team"| node_teams
node_playersview -->|"adds players"| node_rosters
node_teamview -->|"requests team"| node_teams
node_teamview -->|"requests categories"| node_leagues
node_teamview -->|"requests players"| node_playerapi
node_teamview -->|"changes roster"| node_rosters
node_matchupview -->|"requests matchup"| node_matchups
node_matchupview -->|"requests team"| node_teams
node_matchupview -->|"requests roster"| node_rosters
node_matchupview -->|"requests players"| node_playerapi
node_matchups -->|"fetches player data"| node_playerapi
node_leagues -->|"reads and writes"| node_mongodb
node_teams -->|"reads and writes"| node_mongodb
node_requirements -->|"reads and writes"| node_mongodb
node_rosters -->|"reads and writes"| node_mongodb
node_playerapi -->|"reads"| node_mongodb
node_matchups -->|"reads and writes"| node_mongodb

click node_frontend "https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/main.jsx"
click node_routes "https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/App.jsx"
click node_login "https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/pages/Login.jsx"
click node_register "https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/pages/Register.jsx"
click node_success "https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/pages/Success.jsx"
click node_playersview "https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/pages/Players.jsx"
click node_teamview "https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/pages/Team.jsx"
click node_matchupview "https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/pages/Matchup.jsx"
click node_server "https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/server.py"
click node_registry "https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/__init__.py"
click node_users "https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/user.py"
click node_leagues "https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/league.py"
click node_teams "https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/team.py"
click node_requirements "https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/requirement.py"
click node_rosters "https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/roster.py"
click node_playerapi "https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/player.py"
click node_matchups "https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/matchup.py"
click node_batter_scraper "https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/webscraping/scrape_batter.py"
click node_pitcher_scraper "https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/webscraping/scrape_pitcher.py"

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_frontend,node_routes,node_login,node_register,node_success,node_playersview,node_teamview,node_matchupview,node_user toneBlue
class node_server,node_registry,node_users,node_leagues,node_teams,node_requirements,node_mongodb toneAmber
class node_rosters,node_playerapi,node_matchups toneMint
class node_batter_scraper,node_pitcher_scraper toneRose
```

## Components

### Web application

- [React app](https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`
- [Page routing](https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login view](https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Registration view](https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/pages/Register.jsx): `frontend/src/pages/Register.jsx`
- [Success view](https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/pages/Success.jsx): `frontend/src/pages/Success.jsx`
- [Player search](https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/pages/Players.jsx): `frontend/src/pages/Players.jsx`
- [Team roster view](https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/pages/Team.jsx): `frontend/src/pages/Team.jsx`
- [Matchup view](https://github.com/hermesfu/cpbl-fantasy/blob/main/frontend/src/pages/Matchup.jsx): `frontend/src/pages/Matchup.jsx`

### League and teams

- [Flask server](https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/server.py): `backend/server.py`
- [Blueprint registration](https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/__init__.py): `backend/routes/__init__.py`
- [User endpoints](https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/user.py): `backend/routes/user.py`
- [League settings](https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/league.py): `backend/routes/league.py`
- [Team operations](https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/team.py): `backend/routes/team.py`
- [Roster requirements](https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/requirement.py): `backend/routes/requirement.py`

### Players and rosters

- [Roster operations](https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/roster.py): `backend/routes/roster.py`
- [Player search and data](https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/player.py): `backend/routes/player.py`
- [Matchup totals](https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/routes/matchup.py): `backend/routes/matchup.py`

### Player data ingestion

- [Batter scraper](https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/webscraping/scrape_batter.py): `backend/webscraping/scrape_batter.py`
- [Pitcher scraper](https://github.com/hermesfu/cpbl-fantasy/blob/main/backend/webscraping/scrape_pitcher.py): `backend/webscraping/scrape_pitcher.py`

### Other components

- **Fantasy user**
- **MongoDB**

## Connections

- Fantasy user → React app: uses (evidence: `frontend/src/main.jsx`)
- React app → Page routing: renders (evidence: `frontend/src/main.jsx`)
- Page routing → Login view: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Registration view: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Success view: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Player search: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Team roster view: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Matchup view: routes to (evidence: `frontend/src/App.jsx`)
- Flask server → Blueprint registration: registers (evidence: `backend/server.py`)
- Blueprint registration → User endpoints: registers (evidence: `backend/routes/__init__.py`)
- Blueprint registration → Player search and data: registers (evidence: `backend/routes/__init__.py`)
- Blueprint registration → League settings: registers (evidence: `backend/routes/__init__.py`)
- Blueprint registration → Team operations: registers (evidence: `backend/routes/__init__.py`)
- Blueprint registration → Roster requirements: registers (evidence: `backend/routes/__init__.py`)
- Blueprint registration → Roster operations: registers (evidence: `backend/routes/__init__.py`)
- Blueprint registration → Matchup totals: registers (evidence: `backend/routes/__init__.py`)
- Player search → Player search and data: requests data (evidence: `frontend/src/pages/Players.jsx`)
- Player search → League settings: requests settings (evidence: `frontend/src/pages/Players.jsx`)
- Player search → Team operations: requests team (evidence: `frontend/src/pages/Players.jsx`)
- Player search → Roster operations: adds players (evidence: `frontend/src/pages/Players.jsx`)
- Team roster view → Team operations: requests team (evidence: `frontend/src/pages/Team.jsx`)
- Team roster view → League settings: requests categories (evidence: `frontend/src/pages/Team.jsx`)
- Team roster view → Player search and data: requests players (evidence: `frontend/src/pages/Team.jsx`)
- Team roster view → Roster operations: changes roster (evidence: `frontend/src/pages/Team.jsx`)
- Matchup view → Matchup totals: requests matchup (evidence: `frontend/src/pages/Matchup.jsx`)
- Matchup view → Team operations: requests team (evidence: `frontend/src/pages/Matchup.jsx`)
- Matchup view → Roster operations: requests roster (evidence: `frontend/src/pages/Matchup.jsx`)
- Matchup view → Player search and data: requests players (evidence: `frontend/src/pages/Matchup.jsx`)
- Matchup totals → Player search and data: fetches player data (evidence: `backend/routes/matchup.py`)
- League settings → MongoDB: reads and writes (evidence: `backend/routes/league.py`)
- Team operations → MongoDB: reads and writes (evidence: `backend/routes/team.py`)
- Roster requirements → MongoDB: reads and writes (evidence: `backend/routes/requirement.py`)
- Roster operations → MongoDB: reads and writes (evidence: `backend/routes/roster.py`)
- Player search and data → MongoDB: reads (evidence: `backend/routes/player.py`)
- Matchup totals → MongoDB: reads and writes (evidence: `backend/routes/matchup.py`)
