# joinreinvest/reinvest-native architecture

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

- Interactive diagram: https://gitdiagram.com/joinreinvest/reinvest-native
- Repository: https://github.com/joinreinvest/reinvest-native

## Overview

Based on our analysis of the project’s file structure and README, we can see that this is a React Native mobile application that supports iOS and Android native builds. The project follows a “React Native” architectural pattern where most of the application’s code lives under the src folder (organized by assets, components, constants, navigation, screens, etc.) while platform-specific native code is maintained in the ios and android directories. Additionally, deployment, CI/CD configuration, and environment management are incorporated into the repository.

##### Main Components & Layers
– Assets: Images, fonts, videos (in assets and src/assets).
– Components: Reusable UI elements (all components in src/components). They follow patterns (like index.tsx, types.ts, styles.ts) which is a best practice.
– Screens: Various screens that the user navigates through (src/screens). Display these as individual modules or grouped by flows (for onboarding, dashboard, investing, etc.).
– Navigation: Navigators and routing between screens (src/navigation). Emphasize the separation between different navigators (e.g., BottomTabsNavigator, LogInNavigator, etc.)
– Services/Store/Utils: Show how business logic, state management (src/store) and utilities (src/utils) are separate, ensuring the app remains modular.

##### Native Integration
- iOS Folder: This contains Xcode project files, deployment scripts, and certificates alongside platform-specific resources like images and storyboards.
- Android Folder: Similar to iOS, show native configurations and gradle build scripts that support Android deployment. Mention the assets copied from the universal assets folder (like fonts under android/app/src/main/assets).

##### Deployment & Configuration
- Environment Management: Include the .env.example file and refer to how React-native-config is used for providing environment variables.

##### Relationships & Data Flow
- How the JavaScript/TypeScript code under src interacts with native code. For example, the entry point (index.js) loads App.tsx, from which navigation kicks in.
- Screens, components, and APIs (src/api) to show how data is fetched and managed (e.g., API hooks in src/api/hooks and services in src/services).
- Link any state management (src/store) with the UI components, depicting unidirectional data flow typical in React applications.

##### Architectural Patterns & Design Principles
- Modular Components: Point out the principle of “don’t use unnecessary indexes” and the guidelines for organizing components (separate files for component, types, styling).
- Clear Separation of Concerns: Differentiate between UI (components, screens), business logic (store, services, utils), and configuration (environment variables and platform-specific folders).
- Use of Path Aliases: Mention that the tsconfig.json and babel.config.js are structured to allow for easy path aliases, which helps to keep module imports clean.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Points
    subgraph "Entry Points"
        A1("Index.js"):::entry
        A2("App.tsx"):::entry
    end

    %% Mobile Application Frontend (src)
    subgraph "Mobile Application Frontend (src)"
        F1("Assets (src/assets)"):::frontend
        F1b("Fonts (assets/fonts)"):::frontend
        F2("Components (src/components)"):::frontend
        F4("Navigation (src/navigation)"):::frontend
        F3("Screens (src/screens)"):::frontend
        subgraph "Business Logic"
            BL1("Services (src/services)"):::business
            BL2("Store (src/store)"):::business
            BL3("Utils (src/utils)"):::business
        end
    end

    %% Native Integration
    subgraph "Native Integration"
        N1("iOS Native Code (ios)"):::native
        N2("Android Native Code (android)"):::native
    end

    %% Deployment & Configuration
    subgraph "Deployment & Config"
        D1("CI/CD Pipeline (.github/workflows)"):::deployment
        D2("Env Management (.env.example)"):::deployment
        D3("Babel Config (babel.config.js)"):::deployment
        D4("TS Config (tsconfig.json)"):::deployment
    end

    %% Connections
    A1 --> A2
    A2 --> F4
    F4 --> F3
    F3 -->|"callsBL"| BL1
    F2 -->|"usesBL"| BL1
    A2 -->|"integrates_with"| N1
    A2 -->|"integrates_with"| N2
    D1 -->|"triggers_build"| A2
    D2 --> A2
    D3 --> A2
    D4 --> A2

    %% Styles
    classDef entry fill:#ffe0e0,stroke:#b30000,stroke-width:2px;
    classDef frontend fill:#e0f7ff,stroke:#006699,stroke-width:2px;
    classDef business fill:#fff0e0,stroke:#cc6600,stroke-width:2px;
    classDef native fill:#e0ffe0,stroke:#339933,stroke-width:2px;
    classDef deployment fill:#f9e0ff,stroke:#993399,stroke-width:2px;

    %% Click Events
    click A1 "https://github.com/joinreinvest/reinvest-native/blob/development/index.js"
    click A2 "https://github.com/joinreinvest/reinvest-native/blob/development/src/App.tsx"
    click F1 "https://github.com/joinreinvest/reinvest-native/tree/development/src/assets"
    click F1b "https://github.com/joinreinvest/reinvest-native/tree/development/assets/fonts"
    click F2 "https://github.com/joinreinvest/reinvest-native/tree/development/src/components"
    click F3 "https://github.com/joinreinvest/reinvest-native/tree/development/src/screens"
    click F4 "https://github.com/joinreinvest/reinvest-native/tree/development/src/navigation"
    click BL1 "https://github.com/joinreinvest/reinvest-native/tree/development/src/services"
    click BL2 "https://github.com/joinreinvest/reinvest-native/tree/development/src/store"
    click BL3 "https://github.com/joinreinvest/reinvest-native/tree/development/src/utils"
    click N1 "https://github.com/joinreinvest/reinvest-native/tree/development/ios"
    click N2 "https://github.com/joinreinvest/reinvest-native/tree/development/android"
    click D1 "https://github.com/joinreinvest/reinvest-native/tree/development/.github/workflows"
    click D2 "https://github.com/joinreinvest/reinvest-native/blob/development/.env.example"
    click D3 "https://github.com/joinreinvest/reinvest-native/blob/development/babel.config.js"
    click D4 "https://github.com/joinreinvest/reinvest-native/blob/development/tsconfig.json"
```
