Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
961c323
init
hitendras510 Mar 28, 2026
9c7eb39
init
hitendras510 Mar 28, 2026
b620906
init
hitendras510 Mar 29, 2026
c4b2551
architecture updated
hitendras510 Mar 29, 2026
70d9b5b
init
hitendras510 Mar 29, 2026
33c57c8
init
hitendras510 Mar 29, 2026
d9f6638
folder structed
hitendras510 Mar 29, 2026
8bf3ee6
Update README.md
hitendras510 Mar 29, 2026
f8e1f2c
fix: flatten repo structure
hitendras510 Mar 29, 2026
4e27303
Enhance README with project overview and details
hitendras510 Mar 29, 2026
920f319
fix: clean repo, remove venv and cache files
hitendras510 Mar 30, 2026
f656582
do
dhruv0431-sketch Mar 30, 2026
978d76d
Merge pull request #1 from dhruv0431-sketch/main
hitendras510 Mar 30, 2026
8f3c825
Added AI fuel prediction
omdharb-bit Mar 30, 2026
58e4892
routing with shortest path done
hitendras510 Mar 30, 2026
99d0cb6
Merge branch 'hitendras510:main' into main
omdharb-bit Mar 30, 2026
57cca7c
fix: remove unnecessary files
hitendras510 Mar 31, 2026
8b57750
Removed venv and cache files
omdharb-bit Mar 31, 2026
0669ad4
Removed .venv and added to gitignore
omdharb-bit Mar 31, 2026
a345fa1
Cleaned cache files and fixed tracking
omdharb-bit Mar 31, 2026
d6defdb
done
omdharb-bit Apr 1, 2026
1ce4349
init
omdharb-bit Apr 1, 2026
df99d54
Merge pull request #6 from omdharb-bit/main
hitendras510 Apr 1, 2026
8b83632
init
hitendras510 Apr 1, 2026
29f30ff
hii
omdharb-bit Apr 1, 2026
bb4542a
Merge branch 'main' of https://github.com/omdharb-bit/EcoNav-AI
omdharb-bit Apr 1, 2026
16f6f13
init
omdharb-bit Apr 1, 2026
5f9430f
agent trained
hitendras510 Apr 1, 2026
b8729aa
Pytorch
omdharb-bit Apr 1, 2026
9a8d073
resolved merge conflict
omdharb-bit Apr 1, 2026
1a408af
Merge pull request #8 from omdharb-bit/main
omdharb-bit Apr 1, 2026
4e55cec
automation traning added
omdharb-bit Apr 1, 2026
d6198a3
Merge branch 'main' of https://github.com/omdharb-bit/EcoNav-AI
omdharb-bit Apr 1, 2026
5444d08
Merge pull request #9 from omdharb-bit/main
omdharb-bit Apr 1, 2026
155cfd4
init
omdharb-bit Apr 1, 2026
188d6d1
Merge branch 'main' of https://github.com/omdharb-bit/EcoNav-AI
omdharb-bit Apr 1, 2026
0089438
Merge pull request #10 from omdharb-bit/main
omdharb-bit Apr 1, 2026
364d32c
init
hitendras510 Apr 1, 2026
81aacc5
init
omdharb-bit Apr 1, 2026
937244a
Merge branch 'main' of https://github.com/omdharb-bit/EcoNav-AI
omdharb-bit Apr 1, 2026
2e0b242
init
omdharb-bit Apr 1, 2026
4f0736d
init
omdharb-bit Apr 1, 2026
1566850
init
omdharb-bit Apr 1, 2026
fbf4281
Resolved merge conflict with upstream main
omdharb-bit Apr 1, 2026
8a81fe2
Merge pull request #14 from omdharb-bit/omdharb-bit-main
hitendras510 Apr 1, 2026
a356ff5
init
hitendras510 Apr 1, 2026
c3afe69
init
omdharb-bit Apr 1, 2026
53969cc
init
hitendras510 Apr 1, 2026
3e884e6
init
omdharb-bit Apr 1, 2026
35eacef
Complete end-to-end EcoNav hackathon app flow
hitendras510 Apr 1, 2026
677d252
Merge pull request #15 from hitendras510/codex/complete-hackathon-pro…
hitendras510 Apr 1, 2026
bae68a4
init
omdharb-bit Apr 1, 2026
8b093de
init
omdharb-bit Apr 1, 2026
23f33d5
Upgrade Streamlit frontend with richer UX and route history
hitendras510 Apr 1, 2026
9677e80
Harden core packages and eliminate empty-module production gaps
hitendras510 Apr 1, 2026
d733b86
Resolve merge conflicts with main
hitendras510 Apr 1, 2026
048bdd2
Merge pull request #19 from hitendras510/codex/complete-hackathon-pro…
hitendras510 Apr 1, 2026
8c3d578
Merge pull request #18 from hitendras510/codex/complete-hackathon-pro…
hitendras510 Apr 1, 2026
9b18525
init
omdharb-bit Apr 1, 2026
fe52b10
ohhh
omdharb-bit Apr 1, 2026
d6f6586
init
omdharb-bit Apr 1, 2026
b8bdcfc
init
hitendras510 Apr 2, 2026
85c1631
hi
omdharb-bit Apr 2, 2026
1ae2840
feat: implement real-time AQI dashboard, exposure credit system, and …
hitendras510 Apr 2, 2026
30b643f
init
omdharb-bit Apr 2, 2026
c202e38
refactor: migrate frontend from Streamlit to a Vite-based JavaScript …
hitendras510 Apr 2, 2026
59c6b1c
Merge pull request #21 from hitendras510/codex/complete-hackathon-pro…
hitendras510 Apr 2, 2026
19d1cf6
init
omdharb-bit Apr 2, 2026
e86f81a
init
omdharb-bit Apr 2, 2026
a72d736
Merge branch 'main' of https://github.com/omdharb-bit/EcoNav-AI into …
omdharb-bit Apr 2, 2026
ac0bca7
feat: integrate Leaflet map visualization and add OpenEnv RL tasks vi…
hitendras510 Apr 2, 2026
db78fe0
init
hitendras510 Apr 2, 2026
cffe82b
final frontend polish
hitendras510 Apr 2, 2026
4d24bed
meta i love you!!
omdharb-bit Apr 2, 2026
d8af758
Merge branch 'main' of https://github.com/omdharb-bit/EcoNav-AI into …
omdharb-bit Apr 2, 2026
f8a0572
feat: implement traffic multiplier for pollution routing and add glob…
hitendras510 Apr 2, 2026
ce7e387
Merge branch 'main' of https://github.com/omdharb-bit/EcoNav-AI into …
omdharb-bit Apr 2, 2026
d0d9994
feat: implement interactive route network visualization with canvas-b…
hitendras510 Apr 2, 2026
1488750
init
hitendras510 Apr 2, 2026
f967cd9
Merge branch 'main' of https://github.com/omdharb-bit/EcoNav-AI into …
omdharb-bit Apr 2, 2026
302a983
init
omdharb-bit Apr 2, 2026
61ff449
Merge branch 'main' of https://github.com/omdharb-bit/EcoNav-AI into …
omdharb-bit Apr 3, 2026
3975927
Merge branch 'main' of https://github.com/omdharb-bit/EcoNav-AI
omdharb-bit Apr 7, 2026
7274c48
inti
omdharb-bit Apr 8, 2026
7368f9d
Merge branch 'main' of https://github.com/omdharb-bit/EcoNav-AI
omdharb-bit Apr 8, 2026
56636ec
init
omdharb-bit Apr 8, 2026
a677512
Merge branch 'hitendras510:main' into main
omdharb-bit Apr 8, 2026
708dfc3
feat: implement real-time AQI-based route service and frontend visual…
omdharb-bit Apr 8, 2026
8ee3ed7
feat: implement full-stack city and road management system with autom…
omdharb-bit Apr 8, 2026
f4463a7
docs: overhaul README with project structure, tech stack, and setup i…
omdharb-bit Apr 8, 2026
83b3682
feat: initialize FastAPI backend and frontend dashboard structure
omdharb-bit Apr 8, 2026
c267d3f
feat: initialize FastAPI backend and frontend dashboard interface
omdharb-bit Apr 8, 2026
2313fc5
feat: initialize FastAPI application with core API routes and fronten…
omdharb-bit Apr 8, 2026
e9b418a
commit
omdharb-bit Apr 8, 2026
67709e6
feat: implement multi-stage Docker build to serve frontend static fil…
omdharb-bit Apr 8, 2026
ea02454
init
omdharb-bit Apr 8, 2026
29d4f4e
build: refactor Dockerfile dependency installation and add dedicated …
omdharb-bit Apr 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
<<<<<<< HEAD
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Dependencies
node_modules
.pnp
.pnp.js

# Local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Testing
coverage

# Turbo
.turbo

# Vercel
.vercel

# Build Outputs
.next/
out/
build
dist


# Debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Misc
.DS_Store
*.pem
.venv
.venv/
__pycache__/
*.pyc
*.pkl
models/eco_model.pth
=======
.venv/
__pycache__/
*.pyc
Expand All @@ -6,3 +52,4 @@ __pycache__/
node_modules/
.env
dist/
>>>>>>> 1c2f25b401a67215ea459ece945cb72cc7dbd373
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
35 changes: 19 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,46 +1,49 @@
# Use a specific slim Python image that matches openenv.yaml
# Stage 1: Build the frontend
FROM node:20-slim AS frontend-build
WORKDIR /app
COPY package*.json ./
COPY apps/frontend/package*.json ./apps/frontend/
RUN rm -rf package-lock.json
RUN npm install
COPY . .
WORKDIR /app/apps/frontend
RUN npx vite build

# Stage 2: Final image
FROM python:3.10-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PORT=7860

# Set working directory
WORKDIR /app

# Install system dependencies
# Install system dependencies with better error handling and common tools
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
git \
&& rm -rf /var/lib/apt/lists/*

# Install uv for fast dependency resolution
# Install uv and requirements
RUN pip install --no-cache-dir uv

# Copy ONLY requirements first to leverage Docker cache
COPY requirements/ ./requirements/
COPY pyproject.toml uv.lock ./

# Install project dependencies with uv
RUN uv pip install --system --no-cache -r requirements/backend.txt -r requirements/ml.txt

# Copy the rest of the application
# Copy everything
COPY . .

# Set up a new user named "user" with UID 1000 for HF Spaces compatibility
# Copy the bundled frontend from Stage 1
COPY --from=frontend-build /app/apps/frontend/dist /app/apps/frontend/dist

# Set up user for HF
RUN useradd -m -u 1000 user && \
chown -R user:user /app
USER user
ENV PATH="/home/user/.local/bin:$PATH"

# Expose the standard Hugging Face Space port
EXPOSE 7860

# No HEALTHCHECK needed for standard HF Spaces and validator deployments,
# simplifies build logic and reduces potential for false failures.

# Start the application using uvicorn correctly
# Run the backend (which now serves the dist folder)
CMD ["uvicorn", "apps.backend.main:app", "--host", "0.0.0.0", "--port", "7860"]
172 changes: 104 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,96 +5,132 @@ colorFrom: green
colorTo: blue
sdk: docker
app_port: 7860
pinned: false
pinned: true
---

# 🌱 EcoNav AI — Exposure Credit OpenEnv
# 🌱 EcoNav AI — Exposure Credit Platform

An OpenEnv-compliant Reinforcement Learning environment built for the Meta AI Environmental Decision Intelligence Hackathon.
[![EcoNav CI/CD](https://github.com/omdharb-bit/EcoNav-AI/actions/workflows/main.yml/badge.svg)](https://github.com/omdharb-bit/EcoNav-AI/actions)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![OpenEnv Compliant](https://img.shields.io/badge/OpenEnv-Compliant-10b981)](https://github.com/OpenEnv/spec)

## 🌍 Environment Description & Motivation
EcoNav AI is an **intelligent routing platform** and Reinforcement Learning (RL) environment built for the **Meta AI Environmental Decision Intelligence Hackathon**. It empowers users and agents to navigate urban networks while minimizing pollution exposure and maximizing health "Exposure Credits."

EcoNav AI models a realistic urban navigation challenge where an intelligent agent must route through an Indian city network (represented as a dynamic graph). Instead of optimizing solely for distance or time, the agent optimizes to **minimize pollution exposure** and maximize **Exposure Credits**—a gamified health currency.
---

What makes this environment highly functional and unique is its integration with **live, real-world data**. The environment fetches real-time Air Quality Index (AQI) values from the Open-Meteo API. As the agent navigates segments, edge weights (pollution levels) dynamically shift based on reality. The agent earns credits for traversing clean-air segments (Grade A) and loses credits for heavily polluted segments (Grade F). This fills a real gap in mobility algorithms: exposure-aware routing evaluated as an RL task.
## 🌍 Project Overview

## 🧠 Action and Observation Spaces
EcoNav AI transforms navigation from a simple distance-minimization problem into a **multi-objective environmental optimization task**. By integrating real-time Air Quality Index (AQI) data with dynamic traffic simulations, the platform provides a realistic testing ground for eco-aware agents.

### Observation Space
The observation space is a strictly typed JSON dictionary detailing the agent's current location, remaining budget, and available next moves including real-time sensor metrics:
- `current_city` (str): Current city code (e.g. "A").
- `current_city_name` (str): Human readable city name (e.g. "Delhi").
- `destination` (str): Target destination code.
- `destination_name` (str): Target human readable city name.
- `visited` (list[str]): City codes already traversed.
- `neighbors` (list[dict]): Available adjacent cities, featuring:
- `distance`: Distance to neighbor (km).
- `aqi`: Real-time Air Quality Index.
- `grade`: Computed health grade (A to F).
- `credit_delta`: Credits that will be won or lost by making this move.
- `exposure_credits` (int): Current credit balance (starts at 100).
- `total_exposure` (float): Cumulative normalized pollution exposure metric.
- `steps_taken` (int): Number of steps used in current episode.
- `max_steps` (int): Step budget limit for the current task.
### Key Innovations:
- **Live AQI Integration**: Real-time pollution data fetched from the Open-Meteo API for 50+ network nodes across India.
- **Exposure Credits**: A gamified health currency that penalizes high-pollution segments (Grade F) and rewards clean-air segments (Grade A).
- **Dynamic Traffic Engine**: Simulates congestion levels that impact both travel time and localized pollution exposure.
- **OpenEnv Compliance**: Fully compatible with the OpenEnv specification for RL evaluation and agent deployment.

### Action Space
- `city` (str): A string specifying the city code to move to next. The chosen code must belong to the list of current `neighbors`.
---

## 📜 Tasks & Expected Difficulty
## 🛠 Tech Stack

Four discrete tasks of increasing difficulty force the agent to balance trade-offs between step budget, distance, and real-world pollution grids.
The project is architected as a modern **monorepo** for seamless development and deployment.

1. **`easy_route` (Easy)**: Navigate from highly-polluted Delhi to Kolkata. Generous step budget (15 steps) allowing maximum flexibility to seek clean air routes. Baseline passing score: 0.5.
2. **`medium_route` (Medium)**: Same route, but optimized budget (8 steps). Requires balancing direct paths with pollution spikes. Baseline passing score: 0.6.
3. **`hard_pollution_dodge` (Hard)**: Start from Agra to Kolkata with a tight budget (6 steps). Requires aggressive credit optimization to survive the early exposure hits of Northern India. Baseline passing score: 0.7.
4. **`expert_credit_max` (Expert)**: Maximize exposure credits while reaching Kolkata within 10 steps. A rigorous test of the agent's multi-objective reward policy. Baseline passing score: 0.8.
- **Backend**: Python 3.10+, FastAPI, Uvicorn, Pydantic, Torch (ML scoring).
- **Frontend**: Vite, Vanilla JS, CSS3 (Glassmorphism), Leaflet.js (Mapping), Chart.js (Analytics).
- **Infrastructure**: Docker, Turbo (Build system), GitHub Actions (CI/CD).
- **Quality**: Ruff (Linting), Prettier (Formatting).

## 🏆 Baseline Scores
---

We ran the included `inference.py` evaluating a greedy baseline heuristic (which strictly prefers neighbors with higher credit deltas and lower AQI values).
## 📂 Repository Structure

```text
EcoNav-AI/
├── apps/
│ ├── backend/ # FastAPI server, AI services, and RL endpoints
│ ├── frontend/ # Vite-powered dashboard and mapping interface
│ ├── simulator/ # ML training and evaluation logic
│ └── web/ # (Deprecated) Static web assets
├── packages/
│ └── env_core/ # Shared RL environment logic (OpenEnv Spec)
├── requirements/ # Modularized dependency lists
├── server/ # Production entry points for Docker/HF Spaces
├── turbo.json # Monorepo configuration
└── inference.py # Baseline agent evaluation script
```

| Task | Score (0.0 - 1.0) | Grade | Credits Final | Reached Goal |
|---|---|---|---|---|
| `easy_route` | 0.8161 | B | 110 | ✅ |
| `medium_route` | 0.8161 | B | 110 | ✅ |
| `hard_pollution_dodge` | 0.8326 | B | 105 | ✅ |
| `expert_credit_max`| 0.8161 | B | 110 | ✅ |
| **Average Score** | **0.8202** | | | |
---

## 🚀 Setup and Usage Instructions
## 🚀 Getting Started

### Prerequisites
- **Node.js**: >= 18.0.0
- **Python**: >= 3.10
- **npm**: >= 11.11.0

### Quick Start (Recommended)
1. **Clone the repository**:
```bash
git clone https://github.com/omdharb-bit/EcoNav-AI.git
cd EcoNav-AI
```

2. **Install Dependencies**:
```bash
npm install # Installs monorepo build tools
pip install -r requirements/backend.txt # Installs Python backend deps
```

3. **Run Everything**:
Use the Turbo-powered development command to start both the backend and frontend:
```bash
npm run dev
```
*Note: If running on Windows, you may need to set `PYTHONPATH="."` manually if starting the backend via script.*

### Manual Startup
- **Backend**: `python server/app.py` (Runs on [http://localhost:7860](http://localhost:7860))
- **Frontend**: `npm run dev --prefix apps/frontend` (Runs on [http://localhost:5173](http://localhost:5173))

### Run via Docker (Hugging Face Spaces)
The provided `Dockerfile` is optimized to run on Hugging Face Spaces per the OpenEnv specification (automatically exposing port `7860`).
```bash
docker build -t econav-openenv .
docker run -p 7860:7860 econav-openenv
```

### Local Development Setup
```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt # OR pip install fastapi uvicorn requests pydantic openai numpy pyyaml
---

# Start the environment
uvicorn apps.backend.main:app --host 0.0.0.0 --port 8000
```
## 🧠 RL Evaluation (OpenEnv)

### Running Inference
Run the baseline evaluation or LLM-driven agent via `inference.py`.
The environment supports four standard evaluation tasks of increasing complexity:
1. `easy_route`: Delhi to Kolkata (15 steps).
2. `medium_route`: Delhi to Kolkata (8 steps).
3. `hard_pollution_dodge`: Agra to Kolkata (6 steps).
4. `expert_credit_max`: Maximize credits while reaching the goal (10 steps).

**To run the greedy baseline:**
**Baseline Evaluation**:
```bash
export ENV_URL="http://127.0.0.1:8000"
export ENV_URL="http://127.0.0.1:7860"
python inference.py
```

**To run the LLM Agent (OpenAI Client format):**
```bash
export ENV_URL="http://127.0.0.1:8000"
export API_BASE_URL="https://router.huggingface.co/v1"
export MODEL_NAME="meta-llama/Llama-3.1-8B-Instruct"
export HF_TOKEN="your-hf-token"
---

## 🧪 Development & Quality

We maintain high code quality standards through automated linting and formatting.

- **Linting (Python)**: `ruff check .`
- **Fix Linting**: `ruff check --fix .`
- **Formatting (JS/TS/MD)**: `npm run format`

---

## 🏆 Project Status

| Check | Status |
|---|---|
| **CI/CD Pipeline** | Passing ✅ |
| **OpenEnv Spec** | Compliant (v1.0) 🟢 |
| **Real-time Data** | Active (Open-Meteo) 🛰️ |
| **Model Version** | EcoScorer v2.1 🧠 |

---

## 📜 License

Distributed under the **MIT License**. See `LICENSE` for more information.

python inference.py
```
Loading
Loading