# wataru-maeda/react-native-boilerplate architecture

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

- Interactive diagram: https://gitdiagram.com/wataru-maeda/react-native-boilerplate
- Repository: https://github.com/wataru-maeda/react-native-boilerplate

## Overview

##### Main Components
- Mobile/Web UI Layer:
- Screens and navigation hierarchy using Expo Router (note the file-based routing in the “app” and “pages” directories).
- Drawer navigation, tabs, stacks: show “Home”, “Profile”, and their nested screens (e.g., details, index, _layout files).
- Core Components/Modules:
- Global State Management: Highlight the Redux Toolkit slice(s) located in “slices” and their integration via the provider in “providers”. Emphasize how the Redux store (configured in “utils/store.ts”) feeds into the application.
- Theme Management: Include the “theme” directory and related hooks (e.g., “hooks/useColorScheme.ts”) for light/dark theming.
- Service Layer: Represent backend interaction and service logic from the “services” directory (e.g., user.service.ts). Even if these are minimal here, they’re meant to provide a gateway for external API calls.
- Component Library: Group reusable UI components (found under “components”), including common elements (Button, Image, BottomSheet, etc.) and layouts (NavigationHeader components and drawer/bottom sheet contents).
- Environment & Build Configurations:
- Environment variables and configurations (.env files, app.config.ts, app.json, and utils/config.ts) – these setup the app for both development and production environments.
- CI/CD and Testing: Illustrate how GitHub workflows (in .github/workflows), husky pre-commit hooks, ESLint, Prettier, and Jest tests integrate into the development lifecycle.

##### Relationships and Interactions
- Data flow from the UI layer (screens) that use the Redux store and components to manage state and maintain consistency across screens.
- Theme management hook and asset configuration to the UI components to reflect the dynamic theme support.
- That the service layer (e.g., “user.service.ts”) interacts with external APIs or backend systems, feeding data into the Redux store or directly into screens.
- Optionally, add the CI/CD and testing pipeline as an external but integral component that continuously validates the code quality and deployment readiness.

##### Architectural Patterns and Important Design Principles
- File-Based Routing: Emphasize how screens are organized by directory structure, corresponding to navigation stacks, tabs, and drawers.
- Separation of Concerns: Separate UI elements, state management, theming, and services into distinct modules.
- Reusability: Demonstrate how components are modular and reusable (grouping by “components/elements” and “components/layouts”).
- Environment-specific Configuration: Capturing dev vs. prod variables and secure handling of secrets.
- CI/CD: Automated testing, linting, and preview deployments are part of the development cycle.

##### Additional Notes
- At the top: Configuration and build environments (e.g., Environment Variables, CI/CD workflows).
- In the mid-layer: Core application modules (Navigation, State Management, Theme Management, and Service Layer).
- At the bottom: Detailed UI Components (reusable UI elements and layouts).
- Annotations or notes that mention key technologies and frameworks:
- Expo, React Native, Redux Toolkit, Expo Router, Jest, ESLint, Prettier.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Top Layer: Configuration & CI/CD
    subgraph "Configuration & CI/CD"
        ENV["Environment Config"]:::config
        CI["CI/CD & Testing"]:::configExtra

        ENV1[".env.dev.example"]:::file
        ENV2[".env.prod.example"]:::file
        CONFIG1["app.config.ts"]:::file
        CONFIG2["app.json"]:::file
        CONFIG3["utils/config.ts"]:::file

        CI_WORKFLOWS[".github/workflows"]:::file
        ESLINT[".eslintrc.js/.eslintignore"]:::file
        PRETTIER[".prettierrc/.prettierignore"]:::file
        HUSKY[".husky/pre-commit"]:::file
        JEST["jest.config.js"]:::file

        ENV --> ENV1
        ENV --> ENV2
        ENV --> CONFIG1
        ENV --> CONFIG2
        ENV --> CONFIG3
        ENV --- CI
        CI --> CI_WORKFLOWS
        CI --> ESLINT
        CI --> PRETTIER
        CI --> HUSKY
        CI --> JEST
    end

    %% Mid Layer: Core Modules
    subgraph "Core Modules"
        NAV["Expo Router/Navigation"]:::ui
        REDUX_PROVIDER["Redux Provider"]:::redux
        REDUX_STORE["Redux Store (Global State)"]:::store
        THEME["Theme Manager"]:::theme
        SERVICE["Service Layer"]:::service

        %% Redux Slices subgraph inside Core Modules
        subgraph "Redux Slices"
            SLICE1["app.slice.ts"]:::file
            SLICE2["index.ts"]:::file
        end

        %% Theme Files & Hooks subgraph
        subgraph "Theme Files & Hooks"
            THEME_FILES["Theme Files"]:::theme
            THEME_HOOK["useColorScheme Hook"]:::theme
            COLORS["colors.ts"]:::file
            FONTS["fonts.ts"]:::file
            IMAGES["images.ts"]:::file
            THEME_INDEX["index.ts (theme)"]:::file
            THEME_FILES --> COLORS
            THEME_FILES --> FONTS
            THEME_FILES --> IMAGES
            THEME_FILES --> THEME_INDEX
        end

        %% Connections within Core Modules
        REDUX_PROVIDER -->|"wraps"| REDUX_STORE
        REDUX_STORE -->|"integrates"| SLICE1
        REDUX_STORE -->|"integrates"| SLICE2
        SERVICE -->|"feeds data to"| REDUX_STORE
        SERVICE -->|"direct API calls to"| UI_SCREENS
        ENV ---|"configures"| SERVICE
        NAV -->|"routes to"| UI_SCREENS
        REDUX_PROVIDER -->|"provides state to"| UI_SCREENS
        THEME -->|"applies theme to"| UI_SCREENS
    end

    %% Bottom Layer: UI Layer
    subgraph "UI Layer"
        UI_SCREENS["UI Screens (File-based Routing)"]:::uiScreens

        %% File-based routing details
        subgraph "File-based Routing (Screens)"
            APP_ROUTING["app directory"]:::file
            PAGES_ROUTING["pages directory"]:::file
        end

        %% Component Library Details
        COMPONENT_LIB["Component Library"]:::uiScreens
        subgraph "Component Library Details"
            COMPONENT_ELEMENTS["components/elements"]:::file
            COMPONENT_LAYOUTS["components/layouts"]:::file
        end

        UI_SCREENS -->|"derived from"| APP_ROUTING
        UI_SCREENS -->|"derived from"| PAGES_ROUTING
        UI_SCREENS -->|"uses"| COMPONENT_LIB
        COMPONENT_LIB --> COMPONENT_ELEMENTS
        COMPONENT_LIB --> COMPONENT_LAYOUTS
    end

    %% Click Events
    click APP_ROUTING "https://github.com/wataru-maeda/react-native-boilerplate/tree/main/app/(main)/(tabs)/home"
    click PAGES_ROUTING "https://github.com/wataru-maeda/react-native-boilerplate/tree/main/pages/home"
    click SLICE1 "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/slices/app.slice.ts"
    click SLICE2 "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/slices/index.ts"
    click REDUX_PROVIDER "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/providers/Provider.tsx"
    click REDUX_PROVIDER "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/providers/index.ts"
    click REDUX_STORE "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/utils/store.ts"
    click COLORS "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/theme/colors.ts"
    click FONTS "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/theme/fonts.ts"
    click IMAGES "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/theme/images.ts"
    click THEME_INDEX "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/theme/index.ts"
    click THEME_HOOK "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/hooks/useColorScheme.ts"
    click SERVICE "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/services/user.service.ts"
    click SERVICE "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/services/index.ts"
    click COMPONENT_ELEMENTS "https://github.com/wataru-maeda/react-native-boilerplate/tree/main/components/elements"
    click COMPONENT_LAYOUTS "https://github.com/wataru-maeda/react-native-boilerplate/tree/main/components/layouts"
    click ENV1 "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/.env.dev.example"
    click ENV2 "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/.env.prod.example"
    click CONFIG1 "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/app.config.ts"
    click CONFIG2 "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/app.json"
    click CONFIG3 "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/utils/config.ts"
    click CI_WORKFLOWS "https://github.com/wataru-maeda/react-native-boilerplate/tree/main/.github/workflows"
    click ESLINT "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/.eslintrc.js"
    click PRETTIER "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/.prettierrc"
    click HUSKY "https://github.com/wataru-maeda/react-native-boilerplate/tree/main/.husky/pre-commit"
    click JEST "https://github.com/wataru-maeda/react-native-boilerplate/blob/main/jest.config.js"

    %% Styling Classes
    classDef ui fill:#DDEEFF,stroke:#0077CC,stroke-width:2px;
    classDef redux fill:#FFEEDD,stroke:#CC7700,stroke-width:2px;
    classDef store fill:#FFDDDD,stroke:#CC0000,stroke-width:2px;
    classDef theme fill:#DDFFDD,stroke:#00AA00,stroke-width:2px;
    classDef service fill:#FFEECC,stroke:#FF6600,stroke-width:2px;
    classDef config fill:#EEEEEE,stroke:#999999,stroke-width:2px;
    classDef configExtra fill:#CCCCCC,stroke:#666666,stroke-width:2px;
    classDef file fill:#FFFFFF,stroke:#000000,stroke-width:1px;
    classDef uiScreens fill:#CDDDEE,stroke:#003366,stroke-width:2px;
```
