Skip to content

Issue 11: Wire frontend to backend #11

@SriMed

Description

@SriMed

Description

Replace placeholder functions with real API calls. Wire 'Load Example' to /example and 'Analyze' to /analyze. Render DiagnosticCard on success.

Implementation details

  • lib/api.ts:
    • loadExample(domain: string): Promise<ExampleResponse>
    • analyzeExample(exampleId: string): Promise<AnalyzeResponse>
  • Both POST to backend, URL from NEXT_PUBLIC_API_URL (default: http://localhost:8000)
  • On loadExample success: populate preview card
  • On analyzeExample success: render <DiagnosticCard result={response} />
  • On any error: inline error message
  • Disable relevant buttons during in-flight requests
  • Create .env.local.example documenting all env vars

Acceptance criteria

  • 'Load Example' populates preview card with real data
  • 'Analyze' renders DiagnosticCard with real results
  • Buttons disabled during in-flight requests
  • Error message on non-200 or network failure
  • Backend URL configurable via env var
  • .env.local.example documented

TDD

frontend/__tests__/api.test.ts and page.test.tsx:

  1. loadExample posts to /example with correct domain
  2. analyzeExample posts to /analyze with correct example_id
  3. Both return parsed responses on 200
  4. Both throw on non-200
  5. Preview card populates after loadExample
  6. DiagnosticCard renders after analyzeExample
  7. Buttons disabled during loading

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendFastAPI / Python workfrontendNext.js / UI work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions