# melvindebot/idle_plant_mobile architecture

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

- Interactive diagram: https://gitdiagram.com/melvindebot/idle_plant_mobile
- Repository: https://github.com/melvindebot/idle_plant_mobile

## Overview

##### Main Components
- Mobile Frontend: Since this is a React Native application with a main entry point at app/index.tsx, the UI components (located in app/components) are key. Components like Button, Card, Bubble, and custom screens (e.g., PlantGrowthScreen) form the visual building blocks.
- State Management: The presence of a context folder (app/context/UserContext.tsx) indicates that the app uses React Context to manage state—this is a core part of the data flow.
- Utility and Business Logic: The app/utils folder and associated utility files (data.json, function.tsx, etc.) likely encapsulate helper functions and core game logic.
- Assets: The assets folder (with subdirectories for animation, images, and fonts) holds all static resources (Lottie animations for visual effects, images for UI, etc.).

##### Directory Structure for Architectural Patterns
- Separation of Concerns: The separation between app/ (which includes components, context, utilities) and assets/ (which contains visual and animated resources) exemplifies a clear separation between logic and presentation.
- Build and Deployment: The presence of CI/CD configuration (GitHub workflows) and EAS build instructions (for both Android and iOS) can be represented as separate processes outside the main runtime architecture, but still important for overall system design.

- Entry Point & App Initialization: Represent app/index.tsx as the “Application Entry Point” that boots up the app.
- Utilities: Represent utility functions and modules (from app/utils) as the business logic layer that feeds into state changes and component behavior.
- Assets: Encapsulate the assets folder by listing out the animations, images, and fonts. Note that these are passed to the UI components, especially the ones handling animations.

b. Relationships and Data Flow:
- Connection from UI Components to Utilities (for invoking helper functions) and Assets (for static media resources).

