Skip to content

[performance]: interview-prep workspace endpoints risk the same N+1 / sequential-round-trip pattern already identified and fixed in opportunity-rounds — needs the same audit #83

Description

@prince-pokharna

Summary

docs/interview-rounds.md documents, in detail, a real performance bug the maintainer already found and fixed: the original round-creation flow chained 6 sequential Supabase calls server-side plus 2 blocking frontend refetches, and the fix batched reads, passed preloaded state into syncOpportunityFromRounds() to skip redundant SELECTs, and returned the full mutation payload so the frontend never needed a follow-up fetch.

That fix is well-documented and clearly shipped — but the interview-prep workspace (docs/interview-prep.md, backend/src/routes/interview-prep.js) is architecturally the same shape: a parent resource (opportunity) with multiple nested child collections (questions, topics, behavioral answers, research/reflection notes) that plausibly need similar create/update/list orchestration. Given rounds had this exact bug before the documented fix, prep is a strong candidate to have inherited the same pre-fix pattern, since both features were likely built before the rounds performance work was generalized into a reusable lesson.

Why this matters

The maintainer's own interview one-liner for the rounds fix — "chained six Supabase queries on create plus two frontend refetches... returned the full payload from the mutation" — is effectively a checklist. Applying that same checklist to prep (and to the hackathon-collaboration and documents-and-ATS features, which share the same nested-resource shape per the migration file list) is a mechanical, low-risk performance audit rather than net-new design work.

Proposed solution

  • Audit backend/src/routes/interview-prep.js for: (a) sequential Supabase calls that could be batched into one query using select with joined/nested resources, (b) any syncX()-style helper that re-fetches data it was already handed by the caller, (c) whether POST/PUT/DELETE mutation responses return the full updated state (matching the { round, opportunity, rounds } shape pattern) or require a frontend refetch.
  • Apply the same three fixes documented for rounds: batch the initial read, pass preloaded state into any sync/derivation helper, return the full mutation payload.
  • Extend npm run check:architecture (already referenced in the rounds testing section) if it doesn't already flag this pattern generally — turning a one-off fix into a project-wide lint rule is the highest-leverage version of this issue.
  • Document findings in docs/interview-prep.md under a new "Performance notes" section, mirroring the structure already used in interview-rounds.md, regardless of whether the audit finds the bug present or already absent — a documented "we checked, it's fine" is valuable too.

I'd like to be assigned this issue. This is explicitly modeled on a pattern the maintainer already solved once, which makes it a fast, low-ambiguity contribution — ideal as a guided second PR after a first smaller fix.

Labels: performance, good first issue, priority: medium, backend

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions