# hetthie/greenregister architecture

> Architecture diagram of the GitHub repository hetthie/greenregister, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hetthie/greenregister
- Repository: https://github.com/hetthie/greenregister

## Overview

GreenRegister is a mobile plant-care tracker: users sign in, browse plant-care information, add plants, and record and review care activities. The documented product also includes per-species care intervals and last-activity indicators. The mobile screens and services are represented from the tree and README, but their implementations were not sampled; the sampled backend exposes authentication and basic plant creation/listing, so links to undocumented API behavior are intentionally omitted. The README describes a broader API and data model than the sampled backend confirms.

Main entry points: [`greenregister-mobile/src/services/api.js`](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/services/api.js) (API client), [`greenregister-mobile/src/pages/PlantDetail.js`](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/PlantDetail.js) (Plant details), [`greenregister-mobile/src/pages/Catalog.js`](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/Catalog.js) (Plant catalog), [`greenregister-mobile/src/pages/MyPlants.js`](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/MyPlants.js) (My plants)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile app"]
  node_authscreens["Login and register<br/>[Login.js]"]
  node_authcontext["Session context<br/>[AuthContext.js]"]
  node_authservice["Auth service<br/>[auth.js]"]
  node_apiclient["API client<br/>[api.js]"]
  node_catalog["Plant catalog<br/>[Catalog.js]"]
  node_catalogdetail["Catalog details<br/>[CatalogDetail.js]"]
  node_myplants["My plants<br/>[MyPlants.js]"]
  node_plantdetail["Plant details<br/>[PlantDetail.js]"]
  node_activityform["Care activity form"]
  node_activityhistory["Activity history<br/>[ActivityHistory.js]"]
  node_home["Home dashboard<br/>[Home.js]"]
end

subgraph group_backend["Backend API"]
  node_api["Express server<br/>[server.js]"]
  node_authroutes["Auth routes<br/>[auth.routes.js]"]
  node_authcontroller["Auth controller<br/>[authController.js]"]
  node_plantroutes["Plant routes<br/>[planta.routes.js]"]
  node_plantcontroller["Plant controller"]
  node_authmiddleware["JWT middleware<br/>[authMiddleware.js]"]
end

subgraph group_data["Persistence"]
  node_dbconfig["Database pool<br/>[db.js]"]
  node_postgres[("PostgreSQL")]
end

node_user(("Plant owner"))

node_user -->|"enters credentials"| node_authscreens
node_authscreens -->|"requests auth"| node_authservice
node_authcontext -->|"loads session"| node_authservice
node_authservice -->|"sends requests"| node_apiclient
node_user -->|"browses plants"| node_catalog
node_catalog -->|"opens details"| node_catalogdetail
node_user -->|"views collection"| node_myplants
node_myplants -->|"opens plant"| node_plantdetail
node_plantdetail -->|"starts activity"| node_activityform
node_plantdetail -->|"opens history"| node_activityhistory
node_user -->|"views dashboard"| node_home
node_catalog -.->|"requests catalog"| node_apiclient
node_catalogdetail -.->|"requests plant data"| node_apiclient
node_myplants -.->|"requests collection"| node_apiclient
node_plantdetail -->|"fetches and deletes"| node_apiclient
node_activityform -.->|"submits activity"| node_apiclient
node_activityhistory -.->|"requests history"| node_apiclient
node_apiclient -->|"sends HTTP requests"| node_api
node_api -->|"dispatches auth"| node_authroutes
node_api -->|"dispatches plants"| node_plantroutes
node_authroutes -->|"dispatches handlers"| node_authcontroller
node_plantroutes -->|"checks protected routes"| node_authmiddleware
node_authmiddleware -->|"continues authorized request"| node_plantcontroller
node_plantroutes -->|"dispatches handlers"| node_plantcontroller
node_authcontroller -->|"queries users"| node_dbconfig
node_plantcontroller -->|"queries plants"| node_dbconfig
node_dbconfig -->|"connects pool"| node_postgres

click node_authscreens "https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/Login.js"
click node_authcontext "https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/context/AuthContext.js"
click node_authservice "https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/services/auth.js"
click node_apiclient "https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/services/api.js"
click node_catalog "https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/Catalog.js"
click node_catalogdetail "https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/CatalogDetail.js"
click node_myplants "https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/MyPlants.js"
click node_plantdetail "https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/PlantDetail.js"
click node_activityform "https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/RegisterActivity.js"
click node_activityhistory "https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/ActivityHistory.js"
click node_home "https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/Home.js"
click node_api "https://github.com/hetthie/greenregister/blob/main/backend/server.js"
click node_authroutes "https://github.com/hetthie/greenregister/blob/main/backend/src/routes/auth.routes.js"
click node_authcontroller "https://github.com/hetthie/greenregister/blob/main/backend/src/controllers/authController.js"
click node_plantroutes "https://github.com/hetthie/greenregister/blob/main/backend/src/routes/planta.routes.js"
click node_plantcontroller "https://github.com/hetthie/greenregister/blob/main/backend/src/controllers/plantaControllers.js"
click node_authmiddleware "https://github.com/hetthie/greenregister/blob/main/backend/src/middlewares/authMiddleware.js"
click node_dbconfig "https://github.com/hetthie/greenregister/blob/main/backend/src/config/db.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_authscreens,node_authcontext,node_authservice,node_apiclient,node_catalog,node_catalogdetail,node_myplants,node_plantdetail,node_activityform,node_activityhistory,node_home toneBlue
class node_api,node_authroutes,node_authcontroller,node_plantroutes,node_plantcontroller,node_authmiddleware toneAmber
class node_dbconfig,node_postgres toneMint
class node_user toneIndigo
```

## Components

### Mobile app

- [Login and register](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/Login.js): `greenregister-mobile/src/pages/Login.js`
- [Session context](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/context/AuthContext.js): `greenregister-mobile/src/context/AuthContext.js`
- [Auth service](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/services/auth.js): `greenregister-mobile/src/services/auth.js`
- [API client](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/services/api.js): `greenregister-mobile/src/services/api.js`
- [Plant catalog](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/Catalog.js): `greenregister-mobile/src/pages/Catalog.js`
- [Catalog details](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/CatalogDetail.js): `greenregister-mobile/src/pages/CatalogDetail.js`
- [My plants](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/MyPlants.js): `greenregister-mobile/src/pages/MyPlants.js`
- [Plant details](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/PlantDetail.js): `greenregister-mobile/src/pages/PlantDetail.js`
- [Care activity form](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/RegisterActivity.js): `greenregister-mobile/src/pages/RegisterActivity.js`
- [Activity history](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/ActivityHistory.js): `greenregister-mobile/src/pages/ActivityHistory.js`
- [Home dashboard](https://github.com/hetthie/greenregister/blob/main/greenregister-mobile/src/pages/Home.js): `greenregister-mobile/src/pages/Home.js`

### Backend API

- [Express server](https://github.com/hetthie/greenregister/blob/main/backend/server.js): `backend/server.js`
- [Auth routes](https://github.com/hetthie/greenregister/blob/main/backend/src/routes/auth.routes.js): `backend/src/routes/auth.routes.js`
- [Auth controller](https://github.com/hetthie/greenregister/blob/main/backend/src/controllers/authController.js): `backend/src/controllers/authController.js`
- [Plant routes](https://github.com/hetthie/greenregister/blob/main/backend/src/routes/planta.routes.js): `backend/src/routes/planta.routes.js`
- [Plant controller](https://github.com/hetthie/greenregister/blob/main/backend/src/controllers/plantaControllers.js): `backend/src/controllers/plantaControllers.js`
- [JWT middleware](https://github.com/hetthie/greenregister/blob/main/backend/src/middlewares/authMiddleware.js): `backend/src/middlewares/authMiddleware.js`

### Persistence

- [Database pool](https://github.com/hetthie/greenregister/blob/main/backend/src/config/db.js): `backend/src/config/db.js`
- **PostgreSQL**

### Other components

- **Plant owner**

## Connections

- Plant owner → Login and register: enters credentials
- Login and register → Auth service: requests auth
- Session context → Auth service: loads session
- Auth service → API client: sends requests
- Plant owner → Plant catalog: browses plants
- Plant catalog → Catalog details: opens details
- Plant owner → My plants: views collection
- My plants → Plant details: opens plant
- Plant details → Care activity form: starts activity
- Plant details → Activity history: opens history
- Plant owner → Home dashboard: views dashboard
- Plant catalog → API client: requests catalog
- Catalog details → API client: requests plant data
- My plants → API client: requests collection
- Plant details → API client: fetches and deletes
- Care activity form → API client: submits activity
- Activity history → API client: requests history
- API client → Express server: sends HTTP requests
- Express server → Auth routes: dispatches auth
- Express server → Plant routes: dispatches plants
- Auth routes → Auth controller: dispatches handlers
- Plant routes → JWT middleware: checks protected routes
- JWT middleware → Plant controller: continues authorized request
- Plant routes → Plant controller: dispatches handlers
- Auth controller → Database pool: queries users
- Plant controller → Database pool: queries plants
- Database pool → PostgreSQL: connects pool
