Skip to content

nitrocode/token-deathclock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

159 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ’€ AI Token Deathclock

Unit Tests E2E Tests Deploy codecov

๐ŸŒ Live site: nitrocode.github.io/token-deathclock

Every AI prompt has a cost. This site makes it visceral. ๐Ÿ”ฅ

Watch the global AI token counter tick in real time, track environmental milestones as they fall, and discover what humanity could have done instead with those same resources.

Created by RB.


โœจ Features

Feature Details
โฑ๏ธ Live counter Estimated global AI tokens consumed since Jan 2020, ticking in real-time
๐Ÿ“Š Session counter Tokens consumed globally since you opened the page
๐ŸŒฟ Environmental milestones 7 thresholds (trees โ†’ bees โ†’ water โ†’ coral โ†’ glaciers โ†’ ocean โ†’ extinction) with progress bars and consequence descriptions
๐Ÿ“ˆ Growth chart Historical data + 18-month projection on a log scale (Chart.js)
๐Ÿ—“๏ธ Predictions table Predicted calendar dates for each upcoming milestone
๐Ÿ† Doom achievements Unlock badges as global consumption hits new levels
๐ŸŽฎ Accelerate the Doom A satirical mini-game โ€” click to burn tokens faster
๐Ÿงฎ Personal footprint calculator Estimate your own AI token footprint
๐ŸŒ™ Dark / Light mode Toggle button; dark mode is the default

๐Ÿš€ Running Locally

# Clone the repo
git clone https://github.com/nitrocode/token-deathclock.git
cd token-deathclock

# Serve with any static server, e.g.:
npx serve .
# Then open http://localhost:3000

No build step required โ€” it's a fully static site. ๐ŸŽ‰


๐Ÿงช Running Tests

npm install
npm test          # runs Jest with coverage (interactive)
npm run test:ci   # CI mode โ€” fails if coverage drops
npm run test:e2e  # Playwright end-to-end tests

Unit tests live in tests/death-clock.test.js and cover all pure functions in death-clock-core.js.


๐Ÿ“Š Coverage

Unit-test coverage is tracked by Codecov. Every pull request receives an automated comment showing per-file coverage deltas; the PR check fails if coverage decreases.

Unit test coverage Coverage breakdown
Codecov icicle Codecov sunburst

E2E tests run in CI via Playwright (Chromium). Their pass/fail status is shown by the E2E Tests badge above.


๐Ÿšข Deployment

The site deploys automatically on every push to main via the deploy.yml workflow, pushing to the gh-pages branch.

๐Ÿ”— Live URL: https://nitrocode.github.io/token-deathclock/

Pull requests each get an isolated preview URL: https://nitrocode.github.io/token-deathclock/previews/pr-{number}/


๐Ÿ—๏ธ Architecture

How it fits together

flowchart TD
    subgraph Source["๐Ÿ“ Source Files (edit these)"]
        core["death-clock-core.js\nโ˜๏ธ Pure functions\n(no DOM, fully testable)"]
        srcjs["src/js/\n00-state โ€ฆ 21-boot\n(feature modules)"]
        styleSrc["styles/\nvariables, base,\nfeatures, etc."]
        html["index.html\n๐Ÿ  Static HTML shell"]
        yaml["milestones.yaml\nproject-stats.yaml\nCHANGELOG.md"]
    end

    subgraph Generated["โš™๏ธ Auto-Generated (do not edit)"]
        scriptjs["script.js\n(built from src/js/)"]
        stylescss["styles.css\n(built from styles/)"]
        datajs["*-data.js\n(built from YAML / MD)"]
    end

    subgraph Tests["๐Ÿงช Tests"]
        unit["tests/death-clock.test.js\nJest unit tests"]
        e2e["tests/e2e/\nPlaywright E2E tests"]
    end

    subgraph CI["๐Ÿค– GitHub Actions"]
        deploy["deploy.yml\nGH Pages deploy"]
        unitCI["unit-tests.yml\nJest + Codecov"]
        e2eCI["e2e-tests.yml\nPlaywright"]
        preview["preview.yml\nPR preview deploy"]
        release["release-please.yml\nSemVer + changelog"]
    end

    subgraph Live["๐ŸŒ GitHub Pages"]
        site["nitrocode.github.io\n/token-deathclock/"]
    end

    core -->|imported by| srcjs
    srcjs -->|npm run build:js| scriptjs
    styleSrc -->|npm run build:css| stylescss
    yaml -->|npm run build:*| datajs

    html --> Live
    scriptjs --> Live
    stylescss --> Live
    datajs --> Live

    core --> unit
    html --> e2e
    scriptjs --> e2e

    unit --> unitCI
    e2e --> e2eCI
    Live -->|push to main| deploy
    deploy --> site
Loading

Key source files

File Role
death-clock-core.js ๐Ÿง  Pure calculation functions โ€” no DOM, fully unit-testable
src/js/ ๐Ÿ–ฅ๏ธ Feature modules compiled into script.js
styles/ ๐ŸŽจ CSS source files compiled into styles.css
index.html ๐Ÿ  Static HTML shell loaded by GitHub Pages
milestones.yaml ๐Ÿ Source of truth for environmental milestone data
project-stats.yaml ๐Ÿ“ฆ Tracks PR count + tokens consumed building this project

โš ๏ธ Never edit script.js, styles.css, or *-data.js directly โ€” they are auto-generated. Edit the source files and run the relevant npm run build:* command.


๐ŸŒ Environmental Data Sources

Metric Source
Energy per token (~0.0003 kWh / 1K tokens) Google/DeepMind inference benchmarks, MLPerf
COโ‚‚ per kWh (0.4 kg) IEA global average grid intensity 2024
Water per token (~0.5 L / 1K tokens) Microsoft sustainability report 2023
COโ‚‚ per tree (~21 kg/year) US Forest Service estimates
Historical token growth OpenAI usage blog, Epoch AI, AI Index 2024

๐Ÿ“Œ All figures are illustrative estimates intended to communicate scale, not precise measurements.