GridPulse is a comprehensive full-stack solution designed for electrical utility management. It combines real-time monitoring, role-based administration, and AI-driven analytics to streamline substation operations.
The system features a MERN stack web application for management, a Python/Flask microservice for an AI-powered RAG Chatbot, and a Computer Vision pipeline for automated meter reading via OCR.
- Real-Time Dashboard: Live monitoring of voltage, current, and power consumption using Socket.io.
- Role-Based Access:
- Managers: Create substations, assign attendants, and approve/reject data submissions.
- Attendants: Log data for specific substations and view assigned tasks.
- Hierarchical Visualization: Interactive tree views for substation and employee hierarchy.
- Geospatial Tracking: Temperature and location tracking for substations.
- RAG Chatbot (GridPulse AI):
- Uses Google Gemini and LangChain to answer natural language queries about grid status.
- Context-aware responses based on real-time database records (Retrieval-Augmented Generation).
- Computer Vision Pipeline:
- PaddleOCR & OpenCV integration to automatically read 7-segment displays (e.g., meters) from video feeds.
- Automated red-text highlighting and preprocessing for high-accuracy digit recognition.
- Framework: React.js (Vite)
- Styling: Tailwind CSS, Shadcn/UI
- State Management: Redux Toolkit, React Query
- Visualization: Recharts, React-Flow (Hierarchy)
- Communication: Socket.io-client, Axios
- Runtime: Node.js, Express.js
- Database: MongoDB (Mongoose)
- Security: JWT, Bcrypt, Helmet, CORS
- Real-time: Socket.io (Change Streams)
- Framework: Python Flask
- LLM: Google Gemini Flash (via
google-genai) - Vector Search: Sentence Transformers (
all-MiniLM-L6-v2), Scikit-Learn - OCR: PaddleOCR, OpenCV
├── backend/ # Node.js Express Server
│ ├── config/ # DB connection
│ ├── controllers/ # Logic for Auth, Power Data, Managers
│ ├── models/ # Mongoose Schemas (Substation, Attendant)
│ └── routes/ # API Routes
├── frontend/ # React Vite Application
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ ├── pages/ # Dashboard, Login, Hierarchy views
│ │ └── services/ # API connectors
└── python/ # AI Services
├── app.py # Flask RAG Chatbot API
└── final_pipeline.py # OCR/Computer Vision Script
⚙️ Installation & Setup
Prerequisites
Node.js (v16+)
Python (v3.9+)
MongoDB Atlas URI
Google Gemini API Key
1. Backend Setup
Bash
cd backend
npm install
# Create a .env file
echo "PORT=3000" >> .env
echo "MONGODB_URI=your_mongodb_connection_string" >> .env
echo "SESSION_SECRET=your_secret_key" >> .env
echo "NODE_ENV=development" >> .env
npm run dev
2. Frontend Setup
Bash
cd frontend
npm install
# Create a .env file (if required by vite config)
# Start the dev server
npm run dev
3. AI Service (Python) Setup
Bash
cd python
pip install -r requirements.txt
# Create a .env file
echo "MONGO_URI=your_mongodb_connection_string" >> .env
echo "api_key=your_google_gemini_api_key" >> .env
python app.py
📖 Usage Guide
Log in: Use the web portal to log in as a Manager or Attendant.
Dashboard: Monitor live data streams from the ss-4 and ss-5 collections.
Data Entry: Attendants can manually submit readings or use the OCR Pipeline (running final_pipeline.py) to capture readings from camera feeds.
Chatbot: Navigate to the Chatbot page to ask questions like "What is the current load on Transformer 3 in Substation 4?" or "Show me the temperature trends."
🧪 API Endpoints Overview
Service Method Endpoint Description
Node POST /auth/login User authentication
Node POST /power/submit Submit new power readings
Node GET /manager/pending-data Fetch unapproved submissions
Flask POST /chat Query the RAG AI about grid data
Flask GET /grid/status Get holistic system status
Export to Sheets
📜 License
This project is licensed under the ISC License.