TerraFlow Platform is an intelligent IoT solution designed for precision agriculture and environmental monitoring. It features a robust Direct-to-Cloud architecture where ESP32 sensor nodes communicate directly with Firebase Realtime Database, ensuring instant data synchronization. The system combines a high-performance Go (Gin) backend for configuration management with a modern Next.js 14 frontend for real-time visualization and remote control of actuators like pumps and servos.
Tech Stack
Next.js
Go
Gin
Firebase
Docker
ESP32
C++
React
Tailwind CSS
Tools Used
VS Code
Docker
Firebase Console
PlatformIO
Key Features
🤖 Smart Firmware (ESP32)
▸Direct HTTP Communication: Efficient data transmission using `HTTPClient.h` directly to Firebase REST API.
▸Smart Control Logic: Automated actuation of pumps and servos based on real-time sensor readings.
▸Robust Connectivity: Built-in auto-reconnect and retry mechanisms to handle unstable field networks.
🖥️ Modern Dashboard
▸Real-time Visualization: Dynamic charts using `recharts` that update instantly with Firebase data.
▸Interactive Control: Remote manual overrides for field actuators directly from the UI.
▸Responsive Design: Built with Next.js 14 and Tailwind CSS for optimal experience on all devices.
⚡ High-Performance Backend
▸Go (Gin) Server: Ultra-fast API for centralized configuration management.
▸Secure Distribution: Safe delivery of Firebase credentials to authenticated clients.
▸Health Monitoring: Dedicated endpoints for container and service status checks.
☁️ Direct-to-Cloud Architecture
▸Zero-Gateway Latency: Edge devices write directly to the cloud, bypassing intermediate gateways for millisecond-level updates.
▸Scalable Infrastructure: Containerized deployment with Docker ensures consistent environments across development and production.
▸Firebase Sync: Leverages Firebase Realtime Database for instant state synchronization between hardware and all connected clients.
Highlights
Direct-to-Cloud Architecture
Real-time Monitoring
Go High-Performance API
Installation
Environment Setup
PORT=8080
ALLOWED_ORIGINS=http://localhost:3000
FIREBASE_API_KEY=your_key
# Add other Firebase credentials
Deploy with Docker
cd deployments
docker-compose up -d --build
Challenges & Solutions
Challenge
Unstable Field Connectivity
Solution
Implemented a robust state machine in C++ firmware with exponential backoff retries and auto-reconnection logic to ensure zero data loss during network interruptions.
Challenge
Real-time Latency
Solution
Adoption of a Direct-to-Cloud architecture where edge devices bypass intermediate gateways and write directly to Firebase, reducing latency to milliseconds.
Challenge
Secure Config Management
Solution
Developed a centralized Go (Gin) backend service to manage and distribute sensitive configuration and credentials securely, decoupling them from the frontend code.