Skip to content

Repository files navigation

EdgeGuard AIoT

EdgeGuard is an AIoT security project with these main workspaces:

  • mini-app: Next.js dashboard, Telegram Mini App, MQTT bridge, Supabase integration, Telegram alerts, and email alerts.
  • hardware: ESP32/ESP8266 firmware for the IoT device.
  • ai-models: Python workspace for model training, inference, and MQTT-based model outputs.

The MQTT contract follows the same pattern as the NomNom reference project: the hardware device publishes telemetry and event images, while the server subscribes to device topics and publishes commands/configuration back to the device.

Quick Start

Install dependencies:

cd "D:\AIOT\FOMO WEB EVALUATION\EdgeGuard-telegram-email-integration\mini-app"
npm.cmd ci

Prepare a local env file. Do not commit env files. Use the project root .env or mini-app\.env.local for team setup.

Run Telegram Mini App

Use a production server behind a Cloudflare HTTPS tunnel. Keep this terminal open while testing on Telegram.

cd "D:\AIOT\FOMO WEB EVALUATION\EdgeGuard-telegram-email-integration\mini-app"
$env:CLOUDFLARED_PATH="C:\tmp\edgeguard-cloudflared.exe"
npm.cmd run telegram:quick

When the script prints READY, open the Telegram bot, close old Mini App windows, then press Mo EdgeGuard.

Use this full command only when you want to rebuild before opening the Mini App:

cd "D:\AIOT\FOMO WEB EVALUATION\EdgeGuard-telegram-email-integration\mini-app"
$env:CLOUDFLARED_PATH="C:\tmp\edgeguard-cloudflared.exe"
npm.cmd run telegram

If npm.cmd run telegram fails during next build because Google Font fetching is blocked, use npm.cmd run telegram:quick with the existing build.

Run Laptop Dashboard

Run this in a second terminal so the dashboard and Telegram Mini App can run at the same time.

cd "D:\AIOT\FOMO WEB EVALUATION\EdgeGuard-telegram-email-integration\mini-app"

$env:PORT="4001"
$env:TELEGRAM_AUTH_REQUIRED="false"
$env:NEXT_PUBLIC_TELEGRAM_AUTH_REQUIRED="false"
$env:MQTT_ENABLED="false"
$env:TELEGRAM_BOT_UPDATES_ENABLED="false"
node server.js

Open:

http://localhost:4001
http://localhost:4001/logs
http://localhost:4001/settings

Port convention:

  • 4000: Telegram Mini App production server behind Cloudflare tunnel.
  • 4001: laptop dashboard without Telegram auth.
  • 3000: not used by this local demo setup.

If the dashboard says Ngoai tuyen, it usually means MQTT/live device is offline. It does not mean Supabase logs are broken.

Alert Flow

  • Telegram sends alerts to active Telegram users from telegram_device_users.
  • Email sends alerts to active users with an email address and email_alert_enabled = true.
  • Telegram currently has no cooldown.
  • Email has a 1 minute cooldown per deviceId + alertType.
  • Alert images are loaded from Supabase public event image URLs.
  • Alert display time should use the event image timestamp when available, so realtime demo alerts match the ESP32-CAM uploaded image time.

Common Commands

Run Telegram logic tests:

cd "D:\AIOT\FOMO WEB EVALUATION\EdgeGuard-telegram-email-integration\mini-app"
npm.cmd run test:telegram

Run lint:

cd "D:\AIOT\FOMO WEB EVALUATION\EdgeGuard-telegram-email-integration\mini-app"
npm.cmd run lint

Build:

cd "D:\AIOT\FOMO WEB EVALUATION\EdgeGuard-telegram-email-integration\mini-app"
npm.cmd run build

MQTT Defaults

  • Broker: broker.hivemq.com
  • Port: 1883
  • Topic base: /EdgeGuard/device_001
  • Device id: device_001
  • Image topics: /EdgeGuard/device_001/image and /EdgeGuard/device_001/image/json

These defaults are suitable for local development and demos. Use a private broker with TLS, credentials, and per-device authentication before deploying real devices.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages