Implement Faltric MVP: Blockchain, Frontend, Backend, and AI Service#1
Draft
Implement Faltric MVP: Blockchain, Frontend, Backend, and AI Service#1
Conversation
- blockchain/: Solidity ERC-20 EnergyToken (ENRG) + TradeEngine escrow, Hardhat config, deploy script, and test suite - backend/: Express + Socket.io API server with JWT auth, MongoDB models (User, Installation, MeterReading, ChatMessage), REST routes for auth, installations, meter readings, and AI predictions; 15-min meter poller that mints ENRG tokens via ethers.js - frontend/: React + Vite + Tailwind SPA with AuthContext (JWT), Web3Context (MetaMask/ethers.js), Mapbox grid map with color-coded energy node markers, P2P exchange UI with TradeModal, AI prediction dashboard, Socket.io chat, and admin approval dashboard - ai-service/: FastAPI Python service with scikit-learn regression model, weather-weighted scoring (S = Σ W_i * V_i), and reportlab PDF reports - docker-compose.yml: orchestrates all 4 services + MongoDB + Redis - Dockerfiles for backend (Node), ai-service (Python), frontend (Nginx) - .gitignore covering node_modules, build artifacts, .env files Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- TradeEngine.sol: split lockTrade into two phases - seller locks tokens via lockTrade(), buyer locks ETH via fundTrade(); cancelTrade handles unfunded trades gracefully; update tests accordingly - installations.js: move /admin/pending route before /:id to fix Express route ordering conflict - meter.js: import mongoose at top-level instead of inline in aggregation - meterPoller.js: use ethers.ZeroAddress constant instead of hardcoded string - ai-service/main.py: use uuid.UUID() for proper UUID format validation - ai-service/models/recommendation.py: extract INSTALLATION_TYPE_BOOST constant - GridMap.jsx: fix dynamic import race condition - import mapboxgl once, then iterate installations inside the resolved promise Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Precise-Goals <125793243+Precise-Goals@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add technical specifications for Faltric MVP
Implement Faltric MVP: Blockchain, Frontend, Backend, and AI Service
Feb 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Greenfield implementation of the Faltric platform — a decentralized green energy marketplace combining P2P token trading on Ethereum Sepolia, geospatial grid visualization, and AI-driven generation recommendations.
Blockchain (
/blockchain)EnergyToken.sol: ERC-20 (ENRG), 1 token = 1 kWh; minting gated byMINTER_ROLEvia OpenZeppelinAccessControlTradeEngine.sol: Two-phase escrow — seller callslockTrade()(transfers tokens in), buyer callsfundTrade()(sends ETH), then either party or owner triggersreleaseTrade()/cancelTrade(); protected withReentrancyGuardFrontend (
/frontend)localStoragepersistence for auto-reconnect0x71C…)lockTrade(no ETH) thenfundTrade(ETH) as separate phasesBackend (
/backend)register,login,link-walletendpointsUser,Installation(GeoJSON),MeterReading,ChatMessagesetInterval, computes surplusT = max(0, G − C), mints ENRG viaethers.jsAI Service (
/ai-service)POST /predictscores sources viaS = Σ(Wᵢ × Vᵢ)with weather normalization + scikit-learn trend regressionreportlab;GET /reports/{uuid}validates UUID format and guards against path traversal viaPath.resolve()boundary checkInfrastructure
docker-compose.yml: all four services + MongoDB + Redis with health checksBug fixes applied during review
{ value: ethAmountWei }fromlockTradecall — seller does not send ETH at lock phasemeterPollerconfig guard changed fromtokenAddress === ethers.ZeroAddress(always false on env string) to a simple falsiness checkmin(100, …)cap so it can meaningfully influence rankingWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
binaries.soliditylang.org/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/Falitric/Falitric/blockchain/node_modules/.bin/hardhat test(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
As the Head of AI/ML and Blockchain R&D, I have formalized the technical and product specifications for Faltric. This document serves as the master blueprint for the engineering and design teams to begin the development of the MVP (Minimum Viable Product).
Product Requirements Document (PRD): Project Faltric
Version: 1.1
Status: Ready for Technical Implementation
Core Mission: To democratize green energy through decentralized finance, geospatial intelligence, and predictive AI.
1. Product Vision & Goals
Faltric aims to transform the traditional centralized energy grid into a community-driven ecosystem. By leveraging the Ethereum Sepolia Testnet, Faltric ensures transparent P2P transactions while using AI to optimize energy consumption and installation choices.
2. User Personas
3. Functional Requirements
3.1 Web3 & Blockchain Integration (Faltric Exchange)
Wallet Connectivity: Implement a "Persistent Wallet" logic. Upon login via traditional credentials, the system checks for an active MetaMask session. If the user has signed in once, the wallet remains linked to the session.
Smart Contracts: * EnergyToken (ERC-20): 1 Token = 1 kWh generated.
TradeEngine: An escrow contract that holds ETH/Tokens during a P2P trade on Sepolia.
Meter API Integration: Backend services will poll Smart Meter APIs every 15 minutes to sync real-world generation data with the on-chain "Minting" function.
3.2 Geospatial Mapping (Faltric GridMap)
0x71C...) for security.3.3 AI-Driven Analytics (Faltric Predict)
Recommendation Engine: A regression model that processes:
Input A: Historical generation data from the Smart Meter.
Input B: Real-time Weather API (Solar irradiance, wind speed, precipitation).
Output: A structured PDF/Dashboard report recommending the best resource (e.g., "Switch to Wind for Q4") and estimating potential earnings.
3.4 Community & Admin Features
4. Technical Stack
5. System Logic & Formulas
5.1 Energy Credit Calculation
The amount of tokens minted ($T$ ) is derived from the net generation ($G$ ) minus the local consumption ($C$ ):
5.2 Recommendation Logic
The AI score ($S$ ) for a specific renewable source is calculated as:
Where $W$ is the weather weight (e.g., 0.8 for sun) and $V$ is the historical efficiency variable.
6. Success Metrics (KPIs)
7. Roadmap: Phase 1 (Next 4 Weeks)
Next Step:
To begin development, would you like me to generate the Solidity Smart Contract for the Faltric Exchange or the React Template for the Faltric GridMap ...
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.