# Project export: TreeTrash

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: TreeHacks 2025
- Tagline: Quantify, analyze, and improve sustainability with intelligent trash monitoring!
- Devpost: https://devpost.com/software/treetrash
- GitHub: https://github.com/sonnetx/treehacks-2025
- Video: https://www.youtube.com/embed/2TJLV-r9Qss?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Result: winner (OpenAI: Most Creative Use of OpenAI API (OpenAI SF HQ lunch + Swag))
- Team: 3 GitHub contributor(s) — Sonnet Xu (19 commits), Hello World HD (13 commits), Victor Chen (9 commits)

## Devpost submission (written by the team)

### Inspiration

During TreeHacks, we noticed a significant number of items being placed in the wrong waste bins, which reminded us of a broader problem with tracking and understanding waste patterns, so that they could be effectively mitigated in the future. This sparked our idea to expand upon challenge #3 on the sustainability track and leverage AI to not only identify and address this issue but also take it a step further. We wanted to go beyond simply classifying waste and analyzing the weight — we aimed to develop a program that could analyze images of trash, recycling and compost and generate a report that could provide organizations like Stanford with valuable insights into food waste patterns, enabling them to implement more effective sustainability initiatives and reduce unnecessary waste. What It Does TreeTrash leverages computer vision to analyze images of a trash bin taken at regular intervals. We determine which items were misplaced and what the environmental impact of misplacing those items using a custom search pipeline. When we first notice a misplaced item, we use a display and speaker to notify the person. Then, we generate a custom report about the environmental impact of misplacing certain items, as well as specific recommendations about how to improve. How We Built It We use computer vision to list out the items in the image, compare those items to the items in the previous image, use OpenAI's GPT-4o to determine the proper placement of those items, use Perplexity search to identify the environmental impact in terms of kg of CO2e emissions, use gpt-4o-mini to parse this output into a structured output, use Vespa AI RAG to identify how this relates to the sustainability goals of a specific organization, and use Gemini to generate a report. Challenges We Ran Into Implementing RAG with Vespa was a very buggy process and it took a lot of learning about the platform. Also, Perplexity was not able to consistently output a structured output, so we had to add in a layer in the pipeline to transform it into a structured output. Accomplishments That We're Proud Of We're proud of how we improved the accuracy of predictions using grounded information retrieved by perplexity. We are also proud of how we implemented RAG to augment the report by making it specific to an organization's sustainability goals. Being able to leverage our teammates' EE skills to develop a custom monitor to display everything was also important! What We Learned We learned how to construct pipelines that incorporate multiple AI models and implement RAG with new tools (namely Vespa.ai), which we had never had exposure to before. What's Next For TreeTrash We plan to take TreeTrash beyond the hackathon by testing it with real trash bins at Stanford. Our next steps focus on key technical improvements to enhance the system’s accuracy and functionality: Enhancing Retrieval-Augmented Generation (RAG): We have already implemented a RAG system to provide real-time, context-aware explanations about waste sorting. Next, we aim to improve its retrieval accuracy and response relevance by exploring different embedding models and expanding our dataset. Advancing Computer Vision for Waste Classification: We will refine our AI model using a more diverse dataset of waste images, improving its ability to classify items and estimate food waste weight with greater precision. Integrating a Robotic Arm for Automated Sorting: As a long-term goal, we envision incorporating a robotic arm that can physically sort waste based on AI predictions, reducing human error and streamlining waste management.

## README (from the GitHub repository)

# TreeHacks 2025: TreeTrash
https://devpost.com/software/treetrash

## Inspiration
During TreeHacks, we noticed a significant number of items being placed in the wrong waste bins, which reminded us of a broader problem with tracking and understanding waste patterns, so that they could be effectively mitigated in the future. This sparked our idea to expand upon challenge #3 on the sustainability track and leverage AI to not only identify and address this issue but also take it a step further. We wanted to go beyond simply classifying waste and analyzing the weight — we aimed to develop a program that could analyze images of trash, recycling and compost and generate a report that could provide organizations like Stanford with valuable insights into food waste patterns, enabling them to implement more effective sustainability initiatives and reduce unnecessary waste.

## What It Does
TreeTrash leverages computer vision to analyze images of a trash bin taken at regular intervals. We determine which items were misplaced and what the environmental impact of misplacing those items using a custom search pipeline. When we first notice a misplaced item, we use a display and speaker to notify the person. Then, we generate a custom report about the environmental impact of misplacing certain items, as well as specific recommendations about how to improve.

## Technical Overview
TreeTrash implements a multi-model, multi-modal AI pipeline for real-time waste analysis and environmental impact assessment. Our system architecture combines computer vision, large language models, and vector search capabilities to create a comprehensive waste management solution.

## Core Architecture

### Computer Vision Pipeline
- Primary Vision Model: Leveraged YOLOv8 for real-time object detection, fine-tuned on custom labeled dataset
- Frame Processing: Utilizes OpenCV for image preprocessing, including noise reduction and contrast enhancement
- Temporal Analysis: Implements a sliding window to track objects across multiple frames, enabling detection of newly added items

### AI Model Integration
- LLM: GPT-4o: for waste classification and initial analysis
- Secondary Models:
  - Perplexity AI for environmental impact research
  - GPT-4o-mini for structured data transformation and report generation
  - Gemini Pro as a VLM to post-process Vespa.ai RAG outputs
- Custom Prompt Engineering: Developed specialized prompts to improve classification accuracy

### RAG Implementation
- Vector Database: Vespa.ai for storing and retrieving sustainability documentation
- Embedding Model: ColPali (Efficient Document Retrieval with Vision Language Models)

## Data Pipeline
1. Image Capture & Processing
   - Resolution: 1920x1080 @ 30fps
   - Format: JPEG with quality preservation
   - Preprocessing: Gaussian blur (σ=1.5) for noise reduction

2. Object Detection & Classification
   - Model Architecture: YOLOv8 backbone with custom head
   - Inference Time: <50ms per frame
   - GPU Optimization: CUDA acceleration with TensorRT

3. Environmental Impact Analysis
   - Custom API integration with Perplexity
   - Structured output parsing using regex and NLP
   - Carbon footprint calculation using standardized metrics

4. Report Generation
   - Vector similarity search
   - Dynamic template generation
   - PDF export with visualizations

## Future Technical Enhancements

### LLM enhancements
- Improved prompting with DsPy for automated, bootstrapped prompt engineering
- Applying techniques like in-context learning

### RAG System Optimization
- Implementing hybrid search combining sparse and dense retrievers
- Adding cross-encoder reranking
- Developing custom embedding models for waste management domain

### Computer Vision Improvements
- Transfer learning from larger vision models
- Implementation of instance segmentation
- Real-time optical character recognition for packaging

### Robotic Integration
- ROS2 implementation for robotic arm control
- Computer vision-guided path planning


## Detected evidence (automated analysis)

Indexed codebase: 31 recognized source files, 61 KB.
- CSS (language) — detected in the code
- Flask (technology) — detected in the code
- Hugging Face (technology) — detected in the code
- Next.js (technology) — detected in the code
- OpenAI (technology) — detected in the code
- Python (language) — detected in the code
- PyTorch (technology) — detected in the code
- React (technology) — detected in the code
- Tailwind CSS (technology) — detected in the code
- TypeScript (language) — detected in the code
- Google Gemini (technology) — claimed on Devpost, not found in the code
- Vercel (technology) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (120 of 144)

```
.gitattributes
.gitignore
.vscode/settings.json
0.50.0
camera/depthai_example.py
camera/simple_capture.py
camera/take_photo.py
camera/trial_object_detection.py
camera/yolov8n.pt
colpalidemodev/schemas/pdf_page.sd
colpalidemodev/search/query-profiles/default.xml
colpalidemodev/search/query-profiles/types/root.xml
colpalidemodev/services.xml
hardware/CIRCUITPY-feather/backup.py
hardware/CIRCUITPY-feather/boot_out.txt
hardware/CIRCUITPY-feather/code.py
hardware/CIRCUITPY-feather/lib/adafruit_ble/__init__.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/advertising/__init__.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/advertising/adafruit.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/advertising/standard.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/attributes/__init__.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/characteristics/__init__.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/characteristics/float.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/characteristics/int.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/characteristics/json.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/characteristics/stream.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/characteristics/string.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/services/__init__.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/services/circuitpython.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/services/microbit.py
hardware/CIRCUITPY-feather/lib/adafruit_ble/services/nordic.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/services/sphero.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/services/standard/__init__.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/services/standard/device_info.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/services/standard/hid.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ble/uuid/__init__.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bluefruit_connect/__init__.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bluefruit_connect/_xyz_packet.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bluefruit_connect/accelerometer_packet.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bluefruit_connect/button_packet.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bluefruit_connect/color_packet.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bluefruit_connect/gyro_packet.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bluefruit_connect/location_packet.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bluefruit_connect/magnetometer_packet.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bluefruit_connect/packet.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bluefruit_connect/quaternion_packet.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bluefruit_connect/raw_text_packet.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bluefruitspi.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bme680.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bus_device/__init__.py
hardware/CIRCUITPY-feather/lib/adafruit_bus_device/i2c_device.mpy
hardware/CIRCUITPY-feather/lib/adafruit_bus_device/spi_device.mpy
hardware/CIRCUITPY-feather/lib/adafruit_debouncer.mpy
hardware/CIRCUITPY-feather/lib/adafruit_dotstar.mpy
hardware/CIRCUITPY-feather/lib/adafruit_lis3mdl.mpy
hardware/CIRCUITPY-feather/lib/adafruit_lsm6ds/__init__.mpy
hardware/CIRCUITPY-feather/lib/adafruit_lsm6ds/ism330dhcx.mpy
hardware/CIRCUITPY-feather/lib/adafruit_lsm6ds/lsm6ds3.mpy
hardware/CIRCUITPY-feather/lib/adafruit_lsm6ds/lsm6ds33.mpy
hardware/CIRCUITPY-feather/lib/adafruit_lsm6ds/lsm6ds3trc.mpy
hardware/CIRCUITPY-feather/lib/adafruit_lsm6ds/lsm6dso32.mpy
hardware/CIRCUITPY-feather/lib/adafruit_lsm6ds/lsm6dsox.mpy
hardware/CIRCUITPY-feather/lib/adafruit_pixelbuf.mpy
hardware/CIRCUITPY-feather/lib/adafruit_register/__init__.py
hardware/CIRCUITPY-feather/lib/adafruit_register/i2c_bcd_alarm.mpy
hardware/CIRCUITPY-feather/lib/adafruit_register/i2c_bcd_datetime.mpy
hardware/CIRCUITPY-feather/lib/adafruit_register/i2c_bit.mpy
hardware/CIRCUITPY-feather/lib/adafruit_register/i2c_bits.mpy
hardware/CIRCUITPY-feather/lib/adafruit_register/i2c_struct_array.mpy
hardware/CIRCUITPY-feather/lib/adafruit_register/i2c_struct.mpy
hardware/CIRCUITPY-feather/lib/adafruit_rfm9x.mpy
hardware/CIRCUITPY-feather/lib/adafruit_ticks.mpy
hardware/CIRCUITPY-feather/lib/dotstar_featherwing.mpy
hardware/CIRCUITPY-feather/lib/neopixel.mpy
hardware/CIRCUITPY-feather/lib/utils.py
hardware/CIRCUITPY-portal/boot_out.txt
hardware/CIRCUITPY-portal/code.py
hardware/CIRCUITPY-portal/fonts/Arial-ItalicMT-23.bdf
hardware/CIRCUITPY-portal/lib/adafruit_bitmap_font/__init__.py
hardware/CIRCUITPY-portal/lib/adafruit_bitmap_font/bdf.mpy
hardware/CIRCUITPY-portal/lib/adafruit_bitmap_font/bitmap_font.mpy
hardware/CIRCUITPY-portal/lib/adafruit_bitmap_font/glyph_cache.mpy
hardware/CIRCUITPY-portal/lib/adafruit_bitmap_font/pcf.mpy
hardware/CIRCUITPY-portal/lib/adafruit_bitmap_font/ttf.mpy
hardware/CIRCUITPY-portal/lib/adafruit_debouncer.mpy
hardware/CIRCUITPY-portal/lib/adafruit_display_shapes/__init__.py
hardware/CIRCUITPY-portal/lib/adafruit_display_shapes/arc.mpy
hardware/CIRCUITPY-portal/lib/adafruit_display_shapes/circle.mpy
hardware/CIRCUITPY-portal/lib/adafruit_display_shapes/line.mpy
hardware/CIRCUITPY-portal/lib/adafruit_display_shapes/multisparkline.mpy
hardware/CIRCUITPY-portal/lib/adafruit_display_shapes/polygon.mpy
hardware/CIRCUITPY-portal/lib/adafruit_display_shapes/rect.mpy
hardware/CIRCUITPY-portal/lib/adafruit_display_shapes/roundrect.mpy
hardware/CIRCUITPY-portal/lib/adafruit_display_shapes/sparkline.mpy
hardware/CIRCUITPY-portal/lib/adafruit_display_shapes/triangle.mpy
hardware/CIRCUITPY-portal/lib/adafruit_display_text/__init__.mpy
hardware/CIRCUITPY-portal/lib/adafruit_display_text/bitmap_label.mpy
hardware/CIRCUITPY-portal/lib/adafruit_display_text/label.mpy
hardware/CIRCUITPY-portal/lib/adafruit_display_text/outlined_label.mpy
hardware/CIRCUITPY-portal/lib/adafruit_display_text/scrolling_label.mpy
hardware/CIRCUITPY-portal/lib/adafruit_io/__init__.py
hardware/CIRCUITPY-portal/lib/adafruit_io/adafruit_io_errors.mpy
hardware/CIRCUITPY-portal/lib/adafruit_io/adafruit_io.mpy
hardware/CIRCUITPY-portal/lib/adafruit_minimqtt/__init__.py
hardware/CIRCUITPY-portal/lib/adafruit_minimqtt/adafruit_minimqtt.mpy
hardware/CIRCUITPY-portal/lib/adafruit_minimqtt/matcher.mpy
hardware/CIRCUITPY-portal/lib/adafruit_miniqr.mpy
hardware/CIRCUITPY-portal/lib/adafruit_pybadger/__init__.mpy
hardware/CIRCUITPY-portal/lib/adafruit_pybadger/clue.mpy
hardware/CIRCUITPY-portal/lib/adafruit_pybadger/cpb_gizmo.mpy
hardware/CIRCUITPY-portal/lib/adafruit_pybadger/magtag.mpy
hardware/CIRCUITPY-portal/lib/adafruit_pybadger/pewpewm4.mpy
hardware/CIRCUITPY-portal/lib/adafruit_pybadger/pybadge.mpy
hardware/CIRCUITPY-portal/lib/adafruit_pybadger/pybadger_base.mpy
hardware/CIRCUITPY-portal/lib/adafruit_pybadger/pygamer.mpy
hardware/CIRCUITPY-portal/lib/adafruit_pybadger/pyportal.mpy
hardware/CIRCUITPY-portal/lib/adafruit_pyportal/__init__.mpy
hardware/CIRCUITPY-portal/lib/adafruit_pyportal/graphics.mpy
hardware/CIRCUITPY-portal/lib/adafruit_pyportal/network.mpy
hardware/CIRCUITPY-portal/lib/adafruit_pyportal/peripherals.mpy
[24 more files omitted for size]
```

### Dependencies

- report-render/package.json: @emotion/react@^11.14.0, @emotion/styled@^11.14.0, @eslint/eslintrc@^3, @mui/material@^6.4.4, @mui/x-charts@^7.26.0, @types/node@^20, @types/react@^19, @types/react-dom@^19, eslint@^9, eslint-config-next@15.1.7, lucide-react@^0.475.0, next@15.1.7, postcss@^8, react@^19.0.0, react-dom@^19.0.0, shadcn-ui@^0.9.4, tailwindcss@^3.4.1, typescript@^5, ui@github:shadcn/ui
- requirements.txt: accelerate@==1.3.0, aiohappyeyeballs@==2.4.6, aiohttp@==3.11.12, aiosignal@==1.3.2, annotated-types@==0.7.0, anyio@==4.8.0, attrs@==25.1.0, blinker@==1.9.0, cachetools@==5.5.1, certifi@==2025.1.31, cffi@==1.17.1, charset-normalizer@==3.4.1, click@==8.1.8, colpali_engine@==0.3.1, cryptography@==44.0.1, datasets@==2.21.0, depthai@==2.29.0.0, dill@==0.3.8, distro@==1.9.0, docker@==7.1.0, einops@==0.8.1, eval_type_backport@==0.2.2, fastcore@==1.7.29, filelock@==3.17.0, Flask@==3.1.0, frozenlist@==1.5.0, fsspec@==2024.6.1, google-ai-generativelanguage@==0.6.10, google-api-core@==2.24.1, google-api-python-client@==2.161.0, google-auth@==2.38.0, google-auth-httplib2@==0.2.0, google-generativeai@==0.8.3, googleapis-common-protos@==1.67.0, GPUtil@==1.4.0, grpcio@==1.70.0, grpcio-status@==1.70.0, h11@==0.14.0, h2@==4.2.0, hpack@==4.1.0, httpcore@==1.0.7, httplib2@==0.22.0, httpx@==0.28.1, huggingface-hub@==0.28.1, hyperframe@==6.1.0, idna@==3.10, ipykernel, ipython, itsdangerous@==2.2.0, Jinja2@==3.1.5, jiter@==0.8.2, joblib@==1.4.2, jupyter_client, jupyter_core, loguru@==0.7.3, lxml@==5.3.1, markdown-it-py@==3.0.0, MarkupSafe@==3.0.2, mdurl@==0.1.2, mpmath@==1.3.0, mteb@==1.34.14, multidict@==6.1.0, multiprocess@==0.70.16, networkx@==3.4.2, numpy@==1.26.4, openai@==1.63.0, opencv-python@==4.11.0.86, pandas@==2.2.3, pdf2image@==1.17.0, peft@==0.11.1, pillow@==10.4.0, polars@==1.22.0, poppler-utils@==0.1.0, propcache@==0.2.1, proto-plus@==1.26.0, protobuf@==5.29.3, psutil, pure_eval, pyarrow@==19.0.0, pyasn1@==0.6.1, pyasn1_modules@==0.4.1, pycparser@==2.22, pydantic@==2.10.6, pydantic_core@==2.27.2, PyMuPDF@==1.25.3, pyparsing@==3.2.1, pypdf@==5.0.1, python-dotenv@==1.0.1, pytrec-eval-terrier@==0.5.6, pytz@==2025.1, pyvespa@==0.53.0, pywin32@==307, PyYAML@==6.0.2, regex@==2024.11.6, requests@==2.32.3, requests-toolbelt@==1.0.0, rich@==13.9.4, rsa@==4.9, safetensors@==0.5.2, scikit-learn@==1.6.1, scipy@==1.15.1, sentence-transformers@==3.4.1, sentencepiece@==0.2.0, setuptools@==75.8.0, shellingham@==1.5.4, sniffio@==1.3.1, sympy@==1.13.1, tenacity@==9.0.0, threadpoolctl@==3.5.0, tokenizers@==0.21.0, torch@==2.6.0, torchvision@==0.21.0, tornado, tqdm@==4.67.1, transformers@==4.48.3, typer@==0.15.1, tzdata@==2025.1, uritemplate@==4.1.1, urllib3@==2.3.0, vespacli@==8.478.26, vidore_benchmark@==4.0.0, Werkzeug@==3.1.3, wheel@==0.45.1, win32_setctime@==1.2.0, xxhash@==3.5.0, yarl@==1.18.3

### Recent commits (newest first)

- Update README.md
- Update README.md
- Update README.md
- Completed hardware!
- Finished project
- Final project
- Removing comments
- MVP
- Merge branch 'main' of github.com:sonnetx/treehacks-2025
- MVP
- Update README.md
- Serialization test
- Merge branch 'main' of github.com:sonnetx/treehacks-2025
- Test
- testing
- Implement Hardware
- fixed recommendations
- update
- fix recommendation pipeline
- add recommendations

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

### requirements.txt

```
accelerate==1.3.0
aiohappyeyeballs==2.4.6
aiohttp==3.11.12
aiosignal==1.3.2
annotated-types==0.7.0
anyio==4.8.0
attrs==25.1.0
blinker==1.9.0
cachetools==5.5.1
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
click==8.1.8
colpali_engine==0.3.1
cryptography==44.0.1
datasets==2.21.0
depthai==2.29.0.0
dill==0.3.8
distro==1.9.0
docker==7.1.0
einops==0.8.1
eval_type_backport==0.2.2
fastcore==1.7.29
filelock==3.17.0
Flask==3.1.0
frozenlist==1.5.0
fsspec==2024.6.1
google-ai-generativelanguage==0.6.10
google-api-core==2.24.1
google-api-python-client==2.161.0
google-auth==2.38.0
google-auth-httplib2==0.2.0
google-generativeai==0.8.3
googleapis-common-protos==1.67.0
GPUtil==1.4.0
grpcio==1.70.0
grpcio-status==1.70.0
h11==0.14.0
h2==4.2.0
hpack==4.1.0
httpcore==1.0.7
httplib2==0.22.0
httpx==0.28.1
huggingface-hub==0.28.1
hyperframe==6.1.0
idna==3.10
ipykernel
ipython
itsdangerous==2.2.0
Jinja2==3.1.5
jiter==0.8.2
joblib==1.4.2
jupyter_client
jupyter_core
loguru==0.7.3
lxml==5.3.1
markdown-it-py==3.0.0
MarkupSafe==3.0.2
mdurl==0.1.2
mpmath==1.3.0
mteb==1.34.14
multidict==6.1.0
multiprocess==0.70.16
networkx==3.4.2
numpy==1.26.4
openai==1.63.0
opencv-python==4.11.0.86
pandas==2.2.3
pdf2image==1.17.0
peft==0.11.1
pillow==10.4.0
polars==1.22.0
poppler-utils==0.1.0
propcache==0.2.1
proto-plus==1.26.0
protobuf==5.29.3
psutil
pure_eval
pyarrow==19.0.0
pyasn1==0.6.1
pyasn1_modules==0.4.1
pycparser==2.22
pydantic==2.10.6
pydantic_core==2.27.2
PyMuPDF==1.25.3
pyparsing==3.2.1
pypdf==5.0.1
python-dotenv==1.0.1
pytrec-eval-terrier==0.5.6
pytz==2025.1
pyvespa==0.53.0
pywin32==307
PyYAML==6.0.2
regex==2024.11.6
requests==2.32.3
requests-toolbelt==1.0.0
rich==13.9.4
rsa==4.9
safetensors==0.5.2
scikit-learn==1.6.1
scipy==1.15.1
sentence-transformers==3.4.1
sentencepiece==0.2.0
setuptools==75.8.0
shellingham==1.5.4
sniffio==1.3.1
sympy==1.13.1
tenacity==9.0.0
threadpoolctl==3.5.0
tokenizers==0.21.0
torch==2.6.0
torchvision==0.21.0
tornado
tqdm==4.67.1
transformers==4.48.3
typer==0.15.1
tzdata==2025.1
uritemplate==4.1.1
urllib3==2.3.0
vespacli==8.478.26
vidore_benchmark==4.0.0
Werkzeug==3.1.3
wheel==0.45.1
win32_setctime==1.2.0
xxhash==3.5.0
yarl==1.18.3

```

### report-render/package.json

```
{
  "name": "report-render",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@emotion/react": "^11.14.0",
    "@emotion/styled": "^11.14.0",
    "@mui/material": "^6.4.4",
    "@mui/x-charts": "^7.26.0",
    "lucide-react": "^0.475.0",
    "next": "15.1.7",
    "react": "^19.0.0",
    "react-dom": "^19.0.0",
    "shadcn-ui": "^0.9.4",
    "ui": "github:shadcn/ui"
  },
  "devDependencies": {
    "@eslint/eslintrc": "^3",
    "@types/node": "^20",
    "@types/react": "^19",
    "@types/react-dom": "^19",
    "eslint": "^9",
    "eslint-config-next": "15.1.7",
    "postcss": "^8",
    "tailwindcss": "^3.4.1",
    "typescript": "^5"
  }
}

```

### report-render/src/app/layout.tsx

```typescript
import "./globals.css";

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en">
      <body>
        {children}
      </body>
    </html>
  );
}

```

### report-render/src/app/page.tsx

```typescript
"use client";

import { BarChart } from "@mui/x-charts/BarChart";
import { PieChart } from "@mui/x-charts/PieChart";
import { Lightbulb, Leaf, Factory, Home, Car } from "lucide-react";
import { useEffect, useState } from "react";

export default function CarbonEmissionsReport() {
  const currentDate = new Date().toLocaleDateString("en-US", {
    year: "numeric",
    month: "long",
    day: "numeric",
  });

  const [data, setData] = useState(null);

  useEffect(() => {
    fetch("/api/reportData")
      .then((res) => res.json())
      .then((data) => {
        setData(data.data.report_data);
        console.log(data.message);
      })
      .catch((error) => console.error("Error fetching data:", error));
  }, []);

  useEffect(() => {
    console.log(data);
  }, [data]);

  return (
    <div className="min-h-screen bg-gray-100 p-8">
      <main className="container mx-auto bg-white shadow-lg rounded-lg overflow-hidden">
        {/* Header */}
        <header className="bg-gray-800 text-white p-6 text-center">
          <h1 className="text-3xl font-bold">Ecological Footprint Report</h1>
          <p className="text-gray-300 mt-2">Generated on {currentDate}</p>
        </header>

        <div className="p-6 space-y-8">
          {/* Executive Summary & Total Emissions */}
          <section className="bg-white shadow-md rounded-lg p-6">
            <h2 className="text-2xl font-semibold mb-4 text-center text-black">
              Executive Summary & Total Emissions
            </h2>

            <div className="grid md:grid-cols-3 gap-6">
              {/* Pie Chart */}
              <div className="bg-gray-50 rounded-lg p-6 shadow-md flex flex-col items-center justify-center">
                <h3 className="text-lg font-semibold text-black mb-2">
                  Waste Breakdown
                </h3>
                <PieChart
                  series={[
                    {
                      data: data
                        ? [
                            {
                              id: 0,
                              value: data.numTrash ?? 0,
                              label: "Trash",
                            },
                            {
                              id: 1,
                              value: data.numCompost ?? 0,
                              label: "Compost",
                            },
                            {
                              id: 2,
                              value: data.numRecycle ?? 0,
                              label: "Recycle",
                            },
                          ]
                        : [],
                    },
                  ]}
                  width={250}
                  height={200}
                  legend={{
                    labelStyle: { fontSize: 12 },
                    padding: 10,
                  }}
                />
              </div>

              {/* Total Emissions */}
              <div className="bg-gray-50 rounded-lg p-6 shadow-md flex flex-col items-center justify-center">
                <p className="text-xl font-semibold text-black">
                  Total Emissions
                </p>
                <span className="text-5xl font-bold text-blue-600">
                  {data
                    ? (
                        Number(
                          parseFloat(
                            data.recycleInTrashEmissions.toFixed(4) ?? 0
                          )
                        ) +
                        Number(
                          parseFloat(
                            data.compostInTrashEmissions.toFixed(4) ?? 0
                          )
                        ) +
                        Number(parseFloat(data.trashEmissions.toFixed(4) ?? 0))
                      ).toFixed(4)
                    : "Loading..."}
                </span>
                <p className="text-lg text-gray-500">kg CO2e</p>
              </div>

              {/* Bar Chart */}
              <div className="bg-gray-50 rounded-lg p-6 shadow-md flex flex-col items-center justify-center">
                <h3 className="text-lg font-semibold text-black mb-2">
                  Emissions
                </h3>
                {data && (
                  <BarChart
                    xAxis={[
                      {
                        scaleType: "band",
                        data: ["Trash", "Recycle", "Compose"],
                      },
                    ]}
                    series={[
                      {
                        data: [
                          data.trashEmissions,
                          data.recycleInTrashEmissions,
                          data.compostInTrashEmissions,
                        ],
                      },
                    ]}
                    width={300}
                    height={250}
                  />
                )}
                <p className="text-sm text-gray-500 mt-2 text-center">
                  Equivalent Emissions (kg CO2e)
                </p>
              </div>
            </div>
          </section>

          {/* Waste Breakdown */}
          <section className="bg-white rounded-lg p-6 shadow-md">
            <h2 className="text-2xl font-semibold mb-4 text-center text-black">
              Waste Breakdown
            </h2>

            <div className="grid md:grid-cols-2 gap-6">
              {/* Compostable Components */}
              <div className="bg-green-100 p-6 rounded-lg shadow-md">
                <h3 className="text-lg font-semibold text-green-800 flex items-center gap-2">
                  🌱 Compostable Components
                </h3>
                {data?.compostNames?.length > 0 ? (
                  <ul className="list-disc pl-5 mt-2 text-gray-700">
                    {data.compostNames.map((item, index) => (
                      <li key={index}>{item}</li>
                    ))}
                  </ul>
                ) : (
                  <p cla
[truncated — 1757 more characters]
```

### report-render/src/app/api/reportData/route.ts

```typescript
import { NextResponse } from "next/server";

export async function GET() {
  try {
    // Fetch data from the hardcoded external API
    const response = await fetch("http://127.0.0.1:5000/api/data");
    const data = await response.json();

    return NextResponse.json({ message: "Data fetched successfully", data });
  } catch (error) {
    return NextResponse.json(
      { error: "Failed to fetch data", details: error },
      { status: 500 }
    );
  }
}

```

### report-render/next.config.ts

```typescript
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  /* config options here */
};

export default nextConfig;

```

### hardware/control.py

```python
import serial
import time

ser = serial.Serial('/dev/tty.usbmodem1101', 115200, timeout=1)

def show_correct():
    ser.write(f"correct\n".encode())
    print(f"Sent command: correct")

def show_incorrect():
    ser.write(f"incorrect\n".encode())
    print(f"Sent command: incorrect")

show_correct()
ser.close()



```

### report-render/tailwind.config.ts

```typescript
import type { Config } from "tailwindcss";

export default {
  content: [
    "./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
    "./src/components/**/*.{js,ts,jsx,tsx,mdx}",
    "./src/app/**/*.{js,ts,jsx,tsx,mdx}",
  ],
  theme: {
    extend: {
      colors: {
        background: "var(--background)",
        foreground: "var(--foreground)",
      },
    },
  },
  plugins: [],
} satisfies Config;

```

