# Project export: NovaSync

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: Cal Hacks 12.0
- Tagline: Automated power. Smarter savings. No more tokens.
- Devpost: https://devpost.com/software/novasync
- GitHub: https://github.com/garrgi11/novasync.git
- Video: https://www.youtube.com/embed/oOUtuqKmGPo?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Team: 1 GitHub contributor(s) — Gargi Pathak (2 commits)

## Devpost submission (written by the team)

### Overview

Powering the world, one smart trade at a time.

### Inspiration

Growing up, I was fascinated by how different regions approach electricity access. In Kenya, households rely on a prepaid token system, where people manually enter codes into their meters to keep the lights on. It’s simple, but also inefficient and outdated. That sparked a thought — what if I could merge that idea with the U.S. electricity market, where prices constantly fluctuate and retail brokers profit off consumers? I wanted to create something that lets people directly connect to the grid, trade electricity intelligently, and cut out the middlemen. That’s how NovaSync was born.

### What it does

NovaSync is a decentralized energy trading platform that automates how consumers buy electricity. Instead of relying on retail brokers, NovaSync connects directly to centralized electricity exchanges, executing trades on behalf of users. Consumers deposit funds, understand the risk of dynamic pricing, and let the app automatically sync electricity purchases with market fluctuations. By leveraging the Sui blockchain’s ultra-fast and low-cost architecture, trades are executed instantly with the same efficiency as quantitative trading. ✨ Key Features: Sui Actions → automated smart contract triggers Automated energy sync → electricity purchased and delivered instantly The result: cheaper power, faster access, and no retail markups. How I built it I designed NovaSync as a smart contract-powered system that connects electricity market APIs with the Sui blockchain’s scalable architecture. 🔨 Build process: Architected an automated trading engine that reads market prices and executes buys in real time Used Sui Pay for smooth, low-fee user transactions Leveraged Sui smart contracts + Sui Actions to automate trade execution Modeled the Kenyan prepaid token system — but replaced manual entry with instant digital sync Challenges I ran into The hardest challenge was bridging traditional electricity systems with blockchain. Energy markets are complex — simulating trades required extensive design around APIs and smart contracts. Consumer risk management was also key — electricity prices fluctuate like financial assets, so I had to design a framework that balanced automation with transparency. And on the technical side, ensuring trades executed instantly without lag meant deep optimization of the Sui blockchain’s parallel transaction architecture. Accomplishments that I'm proud of I turned an idea inspired by Kenya’s prepaid system into a next-gen electricity trading prototype. 🏆 Highlights: Eliminated retail brokers who profit off consumers Proved blockchain can power real-world utilities beyond finance Showed how Sui’s speed, scalability, and zero-gas architecture make it uniquely suited for decentralized energy What I learned This project taught me how real-world systems can inspire Web3 innovation. 💡 Key lessons: How to adapt traditional infrastructure like Kenya’s token system into a modern decentralized solution The potential of Sui for real-time automation and microtransactions The importance of transparency and trust when dealing with essentials like electricity

### What's next

This is just the beginning 🚀 🔮 Future plans: Expand into developing markets where prepaid models already exist Build risk-adjusted trading strategies for consumers Pilot with energy cooperatives and local utilities Explore cross-border electricity remittances — so families abroad can send power directly home ⚡ Tech Stack Blockchain: Sui Automation: Sui Actions + Smart Contracts Market Data: Electricity exchange APIs

## README (from the GitHub repository)

NovaSync
Powering the world, one smart trade at a time.

Inspiration
Growing up, I was fascinated by how different regions approach electricity access. In Kenya, households rely on a prepaid token system, where people manually enter codes into their meters to keep the lights on. It’s simple, but also inefficient and outdated. That sparked a thought — what if I could merge that idea with the U.S. electricity market, where prices constantly fluctuate and retail brokers profit off consumers? I wanted to create something that lets people directly connect to the grid, trade electricity intelligently, and cut out the middlemen. That’s how NovaSync was born.

