# subham269/prediction-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/subham269/prediction-tracker
- Repository: https://github.com/subham269/prediction-tracker

## Overview

Sports Prediction Tracker is a web app for making cricket and football predictions, recording outcomes, and reviewing accuracy and history. Users enter through shared navigation, optionally authenticate, then submit predictions and view their results through sport-specific and summary pages. The frontend also includes a Node backend and a SQLite database, but the backend source was not excerpted, so its connections to the UI are shown as unverified. The README describes localStorage persistence, while sampled prediction pages call an API; the exact persistence implementation could not be confirmed.

Main entry points: [`src/App.jsx`](https://github.com/subham269/prediction-tracker/blob/main/src/App.jsx) (App Router), [`src/lib/api.js`](https://github.com/subham269/prediction-tracker/blob/main/src/lib/api.js) (API Client), [`src/layouts`](https://github.com/subham269/prediction-tracker/tree/main/src/layouts) (Shared Layout), [`src/lib/protectedroute.jsx`](https://github.com/subham269/prediction-tracker/blob/main/src/lib/protectedroute.jsx) (Route Guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_routing["Application Shell"]
  node_app["App Router<br/>[App.jsx]"]
  node_shell["Shared Layout"]
  node_ui["UI Components"]
end

subgraph group_identity["Authentication"]
  node_auth["Auth State<br/>[AuthContext.jsx]"]
  node_login["Login<br/>[Login.jsx]"]
  node_signup["Registration<br/>[SignUp.jsx]"]
  node_guard["Route Guard<br/>[protectedroute.jsx]"]
end

subgraph group_predictions["Prediction Features"]
  node_cricket["Cricket Predictions<br/>[Cricket.jsx]"]
  node_football["Football Predictions<br/>[Football.jsx]"]
  node_history["Prediction History<br/>[My_predictions.jsx]"]
  node_stats["Accuracy Stats<br/>[Stats.jsx]"]
  node_leaderboard["Leaderboard<br/>[leaderboard.jsx]"]
  node_home["Home<br/>[Home.jsx]"]
end

subgraph group_backend["Backend Services"]
  node_api["API Client<br/>[api.js]"]
  node_server["Backend API<br/>[backend.js]"]
  node_db[("SQLite Database<br/>[predictions-app.db]")]
end

node_visitor(("Visitor"))
node_storage[("Browser Storage")]

node_visitor -->|"opens"| node_app
node_app -->|"renders"| node_shell
node_app -->|"routes"| node_cricket
node_app -->|"routes"| node_football
node_app -->|"routes"| node_home
node_app -->|"routes"| node_stats
node_app -->|"protects"| node_guard
node_guard -->|"renders"| node_history
node_guard -->|"renders"| node_leaderboard
node_app -->|"uses sidebar"| node_ui
node_shell -->|"uses components"| node_ui
node_shell -->|"opens"| node_login
node_shell -->|"opens"| node_signup
node_login -->|"sets session"| node_auth
node_signup -->|"sets session"| node_auth
node_guard -->|"checks session"| node_auth
node_auth -->|"persists session"| node_storage
node_cricket -->|"fetches predictions"| node_api
node_football -->|"fetches predictions"| node_api
node_history -->|"requests history"| node_api
node_leaderboard -->|"requests rankings"| node_api
node_api -.->|"sends requests"| node_server
node_server -.->|"uses database"| node_db

click node_app "https://github.com/subham269/prediction-tracker/blob/main/src/App.jsx"
click node_shell "https://github.com/subham269/prediction-tracker/tree/main/src/layouts"
click node_ui "https://github.com/subham269/prediction-tracker/tree/main/src/components/ui"
click node_auth "https://github.com/subham269/prediction-tracker/blob/main/src/context/AuthContext.jsx"
click node_login "https://github.com/subham269/prediction-tracker/blob/main/src/layouts/Login.jsx"
click node_signup "https://github.com/subham269/prediction-tracker/blob/main/src/layouts/SignUp.jsx"
click node_guard "https://github.com/subham269/prediction-tracker/blob/main/src/lib/protectedroute.jsx"
click node_cricket "https://github.com/subham269/prediction-tracker/blob/main/src/pages/Cricket.jsx"
click node_football "https://github.com/subham269/prediction-tracker/blob/main/src/pages/Football.jsx"
click node_history "https://github.com/subham269/prediction-tracker/blob/main/src/pages/My_predictions.jsx"
click node_stats "https://github.com/subham269/prediction-tracker/blob/main/src/pages/Stats.jsx"
click node_leaderboard "https://github.com/subham269/prediction-tracker/blob/main/src/pages/leaderboard.jsx"
click node_home "https://github.com/subham269/prediction-tracker/blob/main/src/pages/Home.jsx"
click node_api "https://github.com/subham269/prediction-tracker/blob/main/src/lib/api.js"
click node_server "https://github.com/subham269/prediction-tracker/blob/main/backend/backend.js"
click node_db "https://github.com/subham269/prediction-tracker/blob/main/predictions-app.db"

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_app,node_shell,node_ui toneBlue
class node_auth,node_login,node_signup,node_guard,node_storage toneAmber
class node_cricket,node_football,node_history,node_stats,node_leaderboard,node_home toneMint
class node_api,node_server,node_db toneRose
class node_visitor toneIndigo
```

## Components

### Application Shell

- [App Router](https://github.com/subham269/prediction-tracker/blob/main/src/App.jsx): `src/App.jsx`
- [Shared Layout](https://github.com/subham269/prediction-tracker/tree/main/src/layouts): `src/layouts`
- [UI Components](https://github.com/subham269/prediction-tracker/tree/main/src/components/ui): `src/components/ui`

### Authentication

- [Auth State](https://github.com/subham269/prediction-tracker/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`
- [Login](https://github.com/subham269/prediction-tracker/blob/main/src/layouts/Login.jsx): `src/layouts/Login.jsx`
- [Registration](https://github.com/subham269/prediction-tracker/blob/main/src/layouts/SignUp.jsx): `src/layouts/SignUp.jsx`
- [Route Guard](https://github.com/subham269/prediction-tracker/blob/main/src/lib/protectedroute.jsx): `src/lib/protectedroute.jsx`

### Prediction Features

- [Cricket Predictions](https://github.com/subham269/prediction-tracker/blob/main/src/pages/Cricket.jsx): `src/pages/Cricket.jsx`
- [Football Predictions](https://github.com/subham269/prediction-tracker/blob/main/src/pages/Football.jsx): `src/pages/Football.jsx`
- [Prediction History](https://github.com/subham269/prediction-tracker/blob/main/src/pages/My_predictions.jsx): `src/pages/My_predictions.jsx`
- [Accuracy Stats](https://github.com/subham269/prediction-tracker/blob/main/src/pages/Stats.jsx): `src/pages/Stats.jsx`
- [Leaderboard](https://github.com/subham269/prediction-tracker/blob/main/src/pages/leaderboard.jsx): `src/pages/leaderboard.jsx`
- [Home](https://github.com/subham269/prediction-tracker/blob/main/src/pages/Home.jsx): `src/pages/Home.jsx`

### Backend Services

- [API Client](https://github.com/subham269/prediction-tracker/blob/main/src/lib/api.js): `src/lib/api.js`
- [Backend API](https://github.com/subham269/prediction-tracker/blob/main/backend/backend.js): `backend/backend.js`
- [SQLite Database](https://github.com/subham269/prediction-tracker/blob/main/predictions-app.db): `predictions-app.db`

### Other components

- **Visitor**
- **Browser Storage**

## Connections

- Visitor → App Router: opens
- App Router → Shared Layout: renders (evidence: `src/App.jsx`)
- App Router → Cricket Predictions: routes (evidence: `src/App.jsx`)
- App Router → Football Predictions: routes (evidence: `src/App.jsx`)
- App Router → Home: routes (evidence: `src/App.jsx`)
- App Router → Accuracy Stats: routes (evidence: `src/App.jsx`)
- App Router → Route Guard: protects (evidence: `src/App.jsx`)
- Route Guard → Prediction History: renders (evidence: `src/App.jsx`)
- Route Guard → Leaderboard: renders (evidence: `src/App.jsx`)
- App Router → UI Components: uses sidebar (evidence: `src/App.jsx`)
- Shared Layout → UI Components: uses components (evidence: `src/layouts/AppSidebar.jsx`)
- Shared Layout → Login: opens (evidence: `src/layouts/AppHeader.jsx`)
- Shared Layout → Registration: opens (evidence: `src/layouts/AppHeader.jsx`)
- Login → Auth State: sets session (evidence: `src/layouts/Login.jsx`)
- Registration → Auth State: sets session (evidence: `src/layouts/SignUp.jsx`)
- Route Guard → Auth State: checks session (evidence: `src/lib/protectedroute.jsx`)
- Auth State → Browser Storage: persists session (evidence: `src/context/AuthContext.jsx`)
- Cricket Predictions → API Client: fetches predictions (evidence: `src/pages/Cricket.jsx`)
- Football Predictions → API Client: fetches predictions (evidence: `src/pages/Football.jsx`)
- Prediction History → API Client: requests history (evidence: `src/pages/My_predictions.jsx`)
- Leaderboard → API Client: requests rankings (evidence: `src/pages/leaderboard.jsx`)
- API Client → Backend API: sends requests
- Backend API → SQLite Database: uses database
