close
Skip to content

Repository files navigation

Energy Exchange DeFi Platform

A state-of-the-art blockchain-based energy trading platform enabling peer-to-peer energy exchange, carbon tracking, automated market mechanisms, and comprehensive dashboards for multiple user personas.

🌟 Key Features

  • Blockchain-Based Trading: Secure, transparent energy trading using Ethereum-compatible smart contracts
  • Multiple User Personas: Dedicated dashboards for Prosumers, Consumers, Producers, Grid Operators, Regulators, and Traders
  • Carbon Tracking: Real-time carbon emissions monitoring and offset mechanisms
  • DER Management: Register and manage Distributed Energy Resources (solar, batteries, EVs)
  • Automated Market Maker: Efficient price discovery and order matching
  • Scenario Modeling: What-if analysis for energy decisions
  • End-to-End Traceability: Complete provenance tracking from production to consumption
  • Anomaly Detection: AI-powered detection of unusual trading patterns
  • Scalable Architecture: Designed to handle billions of users

🏗️ Architecture

Technology Stack

  • Frontend: React + TypeScript + Vite + Tailwind CSS
  • Backend: Node.js + Express + TypeScript
  • Database: PostgreSQL (production) / SQLite (development)
  • Blockchain: Hardhat (local dev) / Polygon (production)
  • Real-time: WebSocket for live market updates
  • AI/ML: TensorFlow.js for forecasting and anomaly detection

Project Structure

energy-exchange-defi/
├── contracts/           # Smart contracts (Solidity)
├── backend/            # Node.js backend API
├── frontend/           # React frontend application
├── docs/               # Documentation
└── docker-compose.yml  # Docker configuration

🚀 Quick Start

Installation & Demo Setup

  1. Clone and Install

    git clone <repository-url>
    cd energyexchangedapp
    npm install
  2. Start Services

    # In one terminal, start the local blockchain
    npm run local-node
    
    # In another terminal, start the platform (Backend + Frontend)
    npm run dev

    The app will be available at:

🔑 Demo Credentials

Test the platform immediately with our pre-configured demo account:

  • Email: sarah.johnson@email.com
  • Password: demo123

👥 User Personas & High-Fidelity Dashboards

The platform provides specialized, "glass-card" design dashboards for every key participant in the energy ecosystem.

1. Prosumer (Active Household)

Energy producers and consumers who can both buy and sell energy.

  • Sub-Views: Dashboard, Trading Interface, DER Management, Carbon Footprint, Analytics.
  • Key Features: Solar production tracking, battery storage oversight, and P2P trading.

2. Consumer (Energy Buyer)

Households or businesses looking for cost-effective and clean energy.

  • Sub-Views: Dashboard, Marketplace, Billing, Optimization.
  • Key Features: AI-driven cost recommendations and direct renewable energy purchasing.

3. Producer (Industrial Generation)

Large-scale renewable farms and power plants.

  • Sub-Views: Dashboard, Wholesale Desk, Asset Manager, Grid Integration.
  • High-Fidelity features:
    • Wholesale Desk: Interactive market bidding and futures management.
    • Asset Manager: Advanced fleet health monitoring and maintenance scheduling.

4. Grid Operator (Network Stability)

Ensures grid stability and manages infrastructure.

  • Sub-Views: Dashboard, Network Topology, Outage Center, Demand Response.
  • High-Fidelity features:
    • Network Topology: Real-time load flow visualization and node health tracking.
    • Outage Center: Rapid response mission control for service restoration.

5. Regulator (Compliance & Trust)

Oversees market compliance and ensures fairness.

  • Sub-Views: Dashboard, Compliance Tracker, Market Surveillance, Reporting.
  • High-Fidelity features:
    • Compliance Tracker: Automated audit trail generation and threshold monitoring.
    • Market Surveillance: AI-powered detection of price manipulation and wash trading.

6. Trader (Professional Markets)

Professional energy traders and portfolio managers.

  • Sub-Views: Dashboard, Trading Terminal, Risk Analyzer, Portfolio.
  • High-Fidelity features:
    • Trading Terminal: High-performance order books with depth charts and instant execution.
    • Risk Analyzer: Comprehensive VaR metrics and portfolio exposure heatmaps.

🎮 Demo Scenarios

Scenario 1: Prosumer Energy Trading

  1. Connect MetaMask wallet
  2. Register as Prosumer
  3. Add a solar panel (5kW) in DER Management
  4. Create sell order: 10 kWh @ $0.15/kWh
  5. Switch to Consumer account
  6. Purchase energy from marketplace
  7. View trade on blockchain
  8. Check traceability dashboard

Scenario 2: Carbon Tracking

  1. Login as Prosumer
  2. Navigate to Carbon Footprint
  3. View emissions based on energy mix
  4. Run scenario: "Add 2kW battery storage"
  5. Compare carbon impact

Scenario 3: Grid Operator Load Balancing

  1. Login as Grid Operator
  2. View real-time grid topology
  3. Simulate high demand
  4. Activate demand response
  5. Monitor congestion alerts

🧪 Testing

# Run all tests
npm test

# Test smart contracts
npm run test:contracts

# Test backend
npm run test:backend

# Test frontend
npm run test:frontend

# Run with coverage
npm run test:coverage

📊 Smart Contracts

EnergyMarket.sol

Core marketplace for energy trading with automated market maker.

DERRegistry.sol

Registration and management of Distributed Energy Resources.

CarbonCredits.sol

Carbon credit tokenization and trading (ERC-20).

TradeTraceability.sol

Immutable trade history and provenance tracking.

Governance.sol

DAO governance for platform parameters.

🔐 Security

  • JWT authentication with wallet signature verification
  • Role-based access control (RBAC)
  • Smart contract access controls
  • Rate limiting on API endpoints
  • SQL injection prevention
  • XSS protection
  • CORS configuration

📈 Scalability

  • Microservices architecture
  • Database connection pooling
  • Redis caching layer
  • WebSocket for real-time updates
  • Layer 2 blockchain (Polygon) for production
  • CDN for static assets
  • Horizontal scaling support

🌍 Compliance

  • IEC 62325 (energy market communications)
  • ENTSO-E guidelines
  • FERC regulations (US markets)
  • GDPR compliance
  • KYC/AML integration points

📚 Documentation

🤝 Contributing

Contributions are welcome! Please read our contributing guidelines before submitting PRs.

📄 License

MIT License - see LICENSE file for details

🆘 Support

For issues and questions:

  • Create an issue on GitHub
  • Check documentation in /docs
  • Review demo scenarios above

🚀 Deployment

Production Deployment

  1. Set up PostgreSQL database
  2. Configure environment variables for production
  3. Deploy smart contracts to Polygon
  4. Build frontend: npm run build:frontend
  5. Deploy backend to cloud service (AWS, GCP, Azure)
  6. Configure CDN for frontend assets
  7. Set up monitoring and logging

Docker Deployment

docker-compose up -d

This starts all services including PostgreSQL, Redis, and the application.


Built with ❤️ for a sustainable energy future

About

A state-of-the-art blockchain-based energy trading platform enabling peer-to-peer energy exchange, carbon tracking, automated market mechanisms, and comprehensive dashboards for multiple user personas.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages