# semina-by-mindframe/semina-backend architecture

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

- Interactive diagram: https://gitdiagram.com/semina-by-mindframe/semina-backend
- Repository: https://github.com/semina-by-mindframe/semina-backend

## Overview

Semina is a plant-care backend, not the Supabase CLI described by the supplied README; the README appears unrelated to this repository. The principal flow is client requests through Express routes to plant data and care features, with Supabase-backed state and AI-assisted plant guidance. The tree also exposes separate Supabase Edge Functions for chat, plant suggestions/care plans, and image-based health scans. Route source was sampled selectively, so unsampled routes are shown as capabilities without speculative internal wiring.

Main entry points: [`src/app.js`](https://github.com/semina-by-mindframe/semina-backend/blob/main/src/app.js) (Express app), [`src/services/supabaseClient.js`](https://github.com/semina-by-mindframe/semina-backend/blob/main/src/services/supabaseClient.js) (Supabase client), [`supabase/functions/chatbot/index.ts`](https://github.com/semina-by-mindframe/semina-backend/blob/main/supabase/functions/chatbot/index.ts) (Plant chatbot), [`supabase/functions/grow-plant/index.ts`](https://github.com/semina-by-mindframe/semina-backend/blob/main/supabase/functions/grow-plant/index.ts) (Suggest and plan)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["API server<br/>[server.js]"]
  node_app["Express app<br/>[app.js]"]
  node_system["System routes<br/>[system.js]"]
end

subgraph group_care["Plant Care"]
  node_plants["Plant routes<br/>[plants.js]"]
  node_recommendations["Recommendations<br/>[recommendations.js]"]
  node_reminders["Reminders<br/>[reminders.js]"]
  node_logs["Plant logs<br/>[logs.js]"]
  node_sensors["Sensor routes<br/>[sensors.js]"]
  node_recommendation_service["Light matching"]
end

subgraph group_ai["AI Features"]
  node_ai_route["AI routes<br/>[ai.js]"]
  node_chatbot["Plant chatbot<br/>[index.ts]"]
  node_grow["Suggest and plan<br/>[index.ts]"]
  node_scan["Plant health scan<br/>[index.ts]"]
end

subgraph group_state["Data and Sensors"]
  node_supabase_client["Supabase client<br/>[supabaseClient.js]"]
  node_supabase_db[("Supabase data")]
  node_sensor_demo["Sensor demo API<br/>[sensor-demo.js]"]
  node_demo_store[("Latest readings<br/>[sensor-demo.js]")]
end

node_client(("Client"))
node_openai{{"OpenAI"}}
node_gemini{{"Gemini"}}
node_device(("Sensor device"))

node_client -->|"HTTP requests"| node_server
node_server -->|"starts"| node_app
node_app -->|"mounts"| node_plants
node_app -->|"mounts"| node_sensors
node_app -->|"mounts"| node_ai_route
node_app -->|"mounts"| node_recommendations
node_app -->|"mounts"| node_reminders
node_app -->|"mounts"| node_logs
node_app -->|"mounts"| node_system
node_plants -->|"queries"| node_supabase_client
node_reminders -->|"queries"| node_supabase_client
node_recommendation_service -->|"queries"| node_supabase_client
node_supabase_client -->|"reads and writes"| node_supabase_db
node_client -->|"invokes"| node_chatbot
node_chatbot -->|"reads and updates"| node_supabase_db
node_chatbot -->|"requests completion"| node_openai
node_client -->|"invokes"| node_grow
node_grow -->|"requests suggestions"| node_gemini
node_grow -->|"saves care plan"| node_supabase_db
node_client -->|"invokes"| node_scan
node_scan -->|"analyzes image"| node_gemini
node_scan -->|"saves scan"| node_supabase_db
node_device -->|"posts readings"| node_sensor_demo
node_sensor_demo -->|"stores latest"| node_demo_store
node_sensor_demo -->|"serves readings"| node_client

click node_server "https://github.com/semina-by-mindframe/semina-backend/blob/main/src/server.js"
click node_app "https://github.com/semina-by-mindframe/semina-backend/blob/main/src/app.js"
click node_plants "https://github.com/semina-by-mindframe/semina-backend/blob/main/src/routes/plants.js"
click node_recommendations "https://github.com/semina-by-mindframe/semina-backend/blob/main/src/routes/recommendations.js"
click node_reminders "https://github.com/semina-by-mindframe/semina-backend/blob/main/src/routes/reminders.js"
click node_logs "https://github.com/semina-by-mindframe/semina-backend/blob/main/src/routes/logs.js"
click node_sensors "https://github.com/semina-by-mindframe/semina-backend/blob/main/src/routes/sensors.js"
click node_system "https://github.com/semina-by-mindframe/semina-backend/blob/main/src/routes/system.js"
click node_ai_route "https://github.com/semina-by-mindframe/semina-backend/blob/main/src/routes/ai.js"
click node_recommendation_service "https://github.com/semina-by-mindframe/semina-backend/blob/main/src/services/recommendationService.js"
click node_supabase_client "https://github.com/semina-by-mindframe/semina-backend/blob/main/src/services/supabaseClient.js"
click node_chatbot "https://github.com/semina-by-mindframe/semina-backend/blob/main/supabase/functions/chatbot/index.ts"
click node_grow "https://github.com/semina-by-mindframe/semina-backend/blob/main/supabase/functions/grow-plant/index.ts"
click node_scan "https://github.com/semina-by-mindframe/semina-backend/blob/main/supabase/functions/scan-plant/index.ts"
click node_sensor_demo "https://github.com/semina-by-mindframe/semina-backend/blob/main/sensor-demo.js"
click node_demo_store "https://github.com/semina-by-mindframe/semina-backend/blob/main/sensor-demo.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_server,node_app,node_system,node_client toneBlue
class node_plants,node_recommendations,node_reminders,node_logs,node_sensors,node_recommendation_service toneAmber
class node_ai_route,node_chatbot,node_grow,node_scan toneMint
class node_supabase_client,node_supabase_db,node_sensor_demo,node_demo_store toneRose
class node_openai,node_gemini,node_device toneIndigo
```

## Components

### HTTP API

- [API server](https://github.com/semina-by-mindframe/semina-backend/blob/main/src/server.js): `src/server.js`
- [Express app](https://github.com/semina-by-mindframe/semina-backend/blob/main/src/app.js): `src/app.js`
- [System routes](https://github.com/semina-by-mindframe/semina-backend/blob/main/src/routes/system.js): `src/routes/system.js`

### Plant Care

- [Plant routes](https://github.com/semina-by-mindframe/semina-backend/blob/main/src/routes/plants.js): `src/routes/plants.js`
- [Recommendations](https://github.com/semina-by-mindframe/semina-backend/blob/main/src/routes/recommendations.js): `src/routes/recommendations.js`
- [Reminders](https://github.com/semina-by-mindframe/semina-backend/blob/main/src/routes/reminders.js): `src/routes/reminders.js`
- [Plant logs](https://github.com/semina-by-mindframe/semina-backend/blob/main/src/routes/logs.js): `src/routes/logs.js`
- [Sensor routes](https://github.com/semina-by-mindframe/semina-backend/blob/main/src/routes/sensors.js): `src/routes/sensors.js`
- [Light matching](https://github.com/semina-by-mindframe/semina-backend/blob/main/src/services/recommendationService.js): `src/services/recommendationService.js`

### AI Features

- [AI routes](https://github.com/semina-by-mindframe/semina-backend/blob/main/src/routes/ai.js): `src/routes/ai.js`
- [Plant chatbot](https://github.com/semina-by-mindframe/semina-backend/blob/main/supabase/functions/chatbot/index.ts): `supabase/functions/chatbot/index.ts`
- [Suggest and plan](https://github.com/semina-by-mindframe/semina-backend/blob/main/supabase/functions/grow-plant/index.ts): `supabase/functions/grow-plant/index.ts`
- [Plant health scan](https://github.com/semina-by-mindframe/semina-backend/blob/main/supabase/functions/scan-plant/index.ts): `supabase/functions/scan-plant/index.ts`

### Data and Sensors

- [Supabase client](https://github.com/semina-by-mindframe/semina-backend/blob/main/src/services/supabaseClient.js): `src/services/supabaseClient.js`
- **Supabase data**
- [Sensor demo API](https://github.com/semina-by-mindframe/semina-backend/blob/main/sensor-demo.js): `sensor-demo.js`
- [Latest readings](https://github.com/semina-by-mindframe/semina-backend/blob/main/sensor-demo.js): `sensor-demo.js`

### Other components

- **Client**
- **OpenAI**
- **Gemini**
- **Sensor device**

## Connections

- Client → API server: HTTP requests
- API server → Express app: starts
- Express app → Plant routes: mounts
- Express app → Sensor routes: mounts
- Express app → AI routes: mounts
- Express app → Recommendations: mounts
- Express app → Reminders: mounts
- Express app → Plant logs: mounts
- Express app → System routes: mounts
- Plant routes → Supabase client: queries
- Reminders → Supabase client: queries
- Light matching → Supabase client: queries
- Supabase client → Supabase data: reads and writes
- Client → Plant chatbot: invokes
- Plant chatbot → Supabase data: reads and updates
- Plant chatbot → OpenAI: requests completion
- Client → Suggest and plan: invokes
- Suggest and plan → Gemini: requests suggestions
- Suggest and plan → Supabase data: saves care plan
- Client → Plant health scan: invokes
- Plant health scan → Gemini: analyzes image
- Plant health scan → Supabase data: saves scan
- Sensor device → Sensor demo API: posts readings
- Sensor demo API → Latest readings: stores latest
- Sensor demo API → Client: serves readings