What it does
NovaSync is a decentralized energy trading platform that automates how consumers buy electricity. Instead of relying on retail brokers, NovaSync connects directly to centralized electricity exchanges, executing trades on behalf of users. Consumers deposit funds, understand the risk of dynamic pricing, and let the app automatically sync electricity purchases with market fluctuations.

By leveraging the Sui blockchain’s ultra-fast and low-cost architecture, trades are executed instantly with the same efficiency as quantitative trading.

✨ Key Features:

Sui Actions → automated smart contract triggers
Automated energy sync → electricity purchased and delivered instantly
The result: cheaper power, faster access, and no retail markups.

How I built it
I designed NovaSync as a smart contract-powered system that connects electricity market APIs with the Sui blockchain’s scalable architecture.

🔨 Build process:

Architected an automated trading engine that reads market prices and executes buys in real time
Used Sui Pay for smooth, low-fee user transactions
Leveraged Sui smart contracts + Sui Actions to automate trade execution
Modeled the Kenyan prepaid token system — but replaced manual entry with instant digital sync
Challenges I ran into
The hardest challenge was bridging traditional electricity systems with blockchain.

Energy markets are complex — simulating trades required extensive design around APIs and smart contracts. Consumer risk management was also key — electricity prices fluctuate like financial assets, so I had to design a framework that balanced automation with transparency. And on the technical side, ensuring trades executed instantly without lag meant deep optimization of the Sui blockchain’s parallel transaction architecture.

Accomplishments that I'm proud of
I turned an idea inspired by Kenya’s prepaid system into a next-gen electricity trading prototype.

🏆 Highlights:

Eliminated retail brokers who profit off consumers
Proved blockchain can power real-world utilities beyond finance
Showed how Sui’s speed, scalability, and zero-gas architecture make it uniquely suited for decentralized energy
What I learned
This project taught me how real-world systems can inspire Web3 innovation.

💡 Key lessons:

How to adapt traditional infrastructure like Kenya’s token system into a modern decentralized solution
The potential of Sui for real-time automation and microtransactions
The importance of transparency and trust when dealing with essentials like electricity
What’s next for NovaSync
This is just the beginning 🚀

🔮 Future plans:

Expand into developing markets where prepaid models already exist
Build risk-adjusted trading strategies for consumers
Pilot with energy cooperatives and local utilities
Explore cross-border electricity remittances — so families abroad can send power directly home
⚡ Tech Stack

Blockchain: Sui
Automation: Sui Actions + Smart Contracts
Market Data: Electricity exchange APIs

## Detected evidence (automated analysis)

Indexed codebase: 32 recognized source files, 156 KB.
- CSS (language) — detected in the code
- Express (technology) — detected in the code
- HTML (language) — detected in the code
- JavaScript (language) — detected in the code
- React (technology) — detected in the code
- Tailwind CSS (technology) — detected in the code
- C# (language) — claimed on Devpost, not found in the code
- Django (technology) — claimed on Devpost, not found in the code
- Python (language) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (39 of 39)

```
.gitignore
backend/database.js
backend/gridsync.db
backend/package.json
backend/routes/auth.js
backend/routes/orders.js
backend/seed-balance.js
backend/seed-orders.js
backend/server.js
backend/services/userService.js
commit.sh
contracts/trading.move
frontend/.gitignore
frontend/eslint.config.js
frontend/index.html
frontend/package.json
frontend/src/App.css
frontend/src/App.jsx
frontend/src/components/Activity.jsx
frontend/src/components/Buy.jsx
frontend/src/components/EnergyChart.jsx
frontend/src/components/Layout.jsx
frontend/src/components/Onboarding.jsx
frontend/src/components/Sidebar.jsx
frontend/src/constants/contracts.js
frontend/src/constants/design.js
frontend/src/Dashboard.jsx
frontend/src/Diagram.jsx
frontend/src/index.css
frontend/src/main.jsx
frontend/src/services/api.js
frontend/src/services/contractService.js
frontend/src/WalletContext.jsx
frontend/vite.config.js
hardhat.config.js
ignition/modules/Lock.js
package.json
README.md
test/Lock.js
```

### Dependencies

- backend/package.json: bcryptjs@^3.0.2, cors@^2.8.5, dotenv@^17.2.1, express@^4.18.2, jsonwebtoken@^9.0.2, nodemon@^3.1.10, sqlite3@^5.1.7
- frontend/package.json: @eslint/js@^9.30.1, @tailwindcss/vite@^4.1.11, @types/react@^19.1.8, @types/react-dom@^19.1.6, @vitejs/plugin-react@^4.6.0, chart.js@^4.5.0, eslint@^9.30.1, eslint-plugin-react-hooks@^5.2.0, eslint-plugin-react-refresh@^0.4.20, ethers@^6.15.0, globals@^16.3.0, react@^19.1.0, react-chartjs-2@^5.3.0, react-dom@^19.1.0, tailwindcss@^4.1.11, vite@^7.0.4
- package.json: @1inch/limit-order-sdk@^4.9.5-rc.0, @nomicfoundation/hardhat-toolbox@^6.1.0, @nomicfoundation/hardhat-verify@^2.1.0, @openzeppelin/contracts@^5.4.0, chart.js@^4.5.0, cors@^2.8.5, dotenv@^17.2.1, ethers@^6.15.0, express@^5.1.0, hardhat@^2.26.1, react-chartjs-2@^5.3.0

### Recent commits (newest first)

- final fixes
- first push

## Key source files (fetched from GitHub, selected and truncated for size)

### package.json

```
{
  "name": "Wattlink",
  "version": "1.0.0",
  "description": "Wattlink: A Tokenized Utility Access System for East Africa\r 💡 Category: DeFi",
  "homepage": "https://github.com/Shanthan2307/Wattlink#readme",
  "bugs": {
    "url": "https://github.com/Shanthan2307/Wattlink/issues"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Shanthan2307/Wattlink.git"
  },
  "license": "ISC",
  "author": "",
  "type": "commonjs",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
    "@nomicfoundation/hardhat-toolbox": "^6.1.0",
    "@nomicfoundation/hardhat-verify": "^2.1.0",
    "hardhat": "^2.26.1"
  },
  "dependencies": {
    "@1inch/limit-order-sdk": "^4.9.5-rc.0",
    "@openzeppelin/contracts": "^5.4.0",
    "chart.js": "^4.5.0",
    "cors": "^2.8.5",
    "dotenv": "^17.2.1",
    "ethers": "^6.15.0",
    "express": "^5.1.0",
    "react-chartjs-2": "^5.3.0"
  }
}

```

### backend/package.json

```
{
  "name": "backend",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node server.js",
    "dev": "nodemon server.js",
    "test": "echo \"Error: no test specified\" && exit 1",
    "seed": "node seed-orders.js",
    "seed-balance": "node seed-balance.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "type": "commonjs",
  "dependencies": {
    "bcryptjs": "^3.0.2",
    "cors": "^2.8.5",
    "dotenv": "^17.2.1",
    "express": "^4.18.2",
    "jsonwebtoken": "^9.0.2",
    "sqlite3": "^5.1.7"
  },
  "devDependencies": {
    "nodemon": "^3.1.10"
  }
}

```

### frontend/package.json

```
{
  "name": "frontend",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint .",
    "preview": "vite preview"
  },
  "dependencies": {
    "@tailwindcss/vite": "^4.1.11",
    "chart.js": "^4.5.0",
    "ethers": "^6.15.0",
    "react": "^19.1.0",
    "react-chartjs-2": "^5.3.0",
    "react-dom": "^19.1.0",
    "tailwindcss": "^4.1.11"
  },
  "devDependencies": {
    "@eslint/js": "^9.30.1",
    "@types/react": "^19.1.8",
    "@types/react-dom": "^19.1.6",
    "@vitejs/plugin-react": "^4.6.0",
    "eslint": "^9.30.1",
    "eslint-plugin-react-hooks": "^5.2.0",
    "eslint-plugin-react-refresh": "^0.4.20",
    "globals": "^16.3.0",
    "vite": "^7.0.4"
  }
}

```

### backend/server.js

