Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

AndresL230/ecoapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EcoApi

REST API for analyzing codebase API usage, estimating cost, detecting inefficiencies, and generating optimization suggestions.

Alt text

Why This Exists

Developers often ship API-heavy features without visibility into:

  • Monthly API spend risk
  • Redundant or cacheable request patterns
  • Rate-limit and N+1 hotspots

EcoAPI turns parsed API call data into actionable diagnostics:

  • Cost analytics
  • Endpoint-level risk/status
  • Optimization suggestions with estimated savings
  • Graph data for dependency visualization
  • Sustainability stats — electricity (kWh), water (L), and CO2 (g) footprint estimated from API call volume, with AI vs non-AI breakdown

Tech Stack

API

  • Cloudflare Workers — serverless runtime
  • Hono — web framework
  • Cloudflare D1 — SQLite database
  • TypeScript — strict mode

Dashboard

  • React 18 + React Router v7
  • TanStack Query v5, Tailwind CSS v4, D3.js, Radix UI

VSCode Extension

  • TypeScript extension backend
  • React webview UI
  • AI chat — OpenAI (default) or Cloudflare AI (optional)

Project Structure

api/                        # Cloudflare Workers API
  src/
    index.ts                # Workers entry point (Hono app)
    env.ts                  # Shared Env/Variables/AppContext types
    config/
      pricing.ts            # Provider pricing & keyword detection
      sustainability.ts     # Energy/water/CO2 constants per provider
    middleware/
      cors.ts
      content-type.ts
      logging.ts
      request-id.ts
      error-handler.ts
      rate-limit.ts         # KV-based scan rate limiting
    models/
      types.ts              # TypeScript domain types
    routes/
      health.ts             # GET /health
      projects.ts           # Projects, scans, endpoints, suggestions, graph, cost, sustainability
      providers.ts          # GET /providers
      chat.ts               # POST /chat (Cloudflare AI / Llama 3.1 8B)
    services/
      analysis-service.ts   # Core analysis engine (pure, sync)
      project-service.ts    # All CRUD via D1 (async)
      provider-service.ts   # Provider config lookups
      validation-service.ts # Input validation
    utils/
      app-error.ts
      pagination.ts
      sort.ts
  migrations/
    0001_schema.sql         # D1 table definitions
    0002_seed.sql           # Demo project seed data
  wrangler.toml
  package.json
  tsconfig.json
dashboard/                  # React SPA (Cloudflare Pages / local extension server)
  src/
    App.tsx                 # Root component with routing
    theme-context.tsx       # Theme state provider
    themes.ts               # Theme definitions
    components/
      Select.tsx
      animated-tree.tsx
      particles.tsx
    layout/
      Layout.tsx
    lib/
      api.ts                # REST client (VITE_API_URL or same-origin for local mode)
      queries.ts            # TanStack Query hooks
      types.ts              # TypeScript types matching API responses
    pages/
      Dashboard.tsx         # Overview/summary
      Endpoints.tsx         # Endpoint analysis with filtering
      Graph.tsx             # D3 network graph (cluster by provider/file/cost)
      Suggestions.tsx       # Optimization recommendations
    styles/
      index.css
      tailwind.css
      theme.css
      fonts.css
  vite.config.ts
  package.json
extension/                  # VSCode extension
  src/
    extension.ts            # Extension entry point
    api-client.ts           # HTTP client for backend
    local-server.ts         # Embedded HTTP server serving dashboard + local API
    webview-provider.ts     # Sidebar webview provider
    messages.ts             # Message types for extension ↔ webview IPC
    analysis/
      types.ts              # Analysis type definitions
    chat/
      prompts.ts            # AI prompt templates
    scanner/
      patterns.ts           # API call detection regex patterns
      workspace-scanner.ts  # Workspace file scanner
  webview/                  # React sidebar UI
    src/
      App.tsx
      types.ts
      vscode.ts             # VSCode API bridge
      components/
        LandingPage.tsx
        ScanningPage.tsx
        ResultsPage.tsx
        ChatPage.tsx
        Markdown.tsx
        LeafIcon.tsx
      styles/
        index.css
  dashboard-dist/           # Built dashboard (generated by npm run build:dashboard)
  eco-api-analyzer-0.1.0.vsix
scripts/
  install-dashboard.sh      # Install dashboard npm dependencies
  start-extension.sh        # Full extension dev setup (install + build + open VSCode)

API

The API is live at https://api.ecoapi.dev — no setup required.

Full API documentation is available at https://ecoapi.dev.

VSCode Extension

Runs ECO analysis directly inside your editor — no remote API server needed. Scans your workspace for API call patterns, shows cost/risk diagnostics in the sidebar, and opens the full dashboard locally. AI chat is optional — uses OpenAI by default, or Cloudflare AI (Llama 3.1 8B) if preferred.

Quick start

bash scripts/start-extension.sh

Then press F5 in VSCode to launch the Extension Development Host, and click the ECO leaf icon in the Activity Bar.

Install from .vsix

  1. Command Palette (Ctrl+Shift+P) → "Extensions: Install from VSIX..."
  2. Select extension/eco-api-analyzer-0.1.0.vsix
  3. Reload VSCode, then click the ECO icon in the Activity Bar.

Copyright © 2026 Andres Lopez, Aslan Wang, Donggyu Yoon. All rights reserved.

About

EcoAPI is a REST API that analyzes your codebase's API usage to estimate costs and surface optimization opportunities.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages