# saheeranas/react-native-redux-boilerplate architecture

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

- Interactive diagram: https://gitdiagram.com/saheeranas/react-native-redux-boilerplate
- Repository: https://github.com/saheeranas/react-native-redux-boilerplate

## Overview

##### Main Components

- User Interface (UI) Layer:
- Represents the mobile app front end built using React Native.
- Contains screens (app/screens, app/screens/auth) and UI components (app/components) such as Button, Card, Form, Layout, and Text.

- State Management Layer:
- Redux store integrated with Redux Toolkit (located in app/store, including tasksSlice.ts and userSlice.ts).
- Offline storage is handled via Redux Persist.

- Services or API Layer:
- Includes modules for API communication and logic (app/services folder with api-client.ts, auth.ts, news.ts, statusHandler.ts).
- Handles external network calls and secure token handling (app/utils/token.ts, app/utils/keyChain.ts).

- Navigation and Routing:
- Navigation is set up using React Navigation found in app/routes/RootNavigation.tsx and probably spread within the screens to manage transitions.

- Theming and Styling:
- Theme configuration and management through app/theme with files like theme.ts and useTheme.tsx.

- Configuration and Environment:
- Environment variables are handled using .env templates and set up tools (e.g., .env.template, .env.production.template).
- Other configuration and linting rules are provided (eslintrc.js, prettier configuration).

- Platform-specific Code:
- Native layer implementations for Android (android folder) and iOS (ios folder) determine native dependencies, builds, and assets.

##### Relationships and Interactions

- The UI layer (React Native components and screens) interacts with the Redux store to fetch and update application state.
- The Redux store works in tandem with Redux Persist to ensure offline compatibility.
- UI components trigger actions defined by Redux Toolkit, which then might call the services layer to perform API requests.
- The services layer manages asynchronous operations (using Axios and other libraries) and passes data back into the state management layer.
- Navigation components (RootNavigation.tsx and related screens) coordinate the flow between different UI screens, reacting to state changes as needed.
- The theming module provides consistency in UI styling and supports dark mode based on user or system preferences.

##### Important Architectural Patterns and Principles

- Separation of Concerns: UI, state management, services, and navigation are clearly separated into distinct folders.
- Modular Design: Each feature (authentication, CRUD operations, theming) is encapsulated in its own module for easier maintenance and scalability.
- Use of Cross-Platform Abstractions: Core business logic is written in TypeScript and managed through React Native, allowing for consistent behavior on both Android and iOS.
- Integration of Middleware/Dependencies: The use of Redux Toolkit and React Navigation shows a preference for standard, community-supported frameworks.
- Environment-Based Configuration: The use of different .env templates indicates attention to configuration management across different build targets (development vs. production).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Configuration & Tools"
        config1["Environment Templates"]:::config
        config2["Lint & Format Tools"]:::config
    end

    subgraph "React Native Frontend (UI Layer)"
        UI1["Screens"]:::ui
        UI2["Auth Screens"]:::ui
        UI3["UI Components"]:::ui
        Nav["Navigation"]:::nav
        Theme["Theming"]:::theme
    end

    subgraph "State Management"
        Store["Redux Store"]:::store
    end

    subgraph "API/Services"
        API["API Services"]:::services
        TokenUtil["Token Utilities"]:::services
    end

    subgraph "Platform Specific"
        Android["Android"]:::native
        iOS["iOS"]:::native
    end

    %% Connections
    config1 -->|"feeds"| UI1
    config1 -->|"feeds"| Store
    config2 -->|"feeds"| Store

    UI1 -->|"triggers action"| Store
    UI2 -->|"triggers action"| Store
    UI3 -->|"updates UI"| Store

    UI1 -->|"navigates via"| Nav
    UI2 -->|"navigates via"| Nav

    UI1 -->|"styled by"| Theme
    UI2 -->|"styled by"| Theme
    UI3 -->|"styled by"| Theme

    Store -->|"calls API"| API
    API -->|"updates state"| Store
    Store -->|"calls secure utils"| TokenUtil

    UI1 -->|"renders on"| Android
    UI1 -->|"renders on"| iOS
    UI2 -->|"renders on"| Android
    UI2 -->|"renders on"| iOS
    UI3 -->|"renders on"| Android
    UI3 -->|"renders on"| iOS

    %% Click Events
    click UI1 "https://github.com/saheeranas/react-native-redux-boilerplate/tree/main/app/screens"
    click UI2 "https://github.com/saheeranas/react-native-redux-boilerplate/tree/main/app/screens/auth"
    click UI3 "https://github.com/saheeranas/react-native-redux-boilerplate/tree/main/app/components"

    click Store "https://github.com/saheeranas/react-native-redux-boilerplate/tree/main/app/store"

    click API "https://github.com/saheeranas/react-native-redux-boilerplate/tree/main/app/services"
    click TokenUtil "https://github.com/saheeranas/react-native-redux-boilerplate/tree/main/app/utils"

    click Nav "https://github.com/saheeranas/react-native-redux-boilerplate/blob/main/app/routes/RootNavigation.tsx"

    click Theme "https://github.com/saheeranas/react-native-redux-boilerplate/tree/main/app/theme"

    click config1 "https://github.com/saheeranas/react-native-redux-boilerplate/blob/main/.env.development.template"
    click config1 "https://github.com/saheeranas/react-native-redux-boilerplate/blob/main/.env.production.template"
    click config1 "https://github.com/saheeranas/react-native-redux-boilerplate/blob/main/.env.template"

    click config2 "https://github.com/saheeranas/react-native-redux-boilerplate/blob/main/.eslintrc.js"
    click config2 "https://github.com/saheeranas/react-native-redux-boilerplate/blob/main/.prettierrc.js"
    click config2 "https://github.com/saheeranas/react-native-redux-boilerplate/blob/main/react-native.config.js"
    click config2 "https://github.com/saheeranas/react-native-redux-boilerplate/blob/main/babel.config.js"

    click Android "https://github.com/saheeranas/react-native-redux-boilerplate/tree/main/android"
    click iOS "https://github.com/saheeranas/react-native-redux-boilerplate/tree/main/ios"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef store fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef services fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef nav fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef theme fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef config fill:#FAD7A0,stroke:#B9770E,stroke-width:2px;
    classDef native fill:#E6B0AA,stroke:#943126,stroke-width:2px;
```
