EcoCode Insights

SustainabilityIntermediateJan 21, 2026

EcoCode Insights

Optimize your code for a greener, faster future.

The Problem

Solo developers and indie hackers are constantly building and deploying applications, often prioritizing speed and functionality over less visible concerns like energy efficiency or carbon footprint. They use various cloud services (Vercel, Netlify, AWS, GCP) and integrate numerous third-party APIs and libraries. However, they lack easy, automated ways to understand the environmental impact of their choices. A larger bundle size means more data transfer and storage, inefficient database queries consume more CPU, and unoptimized images or videos on a website mean more energy for users to download. This translates to higher hosting costs for the developer, a larger carbon footprint for their application, and often, a slower user experience. Developers lose valuable time manually auditing dependencies or guessing which parts of their stack are resource-intensive, missing opportunities to reduce costs and contribute to sustainability without compromising performance. This problem costs them both money in cloud bills and reputation for slow, resource-heavy apps.

The Solution

EcoCode Insights provides an automated, lightweight static analysis tool and dependency scanner that integrates directly with a developer's GitHub repositories. Upon linking a repo, it scans the project for common "eco-inefficiencies" such as excessively large npm packages, unoptimized image assets, inefficient API usage patterns (e.g., redundant fetches), and suggests greener alternatives or optimizations. It provides a simple, intuitive dashboard showing a "green score" for the project, categorized recommendations (e.g., 'Performance', 'Bundles', 'Data'), and actionable code-level changes. Users can drill down into specific files or dependencies. The uniqueness lies in its developer-centric focus on *actionable code-level changes* for energy reduction, translating sustainability into direct cost savings and performance improvements. It’s not just reporting; it's guiding developers to build more efficient, and thus greener, applications with minimal effort.

Tech Stack

Frontend
Next.js 14ReactTailwind CSSshadcn/ui
Backend
Next.js API RoutesNode.jsOctokit (GitHub API wrapper)TypeScript
Database
PostgreSQL (Supabase)
APIs
GitHub (OAuth, Webhooks)Stripe (Payments)Resend (Email)

System Architecture

Database Schema

-- Enable PostgreSQL extensions for Supabase if needed (e.g., uuid-ossp for UUIDs)
-- CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

-- Users Table
CREATE TABLE users (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    email TEXT UNIQUE NOT NULL,
    password_hash TEXT, -- For email/password auth
    github_id BIGINT UNIQUE,
    github_username TEXT,
    github_access_token TEXT, -- Encrypted in production
    stripe_customer_id TEXT UNIQUE,
    current_plan TEXT DEFAULT 'free' NOT NULL,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
COMMENT ON TABLE users IS 'Stores user information, including GitHub integration details and subscription status.';
COMMENT ON COLUMN users.github_access_token IS 'OAuth token for GitHub API access, should be encrypted at rest.';

-- Repositories Table
CREATE TABLE repositories (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    github_repo_id BIGINT UNIQUE NOT NULL, -- GitHub's internal repo ID
    repo_name TEXT NOT NULL,                -- e.g., 'owner/repo-name'
    repo_url TEXT NOT NULL,
    is_private BOOLEAN DEFAULT TRUE NOT NULL,
    last_scan_at TIMESTAMP WITH TIME ZONE,
    webhook_id BIGINT, -- GitHub webhook ID for future updates
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    UNIQUE (user_id, github_repo_id) -- A user can link a repo only once
);
CREATE INDEX idx_repositories_user_id ON repositories(user_id);
COMMENT ON TABLE repositories IS 'Stores linked GitHub repositories for each user.';

-- ScanResults Table
CREATE TABLE scan_results (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    repo_id UUID NOT NULL REFERENCES repositories(id) ON DELETE CASCADE,
    scan_timestamp TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    green_score INT NOT NULL, -- e.g., 0-100
    bundle_size_kb INT,
    recommendations JSONB, -- Stores an array of structured recommendations
    raw_analysis_data JSONB, -- Optional: store full analysis output for debugging/future use
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE INDEX idx_scan_results_repo_id ON scan_results(repo_id);
CREATE INDEX idx_scan_results_timestamp ON scan_results(scan_timestamp);
COMMENT ON TABLE scan_results IS 'Stores results of each code scan for a repository.';
COMMENT ON COLUMN scan_results.recommendations IS 'JSONB array of recommended optimizations, e.g., [{"type": "bundle", "message": "Reduce lodash size", "details": "..."}, ...]';

-- Subscriptions Table (for Stripe integration)
CREATE TABLE subscriptions (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    stripe_subscription_id TEXT UNIQUE NOT NULL,
    stripe_price_id TEXT NOT NULL,
    status TEXT NOT NULL, -- e.g., 'active', 'canceled', 'past_due'
    current_period_start TIMESTAMP WITH TIME ZONE NOT NULL,
    current_period_end TIMESTAMP WITH TIME ZONE NOT NULL,
    cancel_at_period_end BOOLEAN DEFAULT FALSE,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE INDEX idx_subscriptions_user_id ON subscriptions(user_id);
COMMENT ON TABLE subscriptions IS 'Manages user subscriptions synchronized with Stripe.';

API Endpoints

POST/api/auth/githubInitiates GitHub OAuth flow.
GET/api/auth/callback/githubHandles GitHub OAuth callback, exchanges code for token, creates/logs in user.
GET/api/userFetches current user's profile and linked repos.
GET/api/reposLists all repositories linked by the current user.
POST/api/repos/linkLinks a new GitHub repository to the user's account.
DELETE/api/repos/:idUnlinks a GitHub repository.
POST/api/repos/:id/scanTriggers an on-demand scan for a specific repository.
GET/api/repos/:id/scansRetrieves historical scan results for a specific repository.
GET/api/repos/:id/scans/:scanIdRetrieves detailed results for a specific scan.
POST/api/webhook/githubGitHub webhook endpoint to trigger scans on push/PR (requires signature validation).
POST/api/webhook/stripeStripe webhook endpoint to handle subscription changes.
πŸ€–

Start Building with AI

Copy this prompt for Cursor, v0, Bolt, or any AI coding assistant

πŸ‘·

...

builders copied today

Found this useful? Share it with your builder friends!

BD

BuilderDaily Team

Verified

Indie hackers and full-stack engineers creating validated Micro-SaaS blueprints with production-ready tech stacks.

Sustainability
Code TestedSchema ValidatedProduction Ready
Coming Soon in Beta

Gap Alert

Today's gap expires in ~14 hours

Get tomorrow's blueprint delivered to your inbox so you never miss a profitable idea.

(Email delivery launching soon β€” sign up to be first!)

No spam, everβ€’Unsubscribe anytime