Skip to content

Extract app.js monolith (4,707 lines) into modules #10

@sgardoll

Description

@sgardoll

Summary

app.js contains all application logic in a single 4,707-line file: encryption, API key management, 4 API clients, FlutterFlow API client class, pubspec/YAML handling, commit orchestration, 3 pipeline functions, markdown rendering, UI orchestration, initialization, and feedback.

Risk Assessment

  • Risk Level: High
  • Likelihood: Certain — impacts every development session
  • Impact: Growing — each feature addition increases risk
  • Timeline: Accumulating now, rewrite pressure within 12 months

Current State

A src/ directory exists with ffState/, fileUtils/, types/ subdirectories — suggesting a module split was started but never completed.

Impact Trajectory

  • Today: Cognitive overload, long git diffs, merge conflicts
  • 6 months: Fear of touching code — changes cascade unpredictably
  • 12 months: Rewrite pressure because patching becomes too risky

Suggested Incremental Extraction

Start with pure-logic functions (no DOM dependencies):

Module Lines Dependencies
crypto.js 218-362 None (Web Crypto API)
pubspec.js ~1700-2800 None (pure data)
markdown-renderer.js 3270-3450 highlight.js
flutterflow-client.js 1250-1459 None (fetch)
api-clients.js 992-1230 Global API keys
pipeline.js 2806-3260 API clients
ui.js Remaining DOM code Everything above

Each extraction should:

  1. Move the code to a new ES module file
  2. Export the public API
  3. Import in app.js (preserving behavior)
  4. Verify no regressions

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttech-debtTechnical debt reduction

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions