# safa-kaware/apex-arena architecture

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

- Interactive diagram: https://gitdiagram.com/safa-kaware/apex-arena
- Repository: https://github.com/safa-kaware/apex-arena

## Overview

APEX ARENA is a sports-club management web application. Members sign in with Google, book courts or trainer sessions, and manage reservations; prospective members submit a membership application. The React app sends these requests through its API client to Express routes, which execute SQL through a MySQL-or-SQLite adapter. The README also documents trainer discovery and facility information, represented by the trainer directory and landing-page components. The source excerpts show this core flow; the documented database choice is implemented in the sampled adapter. Firebase authentication is visible, but server-side session guards are not shown in the excerpts.

Main entry points: [`src/App.tsx`](https://github.com/safa-kaware/apex-arena/blob/main/src/App.tsx) (App and auth context), [`src/api.ts`](https://github.com/safa-kaware/apex-arena/blob/main/src/api.ts) (Frontend API client), [`src/components/BookingSystem.tsx`](https://github.com/safa-kaware/apex-arena/blob/main/src/components/BookingSystem.tsx) (Court and trainer booking), [`src/firebase.ts`](https://github.com/safa-kaware/apex-arena/blob/main/src/firebase.ts) (Firebase authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Member experience"]
  node_app["App and auth context<br/>[App.tsx]"]
  node_navbar["Navigation and sign-in<br/>[Navbar.tsx]"]
  node_hero["Club introduction<br/>[Hero.tsx]"]
  node_booking["Court and trainer booking<br/>[BookingSystem.tsx]"]
  node_schedule["Booking schedule<br/>[MyBookings.tsx]"]
  node_benefits["Facility benefits<br/>[Benefits.tsx]"]
  node_trainers["Trainer directory<br/>[MembersGrid.tsx]"]
  node_trainerdata["Trainer profiles<br/>[trainers.ts]"]
  node_footer["Site footer<br/>[Footer.tsx]"]
end

subgraph group_membership["Membership features"]
  node_membershipcta["Membership application<br/>[CTA.tsx]"]
end

subgraph group_backend["API and persistence"]
  node_clientapi["Frontend API client<br/>[api.ts]"]
  node_server["Express API routes<br/>[server.ts]"]
  node_dbadapter["Database adapter<br/>[db.ts]"]
  node_sqldb[("SQLite fallback<br/>[db.ts]")]
  node_mysqldb[("MySQL database")]
end

subgraph group_identity["Identity"]
  node_firebase["Firebase authentication<br/>[firebase.ts]"]
end

node_visitor(("Club visitor"))
node_google(("Google sign-in"))

node_visitor -->|"uses"| node_app
node_app -->|"renders"| node_navbar
node_app -->|"renders"| node_hero
node_app -->|"renders"| node_booking
node_app -->|"renders"| node_schedule
node_app -->|"renders"| node_benefits
node_app -->|"renders"| node_trainers
node_app -->|"renders"| node_membershipcta
node_app -->|"renders"| node_footer
node_app -->|"observes sign-in"| node_firebase
node_app -->|"syncs user"| node_clientapi
node_navbar -->|"signs in or out"| node_firebase
node_google -.->|"authenticates"| node_firebase
node_booking -->|"requests sign-in"| node_firebase
node_booking -->|"uses profiles"| node_trainerdata
node_trainers -->|"reads profiles"| node_trainerdata
node_booking -->|"creates booking"| node_clientapi
node_schedule -->|"loads and cancels"| node_clientapi
node_membershipcta -->|"submits application"| node_clientapi
node_clientapi -->|"sends API requests"| node_server
node_server -->|"executes SQL"| node_dbadapter
node_dbadapter -->|"selects fallback"| node_sqldb
node_dbadapter -->|"selects configured"| node_mysqldb

click node_app "https://github.com/safa-kaware/apex-arena/blob/main/src/App.tsx"
click node_navbar "https://github.com/safa-kaware/apex-arena/blob/main/src/components/Navbar.tsx"
click node_hero "https://github.com/safa-kaware/apex-arena/blob/main/src/components/Hero.tsx"
click node_booking "https://github.com/safa-kaware/apex-arena/blob/main/src/components/BookingSystem.tsx"
click node_schedule "https://github.com/safa-kaware/apex-arena/blob/main/src/components/MyBookings.tsx"
click node_benefits "https://github.com/safa-kaware/apex-arena/blob/main/src/components/Benefits.tsx"
click node_trainers "https://github.com/safa-kaware/apex-arena/blob/main/src/components/MembersGrid.tsx"
click node_trainerdata "https://github.com/safa-kaware/apex-arena/blob/main/src/constants/trainers.ts"
click node_membershipcta "https://github.com/safa-kaware/apex-arena/blob/main/src/components/CTA.tsx"
click node_footer "https://github.com/safa-kaware/apex-arena/blob/main/src/components/Footer.tsx"
click node_clientapi "https://github.com/safa-kaware/apex-arena/blob/main/src/api.ts"
click node_server "https://github.com/safa-kaware/apex-arena/blob/main/server.ts"
click node_dbadapter "https://github.com/safa-kaware/apex-arena/blob/main/src/db.ts"
click node_sqldb "https://github.com/safa-kaware/apex-arena/blob/main/src/db.ts"
click node_firebase "https://github.com/safa-kaware/apex-arena/blob/main/src/firebase.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_navbar,node_hero,node_booking,node_schedule,node_benefits,node_trainers,node_trainerdata,node_footer toneBlue
class node_membershipcta toneAmber
class node_clientapi,node_server,node_dbadapter,node_sqldb,node_mysqldb toneMint
class node_firebase toneRose
class node_visitor,node_google toneIndigo
```

## Components

### Member experience

- [App and auth context](https://github.com/safa-kaware/apex-arena/blob/main/src/App.tsx): `src/App.tsx`
- [Navigation and sign-in](https://github.com/safa-kaware/apex-arena/blob/main/src/components/Navbar.tsx): `src/components/Navbar.tsx`
- [Club introduction](https://github.com/safa-kaware/apex-arena/blob/main/src/components/Hero.tsx): `src/components/Hero.tsx`
- [Court and trainer booking](https://github.com/safa-kaware/apex-arena/blob/main/src/components/BookingSystem.tsx): `src/components/BookingSystem.tsx`
- [Booking schedule](https://github.com/safa-kaware/apex-arena/blob/main/src/components/MyBookings.tsx): `src/components/MyBookings.tsx`
- [Facility benefits](https://github.com/safa-kaware/apex-arena/blob/main/src/components/Benefits.tsx): `src/components/Benefits.tsx`
- [Trainer directory](https://github.com/safa-kaware/apex-arena/blob/main/src/components/MembersGrid.tsx): `src/components/MembersGrid.tsx`
- [Trainer profiles](https://github.com/safa-kaware/apex-arena/blob/main/src/constants/trainers.ts): `src/constants/trainers.ts`
- [Site footer](https://github.com/safa-kaware/apex-arena/blob/main/src/components/Footer.tsx): `src/components/Footer.tsx`

### Membership features

- [Membership application](https://github.com/safa-kaware/apex-arena/blob/main/src/components/CTA.tsx): `src/components/CTA.tsx`

### API and persistence

- [Frontend API client](https://github.com/safa-kaware/apex-arena/blob/main/src/api.ts): `src/api.ts`
- [Express API routes](https://github.com/safa-kaware/apex-arena/blob/main/server.ts): `server.ts`
- [Database adapter](https://github.com/safa-kaware/apex-arena/blob/main/src/db.ts): `src/db.ts`
- [SQLite fallback](https://github.com/safa-kaware/apex-arena/blob/main/src/db.ts): `src/db.ts`
- **MySQL database**

### Identity

- [Firebase authentication](https://github.com/safa-kaware/apex-arena/blob/main/src/firebase.ts): `src/firebase.ts`

### Other components

- **Club visitor**
- **Google sign-in**

## Connections

- Club visitor → App and auth context: uses
- App and auth context → Navigation and sign-in: renders (evidence: `src/App.tsx`)
- App and auth context → Club introduction: renders (evidence: `src/App.tsx`)
- App and auth context → Court and trainer booking: renders (evidence: `src/App.tsx`)
- App and auth context → Booking schedule: renders (evidence: `src/App.tsx`)
- App and auth context → Facility benefits: renders (evidence: `src/App.tsx`)
- App and auth context → Trainer directory: renders (evidence: `src/App.tsx`)
- App and auth context → Membership application: renders (evidence: `src/App.tsx`)
- App and auth context → Site footer: renders (evidence: `src/App.tsx`)
- App and auth context → Firebase authentication: observes sign-in (evidence: `src/App.tsx`)
- App and auth context → Frontend API client: syncs user (evidence: `src/App.tsx`)
- Navigation and sign-in → Firebase authentication: signs in or out (evidence: `src/components/Navbar.tsx`)
- Google sign-in → Firebase authentication: authenticates
- Court and trainer booking → Firebase authentication: requests sign-in (evidence: `src/components/BookingSystem.tsx`)
- Court and trainer booking → Trainer profiles: uses profiles (evidence: `src/components/BookingSystem.tsx`)
- Trainer directory → Trainer profiles: reads profiles (evidence: `src/constants/trainers.ts`)
- Court and trainer booking → Frontend API client: creates booking (evidence: `src/components/BookingSystem.tsx`)
- Booking schedule → Frontend API client: loads and cancels (evidence: `src/components/MyBookings.tsx`)
- Membership application → Frontend API client: submits application (evidence: `src/components/CTA.tsx`)
- Frontend API client → Express API routes: sends API requests (evidence: `src/api.ts`)
- Express API routes → Database adapter: executes SQL (evidence: `server.ts`)
- Database adapter → SQLite fallback: selects fallback (evidence: `src/db.ts`)
- Database adapter → MySQL database: selects configured (evidence: `src/db.ts`)
