# Last Ember — MMUD Web Dashboard

> **CONSOLIDATED:** Last Ember has been merged into the MMUD repo at `src/web/`.
> The standalone repo at `/home/zvx/projects/last-ember` is archived (deprecation notice committed).

Spectator dashboard and admin panel for MMUD (Mesh Multi-User Dungeon). Flask web app that reads from the game's SQLite database. Themed as The Last Ember — the bar that never changes.

## Status

**Phase:** Consolidated into MMUD. No longer a separate project.

## Location

- **Code:** `/home/zvx/projects/mmud/src/web/`
- **Archived repo:** `/home/zvx/projects/last-ember` (deprecated, read-only reference)

## Relationship to MMUD

Last Ember now runs **in-process** with the MMUD mesh daemon as a background daemon thread. Same process, same DB file, WAL mode handles concurrency. Flask starts automatically unless `--no-web` is passed.

## Key Files

- `src/web/__init__.py` — Flask app factory (`create_app`)
- `src/web/config.py` — Web-specific settings (host, port, secret, polling intervals)
- `src/web/routes/` — public.py, api.py, admin.py (session auth)
- `src/web/services/` — gamedb.py, dashboard.py, chronicle.py, admin_service.py
- `src/web/templates/` — Jinja2 templates (dark tavern aesthetic)
- `src/web/static/` — ember.css (design system), embers.js (particles), app.js (AJAX)
- `src/web/prototypes/` — Original HTML design references (visual source of truth)
- `src/db/migrations/004_web_tables.sql` — Web tables (node_config, admin_log, banned_players, npc_journals)

## Stack

- Python 3.11+, Flask 3.x, Jinja2
- SQLite WAL mode (read-only public, read-write admin)
- No build step, no React, no SPA. Server-rendered templates with AJAX polling.
- Docker (python:3.11-slim, /data volume for SQLite)

## CLI

- `--web-port PORT` — override dashboard port (default: 5000)
- `--no-web` — disable web dashboard entirely
- `MMUD_WEB_PORT`, `MMUD_WEB_HOST`, `MMUD_WEB_SECRET`, `MMUD_ADMIN_PASSWORD` env vars

## Pages

**Public (no auth):**
- Main dashboard — live epoch status, leaderboard, broadcasts, bounties, mode status, secrets
- Chronicle — epoch history, NPC daily journals (Grist, Maren, Torval, Whisper)
- How to Play — game guide, command reference

**API (JSON, polled by frontend):**
- `/api/status` (30s), `/api/broadcasts` (15s), `/api/bounties`, `/api/mode`, `/api/leaderboard`

**Admin (session auth):**
- Dashboard — active players, epoch day, node health
- Nodes — assign Meshtastic node IDs to 6 sim node roles
- Players — view, ban, kick, reset
- Epoch — force advance day, force Breach, manual broadcast
- System — DB stats, node config, admin log
