# passiolife/passio-nutrition-ai-rn-ui-module-distribution architecture

> Architecture diagram of the GitHub repository passiolife/passio-nutrition-ai-rn-ui-module-distribution, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution
- Repository: https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution

## Overview

##### Main Components
- Mobile SDK Core: This encapsulates the integration of React Native code (found in the “src” directory), the various UI components (screens, modals, charts, inputs, etc.), navigators (such as NutritionNavigator, BottomTabNavigations), and utility functions.
- Native Modules: Separate Android and iOS directories indicate that native authentication, permission handling, and integration of the Passio SDK (for nutrition data) are handled natively. Also note the existence of additional directories in “example” which help demonstrate how to wire the native parts together.
- Dependency Integration & Providers: The README shows usage of various Context Providers – for instance, BrandingProvider, ServicesProvider (which include NutritionDataService and AnalyticsService) – and the integration with the React Navigation library.
- External Services & Data Flow: The SDK is designed to work with internal or externally-provided services for logging food, saving nutritional profiles, and networking to a backend (via REST APIs, Firebase, etc.), as evidenced by the “NutritionDataService” callbacks.
- Configuration & Build Tools: There are several configuration files (babel.config.js, react-native.config.js, .circleci, Husky hooks, etc.) that set up the CI/CD and building of the project.

##### Establish Relationships & Interactions
- At initialization, the App’s entry point (such as src/NutritionApp.tsx or the example’s App.tsx) configures the SDK using the “usePassioConfig” hook. This ensures the ready status after setting up the SDK key.
- The Providers (BrandingProvider, ServicesProvider) wrap the entire navigation component (NutritionNavigator) so that UI components can seamlessly access global branding, data services, and analytics.
- The NutritionNavigator itself routes the user between multiple screens (home, food logs, recipe editor, etc.) that reside deep in the “src/screens” folder.
- Data flows from UI interactions (e.g., saving a food log via a screen component) through context layer functions (dataService callbacks) into the business logic and potentially to external backends or storage systems.
- Native libraries and external dependencies (like react-native-sqlite-storage, react-native-reanimated, and others specified in the README) are integrated through both JavaScript modules and native configuration files.

##### Architectural Patterns & Design Principles
- Context API & Hooks: Many parts of the code use contexts (for branding, service data, analytics) and custom hooks (e.g., useDailyMacroNutrition, usePassioAuthConfig). This indicates a clean separation of UI and business logic.
- Abstraction & Extensibility: The inclusion of “NutritionDataService” callbacks shows the design is meant to be integrated with customizable backends, enabling external data sources.
- Cross-Platform Native Integration: The native subsections (android, ios) plus the example project display strategies for bridging between React Native and native libraries.

##### Relevant Technologies, Frameworks, and Libraries
- React Native (with its native integration for iOS and Android)
- React Navigation (including native stacks and bottom tabs)
- Various React Native libraries for animations (react-native-reanimated), gesture handling, safe-area context, etc.
- External service integrations for nutrition data, logging, and analytics as captured by NutritionDataService and analyticsService.
- Build and CI/CD tools (.circleci, husky, yarn, etc.)

##### Final Steps
- Outward from the core providers to the navigation and then to each sub-module (screens, context, data and native integrations).
- You capture dependency relationships (e.g., which native libraries are required and how they functionally connect within the app).
- Be detailed: include as many components as possible, ensuring that data flow pathways (such as from user actions to SDK functions) are represented.

## Diagram (Mermaid)

```mermaid
graph TD
    A["App Entry Point (NutritionApp.tsx)"]:::mobile
    B["Mobile SDK Core (src/)"]:::mobile
    C["Context Providers (src/contexts/)"]:::context
    O["Hooks (src/hooks/)"]:::hook
    D["BrandingProvider (src/contexts/branding)"]:::context
    E["ServicesProvider (src/contexts/services)"]:::context
    F["NutritionDataService (src/contexts/services/NutritionDataService.ts)"]:::context
    G["AnalyticsService (src/contexts/services/AnalyticsService.ts)"]:::context
    H["Navigation (src/navigaitons/)"]:::nav
    I1["UI Components (src/components/)"]:::ui
    I2["Screens (src/screens/)"]:::ui
    J["Data Models (src/models/)"]:::external
    K["Utility Functions (src/utils/)"]:::external
    L1["Android Native Code (android/)"]:::native
    L2["Example Android (example/android/)"]:::native
    M1["iOS Native Code (ios/)"]:::native
    M2["Example iOS (example/ios/)"]:::native

    subgraph "Configuration & Build Tools"
        N1[".circleci/"]:::config
        N2["babel.config.js"]:::config
        N3["react-native.config.js"]:::config
        N4[".husky/"]:::config
    end

    A --> B
    B --> C
    B --> O
    B --> L1
    B --> L2
    B --> M1
    B --> M2
    B --> N1
    N1 --> N2
    N2 --> N3
    N3 --> N4
    C --> D
    C --> E
    E --> F
    E --> G
    C --> H
    O --> H
    H --> I1
    I1 --> I2
    I2 --> J
    I2 --> K

    click B "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/tree/main/src/"
    click I1 "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/tree/main/src/components/"
    click I2 "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/tree/main/src/screens/"
    click H "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/tree/main/src/navigaitons/"
    click C "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/tree/main/src/contexts/"
    click O "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/tree/main/src/hooks/"
    click D "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/tree/main/src/contexts/branding"
    click E "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/tree/main/src/contexts/services"
    click F "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/blob/main/src/contexts/services/NutritionDataService.ts"
    click G "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/blob/main/src/contexts/services/AnalyticsService.ts"
    click L1 "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/tree/main/android/"
    click L2 "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/tree/main/example/android/"
    click M1 "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/tree/main/ios/"
    click M2 "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/tree/main/example/ios/"
    click N1 "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/tree/main/.circleci/"
    click N2 "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/blob/main/babel.config.js"
    click N3 "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/blob/main/react-native.config.js"
    click N4 "https://github.com/passiolife/passio-nutrition-ai-rn-ui-module-distribution/tree/main/.husky/"

    classDef mobile fill:#d0e1f9,stroke:#333,stroke-width:2px
    classDef context fill:#ffaaa5,stroke:#333,stroke-width:2px
    classDef hook fill:#f9e79f,stroke:#333,stroke-width:2px
    classDef nav fill:#ffd3b6,stroke:#333,stroke-width:2px
    classDef ui fill:#a8e6cf,stroke:#333,stroke-width:2px
    classDef external fill:#caffbf,stroke:#333,stroke-width:2px
    classDef native fill:#ff8b94,stroke:#333,stroke-width:2px
    classDef config fill:#dcedc1,stroke:#333,stroke-width:2px
```
