Skip to content

refactor(api): Move benchmark data processing from UI to backend #75

@anfredette

Description

@anfredette

Description

The UI currently receives raw benchmark data from the backend and processes it client-side. This processing should be moved to the backend to keep the UI simpler and more maintainable.

Current Behavior

  • load_206_models() in app.py:1600-1624 fetches raw benchmark data from GET /api/v1/benchmarks
  • Returns the full dataset as a pandas DataFrame
  • UI then processes this data for:
    1. Displaying a searchable model catalog in the About tab (app.py:2769-2792)
    2. Showing model count in spinner messages (app.py:4762)

Problems with Current Approach

  • UI coupled to data schema - if benchmark CSV columns change, UI code breaks
  • Duplicate logic risk - multiple UI components extracting similar info leads to inconsistency
  • Harder to test - data transformations in UI are harder to unit test than backend code
  • Larger payloads - full benchmark data transferred when UI only needs a subset
  • UI complexity - UI handles parsing, filtering, and error cases that belong in backend

Proposed Fix

Move data processing to the backend:

  1. Create purpose-specific backend endpoints that return only what the UI needs:

    • Model catalog endpoint (e.g., GET /api/v1/model-catalog) - returns model names and display metadata
    • Model count endpoint or include count in existing responses
  2. Update UI to consume these endpoints directly without DataFrame processing

  3. Remove load_206_models() and related DataFrame handling from UI

Benefits

  1. Simpler UI - just renders what it receives, no data transformation logic
  2. Single source of truth - data processing logic lives in one place (backend)
  3. Decoupled from schema - backend can adapt to data source changes without UI updates
  4. Smaller payloads - transfer only what's needed for each view
  5. Easier testing - backend transformations can be unit tested independently

Files Affected

  • ui/app.py - Remove load_206_models() and DataFrame processing
  • backend/src/api/routes.py - Add new endpoint(s) for processed data

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions