royal-a

byAkhil Adari

Build a production-ready IoT + AI platform for Spirulina raceway pond cultivation. IMPORTANT: This is NOT just a pilot dashboard. Start with a prototype, but design the architecture for REAL-TIME operation of 2 commercial raceway ponds after validation, with future scaling to many ponds and farms without rebuilding the core system. GOAL Build an "AI Spirulina Cultivation Intelligence Platform": Sensors → IoT Gateway → Internet → FastAPI → PostgreSQL → AI → Safety Engine → React Dashboard → Alerts → Human Approval → Future Automation. Initial deployment: - 1 farm - 2 raceway ponds - Independent sensors/data for each pond - Real-time monitoring - AI prediction/recommendations - Alerts - Human override - Future equipment control HARDWARE Each pond should support: - pH - Water temperature - EC/conductivity - Dissolved oxygen (DO) - Light intensity - Water level Future-ready: - ORP - Flow rate - Aerator/pump status - Weather - Ambient temperature/humidity - Solar radiation - Rainfall - Biomass/optical density - Nutrient/dosing data Use ESP32-S3 or industrial IoT gateway. Prefer RS485/Modbus or 4–20mA for industrial sensors. Avoid long analog wiring where possible. Include: - IP-rated enclosure - Waterproof connectors - Surge protection - Electrical isolation - Stable power - Backup power - Watchdog - Local data storage - OTA firmware updates - Future solar support Make sensor sampling and transmission intervals configurable. DATA FLOW Pond sensors → ESP32/IoT Gateway → MQTT/HTTPS → FastAPI → Data validation → PostgreSQL/TimescaleDB → Real-time events → React dashboard → AI engine → Safety engine → Alerts/recommendations → Future equipment control If internet fails, the gateway must continue collecting data locally and synchronize when connectivity returns. DATABASE Design schemas for: Organizations, Farms, Ponds, Devices, Sensors, Sensor Readings, Calibration, Sensor Health, Cultivation Batches, Strains, Water Characteristics, Nutrients, Weather, Biomass, Harvests, Protein %, Phycocyanin, AI Predictions, AI Recommendations, Alerts, Safety Thresholds, Human Approvals, Equipment, Automation Events and Audit Logs. Every reading must contain: farm_id, pond_id, device_id, sensor_id, timestamp, value, unit and quality status. DATA QUALITY Never assume sensor data is correct. Detect: - Missing readings - Disconnected sensors - Stuck values - Impossible values - Spikes/drops - Calibration drift - Communication failure - Abnormal rate of change - Out-of-range values Status: VALID / SUSPECT / INVALID / MISSING / CALIBRATION_REQUIRED. AI must not use invalid/suspicious readings. CALIBRATION Store: sensor ID, installation date, calibration date, calibration method/reference, result, next calibration date and calibration history. Show calibration reminders. SAFETY ENGINE AI must NEVER directly control equipment. For important parameters create configurable: - Optimal range - Warning range - Critical range - Absolute minimum - Absolute maximum - Maximum rate of change Values must be scientifically validated. Architecture: Sensor → Validation → AI → Safety Engine → Human Approval/Automation → Equipment If an absolute limit is reached: - Stop automation - Critical alert - Notify human - Require human inspection - Log the event AI cannot override safety limits. AI Do NOT create a completely separate model for every customer. Use: Scientific/Foundation Model + Farm-specific calibration + Farm historical data Inputs can include: pH, temperature, EC, DO, light, weather, water chemistry, nutrients, strain, pond geometry, biomass and cultivation history. Outputs: - Growth prediction - Biomass prediction - Productivity prediction - Risk prediction - Trend prediction - Recommendations - Confidence score Use: published scientific literature + controlled experiments + pilot data + customer farm data. For a new farm/climate with limited data: - Use scientific baseline - Show confidence - Start in Shadow Mode - Collect actual results - Compare prediction vs actual - Gradually calibrate to the farm - Detect conditions outside the validated model domain Never make high-confidence predictions outside validated conditions. SHADOW MODE AI predicts/recommends but does not control equipment. Store: Prediction → Actual result → Error → Model performance. Only after validation should human-approved recommendations or automation be enabled. DASHBOARD Use React + TypeScript + Material UI. Farm Overview: Pond 1 and Pond 2 with: - pH - Temperature - EC - DO - Light - Water level - Biomass if available - Current batch - Sensor health - AI confidence - Alerts Status: GREEN = optimal YELLOW = warning ORANGE = critical RED = unsafe GREY = unavailable Pond Detail page: - Real-time values - 24h/7d/30d charts - Historical batches - pH - Temperature - EC - DO - Light - Biomass - Growth - Weather Allow Pond 1 vs Pond 2 comparison. AI INSIGHTS Show: "pH has increased for 6 hours." "Current trend may enter warning zone in approximately X hours." "Predicted biomass growth: X%." "Confidence: X%." "Recommended action: Review cultivation conditions." Clearly distinguish measured data from predictions. ALERTS Support dashboard + email, with future SMS/WhatsApp/mobile support. Levels: INFO / WARNING / CRITICAL / EMERGENCY Alert for: - Parameter approaching limit - Rapid change - Sensor failure - Calibration due - Internet failure - Low AI confidence - Predicted safety-limit crossing HUMAN-IN-THE-LOOP For each AI recommendation show: Current value, trend, prediction, confidence, recommendation and reason. Actions: APPROVE / REJECT / SNOOZE / REQUEST REVIEW Record user, timestamp, action, reason and outcome. FUTURE AUTOMATION Support future: - Aerators - Pumps - Valves - Dosing pumps - Mixing systems Architecture: AI → Safety Engine → Human Approval → Control Gateway → PLC/Relay → Equipment Keep automation disabled initially. TWO-POND ARCHITECTURE Pond 1 and Pond 2 must have independent: - Sensor IDs - Devices - Data streams - Cultivation batches - Alerts - AI predictions - History Allow comparison of growth, productivity, environmental conditions and outcomes. MULTI-FARM READY Design as multi-tenant SaaS: Organization → Farm → Ponds → Gateways → Sensors Roles: Super Admin, Farm Owner, Manager, Operator, Scientist, Viewer. Implement tenant isolation and RBAC. DEVICE MANAGEMENT Show: Device ID, online/offline, heartbeat, firmware, signal, power, sensor status, synchronization and errors. Support registration, configuration, sampling intervals and OTA firmware. OFFLINE MODE Gateway stores readings locally during internet failure and synchronizes later. Show last synchronization time. TECHNOLOGY Frontend: React + TypeScript + Material UI + Recharts/Chart.js Backend: Python + FastAPI + Pydantic + SQLAlchemy Database: PostgreSQL + TimescaleDB IoT: ESP32-S3/industrial gateway + RS485/Modbus + MQTT/HTTPS Infrastructure: Docker/Docker Compose initially; cloud-ready. AI: Python + scikit-learn initially, PyTorch when needed, MLflow. Do not introduce Kubernetes initially. SECURITY JWT, RBAC, tenant isolation, HTTPS, device authentication, secure credentials, validation, rate limiting and audit logs. Devices must not submit data for another farm. DEVELOPMENT 1. Architecture/database/auth 2. ESP32 + temperature + pH + EC 3. FastAPI ingestion 4. React dashboard 5. Two-pond system 6. Add DO/light/water level 7. Data-quality/calibration 8. Scientific dataset 9. AI prediction 10. Shadow Mode 11. Human-approved recommendations 12. Optional automation REQUIRED OUTPUT Create a practical engineering blueprint containing: 1. System architecture 2. Hardware architecture 3. Exact sensor recommendations 4. ESP32/gateway design 5. Wiring 6. Power/network architecture 7. MQTT topics 8. FastAPI structure 9. Database schema 10. API design 11. React structure 12. Real-time architecture 13. AI architecture 14. Safety Engine 15. Alerts 16. Human approval 17. Calibration 18. Offline synchronization 19. Two-pond deployment 20. Multi-farm SaaS architecture 21. Security 22. Docker deployment 23. Development roadmap 24. Prototype/pilot/production BOM and INR cost 25. Testing strategy 26. Sensor validation 27. AI validation 28. Failure/recovery scenarios 29. Scaling: 2 → 10 → 100 ponds → multiple farms 30. Commercialization plan Clearly distinguish PROTOTYPE, PILOT and PRODUCTION components. The architecture must be practical for a small engineering team and must NOT need to be rebuilt when moving from prototype to 2 real commercial raceway ponds.

Landing
Landing

Comments (0)

No comments yet. Be the first!

System Requirements

System Requirement Document
Page 1 of 6

System Requirements Document for Royal-A

1. Introduction

Royal-A is an AI Spirulina Cultivation Intelligence Platform designed to facilitate the real-time operation and monitoring of Spirulina raceway ponds. The platform is intended to support the cultivation of Spirulina by providing real-time data analytics, AI-driven insights, and future automation capabilities. The project aims to start with a prototype and scale to a production-ready system capable of managing multiple ponds and farms.

2. System Overview

The Royal-A platform is designed to integrate IoT and AI technologies to optimize Spirulina cultivation. It will initially support one farm with two raceway ponds, each equipped with independent sensors for real-time monitoring. The system architecture is built to scale, allowing for future expansion to multiple ponds and farms without the need for core system redevelopment.

Key Components:

  • IoT Sensors: Collect data on pH, water temperature, EC, dissolved oxygen, light intensity, and water level.
  • IoT Gateway: ESP32-S3 or industrial gateway for data transmission.
  • Backend: Python with FastAPI and PostgreSQL/TimescaleDB for data storage and processing.
  • AI Engine: Provides predictions and recommendations based on scientific models and farm-specific data.
  • Safety Engine: Ensures AI recommendations do not exceed safety thresholds.
  • React Dashboard: Displays real-time data, AI insights, and alerts for human approval.
  • Future Automation: Planned integration for equipment control.
Page 2 of 6

3. Functional Requirements as Story Points

  • As a Farm Owner, I should be able to monitor real-time data from each pond.
  • As a Scientist, I should be able to receive AI-driven predictions and recommendations.
  • As an Operator, I should be able to receive alerts for any critical conditions.
  • As a Manager, I should be able to compare data between Pond 1 and Pond 2.
  • As a Super Admin, I should be able to manage multi-farm operations with tenant isolation.
  • As a Viewer, I should be able to view the dashboard with read-only access.
  • As a Scientist, I should be able to validate sensor data and calibration status.
  • As a Farm Owner, I should be able to approve or reject AI recommendations.
  • As an Operator, I should be able to configure sensor sampling and transmission intervals.
  • As a Manager, I should be able to receive notifications for calibration reminders.
  • As a Farm Owner, I should be able to manage device registration and configuration.
  • As a Scientist, I should be able to analyze historical data and trends.
  • As a Super Admin, I should be able to ensure secure access control and data integrity.

4. User Personas

  • Super Admin: Oversees the entire platform, manages multi-farm operations, and ensures security.
  • Farm Owner: Manages farm operations, approves AI recommendations, and oversees cultivation.
  • Manager: Manages daily operations, compares pond data, and handles alerts.
  • Operator: Monitors real-time data, responds to alerts, and manages sensor configurations.
  • Scientist: Analyzes data, validates sensor readings, and ensures calibration accuracy.
  • Viewer: Accesses the dashboard for informational purposes without editing capabilities.
Page 3 of 6

5. Core User Flows

  • Data Collection: Sensors collect data → IoT Gateway transmits data → FastAPI ingests data → PostgreSQL stores data.
  • AI Insights: Data processed → AI engine generates predictions → Safety engine validates → Dashboard displays insights.
  • Alert Management: Condition detected → Alert generated → Dashboard/email notification → Human approval required.
  • Calibration: Sensor calibration due → Reminder sent → Calibration performed → Status updated.
  • Device Management: Device registered → Configuration set → Data transmission monitored → OTA updates applied.

6. Visuals Colors and Theme

  • primary: #00796B (Teal)
  • primary_light: #48A999 (Light Teal)
  • secondary: #FFC107 (Amber)
  • accent: #FF5722 (Deep Orange)
  • highlight: #FFEB3B (Yellow)
  • bg: #F5F5F5 (Light Grey)
  • surface: #FFFFFF (White)
  • text: #212121 (Dark Grey)
  • text_muted: #757575 (Grey)
  • border: #BDBDBD (Light Grey)

7. Signature Design Concept

Page 4 of 6

Interactive Pond Ecosystem

The landing page will feature an interactive 3D model of a Spirulina raceway pond ecosystem. Users can click on different parts of the pond to reveal real-time data, AI insights, and alerts. The pond will have animated water flow, changing light conditions, and dynamic sensor readings. The design will use @react-three/fiber and @react-three/drei for 3D interactions, with motion/react for smooth transitions.

LANDING HERO MOTION BRIEF

The hero section will depict a Spirulina cultivation process where sensors gather data around a central pond model. As data is collected, the pond's color and animation change to reflect real-time conditions. The animation will loop every 10 seconds, showing the transformation from data collection to AI-driven insights. The scene will be responsive, with reduced motion for accessibility.

8. Interaction Model & Motion Direction

  • Intended Interaction Model: Parallax
  • Description: The landing page will feature layered depth with scroll-triggered animations. Real content will remain in normal flow, while decorative layers will translate at different speeds to create a visually rich first impression.
Page 5 of 6

9. Non-Functional Requirements

  • Scalability: The system must support scaling from 2 to 100 ponds and multiple farms.
  • Reliability: Ensure 99.9% uptime for real-time monitoring.
  • Performance: Data ingestion and processing must occur within 5 seconds.
  • Security: Implement JWT, RBAC, and HTTPS for secure access.
  • Usability: The dashboard should be intuitive and accessible to all user personas.
  • Maintainability: The system should support OTA updates and modular component upgrades.

10. Tech Stack

  • Frontend: React, TypeScript, Material UI, Recharts/Chart.js
  • Backend: Python, FastAPI, Pydantic, SQLAlchemy
  • Database: PostgreSQL, TimescaleDB
  • IoT: ESP32-S3/industrial gateway, RS485/Modbus, MQTT/HTTPS
  • Infrastructure: Docker/Docker Compose
  • AI: Python, scikit-learn, PyTorch, MLflow

11. Assumptions and Constraints

  • The system will initially support one farm with two ponds.
  • Sensor data will be transmitted via MQTT/HTTPS.
  • AI models will be based on scientific literature and farm-specific data.
  • Automation will be disabled initially and require human approval.
  • The platform will be developed with a small engineering team in mind.
Page 6 of 6

12. Glossary

  • AI: Artificial Intelligence
  • EC: Electrical Conductivity
  • DO: Dissolved Oxygen
  • RBAC: Role-Based Access Control
  • OTA: Over-The-Air
  • PLC: Programmable Logic Controller
  • SaaS: Software as a Service

This document outlines the comprehensive requirements for the Royal-A platform, ensuring a scalable, secure, and efficient solution for Spirulina cultivation.

Landing design preview
Landing: View Info
Login: Sign In
Dashboard: View Farm Overview
Pond Detail: View Pond 1
Pond Detail: View Pond 2
Recommendations: Review AI Suggestion
Recommendations: Approve Action
Devices: Manage Registration
Devices: Configure Settings
Alerts: View Alerts
Reports: View Batch History
Landing design preview
Landing: View Info
Login: Sign In
Dashboard: View Farm Overview
Pond Detail: View Pond 1
Pond Detail: View Pond 2
Recommendations: Review AI Suggestion
Recommendations: Approve Action
Devices: Manage Registration
Devices: Configure Settings
Alerts: View Alerts
Reports: View Batch History