```javascript
const express = require('express');
const cors = require('cors');
const { initDatabase } = require('./database');
const authRoutes = require('./routes/auth');
const orderRoutes = require('./routes/orders');

const app = express();
const PORT = process.env.PORT || 3001;

// Middleware
app.use(cors({
  origin: 'http://localhost:5173', // Frontend URL
  credentials: true
}));
app.use(express.json());

// Routes
app.use('/api/auth', authRoutes);
app.use('/api/orders', orderRoutes);

// Health check endpoint
app.get('/api/health', (req, res) => {
  res.json({ 
    success: true, 
    message: 'Gridsync Backend is running',
    timestamp: new Date().toISOString()
  });
});

// Error handling middleware
app.use((err, req, res, next) => {
  console.error('Error:', err);
  res.status(500).json({ 
    success: false, 
    message: 'Internal server error' 
  });
});

// 404 handler
app.use('*', (req, res) => {
  res.status(404).json({ 
    success: false, 
    message: 'Route not found' 
  });
});

// Initialize database and start server
const startServer = async () => {
  try {
    await initDatabase();
    
    app.listen(PORT, () => {
      console.log(`🚀 Gridsync Backend running on port ${PORT}`);
      console.log(`📊 Health check: http://localhost:${PORT}/api/health`);
      console.log(`🔗 Frontend URL: http://localhost:5173`);
    });
  } catch (error) {
    console.error('Failed to start server:', error);
    process.exit(1);
  }
};

startServer(); 
```

### frontend/src/main.jsx

```javascript
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.jsx'
import { WalletProvider } from './WalletContext.jsx'

createRoot(document.getElementById('root')).render(
  <StrictMode>
    <WalletProvider>
      <App />
    </WalletProvider>
  </StrictMode>,
)

```

### frontend/src/App.jsx

```javascript
import { useState, useEffect } from 'react'
import { Chart } from 'chart.js/auto'
import './App.css'
import Diagram from './diagram';
import Layout from './components/Layout';
import Onboarding from './components/Onboarding';
import { useWallet } from './WalletContext';

