# fc-arena-h2h/tournament.com architecture

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

- Interactive diagram: https://gitdiagram.com/fc-arena-h2h/tournament.com
- Repository: https://github.com/fc-arena-h2h/tournament.com

## Overview

FC Arena is a browser/mobile football tournament and match-management app: players and publishers sign in, find or create tournaments, register and report match results, and receive notifications. The main workflow starts when an end user opens the app; the React entry point mounts the application, which selects screens and coordinates authentication, tournament data, and notifications. Firebase provides authentication and cloud data, while local caches and shard routing support offline access and tournament storage across databases.

#### Application and user experience
- **React bootstrap** — `src/main.tsx`: mounts the app and brings in internationalization and Firebase messaging.
- **App orchestration and navigation** — `src/App.tsx`: selects the active screen, handles profile setup and update gates, and processes notification-driven tournament navigation.
- **Navigation shell** — `src/components/layout/Shell.tsx`: provides the application frame, navigation, announcement display, and access to support.
- **Tournament discovery and creation** — `src/pages/Arena.tsx`: presents the arena and tournament entry points; `src/pages/TournamentList.tsx`: lists tournaments; `src/pages/CreateTournament.tsx`: supports tournament creation.
- **Tournament operations** — `src/pages/ArenaDetail.tsx`: handles tournament detail and participation; `src/pages/Matches.tsx`: presents matches and supports result reporting and disputes.
- **Administration** — `src/pages/AdminDashboard.tsx`: provides administrative controls over users, tournaments, matches, and notifications.
- **Authentication and profile screens** — `src/pages/Auth.tsx`: handles sign-in; `src/components/auth/SetupProfile.tsx`: collects profile details; `src/pages/Profile.tsx`: presents and manages player profile information.
- **Shared UI** — `src/components/ui/Primitives.tsx`: supplies reusable animated controls and cards; `src/components/ui/GameLoader.tsx`: provides the app’s loading screen. Other listed UI components include support, notifications, and update overlays.

#### Identity and tournament data
- **Authentication state** — `src/hooks/useAuth.ts`: observes Firebase sign-in state and subscribes to the user’s profile, using cached data for an immediate UI response.
- **Firebase client** — `src/lib/firebase.ts`: initializes Firebase Auth, Firestore, and Realtime Database; configures Firestore persistence and a connection check.
- **User profile persistence** — `src/lib/userDbManager.ts`: reads, writes, and caches user profiles across player, publisher, and master database contexts.
- **Tournament shard routing and queries** — `src/lib/shardManager.ts`: creates Firestore instances for tournament shards, resolves tournament ownership, and queries tournament, registration, and match data across shards.
- **Local database support** — `src/lib/localDbManager.ts`: maintains local routing information and a stale-while-revalidate cache for tournament-related data.
- **Tournament persistence helpers** — `src/lib/localTournaments.ts`: separate local tournament-management module; its specific runtime interactions are not established by the sampled excerpts.
- **Football catalogs** — `src/lib/fcClubs.ts`: provides club data and role-aware lookup, using league data from `src/lib/fcLeagues.ts`.

#### Match verification, notifications, and support
- **Screenshot verification** — `src/utils/matchOcrVerifier.ts`: extracts text from match screenshots and evaluates it against expected player names; the match screen invokes both functions during reporting.
- **Notification management** — `src/lib/notifications.ts`: creates, reads, and subscribes to notification records across notification databases, with a master-database fallback for writes.
- **Push messaging** — `src/lib/fcm.ts`: contains Firebase Cloud Messaging support and references Firebase, user profiles, and notification management.
- **Support assistant** — `src/components/ui/SupportAI.tsx`: implements the in-app support UI and uses `src/lib/supportKnowledgeEngine.ts` for its knowledge behavior.
- **Web push handlers** — `public/sw-push-handler.js`: contains a substantial push-handler script; its callers and runtime registration are not established by the supplied evidence.

#### Relationships
- **End user** -> **React bootstrap**: opens the client; evidence: none (inferred).
- **React bootstrap** -> **App orchestration and navigation**: mounts the app; evidence: `src/main.tsx`.
- **App orchestration and navigation** -> **Tournament discovery and creation**: renders arena, tournament-list, and creation screens; evidence: `src/App.tsx`.
- **App orchestration and navigation** -> **Tournament operations**: renders match and tournament-detail screens; evidence: `src/App.tsx`.
- **App orchestration and navigation** -> **Authentication and profile screens**: renders profile setup and profile screens; evidence: `src/App.tsx`.
- **Authentication state** -> **Firebase client**: observes Firebase Auth state; evidence: `src/hooks/useAuth.ts`.
- **Authentication state** -> **User profile persistence**: loads cached profiles and subscribes to profile updates; evidence: `src/hooks/useAuth.ts`.
- **Tournament operations** -> **Tournament shard routing and queries**: uses shard-aware tournament and match data; evidence: `src/pages/Matches.tsx`.
- **Tournament shard routing and queries** -> **Local database support**: registers tournament-to-shard routes; evidence: `src/lib/shardManager.ts`.
- **Tournament operations** -> **Screenshot verification**: extracts and evaluates screenshot text during match reporting; evidence: `src/pages/Matches.tsx`.
- **App orchestration and navigation** -> **Notification management**: marks notifications read and looks up tournaments named by notifications; evidence: `src/App.tsx`.
- **Notification management** -> **Firebase client**: performs notification document operations in Firestore; evidence: `src/lib/notifications.ts`.
- **Navigation shell** -> **Support assistant**: renders the support UI; evidence: `src/components/layout/Shell.tsx`.
- **Support assistant** -> **Support assistant knowledge engine**: uses the knowledge engine; evidence: `src/components/ui/SupportAI.tsx`.

#### Coverage limits
No README documentation was supplied. Several pages and data managers are represented only by import references, so their full behavior and call sequences cannot be verified. The server and service-worker runtime wiring, notification-triggered push delivery, and the precise role of the Android wrapper are not established; no definite relationships for them are asserted here.

Main entry points: [`src/App.tsx`](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/App.tsx) (App Orchestration), [`src/hooks/useAuth.ts`](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/hooks/useAuth.ts) (Authentication State), [`src/main.tsx`](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/main.tsx) (React Bootstrap), [`src/lib/shardManager.ts`](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/lib/shardManager.ts) (Tournament Shard Routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Application Experience"]
  node_react_bootstrap["React Bootstrap<br/>Entry point"]
  node_app_orchestration["App Orchestration<br/>[App.tsx]"]
  node_navigation_shell["Navigation Shell<br/>UI component"]
  node_tournament_entry["Tournament Entry<br/>Screens"]
  node_tournament_operations["Tournament Operations<br/>Screens"]
  node_auth_profile_screens["Auth and Profile<br/>Screens"]
end

subgraph group_identity_data["Identity and Tournament Data"]
  node_auth_state["Authentication State<br/>Hook"]
  node_firebase_client["Firebase Client<br/>[firebase.ts]"]
  node_user_profile_persistence["User Profile Persistence<br/>Data manager"]
  node_shard_routing["Tournament Shard Routing<br/>Data manager"]
  node_local_database_support["Local Database Support<br/>Cache and routing"]
end

subgraph group_match_support["Match and Support Services"]
  node_screenshot_verification["Screenshot Verification"]
  node_notification_management["Notification Management<br/>[notifications.ts]"]
  node_support_assistant["Support Assistant<br/>UI component"]
  node_support_knowledge_engine["Support Knowledge Engine<br/>Knowledge service"]
end

node_end_user(("End User<br/>External actor"))

node_end_user -.->|"Opens client"| node_react_bootstrap
node_react_bootstrap -->|"Mounts app"| node_app_orchestration
node_app_orchestration -->|"Renders screens"| node_tournament_entry
node_app_orchestration -->|"Renders screens"| node_tournament_operations
node_app_orchestration -->|"Renders screens"| node_auth_profile_screens
node_auth_state -->|"Observes auth"| node_firebase_client
node_auth_state -->|"Loads and subscribes"| node_user_profile_persistence
node_tournament_operations -->|"Uses shard data"| node_shard_routing
node_shard_routing -->|"Registers routes"| node_local_database_support
node_tournament_operations -->|"Verifies screenshots"| node_screenshot_verification
node_app_orchestration -->|"Handles notifications"| node_notification_management
node_notification_management -->|"Reads and writes"| node_firebase_client
node_navigation_shell -->|"Renders assistant"| node_support_assistant
node_support_assistant -->|"Uses knowledge"| node_support_knowledge_engine

click node_react_bootstrap "https://github.com/fc-arena-h2h/tournament.com/blob/main/src/main.tsx"
click node_app_orchestration "https://github.com/fc-arena-h2h/tournament.com/blob/main/src/App.tsx"
click node_navigation_shell "https://github.com/fc-arena-h2h/tournament.com/blob/main/src/components/layout/Shell.tsx"
click node_auth_state "https://github.com/fc-arena-h2h/tournament.com/blob/main/src/hooks/useAuth.ts"
click node_firebase_client "https://github.com/fc-arena-h2h/tournament.com/blob/main/src/lib/firebase.ts"
click node_user_profile_persistence "https://github.com/fc-arena-h2h/tournament.com/blob/main/src/lib/userDbManager.ts"
click node_shard_routing "https://github.com/fc-arena-h2h/tournament.com/blob/main/src/lib/shardManager.ts"
click node_local_database_support "https://github.com/fc-arena-h2h/tournament.com/blob/main/src/lib/localDbManager.ts"
click node_screenshot_verification "https://github.com/fc-arena-h2h/tournament.com/blob/main/src/utils/matchOcrVerifier.ts"
click node_notification_management "https://github.com/fc-arena-h2h/tournament.com/blob/main/src/lib/notifications.ts"
click node_support_assistant "https://github.com/fc-arena-h2h/tournament.com/blob/main/src/components/ui/SupportAI.tsx"
click node_support_knowledge_engine "https://github.com/fc-arena-h2h/tournament.com/blob/main/src/lib/supportKnowledgeEngine.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_react_bootstrap,node_app_orchestration,node_navigation_shell,node_tournament_entry,node_tournament_operations,node_auth_profile_screens,node_end_user toneBlue
class node_auth_state,node_firebase_client,node_user_profile_persistence,node_shard_routing,node_local_database_support toneAmber
class node_screenshot_verification,node_notification_management,node_support_assistant,node_support_knowledge_engine toneMint
```

## Components

### Application Experience

- [React Bootstrap](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/main.tsx): Entry point · `src/main.tsx`
- [App Orchestration](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/App.tsx): Application · `src/App.tsx`
- [Navigation Shell](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/components/layout/Shell.tsx): UI component · `src/components/layout/Shell.tsx`
- **Tournament Entry**: Screens
- **Tournament Operations**: Screens
- **Auth and Profile**: Screens

### Identity and Tournament Data

- [Authentication State](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/hooks/useAuth.ts): Hook · `src/hooks/useAuth.ts`
- [Firebase Client](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/lib/firebase.ts): Client · `src/lib/firebase.ts`
- [User Profile Persistence](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/lib/userDbManager.ts): Data manager · `src/lib/userDbManager.ts`
- [Tournament Shard Routing](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/lib/shardManager.ts): Data manager · `src/lib/shardManager.ts`
- [Local Database Support](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/lib/localDbManager.ts): Cache and routing · `src/lib/localDbManager.ts`

### Match and Support Services

- [Screenshot Verification](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/utils/matchOcrVerifier.ts): Utility · `src/utils/matchOcrVerifier.ts`
- [Notification Management](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/lib/notifications.ts): Service · `src/lib/notifications.ts`
- [Support Assistant](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/components/ui/SupportAI.tsx): UI component · `src/components/ui/SupportAI.tsx`
- [Support Knowledge Engine](https://github.com/fc-arena-h2h/tournament.com/blob/main/src/lib/supportKnowledgeEngine.ts): Knowledge service · `src/lib/supportKnowledgeEngine.ts`

### Other components

- **End User**: External actor

## Connections

- End User → React Bootstrap: Opens client · Inferred; not shown in the code that was read.
- React Bootstrap → App Orchestration: Mounts app (evidence: `src/main.tsx`)
- App Orchestration → Tournament Entry: Renders screens (evidence: `src/App.tsx`)
- App Orchestration → Tournament Operations: Renders screens (evidence: `src/App.tsx`)
- App Orchestration → Auth and Profile: Renders screens (evidence: `src/App.tsx`)
- Authentication State → Firebase Client: Observes auth (evidence: `src/hooks/useAuth.ts`)
- Authentication State → User Profile Persistence: Loads and subscribes (evidence: `src/hooks/useAuth.ts`)
- Tournament Operations → Tournament Shard Routing: Uses shard data
- Tournament Shard Routing → Local Database Support: Registers routes (evidence: `src/lib/shardManager.ts`)
- Tournament Operations → Screenshot Verification: Verifies screenshots
- App Orchestration → Notification Management: Handles notifications (evidence: `src/App.tsx`)
- Notification Management → Firebase Client: Reads and writes (evidence: `src/lib/notifications.ts`)
- Navigation Shell → Support Assistant: Renders assistant (evidence: `src/components/layout/Shell.tsx`)
- Support Assistant → Support Knowledge Engine: Uses knowledge (evidence: `src/components/ui/SupportAI.tsx`)
