Ecosystem Overview 🌐
This page explains the technical flow of how data moves through the REward system.
The Architecture Map
graph TD
User((User)) -->|Uses| App[Flutter Mobile App]
App -->|Reads/Writes| Firebase[(Firebase Firestore)]
App -->|Authenticates| Auth[Firebase Auth]
App -.->|Bluetooth Config| Kiosk[ESP32 Kiosk]
Kiosk -->|Scans QR| User
Kiosk -->|Detects Item| Sensors[Sensors: IR/Inductive]
Kiosk -->|POST Transaction| API[PHP REST API]
API -->|Updates Points| Firebase
API -->|Sends Alert| FCM[Firebase Cloud Messaging]
FCM -->|Push Notification| App
Data Journey: A Recycling Session
- Identification: The user opens the Flutter App and shows their QR Code to the ESP32-CAM on the kiosk.
- Authentication: The Kiosk sends a request to the API to verify the user.
- Detection: The user drops a bottle. The IR sensor detects the object, and the Inductive sensor checks if it's metal.
- Action: If it's a valid item, the Servo motor opens the bin.
- Recording: The Kiosk sends a
POSTrequest to the/kiosk/transactionendpoint of the PHP API. - Update: The API talks to Firestore to increment the user's points and the kiosk's "fill level".
- Notification: The API triggers a Push Notification via FCM to tell the user "You just earned 10 points!".
- Feedback: The user's app refreshes automatically to show the new point balance.
Admin Flow: Hardware Configuration
- Discovery: Admin app scans for kiosks using Bluetooth Low Energy (BLE).
- Handshake: App connects to the
REward-KioskBLE server. - Provisioning: Admin writes WiFi credentials and API keys wirelessly.
- Persistence: ESP32 saves config to NVS (Flash) and reboots to apply.
Key Technologies
| Component | Technology | Why? |
|---|---|---|
| Frontend | Flutter | Cross-platform (Android/iOS) with one codebase. |
| Backend | PHP 8.x | Lightweight, easy to host, and fast for REST API. |
| Database | Firestore | NoSQL, real-time sync, and scales automatically. |
| Hardware | ESP32-S | Dual-core with Wi-Fi and BLE for wireless config. |
| Communication | REST & BLE | Standard protocols for web and local configuration. |