### report/controller.py

```python
from flask import Flask, jsonify
from report import ReportData, Report
from basic_pipeline import EmissionsResponse, TrashAnalyzer
from analyze_trash import CameraCapture
from dotenv import load_dotenv

import os



app = Flask(__name__)

@app.route('/api/data')
def get_data():
    
    # Load environment variables
    load_dotenv()
    
    # Initialize API keys
    openai_api_key = os.getenv("OPENAI_API_KEY")
    perplexity_api_key = os.getenv("PERPLEXITY_API_KEY")
    
    if not openai_api_key or not perplexity_api_key:
        print("Error: Missing API keys in .env file")
        return

    # Initialize analyzer
    analyzer = TrashAnalyzer(openai_api_key, perplexity_api_key)
    
    # # Initialize camera and capture images
    camera = CameraCapture()
    
    before_path = "sample-images/before.jpg"
    after_path = camera.capture_image()
    
    report_data = analyzer.analyze_trash(before_path, after_path)

    report = Report(report_data=report_data)
    return jsonify(report.to_dict())  # Send as JSON

if __name__ == '__main__':
    app.run(debug=True)

```

### colpalidemodev/services.xml

```xml
<?xml version="1.0" encoding="UTF-8" ?>
<services version="1.0">
  <container id="colpalidemodev_container" version="1.0">
    <search></search>
    <document-api></document-api>
    <document-processing></document-processing>
    <clients>
      <client id="mtls" permissions="read,write">
        <certificate file="security/clients.pem"></certificate>
      </client>
      <client id="token_write" permissions="read,write">
        <token id="pyvespa_integration"></token>
      </client>
    </clients>
    <config name="container.qr-searchers">
      <tag>
        <bold>
          <open>&lt;strong&gt;</open>
          <close>&lt;/strong&gt;</close>
        </bold>
        <separator>...</separator>
      </tag>
    </config>
  </container>
  <content id="colpalidemodev_content" version="1.0">
    <redundancy>1</redundancy>
    <documents>
      <document type="pdf_page" mode="index"></document>
    </documents>
    <nodes>
      <node distribution-key="0" hostalias="node1"></node>
    </nodes>
    <config name="vespa.config.search.summary.juniperrc">
      <max_matches>2</max_matches>
      <length>1000</length>
      <surround_max>500</surround_max>
      <min_length>300</min_length>
    </config>
  </content>
</services>
```

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