Skip to content

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

  1. Identification: The user opens the Flutter App and shows their QR Code to the ESP32-CAM on the kiosk.
  2. Authentication: The Kiosk sends a request to the API to verify the user.
  3. Detection: The user drops a bottle. The IR sensor detects the object, and the Inductive sensor checks if it's metal.
  4. Action: If it's a valid item, the Servo motor opens the bin.
  5. Recording: The Kiosk sends a POST request to the /kiosk/transaction endpoint of the PHP API.
  6. Update: The API talks to Firestore to increment the user's points and the kiosk's "fill level".
  7. Notification: The API triggers a Push Notification via FCM to tell the user "You just earned 10 points!".
  8. Feedback: The user's app refreshes automatically to show the new point balance.

Admin Flow: Hardware Configuration

  1. Discovery: Admin app scans for kiosks using Bluetooth Low Energy (BLE).
  2. Handshake: App connects to the REward-Kiosk BLE server.
  3. Provisioning: Admin writes WiFi credentials and API keys wirelessly.
  4. 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.