How abdullah0991/smart-farm-iot works
This is an Expo mobile app for monitoring farm devices and their environmental telemetry. The main flow is sign-in, load or claim devices, inspect device snapshots and connectivity, then open sensor history with live MQTT updates. Separate branches cover device naming/region management, LED commands, authentication recovery, and persisted language/theme preferences. The graph follows the README and source-index references; unsampled implementations are represented only where documented, and uncertain relationships are omitted.
Main entry points: index.tsx Device dashboard · [sensor].tsx Sensor detail screen · mqttClient.ts MQTT subscriber · apiClient.ts Backend API client
Components 30
App experience
- Sign in
src/app/login.tsx - Device dashboard
src/app/index.tsx - Status badge
src/components/DeviceConnectionBadge.tsx - Sensor detail screen
src/app/sensor/[mac]/[sensor].tsx - History chart
src/components/SensorHistoryChart.tsx - LED control
src/components/LedControl.tsx
Device management
- Device actions
src/store/useDeviceStore.ts - Claim device
src/app/add-device.tsx - Device details
src/app/device/[mac].tsx - Connectivity status
src/utils/deviceConnectivity.ts - Weather data model
src/types/weather.ts
Telemetry and history
- MQTT subscriber
src/services/mqttClient.ts - Telemetry decoder
src/services/deviceTelemetry.ts - Live telemetry state
src/store/useLiveTelemetryStore.ts - Sensor state
src/store/useSensorStore.ts - Sensor definitions
src/constants/sensors.ts - History and live merge
src/hooks/useSensorHistory.ts - History timeline
src/utils/sensorTimeline.ts - Reading interpretation
src/utils/sensorDetails.ts - MQTT publisher
src/services/mqttPublisher.ts
Shared platform
- Authentication state
src/store/useAuthStore.ts - Session token
src/services/authToken.ts - Backend API client
src/services/apiClient.ts - Language preference
src/store/useLanguageStore.ts - Translation catalogs
src/i18n/translations.ts - Theme preference
src/store/useThemeStore.ts - Theme definitions
src/theme/themes.ts
Other components
- Farm user
- Application backend
- MQTT broker
Connections 37
- Farm user → Sign in: signs in
src/app/login.tsx - Sign in → Authentication state: submits credentials
src/app/login.tsx - Authentication state → Backend API client: validates session
src/store/useAuthStore.ts - Authentication state → Session token: persists token
src/store/useAuthStore.ts - Farm user → Device dashboard: views devices
README.md - Device dashboard → Device actions: refreshes devices
src/app/index.tsx - Device actions → Backend API client: fetches and updates
src/store/useDeviceStore.ts - Backend API client → Application backend: requests data
src/services/apiClient.ts - Farm user → Claim device: claims device
README.md - Claim device → Device actions: claims device
src/app/add-device.tsx - Farm user → Device details: opens device
README.md - Device details → Device actions: reads device state
src/app/device/[mac].tsx - Device dashboard → Status badge: shows status
src/app/index.tsx - Device details → Status badge: shows status
src/app/device/[mac].tsx - Status badge → Connectivity status: derives state
src/components/DeviceConnectionBadge.tsx - Device dashboard → Backend API client: loads snapshots
src/app/index.tsx - Device dashboard → Live telemetry state: prefers newer readings
README.md - MQTT subscriber → MQTT broker: subscribes
src/services/mqttClient.ts - MQTT subscriber → Telemetry decoder: decodes messages
src/services/mqttClient.ts - MQTT subscriber → Live telemetry state: records telemetry
src/services/mqttClient.ts - MQTT subscriber → Sensor state: updates legacy readings
src/services/mqttClient.ts - Farm user → Sensor detail screen: opens history
README.md - Sensor detail screen → History and live merge: loads timeline
src/app/sensor/[mac]/[sensor].tsx - History and live merge → Backend API client: requests history
src/hooks/useSensorHistory.ts - History and live merge → Live telemetry state: buffers live packets
src/hooks/useSensorHistory.ts - History and live merge → History timeline: builds timeline
src/hooks/useSensorHistory.ts - Sensor detail screen → History chart: renders chart
src/app/sensor/[mac]/[sensor].tsx - History chart → History timeline: plots buckets
src/components/SensorHistoryChart.tsx - Sensor detail screen → Reading interpretation: interprets readings
src/app/sensor/[mac]/[sensor].tsx - Sensor detail screen → Live telemetry state: reads live state
src/app/sensor/[mac]/[sensor].tsx - Sensor state → Sensor definitions: initializes readings
src/store/useSensorStore.ts - Farm user → LED control: controls LED
README.md - LED control → MQTT subscriber: publishes command
src/components/LedControl.tsx - Farm user → Language preference: chooses language
README.md - Language preference → Translation catalogs: selects catalog
src/i18n/index.ts - Farm user → Theme preference: chooses appearance
README.md - Theme preference → Theme definitions: uses definitions
src/store/useThemeStore.ts