How dinesh-m-4103/brain-game-application- works
Purpose and entry points
This is a React Native mobile brain-training application for Android and iOS. The JavaScript entry point is index.js, which registers the root UI in App.tsx. Native hosts bootstrap React Native through android/app/src/main/java/com/braintrainingapp/MainActivity.kt and ios/BrainTrainingApp/AppDelegate.swift.
Application composition and navigation
App.tsx is the top-level composition boundary, expected to select and connect authentication, theming, and application screens. Screen-level product areas include dashboard, games, analytics, reports, profile, subscription, and challenge/progress views under src/screens/, notably src/screens/DashboardScreen.tsx, src/screens/AnalyticsScreen.tsx, and src/screens/SubscriptionScreen.tsx.
Identity, user state, and persistence
Authentication is centralized through src/contexts/AuthContext.tsx; consumer screens obtain current-user state through that context and src/hooks/useUserData.ts. User-domain reads/writes are isolated in src/services/userService.ts, creating a useful boundary between UI/game scoring and backend persistence. Firebase initialization belongs in src/config/firebase.ts; Android service credentials are packaged at android/app/google-services.json.
Theme and shared UI state
src/contexts/ThemeContext.tsx supplies application-wide presentation state independently of authentication and feature screens. This allows game and reporting flows to share visual policy without coupling to user-data operations. Reusable per-game performance presentation is represented by src/components/IndividualGamePerformance.tsx.
Game execution and performance flow
The core training loop is implemented as individual game screens: src/screens/games/MemoryMatchScreen.tsx, src/screens/games/ReactionTimeScreen.tsx, src/screens/games/SequenceRecallScreen.tsx, plus sorting and word-recall variants. A game runs locally in React Native, produces a score/performance result, and should pass persisted user data through the user-service boundary. Dashboard, weekly-progress, and analytics/report screens consume that accumulated performance data rather than owning game mechanics.
Reporting and PDF export
Report presentation is separated from PDF generation. src/screens/ReportScreen.tsx initiates report-oriented UI; src/services/pdfService.ts is the integration-facing export service; src/utils/pdfGenerator.ts and src/utils/simplePdfGenerator.ts contain generation implementations. This boundary isolates native/document-library concerns from analytics and user-data screens.
Payments and external dependencies
Subscription UI is in src/screens/SubscriptionScreen.tsx, while PayPal-specific configuration is isolated at src/config/paypal.ts. Firebase is the material backend integration for authentication/user data; PayPal is the payment configuration boundary. The app runs on the React Native JavaScript runtime via Metro during development, compiled into Android Gradle and iOS Xcode/CocoaPods native applications (android/app/build.gradle, ios/Podfile).
Main entry points: App.tsx App composition · AnalyticsScreen.tsx Analytics · index.js JavaScript entry · useUserData.ts User data hook
Components 18
Native hosts
- Android host
android/app/src/main/java/com/braintrainingapp/MainActivity.kt - iOS host
ios/BrainTrainingApp/AppDelegate.swift
React Native app
- JavaScript entry
index.js - App composition · Connects global providers and application screens.
App.tsx - Auth context
src/contexts/AuthContext.tsx - Theme context
src/contexts/ThemeContext.tsx - Product screens · Dashboard, profile, challenge, progress, and other product views.
- Dashboard
src/screens/DashboardScreen.tsx - Training games · Local game execution produces performance results.
src/screens/games/MemoryMatchScreen.tsx - Analytics
src/screens/AnalyticsScreen.tsx - Subscription
src/screens/SubscriptionScreen.tsx - User data hook
src/hooks/useUserData.ts
Backend and integrations
- User service · Isolates user and performance reads and writes.
src/services/userService.ts - Firebase
src/config/firebase.ts - PayPal config
src/config/paypal.ts
Reporting
- Report UI
src/screens/ReportScreen.tsx - PDF export service
src/services/pdfService.ts - PDF generators · Native/document-library generation implementations.
src/utils/pdfGenerator.ts
Connections 20
- Android host → JavaScript entry: boots React Native
- iOS host → JavaScript entry: boots React Native
- JavaScript entry → App composition: registers
- App composition → Auth context: provides
- App composition → Theme context: provides
- App composition → Product screens: composes
- Product screens → Dashboard: includes
- Product screens → Training games: includes
- Product screens → Analytics: includes
- Product screens → Subscription: includes
- Auth context → Firebase: authenticates via
- User data hook → User service: reads user data
- User service → Firebase: persists to
- Training games → User service: saves scores
- Dashboard → User data hook: consumes performance
- Analytics → User data hook: consumes performance
- Subscription → PayPal config: uses
- Report UI → PDF export service: exports through
- PDF export service → PDF generators: generates with
- Analytics → Report UI: feeds report flow