# wako1203/earthcare architecture

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

- Interactive diagram: https://gitdiagram.com/wako1203/earthcare
- Repository: https://github.com/wako1203/earthcare

## Overview

##### Main Components
- React Native Core: The application bootstraps using React Native (with Metro as the bundler). Represent the “React Native App Runtime” as a core component encapsulating JavaScript execution.
- Application Source Code:
– "src" Directory: Contains key business logic, UI components, screens, navigation, state management, and API integrations.
– Sub-components include:
- Components – reusable UI parts like BottomSheet, Map components (MapBox, MapGoogle) and others.
- Screens – distinct views such as LoginScreen, HomeScreen, ProfileScreen, and additional screens under subdirectories.
- Navigation – files managing routing (AppNavigation, BottomTabs) that structure how the user moves between screens.
- Context & Hooks – “LoadingContext” and “UserContext” for managing global states and user authentication (e.g., userAuth hook).
- API Integrations – custom modules like "firebaseAPI" and "googleMapAPI" which provide connectivity to external services.
- Configuration and Environment:
– Environment files (.env), configuration files (e.g., .eslintrc.js, .prettierrc.js, tsconfig.json) and build/deployment scripts (android/build.gradle, ios/Podfile, etc.) that set up and guide the app’s behavior across environments (development, staging, production).

##### Relationships and Interactions
- Flow from Native to JavaScript: Illustrate how the native layer initializes the Metro bundler and launches the React Native runtime.
- Data Flow within the JavaScript Layer: Show a clear data flow where user interactions in UI components trigger events captured via context and hooks, leading to API calls and then resolution/updating of the UI.
- API Communication: Highlight the connections between the “src/api” modules (firebaseAPI, googleMapAPI) and external services (Firebase, Google Maps).
- Navigation and State: Represent how the navigation system routes between different “screens” and how global contexts (UserContext & LoadingContext) underpin state management across components.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Distinguish clear boundaries between UI (components/screens), business logic (contexts/hooks), and external communication (api modules).
- Modularity: Emphasize that different screens and components likely follow a cohesive modular organization that improves maintainability.
- Cross-Platform Pattern: Represent that the shared JavaScript code handles business logic and UI consistently across both mobile platforms, while the native folders manage platform-specific requirements.

##### Relevant Technologies and Frameworks
- React Native as the core framework.
- Metro bundler for JavaScript bundling.
- Testing framework indicated by __tests__ directory (likely using Jest).
- Native build tools: Gradle (Android) and Xcode (iOS).
- External library or API integration for Firebase and Google Maps.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Native Platforms
    subgraph "Native Platforms"
        AndroidNative["Android Native Code"]:::nativeStyle
        iOSNative["iOS Native Code"]:::nativeStyle
    end

    %% React Native Core
    RNCore["React Native Core (Metro Bundler & App Runtime)"]:::coreStyle

    %% Shared Application Source
    AppSrc["Shared App Source (src)"]:::appStyle

    %% Application Components inside Shared Codebase
    UIComponents["UI Components"]:::appStyle
    ContextState["Context & State Management"]:::appStyle
    CustomHooks["Custom Hooks"]:::appStyle
    Navigation["Navigation Module"]:::appStyle
    Screens["Screens"]:::appStyle
    APIIntegration["API Integration Modules"]:::appStyle

    %% External Services
    ExternalFirebase["Firebase"]:::externalStyle
    ExternalGoogleMaps["Google Maps"]:::externalStyle

    %% Configuration & Environment Subgraph
    subgraph "Configuration & Environment"
        EnvProd[".env.production"]:::fileStyle
        EnvStaging[".env.staging"]:::fileStyle
        ESLint[".eslintrc.js"]:::fileStyle
        Prettier[".prettierrc.js"]:::fileStyle
        TSConfig["tsconfig.json"]:::fileStyle
        AndroidGradle["Android Build (build.gradle)"]:::fileStyle
        iOSPodfile["iOS Build (Podfile)"]:::fileStyle
    end

    %% Connections from Native Platforms to React Native Core
    AndroidNative -->|"initializes"| RNCore
    iOSNative -->|"initializes"| RNCore

    %% React Native Core loads Shared Source Code
    RNCore -->|"loads"| AppSrc

    %% Shared App Source breaks into sub-components
    AppSrc --> UIComponents
    AppSrc --> ContextState
    AppSrc --> Navigation
    AppSrc --> APIIntegration

    %% Application internal interactions
    UIComponents -->|"triggers"| ContextState
    ContextState -->|"utilizes"| CustomHooks
    ContextState -->|"fetches_via"| APIIntegration
    Navigation -->|"routes_to"| Screens

    %% API Integration calls external services
    APIIntegration -->|"calls"| ExternalFirebase
    APIIntegration -->|"calls"| ExternalGoogleMaps

    %% Configuration influences key modules
    ESLint --> RNCore
    AndroidGradle --> AndroidNative
    iOSPodfile --> iOSNative

    %% Styles
    classDef nativeStyle fill:#F1948A,stroke:#C0392B,stroke-width:2px;
    classDef coreStyle fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef appStyle fill:#ABEBC6,stroke:#27AE60,stroke-width:2px;
    classDef fileStyle fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef externalStyle fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;

    %% Click Events for Component Mappings
    click AndroidNative "https://github.com/wako1203/earthcare/tree/test/google-map//android"
    click iOSNative "https://github.com/wako1203/earthcare/tree/test/google-map//ios"
    click RNCore "https://github.com/wako1203/earthcare/blob/test/google-map//index.js"
    click RNCore "https://github.com/wako1203/earthcare/blob/test/google-map//metro.config.js"
    click AppSrc "https://github.com/wako1203/earthcare/tree/test/google-map//src"
    click UIComponents "https://github.com/wako1203/earthcare/tree/test/google-map//src/components"
    click Screens "https://github.com/wako1203/earthcare/tree/test/google-map//src/screens"
    click Navigation "https://github.com/wako1203/earthcare/tree/test/google-map//src/navigation"
    click ContextState "https://github.com/wako1203/earthcare/tree/test/google-map//src/context"
    click CustomHooks "https://github.com/wako1203/earthcare/tree/test/google-map//src/hook"
    click APIIntegration "https://github.com/wako1203/earthcare/tree/test/google-map//src/api"
    click EnvProd "https://github.com/wako1203/earthcare/blob/test/google-map/.env.production"
    click EnvStaging "https://github.com/wako1203/earthcare/blob/test/google-map/.env.staging"
    click ESLint "https://github.com/wako1203/earthcare/blob/test/google-map/.eslintrc.js"
    click Prettier "https://github.com/wako1203/earthcare/blob/test/google-map/.prettierrc.js"
    click TSConfig "https://github.com/wako1203/earthcare/blob/test/google-map/tsconfig.json"
    click AndroidGradle "https://github.com/wako1203/earthcare/blob/test/google-map//android/app/build.gradle"
    click iOSPodfile "https://github.com/wako1203/earthcare/tree/test/google-map//ios/Podfile"
```
