# lander414/coop-monitoring-system architecture

> Architecture diagram of the GitHub repository lander414/coop-monitoring-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lander414/coop-monitoring-system
- Repository: https://github.com/lander414/coop-monitoring-system

## Overview

This is a poultry-coop monitoring and stress-risk evaluator with a React dashboard and Express API. Users review live and historical telemetry, or submit a chicken image for visual analysis and a combined risk assessment. Sensor telemetry is separately received, scored for heat risk, and stored for dashboard retrieval. The sampled code shows these paths and the Supabase and Gemini integrations; the simulator and other unsampled modules are not expanded into inferred workflows.

Main entry points: [`poultry-backend/server.js`](https://github.com/lander414/coop-monitoring-system/blob/main/poultry-backend/server.js) (HTTP server), [`poultry-frontend/src/pages/Dashboard.tsx`](https://github.com/lander414/coop-monitoring-system/blob/main/poultry-frontend/src/pages/Dashboard.tsx) (Monitoring dashboard), [`poultry-frontend/src/services/api.ts`](https://github.com/lander414/coop-monitoring-system/blob/main/poultry-frontend/src/services/api.ts) (Frontend API client), [`poultry-backend/routes/telemetryRoutes.js`](https://github.com/lander414/coop-monitoring-system/blob/main/poultry-backend/routes/telemetryRoutes.js) (Telemetry routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_dashboard["Monitoring dashboard<br/>[Dashboard.tsx]"]
  node_app["App shell<br/>[App.tsx]"]
  node_entry["Frontend entry<br/>[main.tsx]"]
  node_animation["Status animation"]
  node_types["Monitoring types<br/>[monitoring.ts]"]
end

subgraph group_api["API"]
  node_frontend_api["Frontend API client<br/>[api.ts]"]
  node_server["HTTP server<br/>[server.js]"]
  node_telemetry["Telemetry routes<br/>[telemetryRoutes.js]"]
end

subgraph group_assessment["Risk assessment"]
  node_uploads[("Image uploads")]
  node_ai["Image analysis<br/>[aiService.js]"]
  node_risk["Combined risk engine<br/>[riskEngine.js]"]
end

subgraph group_integrations["External services"]
  node_supabase[("Supabase telemetry store")]
  node_gemini["Google Gemini"]
end

node_user(("Coop operator"))
node_sensor(("Coop sensor"))

node_user -->|"views and submits"| node_dashboard
node_entry -->|"renders"| node_app
node_app -->|"renders"| node_dashboard
node_dashboard -->|"requests data and evaluation"| node_frontend_api
node_dashboard -->|"renders status"| node_animation
node_dashboard -->|"uses types"| node_types
node_animation -->|"uses risk type"| node_types
node_frontend_api -->|"uses response types"| node_types
node_frontend_api -->|"calls API"| node_server
node_sensor -->|"posts readings"| node_telemetry
node_server -->|"mounts routes"| node_telemetry
node_telemetry -->|"reads and writes"| node_supabase
node_server -->|"stores images"| node_uploads
node_server -->|"analyzes uploaded image"| node_ai
node_server -->|"calculates assessment"| node_risk
node_ai -->|"requests image analysis"| node_gemini

click node_dashboard "https://github.com/lander414/coop-monitoring-system/blob/main/poultry-frontend/src/pages/Dashboard.tsx"
click node_app "https://github.com/lander414/coop-monitoring-system/blob/main/poultry-frontend/src/App.tsx"
click node_entry "https://github.com/lander414/coop-monitoring-system/blob/main/poultry-frontend/src/main.tsx"
click node_animation "https://github.com/lander414/coop-monitoring-system/blob/main/poultry-frontend/src/components/ChickenStatusAnimation.tsx"
click node_types "https://github.com/lander414/coop-monitoring-system/blob/main/poultry-frontend/src/types/monitoring.ts"
click node_frontend_api "https://github.com/lander414/coop-monitoring-system/blob/main/poultry-frontend/src/services/api.ts"
click node_server "https://github.com/lander414/coop-monitoring-system/blob/main/poultry-backend/server.js"
click node_telemetry "https://github.com/lander414/coop-monitoring-system/blob/main/poultry-backend/routes/telemetryRoutes.js"
click node_uploads "https://github.com/lander414/coop-monitoring-system/tree/main/poultry-backend/uploads"
click node_ai "https://github.com/lander414/coop-monitoring-system/blob/main/poultry-backend/services/aiService.js"
click node_risk "https://github.com/lander414/coop-monitoring-system/blob/main/poultry-backend/services/riskEngine.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_dashboard,node_app,node_entry,node_animation,node_types toneBlue
class node_frontend_api,node_server,node_telemetry toneAmber
class node_uploads,node_ai,node_risk toneMint
class node_supabase,node_gemini toneRose
class node_user,node_sensor toneIndigo
```

## Components

### Dashboard

- [Monitoring dashboard](https://github.com/lander414/coop-monitoring-system/blob/main/poultry-frontend/src/pages/Dashboard.tsx): `poultry-frontend/src/pages/Dashboard.tsx`
- [App shell](https://github.com/lander414/coop-monitoring-system/blob/main/poultry-frontend/src/App.tsx): `poultry-frontend/src/App.tsx`
- [Frontend entry](https://github.com/lander414/coop-monitoring-system/blob/main/poultry-frontend/src/main.tsx): `poultry-frontend/src/main.tsx`
- [Status animation](https://github.com/lander414/coop-monitoring-system/blob/main/poultry-frontend/src/components/ChickenStatusAnimation.tsx): `poultry-frontend/src/components/ChickenStatusAnimation.tsx`
- [Monitoring types](https://github.com/lander414/coop-monitoring-system/blob/main/poultry-frontend/src/types/monitoring.ts): `poultry-frontend/src/types/monitoring.ts`

### API

- [Frontend API client](https://github.com/lander414/coop-monitoring-system/blob/main/poultry-frontend/src/services/api.ts): `poultry-frontend/src/services/api.ts`
- [HTTP server](https://github.com/lander414/coop-monitoring-system/blob/main/poultry-backend/server.js): `poultry-backend/server.js`
- [Telemetry routes](https://github.com/lander414/coop-monitoring-system/blob/main/poultry-backend/routes/telemetryRoutes.js): `poultry-backend/routes/telemetryRoutes.js`

### Risk assessment

- [Image uploads](https://github.com/lander414/coop-monitoring-system/tree/main/poultry-backend/uploads): `poultry-backend/uploads`
- [Image analysis](https://github.com/lander414/coop-monitoring-system/blob/main/poultry-backend/services/aiService.js): `poultry-backend/services/aiService.js`
- [Combined risk engine](https://github.com/lander414/coop-monitoring-system/blob/main/poultry-backend/services/riskEngine.js): `poultry-backend/services/riskEngine.js`

### External services

- **Supabase telemetry store**
- **Google Gemini**

### Other components

- **Coop operator**
- **Coop sensor**

## Connections

- Coop operator → Monitoring dashboard: views and submits (evidence: `poultry-frontend/src/pages/Dashboard.tsx`)
- Frontend entry → App shell: renders (evidence: `poultry-frontend/src/main.tsx`)
- App shell → Monitoring dashboard: renders (evidence: `poultry-frontend/src/App.tsx`)
- Monitoring dashboard → Frontend API client: requests data and evaluation (evidence: `poultry-frontend/src/pages/Dashboard.tsx`)
- Monitoring dashboard → Status animation: renders status (evidence: `poultry-frontend/src/pages/Dashboard.tsx`)
- Monitoring dashboard → Monitoring types: uses types (evidence: `poultry-frontend/src/pages/Dashboard.tsx`)
- Status animation → Monitoring types: uses risk type (evidence: `poultry-frontend/src/components/ChickenStatusAnimation.tsx`)
- Frontend API client → Monitoring types: uses response types (evidence: `poultry-frontend/src/services/api.ts`)
- Frontend API client → HTTP server: calls API (evidence: `poultry-frontend/src/services/api.ts`)
- Coop sensor → Telemetry routes: posts readings (evidence: `poultry-backend/routes/telemetryRoutes.js`)
- HTTP server → Telemetry routes: mounts routes (evidence: `poultry-backend/server.js`)
- Telemetry routes → Supabase telemetry store: reads and writes (evidence: `poultry-backend/routes/telemetryRoutes.js`)
- HTTP server → Image uploads: stores images (evidence: `poultry-backend/server.js`)
- HTTP server → Image analysis: analyzes uploaded image (evidence: `poultry-backend/server.js`)
- HTTP server → Combined risk engine: calculates assessment (evidence: `poultry-backend/server.js`)
- Image analysis → Google Gemini: requests image analysis (evidence: `poultry-backend/services/aiService.js`)
