# benmotyka/myplants-app architecture

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

- Interactive diagram: https://gitdiagram.com/benmotyka/myplants-app
- Repository: https://github.com/benmotyka/myplants-app

## Overview

##### Main Components Identification

a) Client Layer (Mobile Application)
- Frontend Components (React Native/Expo)
- Local Storage (AsyncStorage - evident from __mocks__ directory)
- State Management (indicated by the store directory)

b) Service Layer
- API Services (visible in services directory)
- Notification System (shown by useNotifications hook)
- Image Handling Service

c) External Services
- Sentry (for error tracking)
- Push Notification Service
- Backend Server (referenced in .env.example)

##### Architectural Pattern Representation

a) Component Organization:
- Components hierarchically:
- Screens (home, plants, settings)
- Components (reusable UI elements)
- Services (plant.ts, user.ts, watering.ts)
- Utils (date.ts, device.ts, images.ts)

b) Data Flow:
- Components and Services
- Services and External APIs
- Local Storage and Components

##### Specific Elements

**Frontend Layer:**
**┌─ UI Components**
- Screens
- Home
- Plants Management
- Settings
- Shared Components
- Basic Components
- Modals

- Core Services
- Plant Service
- User Service
- Watering Service

- State Management
- Store

- Utils & Helpers

##### Integration Points

Clear connections for:
- API interactions (config/api)
- Push notifications (hooks/useNotifications)
- Image handling (utils/images)
- Error tracking (Sentry integration)
- Internationalization (translations directory)

##### Technical Stack Callouts

Key technologies:
- Expo
- React Native
- styled-components
- Sentry
- AsyncStorage

Remember to emphasize the mobile-specific aspects like push notifications and camera/image handling, as these are crucial for the app's functionality.

This system design should clearly communicate how the application handles its core features: plant management, watering schedules, notifications, and image management, while showing the integration with external services and the backend API.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        MobileApp["Mobile Application"]
        
        subgraph UI["UI Layer"]
            Screens["Screens"]:::frontend
            BasicComp["Basic Components"]:::frontend
            Modals["Modals"]:::frontend
            PlantComp["Plant Components"]:::frontend
            SettingsComp["Settings Components"]:::frontend
        end

        subgraph Core["Core Services"]
            PlantService["Plant Service"]:::service
            UserService["User Service"]:::service
            WateringService["Watering Service"]:::service
            APIConfig["API Configuration"]:::service
        end

        subgraph State["State Management"]
            Store["Store"]:::state
        end

        subgraph Features["Feature Services"]
            NotificationSystem["Notification System"]:::feature
            ImageHandler["Image Handling"]:::feature
            I18n["Internationalization"]:::feature
        end

        subgraph Utils["Utility Layer"]
            DateUtils["Date Utils"]:::util
            DeviceUtils["Device Utils"]:::util
            ToastUtils["Toast Utils"]:::util
            ConnectivityCheck["Connectivity Check"]:::util
        end

        subgraph ErrorHandling["Error Handling"]
            ErrorBoundary["Error Boundary"]:::error
            APIErrors["API Errors"]:::error
        end

        subgraph Validation["Data Validation"]
            PlantSchemas["Plant Schemas"]:::validation
        end
    end

    subgraph External["External Services"]
        Backend["Backend API"]:::external
        Sentry["Sentry Error Tracking"]:::external
        PushService["Push Notification Service"]:::external
    end

    %% Relationships
    MobileApp --> UI
    UI --> Core
    Core --> State
    Core --> Features
    Core --> Utils
    Core --> ErrorHandling
    Core --> Validation
    Core <--> External

    %% Click Events
    click BasicComp "https://github.com/benmotyka/myplants-app/tree/main/components/Basic*"
    click Screens "https://github.com/benmotyka/myplants-app/tree/main/screens/*"
    click Modals "https://github.com/benmotyka/myplants-app/tree/main/modals/*"
    click PlantComp "https://github.com/benmotyka/myplants-app/tree/main/components/Plant"
    click SettingsComp "https://github.com/benmotyka/myplants-app/tree/main/components/Settings"
    click PlantService "https://github.com/benmotyka/myplants-app/blob/main/services/plant.ts"
    click UserService "https://github.com/benmotyka/myplants-app/blob/main/services/user.ts"
    click WateringService "https://github.com/benmotyka/myplants-app/blob/main/services/watering.ts"
    click APIConfig "https://github.com/benmotyka/myplants-app/blob/main/config/api/plants.ts"
    click Store "https://github.com/benmotyka/myplants-app/blob/main/store/index.ts"
    click NotificationSystem "https://github.com/benmotyka/myplants-app/blob/main/hooks/useNotifications.ts"
    click ImageHandler "https://github.com/benmotyka/myplants-app/blob/main/utils/images.ts"
    click I18n "https://github.com/benmotyka/myplants-app/blob/main/config/i18n.js"
    click DateUtils "https://github.com/benmotyka/myplants-app/blob/main/utils/date.ts"
    click DeviceUtils "https://github.com/benmotyka/myplants-app/blob/main/utils/device.ts"
    click ToastUtils "https://github.com/benmotyka/myplants-app/blob/main/utils/toast.ts"
    click ConnectivityCheck "https://github.com/benmotyka/myplants-app/blob/main/hooks/useCheckConnectivity.ts"
    click ErrorBoundary "https://github.com/benmotyka/myplants-app/tree/main/components/ErrorBoundary"
    click APIErrors "https://github.com/benmotyka/myplants-app/blob/main/enums/api-errors.ts"
    click PlantSchemas "https://github.com/benmotyka/myplants-app/blob/main/schemas/AddPlant.schema.ts"

    %% Styling
    classDef frontend fill:#2196F3,color:white
    classDef service fill:#9C27B0,color:white
    classDef state fill:#FF9800,color:white
    classDef feature fill:#4CAF50,color:white
    classDef util fill:#607D8B,color:white
    classDef error fill:#F44336,color:white
    classDef validation fill:#795548,color:white
    classDef external fill:#009688,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend"]:::frontend
        Service["Services"]:::service
        StateManagement["State"]:::state
        FeatureService["Features"]:::feature
        Utility["Utils"]:::util
        ErrorHandle["Errors"]:::error
        Validate["Validation"]:::validation
        ExternalService["External"]:::external
    end
```
