| from __future__ import annotations | |
| from fastapi import APIRouter, Depends | |
| from app.core.auth import require_user | |
| from app.models.user import User | |
| from app.schemas.study import StudyRequestAnalysis, StudyRequestAnalyzeRequest | |
| from app.services.study_request_analyzer import analyze_study_request | |
| router = APIRouter() | |
| def analyze_request( | |
| payload: StudyRequestAnalyzeRequest, | |
| _current_user: User = Depends(require_user), | |
| ) -> StudyRequestAnalysis: | |
| # Auth required — anonymous callers can otherwise spam this and exhaust | |
| # the parser/AI budget. Onboarding already happens behind /login or /signup, | |
| # so the frontend always holds a JWT by the time it calls this. | |
| result = analyze_study_request(payload.raw_text, payload.syllabus_text) | |
| return StudyRequestAnalysis(**result) | |