function App() {
  const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
  const [activeTab, setActiveTab] = useState('1');
  const { 
    isConnected, 
    account, 
    provider, 
    signer, 
    userData,
    isOnboarding,
    connectWallet, 
    disconnectWallet, 
    completeOnboarding,
    isLoading 
  } = useWallet();

  // Chart initialization effect
  useEffect(() => {
    const ctx = document.getElementById('stakeholderChart');
    let chartInstance = null;
    
    if (ctx) {
      Chart.getChart(ctx)?.destroy();
      
      chartInstance = new Chart(ctx, {
        type: 'doughnut',
        data: {
          labels: ['Households', 'Utility Providers', 'Mobile Money', 'Bridge Partners'],
          datasets: [{
            data: [55, 20, 15, 10],
            backgroundColor: [
              'rgba(59, 130, 246, 0.8)',
              'rgba(16, 185, 129, 0.8)',
              'rgba(245, 158, 11, 0.8)',
              'rgba(107, 114, 128, 0.8)'
            ],
            borderColor: [
              'rgba(59, 130, 246, 1)',
              'rgba(16, 185, 129, 1)',
              'rgba(245, 158, 11, 1)',
              'rgba(107, 114, 128, 1)'
            ],
            borderWidth: 2
          }]
        },
        options: {
          responsive: true,
          maintainAspectRatio: false,
          plugins: {
            legend: {
              position: 'bottom',
              labels: {
                padding: 20,
                usePointStyle: true
              }
            }
          }
        }
      });
    }
    
    return () => {
      if (chartInstance) {
        chartInstance.destroy();
      }
    };
  }, []);

  // Navigation effects
  useEffect(() => {
    const navLinks = document.querySelectorAll('.nav-link, #mobile-menu a');
    navLinks.forEach(link => {
      link.addEventListener('click', function(e) {
        e.preventDefault();
        const targetId = this.getAttribute('href');
        const targetElement = document.querySelector(targetId);
        if (targetElement) {
          targetElement.scrollIntoView({ behavior: 'smooth' });
        }
        setMobileMenuOpen(false);
      });
    });

    const sections = document.querySelectorAll('section');
    const navLinksDesktop = document.querySelectorAll('.nav-link');

    const handleScroll = () => {
      let current = '';
      sections.forEach(section => {
        const sectionTop = section.offsetTop;
        if (pageYOffset >= sectionTop - 120) {
          current = section.getAttribute('id');
        }
      });

      navLinksDesktop.forEach(link => {
        link.classList.remove('text-blue-600', 'border-blue-600');
        link.classList.add('text-gray-600', 'border-transparent');
        if (link.getAttribute('href').includes(current)) {
          link.classList.remove('text-gray-600', 'border-transparent');
          link.classList.add('text-blue-600', 'border-blue-600');
        }
      });
    };

    window.addEventListener('scroll', handleScroll);
    return () => window.removeEventListener('scroll', handleScroll);
  }, []);

  const tabContent = {
    '1': {
      title: 'Conditional Orders',
      content: 'Custom on-chain electricity orders with predicate checks tied to mobile money payments, ensuring atomicity between real-world payments and token transfers.'
    },
    '2': {
      title: 'TWAP-like Budgeting',
      content: 'Automated time-weighted purchases allowing users to set recurring budgets for electricity, creating a series of small, automated limit orders for steady power supply.'
    },
    '3': {
      title: 'Dynamic Pricing',
      content: 'Real-time pricing using oracles to fetch forex rates and utility tariffs, ensuring users get accurate and transparent conversions for fiat-to-ElectricityToken swaps.'
    },
    '4': {
      title: 'Gasless Execution',
      content: 'Backend resolvers monitor signed orders and fulfill them while paying all gas fees, providing a completely gasless experience for end-users.'
    },
    '5': {
      title: 'Order Aggregation',
      content: 'Multi-source aggregation finding the most efficient routes for fiat-to-crypto conversion by checking different bridge partners for optimal rates.'
    }
  };

  // Show loading state while checking connection
  if (isLoading) {
    return (
      <div className="min-h-screen bg-white flex items-center justify-center">
        <div className="text-center">
          <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"></div>
          <p className="text-gray-600">Checking wallet connection...</p>
        </div>
      </div>
    );
  }

  // If connected but onboarding, show onboarding
  if (isConnected && isOnboarding) {
    return (
      <Onboarding 
        walletAddress={account}
        onComplete={completeOnboarding}
      />
    );
  }

  // If connected and user data exists, show dashboard
  if (isConnected && userData) {
    return <Layout />;
  }

  // Landing page with connect wallet button
  return (
    <div className="min-h-screen bg-white font-sans">
      {/* Header */}
      <header className="sticky top-0 z-50 bg-white/80 backdrop-blur-md border-b border-gray-200">
        <nav className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
          <div className="flex justify-between items-center h-16">
            <div className="flex items-center">
              <h1 className="text-xl font-bold text-gray-900">
                Gridsync
              </h1>
            </div>
            
            <div className="hidden md:flex items-center space-x-8">
              <a href="#overview" className="nav-link text-gray-600 hover:text-blue-600 font-medium border-b-2 border-transparent
[truncated — 12999 more characters]
```

### hardhat.config.js

```javascript
require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.28",
};

```

### commit.sh

```shell
#!/bin/bash

# Branch name (change if needed)
BRANCH="main"

# Get list of subfolders in current directory (excluding .git folder)
folders=$(find . -maxdepth 1 -type d ! -name ".git" ! -path ".")

# Loop through each folder
for folder in $folders; do
  echo "Committing folder: $folder"

  # Stage changes in this folder
  git add "$folder"

  # Commit with timestamp
  git commit -m "Auto commit of $folder at $(date '+%Y-%m-%d %H:%M:%S')"

  # Push to remote
  git push origin "$BRANCH"

  # Wait 15 minutes before next commit
  echo "Waiting 15 minutes before next commit..."
  sleep 900
done

echo "✅ All folders committed."

```

### frontend/vite.config.js

```javascript
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'

// https://vite.dev/config/
export default defineConfig({
  plugins: [react(),
    tailwindcss(),

  ],
})

```

### frontend/index.html

```html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Wattlink: Interactive Project Overview</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="/src/main.jsx"></script>
  </body>
</html>

```

[24 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]