Skip to content

Simplify Delta Command for maintenance#8

Draft
nfaggian wants to merge 2 commits into
mainfrom
cursor/simplify-codebase-535c
Draft

Simplify Delta Command for maintenance#8
nfaggian wants to merge 2 commits into
mainfrom
cursor/simplify-codebase-535c

Conversation

@nfaggian

@nfaggian nfaggian commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

Two passes over the codebase from a maintainer's perspective. Net: ~34,000 fewer lines (mostly the unused llms-full.txt dump) plus a ~550-line reduction in actual source across backend and frontend.

Pass 1 — Dead code and duplication (8dfab9e)

  • Deleted 1.2 MB llms-full.txt, apps/delta-command/data/db.json, scripts/capture-ui.mjs
  • Removed getDatabase(), filterTimelineRows(), formatCurrencyShort() — all unused
  • Deleted migrate_legacy_runtime() (migration long complete) and its test
  • Merged three parallel utilization helpers into a single utilizationVariant() returning { bar, text, cell }
  • Replaced KPICard's free-form iconColor string with a typed accent tone
  • Converted Opportunities and Projects to server components (mutations use router.refresh())

Pass 2 — Aggressive simplification for maintenance (50f4747)

The API surface, the Pydantic layer, and the reactive computation were doing more than they needed to. Cut them down.

Single-endpoint API

Backend now has one GET and three PATCHes:

Method Path
GET /api/state — whole database
PATCH /api/opportunities
PATCH /api/projects
PATCH /api/timeline

Deleted: /api/dashboard, /api/engineers (GET + PATCH), /api/opportunities (GET), /api/projects (GET), /api/utilization/timeline (GET). Also deleted their filter query params, the list_engineers search logic, and the update_engineer_utilization code path (unused by the UI).

No more compute-on-read

get_utilization_timeline() was silently backfilling missing weeks and writing to disk on GET. That's gone. Timeline shape is now purely stored data — seed_team.py owns creation, PATCH /api/timeline only mutates existing cells, and column metadata (label, isCurrent) is derived on the client via deriveTimelineWeeks().

Fewer metric definitions

metrics.py (backend) and dashboard-analytics.ts (frontend) were both computing overlapping numbers. Deleted metrics.py, compute_dashboard_metrics, and the DashboardMetrics model. The frontend already computes everything from raw state.

Pydantic boilerplate

Replaced per-field alias="camelCase" declarations with a module-level alias_generator=to_camel. models.py halves in size. Also dropped from __future__ import annotations (Python 3.12+ handles it).

Other trims

  • Removed CORS middleware — Next.js rewrites make it unnecessary
  • Dropped DELTA_CONFIG_PATH alias (one env var only)
  • Deleted the entire utilization_timeline.py module
  • Deleted the frontend getEngineers/getOpportunities/getProjects/getDashboardMetrics/getUtilizationTimeline in favor of a single getState()
  • Deleted the UtilizationTimeline* frontend types (backend no longer returns them)
  • Both READMEs rewritten to describe the (much smaller) surface

Verification

$ uv run pytest       # 9 passed
$ npm run build       # ✓ Compiled successfully
$ curl /api/state     # engineers: 30, opps: 8, projects: 10, timeline weeks: 8

All four pages render correctly against the live backend.

Open in Web Open in Cursor 

cursoragent and others added 2 commits July 4, 2026 22:28
Remove dead code and unify data-fetching patterns.

Frontend:
- Delete src/core/team-utils.ts (inline formatNameList into utils.ts)
- Delete getDatabase() from api.ts (never called)
- Delete filterTimelineRows() from TeamFilters.tsx (never called)
- Remove duplicate formatCurrencyShort() in dashboard-analytics.ts
- Consolidate getUtilizationColor/TextColor/CellStyle into a single
  utilizationVariant() helper returning { bar, text, cell }
- Replace KPICard's free-form iconColor string prop with a typed
  accent tone ('blue' | 'violet' | ...)
- Drop unnecessary CHART_GRID_COLOR / CHART_TICK_COLOR aliases
- Route API calls through Next.js rewrites when called from the
  browser so client components share the same api.ts client
- Convert Opportunities and Projects pages to server-rendered
  components (matching the Team page pattern); mutations use
  router.refresh() instead of manual re-fetching, eliminating
  loading spinners and two ad-hoc fetch calls
- Delete scripts/capture-ui.mjs (one-off dev screenshot helper)

Backend:
- Delete migrate_legacy_runtime() and LEGACY_RUNTIME_PATH now that
  the YAML->JSON migration is long complete
- Inline the _data_path() wrapper (just database_path())
- Add missing EngineerStatus import in store.py
- Drop legacy config/runtime.{json,yaml} entries from .gitignore
- Remove the now-obsolete migration test

Repo:
- Delete llms-full.txt (1.2 MB unused ADK docs dump)
- Delete apps/delta-command/data/ (leftover from earlier data location)

Verified: npm run build passes; uv run pytest passes 14/14.

Co-authored-by: Nathan Faggian <nathan.faggian@gmail.com>
Trim the API surface, kill compute-on-read side effects, and let the
frontend derive every metric from a single GET call. Net: ~550 fewer
lines across backend and frontend.

Backend
- Collapse 7 read endpoints (dashboard, engineers, opportunities,
  projects, timeline, and their filter variants) into ONE endpoint:
    GET /api/state -> whole database
  The frontend derives every metric, KPI, and timeline column from it.
- Delete PATCH /api/engineers (was unused by the UI)
- Delete metrics.py, DashboardMetrics model, compute_dashboard_metrics
  (frontend already computes everything via dashboard-analytics.ts)
- Delete utilization_timeline.py entirely. The timeline shape is now
  purely stored data. seed_team.py owns timeline creation, the PATCH
  endpoint only mutates existing cells, and column metadata (label,
  isCurrent) is derived on the client from today's date via
  deriveTimelineWeeks()
- get_utilization_timeline no longer writes to disk on GET (was
  silently backfilling missing weeks). All reads are now pure.
- Remove CORS middleware — Next.js rewrites make it unnecessary
- Drop DELTA_CONFIG_PATH alias (keep DELTA_DATA_PATH only)
- Replace per-field alias= declarations with a single module-level
  alias_generator=to_camel on every model. Cuts models.py in half.
- Drop the 'from __future__ import annotations' preamble everywhere
  (Python 3.12+ handles it natively)

Frontend
- api.ts now has one getState() + three PATCH helpers. Deleted
  getEngineers, getOpportunities, getProjects, getDashboardMetrics,
  getUtilizationTimeline.
- Every page.tsx destructures from a single getState() call
- UtilizationTimelineView takes engineers directly and derives
  { weekStart, label, isCurrent } from stored cells — no separate
  timeline endpoint or response type
- Delete UtilizationTimelineWeek/Cell/Row/UtilizationTimeline types
  and DashboardMetrics interface
- TeamPageClient stat cards extracted into a small StatCard helper
- Refresh both READMEs to describe the new (much smaller) surface

Verified: 9/9 backend tests pass; npm run build passes; all four
pages render correctly against the running backend.

Co-authored-by: Nathan Faggian <nathan.faggian@gmail.com>
@cursor cursor Bot changed the title Simplify Delta Command codebase Simplify Delta Command for maintenance Jul 4, 2026
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.

2 participants