##### Architectural Patterns & Design Principles
- Component-based modularity: Emphasize that each UI component is self-contained and reusable.
- Separation of concerns: Data management (context), visual elements (components), and static assets (assets folder) each have dedicated sections.
- Unidirectional data flow: Highlight how state changes propagate in one clear direction.
- Mobile development best practices: Incorporate notes about platform-specific builds (using EAS for Android and iOS) and how the build pipeline is integrated into the development workflow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Mobile App Architecture
    subgraph "Mobile App Architecture"
        EP["Main App Entry: app/index.tsx"]:::entry
        subgraph "Presentation Layer (UI Components)"
            UI_Button["Button"]:::ui
            UI_Card["Card"]:::ui
            UI_Bubble["Bubble"]:::ui
            UI_Guide["Guide"]:::ui
            UI_LayoutAni["LayoutAnimation"]:::ui
            UI_LevelInd["LevelIndicator"]:::ui
            UI_Oxygen["OxygenCounter"]:::ui
            UI_PlantGrow["PlantGrowthScreen"]:::ui
            UI_Tabs["Tabs"]:::ui
        end
        SM["State Provider: UserContext"]:::context
        UT["Utilities & Business Logic (app/utils)"]:::utils
        AS["Media Assets: Animations, Images, Fonts"]:::assets
    end

    %% Build and Deployment Section
    subgraph "Configuration & Deployment"
        CFG["Configuration: package.json, tsconfig.json, app.json"]:::config
        BP["CI/CD & Build: GitHub Workflows, EAS CLI"]:::build
    end

    %% Relationships and Data Flow
    EP -->|"renders"| UI_Button
    EP -->|"renders"| UI_Card
    EP -->|"renders"| UI_Bubble
    EP -->|"renders"| UI_Guide
    EP -->|"renders"| UI_LayoutAni
    EP -->|"renders"| UI_LevelInd
    EP -->|"renders"| UI_Oxygen
    EP -->|"renders"| UI_PlantGrow
    EP -->|"renders"| UI_Tabs

    UI_Button -->|"triggers updates"| SM
    UI_Card -->|"triggers updates"| SM
    UI_Bubble -->|"triggers updates"| SM
    UI_Guide -->|"triggers updates"| SM
    UI_LayoutAni -->|"triggers updates"| SM
    UI_LevelInd -->|"triggers updates"| SM
    UI_Oxygen -->|"triggers updates"| SM
    UI_PlantGrow -->|"triggers updates"| SM
    UI_Tabs -->|"triggers updates"| SM

    UI_Button -->|"invokes"| UT
    UI_Card -->|"invokes"| UT
    UI_Bubble -->|"invokes"| UT
    UI_Guide -->|"invokes"| UT
    UI_LayoutAni -->|"invokes"| UT
    UI_LevelInd -->|"invokes"| UT
    UI_Oxygen -->|"invokes"| UT
    UI_PlantGrow -->|"invokes"| UT
    UI_Tabs -->|"invokes"| UT

    UI_Button -->|"loads media"| AS
    UI_Card -->|"loads media"| AS
    UI_Bubble -->|"loads media"| AS
    UI_Guide -->|"loads media"| AS
    UI_LayoutAni -->|"loads media"| AS
    UI_LevelInd -->|"loads media"| AS
    UI_Oxygen -->|"loads media"| AS
    UI_PlantGrow -->|"loads media"| AS
    UI_Tabs -->|"loads media"| AS

    SM -->|"updates state"| UI_Button
    SM -->|"updates state"| UI_Card
    SM -->|"updates state"| UI_Bubble
    SM -->|"updates state"| UI_Guide
    SM -->|"updates state"| UI_LayoutAni
    SM -->|"updates state"| UI_LevelInd
    SM -->|"updates state"| UI_Oxygen
    SM -->|"updates state"| UI_PlantGrow
    SM -->|"updates state"| UI_Tabs

    %% External Build & Deployment Flows
    BP -->|"builds and deploys"| EP
    CFG -->|"configures"| EP

    %% Click Events
    click EP "https://github.com/melvindebot/idle_plant_mobile/blob/master/app/index.tsx"
    click UI_Button "https://github.com/melvindebot/idle_plant_mobile/blob/master/app/components/Button/Button.tsx"
    click UI_Card "https://github.com/melvindebot/idle_plant_mobile/blob/master/app/components/Card/Card.tsx"
    click UI_Bubble "https://github.com/melvindebot/idle_plant_mobile/blob/master/app/components/Bubble/Bubble.tsx"
    click UI_Guide "https://github.com/melvindebot/idle_plant_mobile/blob/master/app/components/Guide/Guide.tsx"
    click UI_LayoutAni "https://github.com/melvindebot/idle_plant_mobile/blob/master/app/components/LayoutAnimation/LayoutAnimation.tsx"
    click UI_LevelInd "https://github.com/melvindebot/idle_plant_mobile/blob/master/app/components/LevelIndicator/LevelIndicator.tsx"
    click UI_Oxygen "https://github.com/melvindebot/idle_plant_mobile/blob/master/app/components/OxygenCounter/OxygenCounter.tsx"
    click UI_PlantGrow "https://github.com/melvindebot/idle_plant_mobile/blob/master/app/components/PlantGrowthScreen/PlantGrowthScreen.tsx"
    click UI_Tabs "https://github.com/melvindebot/idle_plant_mobile/blob/master/app/components/Tabs/Tabs.tsx"
    click SM "https://github.com/melvindebot/idle_plant_mobile/blob/master/app/context/UserContext.tsx"
    click UT "https://github.com/melvindebot/idle_plant_mobile/tree/master/app/utils"
    click AS "https://github.com/melvindebot/idle_plant_mobile/tree/master/assets"
    click CFG "https://github.com/melvindebot/idle_plant_mobile/blob/master/package.json"
    click BP "https://github.com/melvindebot/idle_plant_mobile/blob/master/.github/workflows/node.js.yml"

    %% Styles
    classDef entry fill:#f9e79f,stroke:#b9770e,stroke-width:2px;
    classDef ui fill:#aed6f1,stroke:#2874a6,stroke-width:2px;
    classDef context fill:#abebc6,stroke:#229954,stroke-width:2px;
    classDef utils fill:#fad7a0,stroke:#d35400,stroke-width:2px;
    classDef assets fill:#f9c7c7,stroke:#c0392b,stroke-width:2px;
    classDef config fill:#d7bde2,stroke:#7d3c98,stroke-width:2px;
    classDef build fill:#f5b7b1,stroke:#943126,stroke-width:2px;
```
