How duokhang1676/smart-shelf-cs17iuh works
Purpose and System Shape
Smart Vending Shelf is an IoT retail system for weight-based inventory tracking, customer/behavior detection, QR payment, and unpaid-item alerts. It is a multi-runtime monorepo: embedded BLE sensor firmware, Jetson edge software, cloud API/MQTT integration, browser management dashboard, and Android staff app. Primary top-level guidance: README.md, projects/README.md.
Edge Runtime: Shelf Controller
The Jetson-hosted Python application is the physical-system coordinator. Its entry point is projects/local_server/main.py, with Flask/web-server setup in projects/local_server/app/webserver.py. Route modules expose local UI/API, payment/webhook, Wi-Fi, load-cell, debug, and WebSocket endpoints: projects/local_server/app/routes/.
It persists operational shelf/product/RFID/payment data as local JSON files under projects/local_server/database/, establishing an offline/local boundary before cloud synchronization.
Device and Perception Pipeline
The edge layer ingests:
• BLE/load-cell quantity updates and reconciliation through projects/local_server/app/modules/update_loadcell_quantity.py and projects/local_server/app/modules/quantity_change_monitor.py.
• RFID identity/state through projects/local_server/app/modules/listen_rfid.py and projects/local_server/app/modules/rfid_state_monitor.py.
• Camera detection and SORT tracking through projects/local_server/app/modules/detector/ and projects/local_server/app/modules/tracking_customer_behavior.py.
• UART-connected XG26 sensor and voice-command processing through projects/local_server/app/modules/xg26_sensor.py and projects/local_server/app/modules/voice_command_monitor.py.
These signals drive inventory changes, cart/payment state, customer tracking, local alerts/UI, and cloud events.
Cloud Backend and External Boundaries
The Node.js/Express backend starts via projects/cloud_server/smart-shelf-server-backend/app.js and projects/cloud_server/smart-shelf-server-backend/bin/www. It separates HTTP routes, controllers, and MongoDB-style domain models in:
projects/cloud_server/smart-shelf-server-backend/src/routes/,
projects/cloud_server/smart-shelf-server-backend/src/controller/,
projects/cloud_server/smart-shelf-server-backend/src/model/.
Cloud boundaries include MongoDB Atlas, an MQTT broker, Cloudinary uploads, and SEPAY payment/webhooks, configured or represented in src/config/database.js, src/config/mqtt.js, and src/config/cloudinary.js. Authentication is enforced at the API middleware boundary in src/middleware/auth.js.
Management Dashboard
The Vite/React dashboard begins at projects/cloud_server/smart-shelf-server-frontend/src/main.jsx, with application composition in src/App.jsx. Pages manage shelves, products, receipts/orders, tasks, history, notifications, posters, users, and payment configuration under src/pages/. Service modules are the REST boundary to the cloud backend, e.g. src/service/shefl.service.ts, src/service/product.service.ts, and src/service/receipt.service.ts.
The dashboard also has a direct MQTT client path for live operational data: src/lib/mqttClient.ts and src/lib/useMqtt.ts, consumed by realtime shelf components such as src/components/ShelfRealtimePanel.tsx.
Android Staff Client
The native Android app is a separate staff-facing client, with shell entry activities at projects/mobile_app/Android.IOT_Mobile_App/app/src/main/java/com/example/iot_employee_android/MainActivity.java and LoginActivity.java. It calls cloud auth/shelf APIs through api/AuthApi.java and api/ShelfApi.java, presents shelf and history workflows, and includes local Bluetooth/socket facilities (bluetooth/BluetoothManager.java, SocketService.java). Its role is monitoring and operational access rather than edge control.
Embedded Firmware and Hardware Boundary
Silicon Labs firmware projects target the physical peripherals:
• BGM220 load-cell/HX711/LCD device: projects/silabs-firmware-edge-device/app/bt_soc_bgm220_loadcell/main.c, hx711.c, ble.c.
• EFR32xG26 BLE environmental sensor device: projects/silabs-firmware-edge-device/app/bt_soc_xg26_sensor/main.c, advertise.c, and driver/.
• XG26 audio capture/keyword classification: app/i2s_mic_xg26_audio_data_capture/main.c and app/ml_xg26_audio_classifier/audio_classifier.cc.
BLE is the MCU-to-Jetson boundary; UART is used for XG26 command reception. Silicon Labs bootloader projects provide device update infrastructure under projects/silabs-firmware-edge-device/bootloader/.
Main entry points: update_loadcell_quantity.py Device Signal Processing · app.js Cloud API Server · webserver.py Local Web and API · main.py Shelf Controller
Components 19
Embedded Firmware
- BGM220 Load-Cell Firmware · Reads HX711 and publishes BLE data.
projects/silabs-firmware-edge-device/app/bt_soc_bgm220_loadcell/main.c - XG26 Sensor Firmware · BLE environmental sensor device.
projects/silabs-firmware-edge-device/app/bt_soc_xg26_sensor/main.c - XG26 Audio Classifier · Captures audio and classifies keywords.
projects/silabs-firmware-edge-device/app/ml_xg26_audio_classifier/audio_classifier.cc - Device Bootloaders
Jetson Edge Runtime
- Shelf Controller · Coordinates local physical shelf operations.
projects/local_server/main.py - Local Web and API · Hosts local UI, APIs, webhooks, and WebSockets.
projects/local_server/app/webserver.py - Device Signal Processing · Reconciles load-cell, RFID, camera, tracking, sensor, and voice signals.
projects/local_server/app/modules/update_loadcell_quantity.py - Local Shelf Store · Offline shelf, product, RFID, and payment state.
Cloud Backend
- Cloud API Server · Cloud API and MQTT integration entry point.
projects/cloud_server/smart-shelf-server-backend/app.js - HTTP Routes
- Domain Controllers
- Domain Models
Staff Clients
- Management Dashboard · Manages shelves, products, orders, staff, and configuration.
projects/cloud_server/smart-shelf-server-frontend/src/main.jsx - Dashboard Realtime Client
projects/cloud_server/smart-shelf-server-frontend/src/lib/mqttClient.ts - Android Staff App · Staff monitoring and operational access.
projects/mobile_app/Android.IOT_Mobile_App/app/src/main/java/com/example/iot_employee_android/MainActivity.java - Android Bluetooth and Socket
projects/mobile_app/Android.IOT_Mobile_App/app/src/main/java/com/example/iot_employee_android/bluetooth/BluetoothManager.java
Other components
- MongoDB Atlas
- MQTT Broker · Live shelf and operational events.
- SEPAY and Cloudinary · Payment webhooks and media uploads.
Connections 22
- BGM220 Load-Cell Firmware → Device Signal Processing: BLE load-cell updates
- XG26 Sensor Firmware → Device Signal Processing: BLE sensor data
- XG26 Audio Classifier → Device Signal Processing: UART commands
- Device Bootloaders → BGM220 Load-Cell Firmware: updates
- Device Bootloaders → XG26 Sensor Firmware: updates
- Shelf Controller → Local Web and API: starts
- Shelf Controller → Device Signal Processing: coordinates
- Device Signal Processing → Local Shelf Store: persists shelf state
- Local Web and API → Local Shelf Store: reads and writes
- Device Signal Processing → MQTT Broker: publishes events
- Local Web and API → SEPAY and Cloudinary: payment webhooks
- Cloud API Server → HTTP Routes: serves
- HTTP Routes → Domain Controllers: dispatches
- Domain Controllers → Domain Models: uses
- Domain Models → MongoDB Atlas: persists
- Cloud API Server → MQTT Broker: publishes and subscribes
- Cloud API Server → SEPAY and Cloudinary: integrates
- Management Dashboard → Cloud API Server: authenticated REST API
- Dashboard Realtime Client → MQTT Broker: live operational data
- Management Dashboard → Dashboard Realtime Client: uses
- Android Staff App → Cloud API Server: auth and shelf APIs
- Android Staff App → Android Bluetooth and Socket: uses