Skip to content

Repository files navigation

GridShield

Multi-Layer Security Framework for Advanced Metering Infrastructure (AMI)

License: MITVersionC++17ESP-IDFPlatformCI


🛡️ Overview

GridShield is a production-grade security solution designed to protect smart electricity meters from physical tampering, network attacks, and consumption fraud. Built for resource-constrained embedded systems, it implements a defense-in-depth strategy across three security layers.

Why GridShield? Traditional meter security relies on single-point defenses. GridShield correlates physical, network, and behavioral signals to detect sophisticated attacks that bypass conventional safeguards.

✨ Key Features

🔐 Physical Security Layer

  • ISR-driven tamper detection with debouncing logic
  • Backup power (UPS) — Li-ion 2500mAh via TP4056 + MT3608
  • Buzzer alarm — 4 alert patterns (tamper, temp, PZEM fail, boot)
  • Priority flagging for emergency transmission

🌐 Network Security Layer

  • Lightweight ECC (secp256r1) via micro-ecc
  • ECDSA packet signing + SHA256 integrity checks
  • Replay protection with sequence numbering

📊 Analytics Layer

  • Real-time consumption anomaly detection
  • Profile-based behavioral analysis (24-hour baseline)
  • Cross-layer validation engine

🎯 Production Ready

  • Zero heap allocation design (embedded-friendly)
  • Type-safe error handling via Result<T> monad (no exceptions)
  • Platform abstraction layer (HAL) for portability
  • Mock implementations for simulation testing

🖥️ Backend & Dashboard

  • FastAPI REST backend with 12 API endpoints
  • SQLite database with SQLAlchemy ORM
  • Vite + Chart.js real-time web dashboard
  • 5 dashboards: Live Monitor (hero cards), Alerts, Anomalies, Fleet, Notifications
  • Bilingual UI (Bahasa Indonesia + English)
  • 2-second live polling with threshold coloring

🧪 CI/CD & Testing

  • 186 unit tests across 20 test suites
  • 7-job GitHub Actions pipeline (build, test, backend-test, backend-lint, frontend-build, clang-tidy, coverage)
  • LibFuzzer + ASan/UBSan fuzzing for packet parser
  • Code coverage reports via gcov/lcov
  • Hardware tested on ESP32-D0WD rev1.1 (Dual Core 240MHz)

🚀 Quick Start

Prerequisites

Build & Run

# Clone repository
git clone https://github.com/zuudevs/gridshield.git
cd gridshield
# Build firmware
.\scripts\script.ps1 --build
# Run in QEMU simulator
.\scripts\script.ps1 --run

Or manually with ESP-IDF:

cd firmware
idf.py set-target esp32
idf.py build
idf.py -p COM3 flash # flash to physical ESP32
idf.py -p COM3 monitor # serial monitor
idf.py qemu monitor # or run in QEMU simulator

See BUILD.md for full instructions.

📦 Target Platform

PlatformMCUFlashRAMStatus
ESP32 DevKit V1Xtensa LX64 MB520 KB✅ Active
QEMU (Simulation)Emulated Xtensa✅ Active

📚 Documentation

🏗️ Project Structure

gridshield/
├── firmware/ # ESP-IDF firmware project
│ ├── CMakeLists.txt # Root build config
│ ├── include/ # Header files
│ │ ├── common/ # Platform-agnostic headers
│ │ └── platform/ # HAL interfaces + mock impls
│ ├── main/ # Implementation files
│ ├── test_app/ # Unity test suites (186 tests)
│ ├── fuzz/ # LibFuzzer harness
│ ├── coverage/ # gcov/lcov coverage scripts
│ └── lib/micro-ecc/ # ECC library (secp256r1)
├── backend/ # FastAPI REST backend
│ ├── app/ # Python application
│ │ ├── main.py # FastAPI app entry
│ │ ├── routes.py # API endpoints
│ │ ├── models.py # SQLAlchemy models
│ │ └── schemas.py # Pydantic schemas
│ └── requirements.txt # Python dependencies
├── frontend/ # Vite + Chart.js dashboard
│ ├── src/
│ │ ├── pages/ # Dashboard, Alerts, Anomalies, Fleet
│ │ ├── components/ # Navbar, Chart components
│ │ └── api.js # Backend API client
│ └── package.json
├── .github/workflows/ # CI/CD (7-job pipeline)
├── scripts/script.ps1 # Build/run automation
└── docs/ # Documentation
└── design/ # IoT hardware design (HTML/CSS)

🤝 Contributing

We welcome contributions! Please read CONTRIBUTING.md for code style guidelines and PR process.

🔒 Security

Found a vulnerability? Do not open a public issue. See SECURITY.md for responsible disclosure.

📄 License

This project is licensed under the MIT License - see LICENSE file for details.

👥 Authors

  • Muhammad Ichwan Fauzi — Team Leader
  • Rafi Indra Pramudhito Zuhayr — Firmware, Backend, Frontend, CI/CD, Dokumentasi, Testing, System Architecture, Project Manager
  • Cesar Ardika Bhayangkara — Hardware Integration

Catatan: Seluruh implementasi teknis yang ada di repository ini (firmware, backend, frontend, CI/CD, dokumentasi, testing, dan seluruh konfigurasi project) merupakan hasil pekerjaan Rafi Indra Pramudhito Zuhayr.

Institut Teknologi PLN — 2026

🌟 Acknowledgments

  • Inspired by NIST SP 800-53 security controls
  • Built with lessons from IoT security research
  • Cryptography: micro-ecc (secp256r1)

⭐ Star this repo if GridShield helps your project!

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages