EcoLafaek - Autonomous AI Agent for Environmental Monitoring

Live Demo: www.ecolafaek.com | Documentation: docs.ecolafaek.com


__Inspiration

As a young person living in Timor-Leste, a nation that only gained independence in 2002, I have witnessed firsthand the severe environmental challenges facing my country—especially regarding waste management. In the capital city, Dili, I observed people disposing of trash carelessly, often not placing waste in proper disposal sites. Sometimes there are no garbage bins nearby, and even when bins are available, people still dispose of waste outside them. This demonstrated a critical lack of proper waste management infrastructure and public awareness.

What truly alarmed me was discovering JICA survey data showing that Dili produces over 300 tons of waste daily, yet more than 100 tons go uncollected each day. This uncollected waste clogs drainage systems, causing devastating flooding during the rainy season and creating serious environmental and health hazards for our communities.

I was inspired to build a solution that could empower citizens to become part of the solution while providing authorities with the data-driven insights they need to prioritize cleanup efforts. When I learned about Amazon Bedrock AgentCore and its autonomous AI capabilities, I realized I could create a truly intelligent system that doesn't just collect data—it actively analyzes, reasons, and provides actionable insights through multi-round tool orchestration.

__What it does

EcoLafaek (named after the sacred crocodile "Lafaek" in Timorese culture) is an autonomous AI agent system that transforms waste management through intelligent community engagement and advanced AI reasoning.

Core Capabilities:

1. Intelligent Waste Reporting (Mobile App)

  • Citizens capture photos of waste issues with their smartphones
  • GPS automatically records exact locations
  • Amazon Bedrock Nova-Pro analyzes images to classify waste types (plastic, organic, metal, electronic, hazardous, construction, mixed)
  • AI assesses severity scores, environmental impact, and safety concerns
  • Users track their personal impact and contribution to community cleanliness

2. Autonomous AI Agent Chat (Public Dashboard)

  • Natural language interface powered by Amazon Bedrock AgentCore
  • Multi-round tool calling: Agent autonomously chains 5+ tools
    • Executes SQL queries to fetch data
    • Generates matplotlib visualizations via AgentCore Code Interpreter
    • Creates interactive Folium maps with hotspot markers
    • Scrapes web content using AgentCore Browser Tool with Playwright
  • Users ask questions like "Show waste trends this month" and the agent autonomously decides which tools to execute and in what sequence

3. Semantic Vector Search

  • Amazon Titan Embed generates 1024-dimensional embeddings for every report image
  • Find similar waste issues using cosine similarity matching
  • Enables pattern recognition across thousands of reports

4. Real-time Analytics & Hotspot Detection

  • Interactive geospatial maps showing waste accumulation clusters
  • Real-time statistics on waste types, severity trends, and collection gaps
  • Community leaderboards recognizing top contributors

5. Admin Panel (Local Security)

  • User management, report moderation, and system configuration
  • Intentionally runs only on localhost for enhanced security
  • Direct database access for rapid administrative operations

__How we built it

System Architecture

EcoLafaek Architecture Diagram

📐 Complete Architecture Documentation: docs.ecolafaek.com/architecture

Architecture Overview

Mobile Application (Flutter/Dart)

  • Cross-platform app for iOS and Android
  • Camera integration for waste photo capture
  • GPS location tracking with reverse geocoding
  • Provider-based state management
  • JWT token authentication with secure storage
  • Offline support with local SQLite caching

Backend API (FastAPI + Amazon Bedrock AgentCore)

  • Built on agentcore_app.run() framework
  • Amazon Bedrock Nova-Pro v1.0 (amazon.nova-pro-v1:0) as reasoning LLM
  • AgentCore Code Interpreter: Executes Python code in sandboxed environment for chart generation
  • AgentCore Browser Tool: Playwright-powered web scraping for dynamic content
  • 5 Custom Tools integrated with AgentCore:
    • execute_sql_query: Database queries
    • generate_visualization: matplotlib/pandas charts
    • create_map_visualization: Folium interactive maps
    • scrape_webpage_with_browser: Web content extraction
    • get_ecolafaek_info: Project information retrieval
  • Rate limiting with slowapi (30 requests/min for chat)
  • PBKDF2-HMAC-SHA256 password hashing
  • Deployed on AWS Lightsail (Ubuntu 22.04, systemd service)

Public Dashboard (Next.js 15 on Vercel)

  • Server-side rendering with React 18
  • TypeScript for type safety
  • Tailwind CSS for responsive UI
  • Leaflet.js for interactive maps
  • Chart.js and Tremor Charts for data visualization
  • reCAPTCHA v2 for bot protection
  • Direct database connections from API routes

Database (TiDB Cloud - Distributed SQL)

  • MySQL-compatible with VECTOR(1024) support
  • 17 tables including users, reports, analysis_results, hotspots, waste_types
  • Vector embeddings in analysis_results.image_embedding and analysis_results.location_embedding
  • Geospatial indexes for hotspot clustering
  • Connection pooling for high concurrency

Amazon Bedrock Integration

  • Nova-Pro LLM: Multi-modal image+text analysis, autonomous reasoning, tool orchestration
  • Titan Embed Image v1: 1024-dimensional vector embeddings for semantic search
  • AgentCore Runtime: ARM64 Docker containers deployed via AWS CodeBuild → Amazon ECR
  • ARN: arn:aws:bedrock-agentcore:us-east-1:ACCOUNT_ID:runtime/ecolafaek_waste_agent-TGrtjyF5VC

Storage & Infrastructure

  • Amazon S3: Image storage with organized folder structure (reports/, charts/, maps/)
  • AWS Lightsail: Fixed-cost compute for backend API
  • Vercel Edge Network: Global CDN for dashboard with automatic deployments
  • AWS CodeBuild: Automated AgentCore container builds (ARM64)

Development Workflow

  1. AgentCore Deployment: Used agentcore launch CLI to deploy autonomous agent runtime
  2. Multi-round Tool Testing: Iteratively tested tool calling sequences to optimize agent reasoning
  3. Vector Search Implementation: Generated embeddings for 50+ existing reports to test similarity search
  4. Mobile App Testing: Tested on Android 15 and iOS devices with real waste photos
  5. Load Testing: Validated rate limiting and concurrent chat sessions

__Challenges we ran into

1. Multi-Round Tool Calling Complexity

Initially, the agent would sometimes call tools in suboptimal sequences or fail to chain tools together. For example, it might generate a chart without first fetching the data.

Solution: Refined tool descriptions with clear input/output schemas, added more context in system prompts about when to use each tool, and implemented conversation history tracking to help the agent remember previous tool results.

2. AgentCore Code Interpreter File Persistence

Generated charts needed to be uploaded to S3, but the Code Interpreter's temporary file system was tricky to work with.

Solution: Modified the tool to return base64-encoded images directly from the Code Interpreter execution, then decode and upload to S3 in the main API code.

3. Vector Search Performance with Large Embeddings

Cosine similarity calculations on 1024-dimensional vectors became slow as the dataset grew.

Solution: Added database indexes optimized for vector operations and implemented result pagination to limit computation.

4. Cross-Platform Image Handling

Image formats and sizes varied significantly between iOS and Android devices.

Solution: Standardized all uploads to JPEG with maximum 1920x1080 resolution using Flutter Image Compress, reducing S3 storage costs and speeding up AI analysis.

5. Rate Limiting Without Breaking User Experience

Needed to prevent API abuse while allowing legitimate concurrent users.

Solution: Implemented tiered rate limits (30/min for chat, 60/min for reports, 10/min for login) with clear error messages and retry-after headers.

7. Admin Panel Security

Wanted powerful admin tools without exposing them to the internet.

Solution: Built admin panel to run exclusively on localhost with direct database access, eliminating the need for complex authentication/authorization over the network.

__Accomplishments that we're proud of

Production Deployment with Real Users

  • Live system accessible at www.ecolafaek.com (dashboard) and www.ecolafaek.xyz (API)
  • 50+ waste reports submitted and analyzed
  • 3+ active mobile app users contributing to community cleanliness
  • 25+ AI agent interactions demonstrating autonomous tool orchestration

True Autonomous AI Agent

  • Agent successfully chains 5 tools across multiple conversation rounds
  • Demonstrates intelligent decision-making (Nova-Pro determines which tools to call and when)
  • Generates actionable insights from natural language queries
  • Example: "Show waste trends and map hotspots" → Agent executes SQL query → Generates chart → Queries hotspot data → Creates interactive map → Returns comprehensive response

Complete Full-Stack Implementation

  • Mobile app (Flutter) ✓
  • Backend API (FastAPI + AgentCore) ✓
  • Public dashboard (Next.js) ✓
  • Admin panel (Next.js local) ✓
  • Database with vector search (TiDB) ✓
  • All integrated seamlessly with real data flow

Advanced AI Features

  • Multi-modal image analysis with Nova-Pro
  • Semantic similarity search with Titan Embed
  • Autonomous code execution via AgentCore Code Interpreter
  • Web scraping with AgentCore Browser Tool

Social Impact

  • Addressing a real crisis: 100+ tons of uncollected waste daily in Dili
  • Empowering citizens to contribute to environmental solutions
  • Providing authorities with data-driven insights for resource allocation

Comprehensive Documentation

  • Complete README files for all components
  • Architecture diagrams
  • API documentation
  • Database schema documentation
  • VitePress documentation site at docs.ecolafaek.com

__What we learned

Amazon Bedrock AgentCore is Powerful

The autonomous capabilities of AgentCore exceeded my expectations. The ability to execute Python code, browse the web, and chain multiple tools together opens up endless possibilities for intelligent applications. The Code Interpreter primitive is especially powerful—it's like giving the AI hands to manipulate data and create visualizations.

Multi-Modal LLMs are Game-Changers for Civic Tech

Amazon Nova-Pro's ability to analyze images and provide structured JSON responses made it possible to build a waste classification system without training custom ML models. This dramatically accelerated development and made the project feasible for a solo developer.

Vector Embeddings Enable Powerful Search

Amazon Titan Embed's 1024-dimensional embeddings unlocked semantic search capabilities that would have been impossible with traditional keyword matching. Finding similar waste reports helps identify patterns and recurring issues.

Timor-Leste Needs More Tech Solutions

Building this project reinforced my belief that technology can solve real problems in developing nations. Access to AWS's AI services levels the playing field—small teams can build sophisticated systems that would have required massive resources.

Deployment Complexity Matters

Choosing the right deployment strategy (AWS Lightsail for backend, Vercel for dashboard, local-only for admin panel) was crucial. Each platform has trade-offs in cost, complexity, and capabilities.

User Experience is Critical

No matter how advanced the AI is, if the mobile app is slow or confusing, people won't use it. I learned to prioritize image compression, and clear visual feedback.

Security Cannot Be an Afterthought

Implementing proper authentication (JWT tokens), password hashing (PBKDF2), rate limiting, and CORS policies from the start prevented major refactoring later. The decision to keep the admin panel local-only eliminated an entire class of security concerns.

__What's next for EcoLafaek

Short-term Goals

1. Government Partnership

  • Present the system to Timor-Leste's Ministry of Environment
  • Pilot program with Dili's municipal waste management department

2. Waste Collection Integration

  • Add status update feature for authorities to mark reports as "Resolved"
  • Before/after photo comparison to verify cleanup
  • Automatic notification to original reporter when issue is resolved

3. Mobile App Enhancements

  • Push notifications for nearby waste issues
  • Gamification improvements (achievements, streaks, team challenges)
  • Offline map caching for areas with poor connectivity

Medium-term Goals

4. AI Agent Improvements

  • Add more autonomous tools (SMS notifications, automated report generation)
  • Multi-language support (Tetum and English)
  • Predictive analytics (forecast waste accumulation based on historical patterns)

5. Scale to Other Districts

  • Expand beyond Dili to Baucau, Maliana, and other municipalities
  • Partner with schools to engage students in environmental monitoring
  • Community workshops on proper waste disposal

6. Data Insights for Policy Making

  • Generate monthly reports on waste trends for government
  • Identify areas lacking infrastructure (garbage bins, collection routes)
  • Cost-benefit analysis of cleanup interventions

Long-term Vision

7. ASEAN Regional Expansion

  • Adapt the system for other Southeast Asian nations
  • Open-source the codebase for other civic tech developers
  • Create a regional network for sharing best practices

8. AWS AI-for-Good Initiative

  • Apply for AWS Impact programs to support scaling
  • Collaborate with other environmental tech projects
  • Speak at conferences about AI for civic tech in developing nations

9. Advanced Features

  • Blockchain-based incentive system for verified cleanups
  • Integration with circular economy platforms (recycling marketplaces)
  • Carbon credit calculations for waste diversion

10. Sustainability & Business Model

  • Explore government contracts for SaaS-based deployment
  • Partner with waste management companies for data insights
  • Grant funding from environmental NGOs
  • Freemium model for other municipalities

Impact Metrics We're Tracking

  • Total waste reports submitted
  • Average time to resolution
  • Hotspots identified and cleaned
  • User engagement (daily active users, retention rate)
  • AI analysis accuracy (confidence scores, manual verification)

Why This Matters

Timor-Leste is a young nation facing enormous challenges. Climate change, limited resources, and rapid urbanization threaten our environment and quality of life. But technology—especially AI—can be an equalizer.

With EcoLafaek, every citizen with a smartphone becomes an environmental guardian. Every photo they take trains our AI to better understand waste patterns. Every report they submit helps authorities make smarter decisions.

This is not just an app. It's a movement toward a cleaner, healthier Timor-Leste.

And with Amazon Bedrock AgentCore, we're not just collecting data—we're building an autonomous intelligence that reasons, analyzes, and acts to solve environmental challenges.


🔗 Additional Resources

Architecture Components Documentation


Built with ❤️ for Timor-Leste | AWS AI Agent Global Hackathon

Powered by Amazon Bedrock AgentCore, Nova-Pro, and Titan Embed

Built With

+ 11 more
Share this project:

Updates