# lucalves/plant-manager architecture

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

- Interactive diagram: https://gitdiagram.com/lucalves/plant-manager
- Repository: https://github.com/lucalves/plant-manager

## Overview

##### Project type and purpose
- This is a React Native mobile application (built with Expo and TypeScript) called “Plant Manager.”
- Purpose: allow users to register plants, schedule watering reminders and persist data either locally (AsyncStorage) or via a fake REST API (json-server).

##### File structure
- App entry point (App.tsx) at the root loads navigation and bootstraps Expo.
- src/pages – screen-level components (Welcome, UserIdentification, PlantSelect, PlantSave, Confirmation, MyPlants).
- src/components – reusable UI building blocks (Button, Header, PlantCard, Load spinner, etc.).
- src/routes – React Navigation stacks and tabs.
- src/services – api.ts (HTTP client), server.json (fake API schema).
- src/libs/storage.ts – wrapper around AsyncStorage for local persistence.

##### README for additional insights
- The app relies on Expo for build and bundling.
- json-server runs on port 3333 to simulate a backend REST API with a delay.
- Local storage is used for device notifications and offline support.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Mobile Client
    subgraph "Mobile Client"
        Mobile["Mobile Device / Expo Client"]:::client
    end

    %% UI Layer
    subgraph "UI Layer"
        subgraph "Pages"
            Welcome["Welcome"]:::client
            UserId["UserIdentification"]:::client
            PlantSelect["PlantSelect"]:::client
            PlantSave["PlantSave"]:::client
            Confirmation["Confirmation"]:::client
            MyPlants["MyPlants"]:::client
        end
        subgraph "Components"
            Button["Button"]:::client
            EnvBtn["EnviromentButton"]:::client
            Header["Header"]:::client
            Load["Load Spinner"]:::client
            CardP["PlantCardPrimary"]:::client
            CardS["PlantCardSecondary"]:::client
        end
    end

    %% Navigation Layer
    subgraph "Navigation Layer"
        Routes["Index Routes"]:::client
        Stack["Stack Navigator"]:::client
        Tab["Tab Navigator"]:::client
    end

    %% Data Layer
    subgraph "Data Layer"
        API["API Client (services/api.ts)"]:::data
    end

    %% Persistence
    subgraph "Local Persistence"
        Storage[(AsyncStorage Wrapper)]:::data
    end

    %% Remote API
    subgraph "Remote API"
        AServer{{"json-server (port 3333)"}}:::external
        DB[(server.json)]:::data
    end

    %% Device Services
    subgraph "Device Services"
        Notif(("Notification Scheduler")):::external
    end

    %% Connections
    Mobile -->|"loads navigation"| Routes
    Routes --> Stack
    Routes --> Tab
    Stack --> Welcome
    Stack --> UserId
    Tab --> PlantSelect
    Tab --> MyPlants
    PlantSelect --> PlantSave
    PlantSave --> Confirmation

    %% UI to Components
    Welcome --> Button
    UserId --> Header
    UserId --> Button
    PlantSelect --> EnvBtn
    PlantSelect --> CardP
    PlantSelect --> CardS
    MyPlants --> CardP
    MyPlants --> CardS
    PlantSave --> Load

    %% Pages to Data Layer
    PlantSelect -->|"fetch data"| API
    MyPlants -->|"fetch saved plants"| Storage
    PlantSave -->|"save plant"| Storage
    PlantSave -->|"post plant"| API

    %% Data Layer to Remote API
    API -->|"HTTP requests"| AServer
    AServer --> DB

    %% Pages to Notification
    PlantSave -->|"schedule reminder"| Notif

    %% Click Events
    click Mobile "https://github.com/lucalves/plant-manager/blob/main/App.tsx"
    click Welcome "https://github.com/lucalves/plant-manager/blob/main/src/pages/Welcome.tsx"
    click UserId "https://github.com/lucalves/plant-manager/blob/main/src/pages/UserIdentification.tsx"
    click PlantSelect "https://github.com/lucalves/plant-manager/blob/main/src/pages/PlantSelect.tsx"
    click PlantSave "https://github.com/lucalves/plant-manager/blob/main/src/pages/PlantSave.tsx"
    click Confirmation "https://github.com/lucalves/plant-manager/blob/main/src/pages/Confirmation.tsx"
    click MyPlants "https://github.com/lucalves/plant-manager/blob/main/src/pages/MyPlants.tsx"
    click Button "https://github.com/lucalves/plant-manager/blob/main/src/components/Button.tsx"
    click EnvBtn "https://github.com/lucalves/plant-manager/blob/main/src/components/EnviromentButton.tsx"
    click Header "https://github.com/lucalves/plant-manager/blob/main/src/components/Header.tsx"
    click Load "https://github.com/lucalves/plant-manager/blob/main/src/components/Load.tsx"
    click CardP "https://github.com/lucalves/plant-manager/blob/main/src/components/PlantCardPrimary.tsx"
    click CardS "https://github.com/lucalves/plant-manager/blob/main/src/components/PlantCardSecundary.tsx"
    click Routes "https://github.com/lucalves/plant-manager/blob/main/src/routes/index.tsx"
    click Stack "https://github.com/lucalves/plant-manager/blob/main/src/routes/stack.routes.tsx"
    click Tab "https://github.com/lucalves/plant-manager/blob/main/src/routes/tab.routes.tsx"
    click API "https://github.com/lucalves/plant-manager/blob/main/src/services/api.ts"
    click DB "https://github.com/lucalves/plant-manager/blob/main/src/services/server.json"
    click Storage "https://github.com/lucalves/plant-manager/blob/main/src/libs/storage.ts"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef data fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
```
