# arhamifham/banamatics architecture

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

- Interactive diagram: https://gitdiagram.com/arhamifham/banamatics
- Repository: https://github.com/arhamifham/banamatics

## Overview

Banamatix is a browser-based banana-math quiz game with trial and logged-in play, account access, coin rewards, and a theme store. Users enter through the routed app, play puzzles fetched from an external quiz service, and can sign in to continue and spend coins on themes. The PHP backend handles account and user/theme operations against MySQL; theme selection is also applied and persisted in browser storage. Backend endpoint links to the database are supported by the source index; frontend-to-backend calls are shown where excerpts expose them.

Main entry points: [`src/components/StorePage.tsx`](https://github.com/arhamifham/banamatics/blob/master/src/components/StorePage.tsx) (Theme store), [`backend/db.php`](https://github.com/arhamifham/banamatics/blob/master/backend/db.php) (MySQL connection), [`src/App.tsx`](https://github.com/arhamifham/banamatics/blob/master/src/App.tsx) (Route application), [`src/components/LoginPage.tsx`](https://github.com/arhamifham/banamatics/blob/master/src/components/LoginPage.tsx) (Login and registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_app["Route application<br/>[App.tsx]"]
end

subgraph group_game["Quiz gameplay"]
  node_home["Trial quiz<br/>[HomePage.tsx]"]
  node_gameplay["Full game<br/>[GamePage.tsx]"]
  node_quizgen["Quiz generator<br/>[quizGenerator.ts]"]
  node_quizimage["Quiz image<br/>[QuizImage.tsx]"]
end

subgraph group_accounts["Accounts and persistence"]
  node_login["Login and registration<br/>[LoginPage.tsx]"]
  node_php_login["Login endpoint<br/>[login.php]"]
  node_php_register["Registration endpoint<br/>[register.php]"]
  node_google_login["Google login endpoint<br/>[google_login.php]"]
  node_user_update["User update endpoint<br/>[update_user.php]"]
  node_theme_update["Theme update endpoint<br/>[update_theme.php]"]
  node_token_verify["Token verification<br/>[verify_token.php]"]
  node_db[("MySQL connection<br/>[db.php]")]
end

subgraph group_themes["Themes and store"]
  node_store["Theme store<br/>[StorePage.tsx]"]
  node_theme_context["Theme state<br/>[ThemeContext.tsx]"]
  node_theme_config["Theme catalog<br/>[themeConfig.ts]"]
end

node_browser(("Player browser"))
node_quizapi{{"Quiz API"}}
node_local_storage[("Browser storage")]

node_browser -->|"opens"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_gameplay
node_app -->|"routes to"| node_store
node_home -->|"requests quiz"| node_quizgen
node_gameplay -->|"requests quiz"| node_quizgen
node_quizgen -->|"fetches puzzle"| node_quizapi
node_home -->|"renders puzzle"| node_quizimage
node_gameplay -->|"renders puzzle"| node_quizimage
node_login -->|"posts credentials"| node_php_login
node_login -->|"posts registration"| node_php_register
node_login -.->|"uses Google sign-in"| node_google_login
node_php_login -->|"uses connection"| node_db
node_php_register -->|"uses connection"| node_db
node_google_login -->|"uses connection"| node_db
node_user_update -->|"uses connection"| node_db
node_theme_update -->|"uses connection"| node_db
node_token_verify -->|"uses connection"| node_db
node_store -->|"syncs user"| node_user_update
node_store -->|"saves selection"| node_theme_update
node_store -->|"applies theme"| node_theme_context
node_store -->|"reads catalog"| node_theme_config
node_theme_context -->|"loads defaults"| node_theme_config
node_theme_context -->|"persists selection"| node_local_storage
node_login -->|"stores session"| node_local_storage
node_store -->|"updates user"| node_local_storage

click node_app "https://github.com/arhamifham/banamatics/blob/master/src/App.tsx"
click node_home "https://github.com/arhamifham/banamatics/blob/master/src/components/HomePage.tsx"
click node_gameplay "https://github.com/arhamifham/banamatics/blob/master/src/components/GamePage.tsx"
click node_quizgen "https://github.com/arhamifham/banamatics/blob/master/src/components/utils/quizGenerator.ts"
click node_quizimage "https://github.com/arhamifham/banamatics/blob/master/src/components/QuizImage.tsx"
click node_login "https://github.com/arhamifham/banamatics/blob/master/src/components/LoginPage.tsx"
click node_php_login "https://github.com/arhamifham/banamatics/blob/master/backend/login.php"
click node_php_register "https://github.com/arhamifham/banamatics/blob/master/backend/register.php"
click node_google_login "https://github.com/arhamifham/banamatics/blob/master/backend/google_login.php"
click node_user_update "https://github.com/arhamifham/banamatics/blob/master/backend/update_user.php"
click node_theme_update "https://github.com/arhamifham/banamatics/blob/master/backend/update_theme.php"
click node_token_verify "https://github.com/arhamifham/banamatics/blob/master/backend/verify_token.php"
click node_db "https://github.com/arhamifham/banamatics/blob/master/backend/db.php"
click node_store "https://github.com/arhamifham/banamatics/blob/master/src/components/StorePage.tsx"
click node_theme_context "https://github.com/arhamifham/banamatics/blob/master/src/components/ThemeContext.tsx"
click node_theme_config "https://github.com/arhamifham/banamatics/blob/master/src/components/themeConfig.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_app,node_browser toneBlue
class node_home,node_gameplay,node_quizgen,node_quizimage,node_local_storage toneAmber
class node_login,node_php_login,node_php_register,node_google_login,node_user_update,node_theme_update,node_token_verify,node_db,node_quizapi toneMint
class node_store,node_theme_context,node_theme_config toneRose
```

## Components

### Web application

- [Route application](https://github.com/arhamifham/banamatics/blob/master/src/App.tsx): `src/App.tsx`

### Quiz gameplay

- [Trial quiz](https://github.com/arhamifham/banamatics/blob/master/src/components/HomePage.tsx): `src/components/HomePage.tsx`
- [Full game](https://github.com/arhamifham/banamatics/blob/master/src/components/GamePage.tsx): `src/components/GamePage.tsx`
- [Quiz generator](https://github.com/arhamifham/banamatics/blob/master/src/components/utils/quizGenerator.ts): `src/components/utils/quizGenerator.ts`
- [Quiz image](https://github.com/arhamifham/banamatics/blob/master/src/components/QuizImage.tsx): `src/components/QuizImage.tsx`

### Accounts and persistence

- [Login and registration](https://github.com/arhamifham/banamatics/blob/master/src/components/LoginPage.tsx): `src/components/LoginPage.tsx`
- [Login endpoint](https://github.com/arhamifham/banamatics/blob/master/backend/login.php): `backend/login.php`
- [Registration endpoint](https://github.com/arhamifham/banamatics/blob/master/backend/register.php): `backend/register.php`
- [Google login endpoint](https://github.com/arhamifham/banamatics/blob/master/backend/google_login.php): `backend/google_login.php`
- [User update endpoint](https://github.com/arhamifham/banamatics/blob/master/backend/update_user.php): `backend/update_user.php`
- [Theme update endpoint](https://github.com/arhamifham/banamatics/blob/master/backend/update_theme.php): `backend/update_theme.php`
- [Token verification](https://github.com/arhamifham/banamatics/blob/master/backend/verify_token.php): `backend/verify_token.php`
- [MySQL connection](https://github.com/arhamifham/banamatics/blob/master/backend/db.php): `backend/db.php`

### Themes and store

- [Theme store](https://github.com/arhamifham/banamatics/blob/master/src/components/StorePage.tsx): `src/components/StorePage.tsx`
- [Theme state](https://github.com/arhamifham/banamatics/blob/master/src/components/ThemeContext.tsx): `src/components/ThemeContext.tsx`
- [Theme catalog](https://github.com/arhamifham/banamatics/blob/master/src/components/themeConfig.ts): `src/components/themeConfig.ts`

### Other components

- **Player browser**
- **Quiz API**
- **Browser storage**

## Connections

- Player browser → Route application: opens
- Route application → Trial quiz: routes to (evidence: `src/App.tsx`)
- Route application → Login and registration: routes to (evidence: `src/App.tsx`)
- Route application → Full game: routes to (evidence: `src/App.tsx`)
- Route application → Theme store: routes to (evidence: `src/App.tsx`)
- Trial quiz → Quiz generator: requests quiz (evidence: `src/components/HomePage.tsx`)
- Full game → Quiz generator: requests quiz (evidence: `src/components/GamePage.tsx`)
- Quiz generator → Quiz API: fetches puzzle (evidence: `src/components/utils/quizGenerator.ts`)
- Trial quiz → Quiz image: renders puzzle (evidence: `src/components/HomePage.tsx`)
- Full game → Quiz image: renders puzzle (evidence: `src/components/GamePage.tsx`)
- Login and registration → Login endpoint: posts credentials (evidence: `src/components/LoginPage.tsx`)
- Login and registration → Registration endpoint: posts registration (evidence: `src/components/LoginPage.tsx`)
- Login and registration → Google login endpoint: uses Google sign-in
- Login endpoint → MySQL connection: uses connection (evidence: `backend/login.php`)
- Registration endpoint → MySQL connection: uses connection (evidence: `backend/register.php`)
- Google login endpoint → MySQL connection: uses connection (evidence: `backend/google_login.php`)
- User update endpoint → MySQL connection: uses connection (evidence: `backend/update_user.php`)
- Theme update endpoint → MySQL connection: uses connection (evidence: `backend/update_theme.php`)
- Token verification → MySQL connection: uses connection (evidence: `backend/verify_token.php`)
- Theme store → User update endpoint: syncs user (evidence: `src/components/StorePage.tsx`)
- Theme store → Theme update endpoint: saves selection (evidence: `src/components/StorePage.tsx`)
- Theme store → Theme state: applies theme (evidence: `src/components/StorePage.tsx`)
- Theme store → Theme catalog: reads catalog (evidence: `src/components/StorePage.tsx`)
- Theme state → Theme catalog: loads defaults (evidence: `src/components/ThemeContext.tsx`)
- Theme state → Browser storage: persists selection (evidence: `src/components/ThemeContext.tsx`)
- Login and registration → Browser storage: stores session (evidence: `src/components/LoginPage.tsx`)
- Theme store → Browser storage: updates user (evidence: `src/components/StorePage.tsx`)
