Skip to content

Nikolife13/smart-microgrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ Smart Microgrid – Affordable and Clean Energy Simulation

Node.js Version gRPC SDG 7

This project simulates a Smart Microgrid ecosystem for modern homes or small industrial facilities. It was developed to support UN Sustainable Development Goal #7, focusing on efficient energy distribution and monitoring using distributed systems.

The architecture consists of three independent gRPC services (Solar, Meter, Battery) coordinated via a Naming Service and managed through a centralized Web GUI.


🛠 Technologies

  • Backend: Node.js
  • Communication: gRPC (@grpc/grpc-js, @grpc/proto-loader)
  • Web Server: Express.js
  • Frontend: HTML5, CSS3 (Modern UI), JavaScript
  • Version Control: Git

📂 Project Structure

smart-microgrid/
├── proto/               # Protocol buffer definitions (.proto)
├── services/            # gRPC server-side logic
│   ├── naming_server.js
│   ├── naming_client_helper.js
│   ├── solar_panel.js
│   ├── smart_meter.js
│   └── battery.js
├── gui/                 # Express gateway & Web interface
│   ├── server.js
│   └── public/          # Client-side assets
├── package.json
└── README.md
🚀 Getting StartedPrerequisitesNode.js (v14 or higher)
npm
Installation
Bash
# Clone the repository
git clone (https://github.com/Nikolife13/smart-microgrid.git)

# Navigate into the project
cd smart-microgrid
# Install dependencies
npm install

Running the System
Open five separate terminal tabs and run the following commands in order:
Step     Service,       Command                Port
1    Naming Service     npm run naming         50055
2    Solar Panel        npm run solar          50051
3    Smart Meter        npm run meter          50052
4    Battery Storage    npm run battery        50053
5    Web GUI            npm run gui            3000

Access the Dashboard: Once all services are running, visit http://localhost:3000.
📡 RPC Implementation Details
This project demonstrates all four gRPC communication patterns:

Unary (GetCurrentPower): Simple request-response to fetch instantaneous solar data.

Server-Streaming (StreamPower): Real-time telemetry feed from the solar panels every 2 seconds.

Client-Streaming (SubmitReadings): Batch upload of energy consumption data for server-side processing and summarization.

Bidirectional Streaming (ManageBattery): Real-time control loop where client commands and battery status updates flow simultaneously.

✨ Advanced Features
Service Discovery: Services register themselves with the Naming Service, allowing the GUI to locate them dynamically.

Deadlines & Timeouts: All gRPC calls include enforced deadlines (5s-10s) to prevent system hangs.

Metadata Integration: The GUI passes a user-id header in metadata for service-side logging and auditing.

Resource Management: Stream cancellation is handled properly; closing the browser UI triggers server-side cleanup.

Robust Error Handling: Custom gRPC error codes (e.g., INVALID_ARGUMENT, UNAVAILABLE) with human-readable feedback.

👨‍💻 Author
Vitakii Nikitenko

Student at National College of Ireland

Distributed Systems Module

About

Distributed smart microgrid simulation using Node.js and gRPC. Implements all 4 RPC types (Unary, Client/Server/Bi-di streaming) with service discovery and a web-based GUI.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors