Skip to content

feat(ai-service): replace mock AI/diff/quiz/defend routes with real service boundaries #5

@SharanyoBanerjee

Description

@SharanyoBanerjee

The AI service endpoints are currently mock implementations:

  • generate.py checks ANTHROPIC_API_KEY but still returns mock text even when a key exists (apps/ai-service/app/routes/generate.py lines 18-28).
  • quiz generation returns sample questions from query params rather than annotated code.
  • defend evaluation passes after message count rather than evaluating the answer.
  • diff returns a fixed sample diff instead of comparing the submitted code.

These are fine for scaffolding, but they do not yet implement the README's core Decode/Rebuild/Defend learning loop.

Suggested fix

Introduce clear service modules and request/response contracts:

  • Claude client wrapper with timeout/error handling
  • quiz generation from code/annotations
  • defend question/evaluation flow
  • actual diff/scoring engine
  • tests for each route with mocked external providers

Acceptance criteria

  • Routes no longer return fixed sample content in normal execution.
  • Missing provider keys fail clearly or enter an explicit local mock mode.
  • External AI calls are isolated behind service classes/functions.
  • Each route has at least one test for success and one for error behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions