Spaces:
Sleeping
Sleeping
File size: 9,990 Bytes
22836fe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | # YourCarbonFootprint - AI Agents powered Carbon Accounting Tool




A lightweight, multilingual carbon accounting and reporting tool for SMEs in Asia, with AI-powered insights and data entry.
## 📋 Table of Contents
- [Features](#-features)
- [Architecture](#-architecture)
- [Installation](#-installation)
- [Configuration](#-configuration)
- [Usage](#-usage)
- [AI Agents](#-ai-agents)
- [Data Structure](#-data-structure)
- [Contributing](#-contributing)
- [License](#-license)
## ✨ Features
### Core Features
- **Enterprise-Grade Data Entry**: Comprehensive form with business unit tracking, project categorization, facility details, and data quality indicators
- **Dashboard Visualization**: Interactive charts and graphs for emissions data analysis
- **AI-Powered Insights**: Specialized AI agents for various carbon accounting tasks
- **Data Management**: CSV import/export, robust error handling, and automatic backups
- **Multilingual Support**: Available in multiple languages
### AI Agent Features
| Agent | Role |
|-------|------|
| Data Entry Assistant | Helps users classify emissions, map to scopes, and validate data entries |
| Report Summary Generator | Converts emission data into human-readable summaries |
| Carbon Offset Advisor | Suggests verified offset options based on user profile and location |
| Regulation Radar | Notifies users of upcoming compliance needs |
| Emission Optimizer | Uses historical data to suggest reductions and savings |
## 🏗 Architecture
```
┌─────────────────────────────────────────────────────────────────────────┐
│ YourCarbonFootprint App │
└───────────────────────────────────┬─────────────────────────────────────┘
│
┌─────────────────────────────────────┐
│ │
┌───────────────▼───────────────┐ ┌─────────────▼─────────────┐
│ Frontend (Streamlit) │ │ Backend Services │
│ │ │ │
│ ┌─────────────────────────┐ │ │ ┌─────────────────────┐ │
│ │ Navigation System │ │ │ │ Data Management │ │
│ │ - Dashboard │ │ │ │ - JSON Storage │ │
│ │ - Data Entry │ │ │ │ - CSV Import │ │
│ │ - AI Insights │ │ │ │ - Backup System │ │
│ │ - Settings │ │ │ └─────────────────────┘ │
│ └─────────────────────────┘ │ │ │
│ │ │ ┌─────────────────────┐ │
│ ┌─────────────────────────┐ │ │ │ AI Agent System │ │
│ │ Data Entry Module │ │ │ │ - CrewAI Framework │ │
│ │ - Enterprise Form │◄─┼───────┼──┤ - Groq LLM │ │
│ │ - Validation │ │ │ │ - Specialized │ │
│ │ - AI Suggestions │ │ │ │ Agent Roles │ │
│ └─────────────────────────┘ │ │ └─────────────────────┘ │
│ │ │ │
│ ┌─────────────────────────┐ │ │ ┌─────────────────────┐ │
│ │ Dashboard Module │ │ │ │ Analytics Engine │ │
│ │ - Emissions Overview │◄─┼───────┼──┤ - Data Processing │ │
│ │ - Charts & Graphs │ │ │ │ - Calculations │ │
│ │ - Filtering │ │ │ │ - Visualization │ │
│ └─────────────────────────┘ │ │ └─────────────────────┘ │
└───────────────────────────────┘ └───────────────────────────┘
```
## 🚀 Installation
### Prerequisites
- Python 3.9+
- Groq API key (for AI features)
### Setup
1. Clone the repository:
```bash
git clone https://github.com/AIAnytime/Your-Carbon-Footprint/tree/main.git
cd Your-Carbon-Footprint/
```
2. Create and activate a virtual environment:
```bash
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
```
3. Install dependencies:
```bash
pip install -r requirements.txt
```
4. Create a `.env` file in the project root with your Groq API key:
```
GROQ_API_KEY=your_groq_api_key_here
```
## ⚙️ Configuration
### Environment Variables
- `GROQ_API_KEY`: Your Groq API key for AI agent functionality
### Data Storage
- Emissions data is stored in `data/emissions.json`
- Company settings are stored in `data/settings.json`
- Automatic backups are created for corrupted files with timestamped filenames
## 📊 Usage
### Running the Application
```bash
streamlit run app.py
```
### Navigation
- **Dashboard**: View emissions data visualizations and analytics
- **Data Entry**: Add new emission entries with enterprise-grade form
- **AI Insights**: Access specialized AI agents for carbon accounting assistance
- **Settings**: Configure company information and preferences
### Data Entry Form
The enhanced enterprise-grade data entry form includes:
- Business unit and project tracking
- Facility location and responsible person fields
- Data quality indicators and verification status
- AI-powered emission factor suggestions
- Financial impact tracking (optional)
### CSV Import/Export
- Upload CSV files with emissions data
- Download sample CSV template
- Export emissions data as CSV or PDF reports
## 🤖 AI Agents
YourCarbonFootprint integrates five specialized AI agents using CrewAI and Groq LLM:
1. **Data Entry Assistant**: Helps classify emissions and validate data entries
2. **Report Summary Generator**: Creates human-readable summaries from emissions data
3. **Carbon Offset Advisor**: Recommends verified carbon offset options
4. **Regulation Radar**: Provides updates on compliance requirements
5. **Emission Optimizer**: Suggests ways to reduce emissions based on historical data
### AI Agent Implementation
```python
from crewai import Agent, Task, Crew, Process
from crewai.llms import LLM
# Initialize LLM
llm = LLM(provider="groq", model="llama3-70b-8192")
# Create an agent
data_entry_assistant = Agent(
llm=llm,
role="Data Entry Assistant",
goal="Help users classify emissions, map to scopes, and validate data entries",
backstory="You are an expert in carbon accounting who helps users correctly categorize "
"their emissions data and ensure it's properly mapped to the right scope.",
allow_delegation=False,
verbose=False
)
# Create a task
data_entry_task = Task(
description="Analyze the user's emission data and provide guidance on classification",
agent=data_entry_assistant
)
# Create and run a crew
crew = Crew(
agents=[data_entry_assistant],
tasks=[data_entry_task],
verbose=False,
process=Process.sequential
)
result = crew.kickoff(inputs={"user_query": "How should I categorize my company's electricity usage?"})
```
## 📁 Data Structure
### Emissions Data Format
```json
{
"date": "2025-01-15",
"business_unit": "Corporate",
"project": "Carbon Reduction Initiative",
"scope": "Scope 2",
"category": "Electricity",
"activity": "Office Electricity",
"country": "India",
"facility": "Mumbai HQ",
"responsible_person": "Rahul Sharma",
"quantity": 1000.0,
"unit": "kWh",
"emission_factor": 0.82,
"emissions_kgCO2e": 820.0,
"data_quality": "High",
"verification_status": "Internally Verified",
"notes": "Monthly electricity bill"
}
```
## 🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## 📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
---
Built by AI Anytime with ❤️ for a sustainable future
|