How fc-arena-h2h/tournament.com works
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: App.tsx App Orchestration · useAuth.ts Authentication State · main.tsx React Bootstrap · shardManager.ts Tournament Shard Routing
Components 16
Application Experience
- React Bootstrap
src/main.tsx - App Orchestration
src/App.tsx - Navigation Shell
src/components/layout/Shell.tsx - Tournament Entry
- Tournament Operations
- Auth and Profile
Identity and Tournament Data
- Authentication State
src/hooks/useAuth.ts - Firebase Client
src/lib/firebase.ts - User Profile Persistence
src/lib/userDbManager.ts - Tournament Shard Routing
src/lib/shardManager.ts - Local Database Support
src/lib/localDbManager.ts
Match and Support Services
- Screenshot Verification
src/utils/matchOcrVerifier.ts - Notification Management
src/lib/notifications.ts - Support Assistant
src/components/ui/SupportAI.tsx - Support Knowledge Engine
src/lib/supportKnowledgeEngine.ts
Other components
- End User
Connections 14
- End User → React Bootstrap: Opens client · Inferred; not shown in the code that was read.
- React Bootstrap → App Orchestration: Mounts app
src/main.tsx - App Orchestration → Tournament Entry: Renders screens
src/App.tsx - App Orchestration → Tournament Operations: Renders screens
src/App.tsx - App Orchestration → Auth and Profile: Renders screens
src/App.tsx - Authentication State → Firebase Client: Observes auth
src/hooks/useAuth.ts - Authentication State → User Profile Persistence: Loads and subscribes
src/hooks/useAuth.ts - Tournament Operations → Tournament Shard Routing: Uses shard data
- Tournament Shard Routing → Local Database Support: Registers routes
src/lib/shardManager.ts - Tournament Operations → Screenshot Verification: Verifies screenshots
- App Orchestration → Notification Management: Handles notifications
src/App.tsx - Notification Management → Firebase Client: Reads and writes
src/lib/notifications.ts - Navigation Shell → Support Assistant: Renders assistant
src/components/layout/Shell.tsx - Support Assistant → Support Knowledge Engine: Uses knowledge
src/components/ui/SupportAI.tsx