# firaol240/stat-tool-web architecture

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

- Interactive diagram: https://gitdiagram.com/firaol240/stat-tool-web
- Repository: https://github.com/firaol240/stat-tool-web

## Overview

This is a browser-based NBA player lookup and comparison tool. A user enters a player name; the page derives an ID and requests box-score and advanced stats through the Express API, which fetches both datasets from an external NBA stats service. The browser aggregates seasons, displays each player’s stats, then compares two loaded players with a chart and leader highlights. The README also identifies box and advanced statistics as the product’s core capabilities. The HTML and styling are present in the tree but were not sampled, so their exact page wiring is not represented.

Main entry points: [`public/Mainpg.js`](https://github.com/firaol240/stat-tool-web/blob/main/public/Mainpg.js) (Player search), [`server.js`](https://github.com/firaol240/stat-tool-web/blob/main/server.js) (Express API), [`public`](https://github.com/firaol240/stat-tool-web/tree/main/public) (Web pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Player comparison"]
  node_pages["Web pages"]
  node_comparison["Player search<br/>[Mainpg.js]"]
  node_aggregation["Season aggregation<br/>[Mainpg.js]"]
  node_stat_display["Stat display<br/>[Mainpg.js]"]
  node_chart["Comparison chart<br/>[Mainpg.js]"]
  node_leaders["Leader highlights<br/>[Mainpg.js]"]
end

subgraph group_service["API service"]
  node_api["Express API<br/>[server.js]"]
  node_search_history["Search history API<br/>[server.js]"]
end

subgraph group_external["External data"]
  node_supabase[("Supabase searches")]
  node_nba_stats["NBA stats service"]
end

node_user(("NBA fan"))

node_user -.->|"opens"| node_pages
node_pages -.->|"hosts"| node_comparison
node_comparison -->|"requests stats"| node_api
node_api -->|"fetches stats"| node_nba_stats
node_api -->|"returns datasets"| node_comparison
node_comparison -->|"organizes stats"| node_aggregation
node_comparison -->|"updates columns"| node_stat_display
node_comparison -->|"updates chart"| node_chart
node_comparison -->|"highlights leaders"| node_leaders
node_api -->|"routes searches"| node_search_history
node_search_history -->|"reads and writes"| node_supabase

click node_pages "https://github.com/firaol240/stat-tool-web/tree/main/public"
click node_comparison "https://github.com/firaol240/stat-tool-web/blob/main/public/Mainpg.js"
click node_aggregation "https://github.com/firaol240/stat-tool-web/blob/main/public/Mainpg.js"
click node_stat_display "https://github.com/firaol240/stat-tool-web/blob/main/public/Mainpg.js"
click node_chart "https://github.com/firaol240/stat-tool-web/blob/main/public/Mainpg.js"
click node_leaders "https://github.com/firaol240/stat-tool-web/blob/main/public/Mainpg.js"
click node_api "https://github.com/firaol240/stat-tool-web/blob/main/server.js"
click node_search_history "https://github.com/firaol240/stat-tool-web/blob/main/server.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_pages,node_comparison,node_aggregation,node_stat_display,node_chart,node_leaders toneBlue
class node_api,node_search_history toneAmber
class node_supabase,node_nba_stats toneMint
class node_user toneIndigo
```

## Components

### Player comparison

- [Web pages](https://github.com/firaol240/stat-tool-web/tree/main/public): `public`
- [Player search](https://github.com/firaol240/stat-tool-web/blob/main/public/Mainpg.js): `public/Mainpg.js`
- [Season aggregation](https://github.com/firaol240/stat-tool-web/blob/main/public/Mainpg.js): `public/Mainpg.js`
- [Stat display](https://github.com/firaol240/stat-tool-web/blob/main/public/Mainpg.js): `public/Mainpg.js`
- [Comparison chart](https://github.com/firaol240/stat-tool-web/blob/main/public/Mainpg.js): `public/Mainpg.js`
- [Leader highlights](https://github.com/firaol240/stat-tool-web/blob/main/public/Mainpg.js): `public/Mainpg.js`

### API service

- [Express API](https://github.com/firaol240/stat-tool-web/blob/main/server.js): `server.js`
- [Search history API](https://github.com/firaol240/stat-tool-web/blob/main/server.js): `server.js`

### External data

- **Supabase searches**
- **NBA stats service**

### Other components

- **NBA fan**

## Connections

- NBA fan → Web pages: opens (evidence: `README.md`)
- Web pages → Player search: hosts
- Player search → Express API: requests stats (evidence: `public/Mainpg.js`)
- Express API → NBA stats service: fetches stats (evidence: `server.js`)
- Express API → Player search: returns datasets (evidence: `server.js`)
- Player search → Season aggregation: organizes stats (evidence: `public/Mainpg.js`)
- Player search → Stat display: updates columns (evidence: `public/Mainpg.js`)
- Player search → Comparison chart: updates chart (evidence: `public/Mainpg.js`)
- Player search → Leader highlights: highlights leaders (evidence: `public/Mainpg.js`)
- Express API → Search history API: routes searches (evidence: `server.js`)
- Search history API → Supabase searches: reads and writes (evidence: `server.js`)
