A sustainability-focused application that monitors your digital carbon footprint across browser and system activities. Track your energy consumption, earn rewards for eco-friendly behavior, and get AI-powered tips to reduce your environmental impact.
- โ Real-time Energy Monitoring - Track CPU, memory, and power consumption (in watts/milliwatts)
- โ AI-Powered Tips - Get personalized sustainability recommendations via OpenAI integration
- โ AI Chatbot - Interactive chat with context-aware responses about your system usage
- โ Gamification System - Earn "leaves" (currency) for eco-friendly behavior
- โ Challenges - Complete sustainability challenges like "Touch Grass" and "Low-Carbon Life"
- โ History & Analytics - View historical data with interactive charts (powered by Recharts)
- โ Process Management - Kill energy-hungry apps and tabs directly from the dashboard
- โ Chrome Extension - Monitor tabs with a popup UI showing mood-based system status
- โ Tab & App Tracking - See which apps/tabs are consuming the most energy
SwampSaver consists of three integrated components:
- Port: 8000
- Framework: FastAPI with uvicorn
- Routes:
GET /stats- Returns system stats, apps, tabs, history, and AI tipsPOST /update-tabs- Receives tab data from Chrome extensionGET /extension-poll- Extension polls for pending actions (tab kills)POST /kill-process- Terminates a process by PIDPOST /kill-tab- Queues a tab to be closed by the extensionGET /leaves- Returns current leaf countPOST /bank-leaves- Adds leaves to your balancePOST /chat- AI chatbot endpoint with context-aware responsesGET /challenges- Returns current challenge statusPOST /reset-challenge- Reset a specific challenge
- Manifest V3 compliant
- Popup UI with mood-based status indicators (happy/concerned/mad)
- Monitors tab changes and open tab count
- Sends tab data to backend via
POST /update-tabs - Polls for and executes tab kill commands
- Quick access "Open Dashboard" button
- Dashboard - Real-time stats, AI tips, app/tab management, chatbot
- Challenges Page - View and complete sustainability challenges
- History Page - Interactive charts for energy tracking over time
- Styled with custom CSS (dark theme with accent colors)
- Polls backend every 3 seconds for live updates
- Python 3.8+
- Node.js 16+
- Chrome browser
- OpenAI API key (for AI features)
cd backend
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Create .env file with your OpenAI API key
echo "OPENAI_API_KEY=your_api_key_here" > .env
# Run the server
python app.pycd backend
# Create virtual environment
python -m venv venv
# Activate virtual environment
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Create .env file with your OpenAI API key
echo OPENAI_API_KEY=your_api_key_here > .env
# Run the server
python app.pyThe FastAPI server will start on http://localhost:8000
cd frontend
npm install
npm startThe React app will open on http://localhost:3000
- Open Chrome and go to
chrome://extensions/ - Enable "Developer mode" (top right)
- Click "Load unpacked"
- Select the
/extensionfolder - The extension will appear in your Chrome toolbar
- Click the extension icon to see the popup with real-time stats
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Chrome Extension โ
โ (background.js) โ
โ โ
โ Monitors tab changes โโโPOST /update-tabsโโโ
โ Counts open tabs โ โ
โ Polls for tab kills โโโGET /extension-pollโ
โ Shows popup UI โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FastAPI Backend โ
โ (app.py) โ
โ Port: 8000 โ
โ โ
โ โก System monitoring โ
โ ๐ค OpenAI integration โ
โ ๐ฎ Challenge tracking โ
โ ๐ Leaf currency system โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ
โ
GET /stats
(poll every 3s)
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ React Frontend โ
โ Port: 3000 โ
โ โ
โ ๐ Dashboard โ
โ ๐ History charts โ
โ ๐ Challenges โ
โ ๐ฌ AI Chatbot โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
Earn leaves by maintaining low energy consumption. The formula:
Leaves = ((Baseline - Current) / 1000) ร minutes
- The Low-Carbon Life - Keep system draw below 32560 mW
- Touch Grass - Stay idle for 15+ minutes (auto-detected)
- Night Mode Master - Keep watts < 25W for 30 minutes
- Energy Efficiency Champion - Reduce energy by 50% for 1 hour
SwampSaver/
โโโ backend/
โ โโโ app.py # FastAPI server (main application)
โ โโโ ai_tips.py # AI tip generation utilities
โ โโโ coins.txt # Persistent leaf storage
โ โโโ requirements.txt # Python dependencies
โ โโโ .env # Environment variables (API keys)
โโโ extension/
โ โโโ manifest.json # Extension configuration (Manifest V3)
โ โโโ background.js # Service worker (tab monitoring)
โ โโโ popup.html # Extension popup UI
โ โโโ popup.js # Popup logic
โ โโโ popup.css # Popup styling
โ โโโ *.png # Mood icons (happy, concerned, mad)
โโโ frontend/
โ โโโ public/
โ โ โโโ index.html
โ โโโ src/
โ โ โโโ App.js # Main dashboard component
โ โ โโโ App.css # Dashboard styles
โ โ โโโ Challenges.js # Challenges page component
โ โ โโโ History.js # History/analytics page
โ โ โโโ HistoryManager.js # Data persistence for history
โ โ โโโ index.js # React entry point
โ โ โโโ index.css # Global styles
โ โโโ package.json
โโโ README.md
Prerequisites:
- Virtual environment activated in backend directory
- OpenAI API key configured in
.env - Backend running on
http://localhost:8000 - Frontend running on
http://localhost:3000 - Chrome extension loaded in developer mode
Steps:
- Start the FastAPI backend (see Backend Setup above)
- In a new terminal, start the React frontend (see Frontend Setup above)
- Load the Chrome extension
- Open multiple tabs in Chrome
- Switch between tabs
- Watch the React dashboard update in real-time
- Try the AI chatbot - ask about your energy usage
- Check the Challenges page to see your progress
- View the History page for energy trends over time
Troubleshooting:
- Backend not connecting? Make sure uvicorn is running on port 8000
- AI tips not working? Verify your OpenAI API key is set in
.env - Port already in use? On macOS, AirPlay may use port 5000. SwampSaver uses port 8000 by default
- Virtual environment issues? Ensure you've activated the venv before running
pip installandpython app.py - Extension not updating? Check the extension's service worker in
chrome://extensions/for errors
Backend:
- FastAPI
- uvicorn
- psutil 5.9.5
- openai
- python-dotenv
Frontend:
- React 18.2.0
- React DOM 18.2.0
- Recharts 3.7.0
Extension:
- Vanilla JavaScript
- Chrome Manifest V3 APIs
Create a .env file in the /backend directory:
OPENAI_API_KEY=your_openai_api_key_here
Built with โค๏ธ for the SwampHacks hackathon ๐