EchoDB

EchoDB — The Sound of Change

Every change has a sound. EchoDB is a polished PHP 8.3 demo that turns database mutations into living visuals, stats, and audio. It shows how a lightweight stack can deliver Change Data Capture (CDC) vibes with Server-Sent Events, tasteful UX, and clean architecture.

EchoDB logo

🛠️ Built with pure PHP, PDO, Monolog, and Dotenv — no heavy frameworks, no bundlers.

Highlights

Architecture at a Glance

                   ┌────────┐     insert/update/delete     ┌──────────┐
Browser UI ◀───────┤ stream │◀─────────────────────────────┤ EventStore│
   ▲   ▲           └────────┘                               └─────┬────┘
   │   │                   ▲                                       │
   │   └──── AJAX / REST ──┘                                       │
   │                                                               │
Visualizer · Timeline · Sound                                 ┌────▼─────┐
   │                                                         │ Database │
   └───────────── Server-Sent Events pulses ─────────────────┤  (MySQL) │
                                                             └──────────┘

Quick Start

  1. Install dependencies
    composer install
    
  2. Configure environment
    cp config/.env.example .env
    # edit DB credentials & APP_URL
    
  3. Provision the database
    mysql -u <user> -p -e "CREATE DATABASE echodb DEFAULT CHARACTER SET utf8mb4;"
    mysql -u <user> -p echodb < sql/init.sql
    
  4. Run locally
    php -S localhost:8080 -t public
    
  5. Open http://localhost:8080 and start crafting database ripples.

API Reference

Base URL: /api

Method Endpoint Description
GET /api/index Health info + app version.
GET /api/events List recent events (limit, after_id).
POST /api/events Emulate mutation + emit CDC event.
GET /api/stream Server-Sent Events (Last-Event-ID aware).
GET /api/stats Counts per type/table + events per min.

Sample mutation

curl -X POST \
     -H "Content-Type: application/json" \
     -d '{"table":"orders","row_id":1,"type":"update","changes":{"status":"shipped"},"actor":"demo"}' \
     http://localhost:8080/api/events

SSE stream from the terminal:

curl -N http://localhost:8080/api/stream

Database Schema

users  (id, name, email)
orders (id, user_id, status ENUM, amount DECIMAL, updated_at TIMESTAMP)
events (id BIGINT, type ENUM, table_name, row_id, diff JSON, actor, created_at)

Example events.diff snapshot:

{
  "status": {"old": "pending", "new": "shipped"},
  "amount": {"old": 24.9, "new": 24.9}
}

Tooling & Quality

Deployment Notes

Screenshots & Demo

Why It’s Cool

Testing & Smoke Checks

See tests/smoke.md for curl snippets and manual verification steps.

License

Released under the MIT License. See LICENSE.