# saigontechnology/rn-base-project-expo architecture

> Architecture diagram of the GitHub repository saigontechnology/rn-base-project-expo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saigontechnology/rn-base-project-expo
- Repository: https://github.com/saigontechnology/rn-base-project-expo

## Overview

##### Project type and purpose
- This is a full-featured Expo React Native mobile-app template.
- Purpose: Provide a boilerplate for building cross-platform iOS/Android apps with built-in state management (Redux Toolkit + Saga), networking (axios), persistence (AsyncStorage), localization (i18n-js), theming, navigation and CI/CD (Expo, Fastlane, GitHub/Azure/Bitbucket pipelines).

##### File structure
- Top-level folders:
- app/ (Next-style layout & routes for Expo Router)
- src/ (core React Native code: assets, components, screens, services, stores, themes, utilities)
- scripts/ (build, deploy, env tasks)
- docs/, .github/, pipelines (CI/CD configs)
- Key patterns:
- “app/” for entry-point and routing (Expo Router).
- “src/components” for reusable UI.
- “src/screens” for feature screens grouped by domain (auth, home).
- “src/services” for API/networking layer.
- “src/stores” for Redux Toolkit slices, sagas, selectors.
- Theming under “src/themes”.
- Utilities & custom hooks.

##### README for insights
- Tech stack: Expo SDK, React Native, Redux Toolkit, Redux Saga, axios, Async-Storage, i18n-js, Jest, Husky
- CI/CD: fastlane, Expo builds, GitHub/Azure/Bitbucket pipelines
- Features: multi-env, in-app debug menu, debug scripts

##### Main components & interactions
a. Components
- Mobile Device (Expo Go / custom client)
- Expo Runtime & Router
- UI Layer
- Screens (AuthFlow, HomeFlow)
- Reusable Components
- Theming & Localization
- State Management
- Redux Store (Toolkit slices)
- Redux Saga (side-effects)
- Services Layer
- HTTP Client (axios)
- API modules
- Networking wrapper
- AsyncStorage persistence
- Configuration & Environment
- .env variables
- app.config.ts (Expo config)
- CI/CD & Deployment
- Scripts (build-app.sh, upload-app.sh)
- Fastlane
- GitHub/Azure/Bitbucket pipelines
b. Relationships & Data Flows
1. User taps UI → Action dispatched to Redux Store
2. Saga intercepts action → calls Services (axios → remote API)
3. Service returns data → Saga dispatches success/failure actions
4. Reducers update Store → UI subscribed via selectors re-renders
5. Persistence: certain state written/read from AsyncStorage
6. Navigation: Expo Router transitions between Screens
8. CI/CD pipelines trigger scripts → build via Expo / fastlane → deploy to stores
c. Architectural patterns & principles
- Modular folder structure by concern (UI, state, services, assets)
- Unidirectional data flow (Redux + Saga)
- Separation of concerns: UI vs business logic vs networking vs persistence
- Configuration-driven (multiple envs via .env & eas.json)
d. Key technologies/frameworks
- Expo SDK & Router
- React Native & React
- Redux Toolkit & Redux Saga
- axios & AsyncStorage
- i18n-js
- Fastlane, GitHub Actions, Azure Pipelines, Bitbucket Pipelines

##### Elements
- UI → Store → Saga → API → Saga → Store → UI
- Store ↔ AsyncStorage (persistence)
- CI/CD pipeline → build scripts → Expo / Fastlane → App Store / Play Store
- Blue rectangles for UI components
- Green circles for state (Store, Sagas)
- Purple hexagons for CI/CD elements

##### Final advice
- Cross-cutting concerns (themes, localization, env config).
- Both runtime data flows (user actions, API calls) and deployment flows (build → deploy).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile App Container
    subgraph "Mobile App"
        direction TB
        %% Expo Runtime & Router
        Router["Expo Runtime & Router"]:::runtime
        %% UI Layer
        subgraph "UI Layer"
            direction TB
            AuthFlow["AuthFlow Screens"]:::ui
            HomeFlow["HomeFlow Screens"]:::ui
            CoreScreens["Core Screens"]:::ui
            Components["Reusable Components"]:::ui
            Themes["Theming & Localization"]:::ui
        end
        %% State Management
        subgraph "State Management"
            direction TB
            Store["Redux Store"]:::state
            Sagas["Redux Saga"]:::state
        end
        %% Services Layer
        subgraph "Services Layer"
            direction TB
            HTTP["axios HTTP Client"]:::infra
            Wrapper["Networking Wrapper"]:::infra
            API["API Modules"]:::infra
        end
        %% Persistence & Config
        Storage["AsyncStorage Persistence"]:::infra
        Config["Configuration & Environment"]:::config
    end

    %% External Services & CI/CD
    ExternalAPI["Remote API"]:::external
    CI["CI/CD Pipeline"]:::cicd
    Scripts["Build/Deploy Scripts"]:::cicd
    Fastlane["Fastlane"]:::cicd
    Stores["App Store / Play Store"]:::external

    %% Runtime & Navigation
    Router -->|"renders"| AuthFlow
    Router -->|"renders"| HomeFlow
    Router -->|"renders"| CoreScreens

    %% UI to State
    AuthFlow -->|"dispatch action"| Store
    HomeFlow -->|"dispatch action"| Store
    CoreScreens -->|"dispatch action"| Store
    Components -->|"uses"| Themes

    %% State to Service
    Store -->|"trigger saga"| Sagas
    Sagas -->|"call HTTP client"| HTTP
    HTTP -->|"network request"| ExternalAPI
    ExternalAPI -->|"response"| Sagas
    Sagas -->|"dispatch result"| Store
    Store -->|"update UI"| AuthFlow
    Store -->|"update UI"| HomeFlow
    Store -->|"update UI"| CoreScreens

    %% Persistence
    Store <-->|"persist state"| Storage

    %% Configuration
    Config -->|"env vars"| Router
    Config -->|"env vars"| HTTP
    Config -->|"env vars"| Store

    %% CI/CD flow
    CI -->|"invoke"| Scripts
    Scripts -->|"build via Expo / fastlane"| Fastlane
    Fastlane -->|"deploy"| Stores

    %% Click Events
    click Router "https://github.com/saigontechnology/rn-base-project-expo/tree/main/app/"
    click AuthFlow "https://github.com/saigontechnology/rn-base-project-expo/tree/main/src/screens/auth"
    click HomeFlow "https://github.com/saigontechnology/rn-base-project-expo/tree/main/src/screens/home"
    click CoreScreens "https://github.com/saigontechnology/rn-base-project-expo/tree/main/src/screens"
    click Components "https://github.com/saigontechnology/rn-base-project-expo/tree/main/src/components/"
    click Themes "https://github.com/saigontechnology/rn-base-project-expo/tree/main/src/themes/"
    click Store "https://github.com/saigontechnology/rn-base-project-expo/blob/main/src/stores/store.ts"
    click Sagas "https://github.com/saigontechnology/rn-base-project-expo/tree/main/src/stores/saga/"
    click HTTP "https://github.com/saigontechnology/rn-base-project-expo/blob/main/src/services/networking/axios.ts"
    click Wrapper "https://github.com/saigontechnology/rn-base-project-expo/blob/main/src/services/networking/index.ts"
    click API "https://github.com/saigontechnology/rn-base-project-expo/blob/main/src/services/api/api.ts"
    click Storage "https://github.com/saigontechnology/rn-base-project-expo/blob/main/src/utilities/storage.ts"
    click Config "https://github.com/saigontechnology/rn-base-project-expo/blob/main/app.config.ts"
    click Scripts "https://github.com/saigontechnology/rn-base-project-expo/tree/main/scripts/"
    click Fastlane "https://github.com/saigontechnology/rn-base-project-expo/tree/main/fastlane/"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef state fill:#90EE90,stroke:#333,stroke-width:1px
    classDef infra fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef config fill:#EEE8AA,stroke:#333,stroke-width:1px
    classDef cicd fill:#D8BFD8,stroke:#333,stroke-width:1px
    classDef runtime fill:#87CEEB,stroke:#333,stroke-width:1px
```
