Skip to content

zuudevs/gridshield

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

90 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GridShield

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

License: MIT Version C++17 ESP-IDF Platform CI


πŸ›‘οΈ 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

Platform MCU Flash RAM Status
ESP32 DevKit V1 Xtensa LX6 4 MB 520 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

Watchers

Forks

Releases

Packages

Contributors

Languages