# stratezone/mobile architecture

> Architecture diagram of the GitHub repository stratezone/mobile, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stratezone/mobile
- Repository: https://github.com/stratezone/mobile

## Overview

##### Project type and purpose
- This is a mobile-only, full-stack client application built with Expo (React Native) using file-based routing.
- Its purpose is to let users browse and book “tables” (game appointments), manage profiles (including payments and history), participate in a community forum, exchange vouchers, view tournaments, and receive notifications.

##### Key architectural elements revealed by the file tree
- Top-level “app” folder uses Expo’s file-based router for navigation. It contains a tab navigator (“app/(tab)”), with subfolders for each tab:
- appointment, auth, clause, community, product, profile, tournament, notification
- Reusable UI is in “components/…” (buttons, cards, dialogs, bottom sheets, etc.).
- Global state is handled via React Context providers (“context/auth-context.tsx”, “context/select-table.tsx”).
- API requests are encapsulated in “helpers/api-requests.ts”.
- Configuration values are in “config/index.ts”; type definitions under “constants/types”.
- Assets (fonts, images) are under “assets/…”.
- Native projects for iOS/Android are managed by Expo (ios/…, metro.config.js, app.json, etc.).

##### Main components
A. Mobile App (Expo JS Runtime)
- File-based Router → Tab Navigator
- Tab screens: AppointmentTab, AuthTab, ClauseTab, CommunityTab, ProductTab, ProfileTab, TournamentTab, NotificationTab
- Shared UI Component Library (components/)
- State Management Layer (AuthContext, SelectTableContext)
- API Service Layer (helpers/api-requests.ts + config)
- Style System (nativewind/tailwind.config.js + global.css)
- Asset Store (fonts, images)
- Third-party SDKs: Expo modules (Notifications, Secure Storage, etc., if used)

B. External Systems
- Backend API Service (REST or GraphQL)
- Authentication Provider (OAuth / custom JWT)
- Payment Gateway (in-app purchase / external payment API)
- Push Notification Service (Expo Push, FCM / APNs)

##### Relationships & interactions
- Router directs user events to Screen Components.
- Screen Components call into Context or directly invoke API Service to fetch/post data.
- Context providers maintain auth state, selected table, and expose that to UI.
- API Service uses config base URL to communicate with the backend (Authentication, Table booking, Community threads, Transactions, etc.).
- Backend returns JSON, which the service layer normalizes (using TypeScript types) and passes back to contexts or screens.
- Asset Store provides static resources for UI.
- Expo runtime bundles all JS/TS and serves it to the device via Metro bundler, enabling hot reload in development.

##### Architectural patterns & design principles
- Separation of concerns:
- Navigation (file-based router)
- Presentation (screens + reusable components)
- Stateful logic (React Context)
- Data access (API layer)
- File-based routing enforces a 1:1 mapping of files to navigation routes.
- Type safety through TypeScript types in “constants/types”.
- Theming/styling via Tailwind (nativewind) and global style guide (UIStyleGuide).
- Modular assets: grouping of images and fonts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile App JS Bundle"
        subgraph "Navigation Layer"
            Router["File-based Router\n(app/(tab))"]:::nav
            subgraph "Tab Navigator"
                APTab["AppointmentTab Screens"]:::ui
                AuthTab["AuthTab Screens"]:::ui
                ClauseTab["ClauseTab Screen"]:::ui
                CommTab["CommunityTab Screens"]:::ui
                ProdTab["ProductTab Screen"]:::ui
                ProfileTab["ProfileTab Screens"]:::ui
                TourTab["TournamentTab Screen"]:::ui
                NotifTab["NotificationTab Screens"]:::ui
            end
            TabNav[/"Tab Navigator"/]:::nav
            Router --> TabNav
            TabNav --> APTab
            TabNav --> AuthTab
            TabNav --> ClauseTab
            TabNav --> CommTab
            TabNav --> ProdTab
            TabNav --> ProfileTab
            TabNav --> TourTab
            TabNav --> NotifTab
            NotFound["Not Found & Global Layout\n(app/+not-found.tsx,\napp/_layout.tsx,\napp/splash-screen.tsx)"]:::nav
            Router --> NotFound
        end

        subgraph "UI Layer"
            Components["Shared UI Component Library\n(components/)"]:::ui
        end

        subgraph "State Management Layer"
            AuthCTX["AuthContext\n(context/auth-context.tsx)"]:::state
            SelectTableCTX["SelectTableContext\n(context/select-table.tsx)"]:::state
        end

        subgraph "API Service Layer"
            APIService["API Service\n(helpers/api-requests.ts)"]:::api
            Config["Configuration Values\n(config/index.ts)"]:::config
            Types["Type Definitions\n(constants/types/)"]:::config
        end

        subgraph "Styling System"
            TailwindCfg["tailwind.config.js"]:::styling
            NativeWindTypes["nativewind-env.d.ts"]:::styling
            GlobalStyles["global.css"]:::styling
            UIStyleGuide["UIStyleGuide Component\n(components/UIStyleGuide.tsx)"]:::styling
        end

        subgraph "Asset Store"
            Fonts["Fonts\n(assets/fonts)"]:::assets
            Images["Images\n(assets/images)"]:::assets
        end

        subgraph "Expo Native & Bundler"
            ExpoConfig["Expo Configs\n(app.json,\nmetro.config.js,\nbabel.config.js)"]:::config
            iOSProj["iOS Project\n(ios/)"]:::config
        end
    end

    subgraph "External Services"
        Backend["Backend API Service"]:::external
        AuthProvider["Authentication Provider"]:::external
        PaymentGW["Payment Gateway"]:::external
        PushSvc["Push Notification Service"]:::external
    end

    %% Relationships
    APTab -->|"uses"| Components
    AuthTab -->|"uses"| Components
    ClauseTab -->|"uses"| Components
    CommTab -->|"uses"| Components
    ProdTab -->|"uses"| Components
    ProfileTab -->|"uses"| Components
    TourTab -->|"uses"| Components
    NotifTab -->|"uses"| Components

    AuthCTX -->|"provides auth state"| AuthTab
    SelectTableCTX -->|"provides table state"| APTab

    APTab -->|"fetches/post data via"| APIService
    AuthTab -->|"fetches/post data via"| APIService
    ClauseTab -->|"fetches/post data via"| APIService
    CommTab -->|"fetches/post data via"| APIService
    ProdTab -->|"fetches/post data via"| APIService
    ProfileTab -->|"fetches/post data via"| APIService
    TourTab -->|"fetches/post data via"| APIService
    NotifTab -->|"fetches/post data via"| APIService

    APIService -->|"reads baseURL"| Config
    APIService -->|"uses types"| Types
    APIService -->|"calls"| Backend

    Components -->|"loads assets"| Fonts
    Components -->|"loads assets"| Images
    Components -->|"uses style guide"| UIStyleGuide

    APTab -->|"styled by"| TailwindCfg
    AuthTab -->|"styled by"| TailwindCfg

    ExpoConfig -->|"bundles via Metro"| Router
    iOSProj -->|"run on device"| Router

    PushSvc -->|"delivers via Expo"| NotifTab

    %% Click Events
    click Router "https://github.com/stratezone/mobile/tree/master/app/(tab)"
    click APTab "https://github.com/stratezone/mobile/tree/master/app/(tab)/(appointment)"
    click AuthTab "https://github.com/stratezone/mobile/tree/master/app/(tab)/(auth)"
    click ClauseTab "https://github.com/stratezone/mobile/tree/master/app/(tab)/(clause)"
    click CommTab "https://github.com/stratezone/mobile/tree/master/app/(tab)/(community)"
    click ProdTab "https://github.com/stratezone/mobile/tree/master/app/(tab)/(product)"
    click ProfileTab "https://github.com/stratezone/mobile/tree/master/app/(tab)/(profile)"
    click TourTab "https://github.com/stratezone/mobile/tree/master/app/(tab)/(tournament)"
    click NotifTab "https://github.com/stratezone/mobile/tree/master/app/(tab)/notification"
    click NotFound "https://github.com/stratezone/mobile/blob/master/app/+not-found.tsx"
    click Components "https://github.com/stratezone/mobile/tree/master/components/"
    click AuthCTX "https://github.com/stratezone/mobile/blob/master/context/auth-context.tsx"
    click SelectTableCTX "https://github.com/stratezone/mobile/blob/master/context/select-table.tsx"
    click APIService "https://github.com/stratezone/mobile/blob/master/helpers/api-requests.ts"
    click Config "https://github.com/stratezone/mobile/blob/master/config/index.ts"
    click Types "https://github.com/stratezone/mobile/tree/master/constants/types/"
    click Fonts "https://github.com/stratezone/mobile/tree/master/assets/fonts"
    click Images "https://github.com/stratezone/mobile/tree/master/assets/images"
    click TailwindCfg "https://github.com/stratezone/mobile/blob/master/tailwind.config.js"
    click NativeWindTypes "https://github.com/stratezone/mobile/blob/master/nativewind-env.d.ts"
    click GlobalStyles "https://github.com/stratezone/mobile/blob/master/global.css"
    click UIStyleGuide "https://github.com/stratezone/mobile/blob/master/components/UIStyleGuide.tsx"
    click ExpoConfig "https://github.com/stratezone/mobile/blob/master/app.json"
    click iOSProj "https://github.com/stratezone/mobile/tree/master/ios/"

    %% Styles
    classDef ui fill:#bbdefb,stroke:#1e88e5,color:#0d47a1
    classDef nav fill:#b3e5fc,stroke:#0288d1,color:#01579b
    classDef state fill:#c8e6c9,stroke:#43a047,color:#1b5e20
    classDef api fill:#ffe0b2,stroke:#fb8c00,color:#e65100
    classDef external fill:#eeeeee,stroke:#9e9e9e,color:#424242
    classDef assets fill:#f3e5f5,stroke:#8e24aa,color:#4a148c
    classDef styling fill:#fff9c4,stroke:#fbc02d,color:#f57f17
    classDef config fill:#d7ccc8,stroke:#795548,color:#3e2723
```
