Skip to content

refactor: split monolithic app.js into focused ES modules#38

Open
bin101 wants to merge 1 commit into
mainfrom
refactor/frontend-modules
Open

refactor: split monolithic app.js into focused ES modules#38
bin101 wants to merge 1 commit into
mainfrom
refactor/frontend-modules

Conversation

@bin101

@bin101 bin101 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replaces the 1450-line static/app.js with 12 focused ES modules (state.js, dom.js, api.js, format.js, schedule-matrix.js, athletes.js, config.js, settings.js, feed.js, status.js, tabs.js, main.js)
  • Shared mutable state is isolated in state.js (single exported object) β€” no circular dependencies
  • routes.py::serve_index generates an importmap that covers all local modules, so every module is cache-busted on each release
  • Entry point changes from app.js β†’ main.js; index.html updated accordingly
  • Pure refactor β€” no behaviour change, all 380 tests pass, coverage 87 %

Module overview

Module Responsibility
state.js Shared mutable state (sport types, athlete caches, feed data, polling, run-button state, auto-save flag)
dom.js $, toast, setButtonLoading, makeRemoveBtn, initRevealButtons
api.js fetchJson, putJson
format.js formatRelative, formatTime, formatSportLabel
schedule-matrix.js 7Γ—24 schedule matrix: render, toggle, read, dim/enable
athletes.js Athlete managed-list rows + search modal
config.js Config tab: rules tables, loadConfig/saveConfig, auto-save
settings.js Settings tab: loadSettings/saveSettings, quiet-hours, auto-save
feed.js Feed tab: loadFeed, renderFeed, filter
status.js pollStatus, pollLog, polling lifecycle, startRun, initRunButtons
tabs.js activateTab, initTabs, initLangSelect
main.js init() entry point

Test plan

  • ruff check src tests β€” zero lint issues
  • ruff format --check src tests β€” zero formatting issues
  • mypy src β€” zero type errors
  • pytest β€” 380 passed, coverage 87 %
  • Manual: open the app, switch all tabs, save config, drag schedule matrix, search athletes, run dry-run

πŸ€– Generated with Claude Code

The 1450-line app.js is replaced by 12 focused ES modules:
state.js, dom.js, api.js, format.js, schedule-matrix.js,
athletes.js, config.js, settings.js, feed.js, status.js,
tabs.js, main.js.

The importmap in routes.py::serve_index now covers all local
modules so every module is cache-busted on release. Entry
point changes from app.js to main.js.

No behaviour change β€” all 380 tests pass, coverage 87 %.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant