# kimei-global-co/react-native-boilerplate architecture

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

- Interactive diagram: https://gitdiagram.com/kimei-global-co/react-native-boilerplate
- Repository: https://github.com/kimei-global-co/react-native-boilerplate

## Overview

##### Project type and purpose
- This is a React Native boilerplate template (mobile full-stack starter kit) designed to accelerate cross-platform iOS/Android development.
- It uses TypeScript, Expo, Redux Toolkit, React Navigation, Ky for API, Jest for testing, and code-quality tools (ESLint, Prettier, Husky).

##### File structure
- Top-level:
- template/ – the actual boilerplate code
- template/src/
– App.tsx (entry point)
– assets/ (images, fonts)
- README-recommended src layout:
- api/ – HTTP clients, endpoints
- components/ – reusable UI pieces
- navigation/ – React Navigation stacks/tabs
- screens/ – screen containers
- store/ – Redux slices, store config
- theme/ – theming, styling utilities
- utils/ – helper functions

##### Main components and their relationships
a. Mobile App (React Native):
– Entry point: App.tsx
– UI layer: Screens & Components
– Navigation layer: React Navigation (Stack, Tab)
– Styling/Theming: theme module
b. State Management:
– Redux Toolkit store & slices
– UI dispatches actions → store updates → UI selects state
c. API Service:
– Ky‐based HTTP client
– Services under api/ call external REST endpoints
– API calls triggered by Redux async thunks or direct service calls
d. Authentication Flow:
– Login Screen → dispatch auth action → API service → store token → navigation guard
e. Assets:
– Images, fonts loaded via asset module
f. Build & Tooling:
– Metro bundler (dev server)
– Bun (package manager and scripts)
– Expo CLI (for bundling, deployments)
g. CI/CD & Code Quality:
– GitHub Actions (pipeline for lint, test, build)
– Husky + commitlint + ESLint + Prettier (pre-commit & commit-msg hooks)

##### External services
– Expo servers (over-the-air updates)
– Third-party REST APIs (your backend)
– Apple/Google build services

##### Architectural patterns & design principles
– Separation of concerns: UI / Navigation / State / API / Theme / Utils
– Unidirectional data flow: React → Actions → Reducers → State → React
– Modular folder structure for scalability
– CI/CD “shift left” for quality

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD & Quality Pipeline
    subgraph "CI/CD & Quality"
        direction TB
        GitHubActions["GitHub Actions"]:::external
        HuskyHooks["Husky Hooks"]:::tool
        CommitLint["Commitlint"]:::tool
        GitHubActions -->|runs| HuskyHooks
        GitHubActions -->|runs| CommitLint
    end

    %% Project Configuration & Documentation
    subgraph "Project Config & Docs"
        direction TB
        TSConfig["tsconfig.json"]:::config
        BabelConfig["babel.config.js"]:::config
        PackageJSON["package.json"]:::config
        GitIgnore[".gitignore"]:::config
        README["README.md"]:::config
        CLIIndex["index.ts"]:::config
        TSConfig --> BabelConfig
        BabelConfig --> PackageJSON
        PackageJSON --> GitIgnore
        README --> CLIIndex
    end

    %% Mobile App Container
    subgraph "Mobile App (iOS/Android)"
        direction TB
        AppEntry["App.tsx"]:::internal
        subgraph "Navigation Layer"
            direction TB
            Navigation["React Navigation"]:::internal
        end
        subgraph "UI Layer"
            direction TB
            Screens["Screens"]:::internal
            Components["Components"]:::internal
        end
        subgraph "Business Logic"
            direction TB
            Store["Redux Store"]:::internal
            APIClient["API Client (Ky)"]:::internal
        end
        subgraph "Theme & Assets"
            direction TB
            Theme["Theme & Styling"]:::green
            Assets["Assets (images, fonts)"]:::green
        end

        AppEntry --> Navigation
        Navigation --> Screens
        Screens --> Components
        Screens -->|dispatches| Store
        Store -->|selects| Components
        Store -->|uses thunks| APIClient
        APIClient -->|fetches| Store
        Theme --> Components
        Assets --> Components
    end

    %% External Services
    subgraph "External Services"
        direction TB
        BackendAPI["Backend REST API"]:::external
        ExpoOTA["Expo OTA Updates"]:::external
        BuildServices["Apple/Google Build Services"]:::external
        APIClient -->|calls| BackendAPI
        ExpoCLI -->|publishes| ExpoOTA
        ExpoCLI -->|submits| BuildServices
    end

    %% Toolchain
    subgraph "Toolchain" 
        direction TB
        Metro["Metro Bundler"]:::tool
        Bun["Bun Scripts"]:::tool
        ExpoCLI["Expo CLI"]:::tool
        Metro -->|bundles| AppEntry
        Bun -->|runs scripts| AppEntry
        ExpoCLI -->|builds| AppEntry
    end

    %% Click Events for Component Mapping
    click AppEntry "https://github.com/kimei-global-co/react-native-boilerplate/blob/main/template/src/App.tsx"
    click Assets "https://github.com/kimei-global-co/react-native-boilerplate/tree/main/template/src/assets"
    click ExpoConfig "https://github.com/kimei-global-co/react-native-boilerplate/blob/main/template/app.json"
    click Metro "https://github.com/kimei-global-co/react-native-boilerplate/blob/main/template/metro.config.js"
    click Bun "https://github.com/kimei-global-co/react-native-boilerplate/blob/main/template/bun.lockb"
    click TSConfig "https://github.com/kimei-global-co/react-native-boilerplate/blob/main/template/tsconfig.json"
    click BabelConfig "https://github.com/kimei-global-co/react-native-boilerplate/blob/main/template/babel.config.js"
    click PackageJSON "https://github.com/kimei-global-co/react-native-boilerplate/blob/main/template/package.json"
    click GitHubActions "https://github.com/kimei-global-co/react-native-boilerplate/blob/main/template/.github/pull_request_template.md"
    click HuskyHooks "https://github.com/kimei-global-co/react-native-boilerplate/tree/main/template/.husky/"
    click CommitLint "https://github.com/kimei-global-co/react-native-boilerplate/blob/main/template/commitlint.config.js"
    click GitIgnore "https://github.com/kimei-global-co/react-native-boilerplate/blob/main/template/.gitignore"
    click README "https://github.com/kimei-global-co/react-native-boilerplate/blob/main/README.md"
    click CLIIndex "https://github.com/kimei-global-co/react-native-boilerplate/blob/main/template/index.ts"

    %% Styles
    classDef internal fill:#cce5ff,stroke:#0366d6,color:#000;
    classDef green fill:#d4edda,stroke:#155724,color:#000;
    classDef external fill:#ffe5b4,stroke:#c46210,color:#000,shape:cylinder;
    classDef tool fill:#f8f9fa,stroke:#6c757d,color:#000,stroke-dasharray: 5 5;
    classDef config fill:#f0f0f0,stroke:#343a40,color:#000;
```
