# dinesh-m-4103/brain-game-application- architecture

> Architecture diagram of the GitHub repository dinesh-m-4103/brain-game-application-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dinesh-m-4103/brain-game-application-
- Repository: https://github.com/dinesh-m-4103/brain-game-application-

## Overview

#### 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`](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/App.tsx) (App composition), [`src/screens/AnalyticsScreen.tsx`](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/screens/AnalyticsScreen.tsx) (Analytics), [`index.js`](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/index.js) (JavaScript entry), [`src/hooks/useUserData.ts`](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/hooks/useUserData.ts) (User data hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_native["Native hosts"]
  node_android_host["Android host<br/>native bootstrap<br/>[MainActivity.kt]"]
  node_ios_host["iOS host<br/>native bootstrap<br/>[AppDelegate.swift]"]
end

subgraph group_app["React Native app"]
  node_js_entry["JavaScript entry<br/>entry point<br/>[index.js]"]
  node_app_root["App composition<br/>root UI<br/>[App.tsx]"]
  node_auth_context["Auth context<br/>identity state<br/>[AuthContext.tsx]"]
  node_theme_context["Theme context<br/>presentation state<br/>[ThemeContext.tsx]"]
  node_product_screens["Product screens<br/>screen area"]
  node_dashboard["Dashboard<br/>screen"]
  node_game_screens["Training games<br/>game screens"]
  node_analytics["Analytics<br/>screen"]
  node_subscription["Subscription<br/>screen"]
  node_user_hook["User data hook<br/>UI data access<br/>[useUserData.ts]"]
end

subgraph group_backend["Backend and integrations"]
  node_user_service["User service<br/>persistence boundary<br/>[userService.ts]"]
  node_firebase[("Firebase<br/>backend integration<br/>[firebase.ts]")]
  node_paypal_config["PayPal config<br/>payment boundary<br/>[paypal.ts]"]
end

subgraph group_reporting["Reporting"]
  node_report_screen["Report UI<br/>screen<br/>[ReportScreen.tsx]"]
  node_pdf_service["PDF export service<br/>export boundary<br/>[pdfService.ts]"]
  node_pdf_generators["PDF generators<br/>document generation<br/>[pdfGenerator.ts]"]
end

node_android_host -->|"boots React Native"| node_js_entry
node_ios_host -->|"boots React Native"| node_js_entry
node_js_entry -->|"registers"| node_app_root
node_app_root -->|"provides"| node_auth_context
node_app_root -->|"provides"| node_theme_context
node_app_root -->|"composes"| node_product_screens
node_product_screens -->|"includes"| node_dashboard
node_product_screens -->|"includes"| node_game_screens
node_product_screens -->|"includes"| node_analytics
node_product_screens -->|"includes"| node_subscription
node_auth_context -->|"authenticates via"| node_firebase
node_user_hook -->|"reads user data"| node_user_service
node_user_service -->|"persists to"| node_firebase
node_game_screens -->|"saves scores"| node_user_service
node_dashboard -->|"consumes performance"| node_user_hook
node_analytics -->|"consumes performance"| node_user_hook
node_subscription -->|"uses"| node_paypal_config
node_report_screen -->|"exports through"| node_pdf_service
node_pdf_service -->|"generates with"| node_pdf_generators
node_analytics -->|"feeds report flow"| node_report_screen

click node_js_entry "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/index.js"
click node_app_root "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/App.tsx"
click node_auth_context "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/contexts/AuthContext.tsx"
click node_theme_context "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/contexts/ThemeContext.tsx"
click node_dashboard "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/screens/DashboardScreen.tsx"
click node_game_screens "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/screens/games/MemoryMatchScreen.tsx"
click node_analytics "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/screens/AnalyticsScreen.tsx"
click node_subscription "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/screens/SubscriptionScreen.tsx"
click node_user_hook "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/hooks/useUserData.ts"
click node_user_service "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/services/userService.ts"
click node_firebase "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/config/firebase.ts"
click node_paypal_config "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/config/paypal.ts"
click node_report_screen "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/screens/ReportScreen.tsx"
click node_pdf_service "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/services/pdfService.ts"
click node_pdf_generators "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/utils/pdfGenerator.ts"
click node_android_host "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/android/app/src/main/java/com/braintrainingapp/MainActivity.kt"
click node_ios_host "https://github.com/dinesh-m-4103/brain-game-application-/blob/main/ios/BrainTrainingApp/AppDelegate.swift"

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_android_host,node_ios_host toneBlue
class node_js_entry,node_app_root,node_auth_context,node_theme_context,node_product_screens,node_dashboard,node_game_screens,node_analytics,node_subscription,node_user_hook toneAmber
class node_user_service,node_firebase,node_paypal_config toneMint
class node_report_screen,node_pdf_service,node_pdf_generators toneRose
```

## Components

### Native hosts

- [Android host](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/android/app/src/main/java/com/braintrainingapp/MainActivity.kt): native bootstrap · `android/app/src/main/java/com/braintrainingapp/MainActivity.kt`
- [iOS host](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/ios/BrainTrainingApp/AppDelegate.swift): native bootstrap · `ios/BrainTrainingApp/AppDelegate.swift`

### React Native app

- [JavaScript entry](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/index.js): entry point · `index.js`
- [App composition](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/App.tsx): root UI · Connects global providers and application screens. · `App.tsx`
- [Auth context](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/contexts/AuthContext.tsx): identity state · `src/contexts/AuthContext.tsx`
- [Theme context](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/contexts/ThemeContext.tsx): presentation state · `src/contexts/ThemeContext.tsx`
- **Product screens**: screen area · Dashboard, profile, challenge, progress, and other product views.
- [Dashboard](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/screens/DashboardScreen.tsx): screen · `src/screens/DashboardScreen.tsx`
- [Training games](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/screens/games/MemoryMatchScreen.tsx): game screens · Local game execution produces performance results. · `src/screens/games/MemoryMatchScreen.tsx`
- [Analytics](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/screens/AnalyticsScreen.tsx): screen · `src/screens/AnalyticsScreen.tsx`
- [Subscription](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/screens/SubscriptionScreen.tsx): screen · `src/screens/SubscriptionScreen.tsx`
- [User data hook](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/hooks/useUserData.ts): UI data access · `src/hooks/useUserData.ts`

### Backend and integrations

- [User service](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/services/userService.ts): persistence boundary · Isolates user and performance reads and writes. · `src/services/userService.ts`
- [Firebase](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/config/firebase.ts): backend integration · `src/config/firebase.ts`
- [PayPal config](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/config/paypal.ts): payment boundary · `src/config/paypal.ts`

### Reporting

- [Report UI](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/screens/ReportScreen.tsx): screen · `src/screens/ReportScreen.tsx`
- [PDF export service](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/services/pdfService.ts): export boundary · `src/services/pdfService.ts`
- [PDF generators](https://github.com/dinesh-m-4103/brain-game-application-/blob/main/src/utils/pdfGenerator.ts): document generation · Native/document-library generation implementations. · `src/utils/pdfGenerator.ts`

## Connections

- 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
