# AIService Endpoints

All Django-Ninja API endpoints registered in `aiservice/urls.py`.

## Endpoint Map

| Path | API | Module | Description |
|------|-----|--------|-------------|
| `/ai/optimize` | `optimize_api` | `core.shared.optimizer_router` | Main optimization — dispatches by language |
| `/ai/optimize-line-profiler` | `optimize_line_profiler_api` | `core.languages.python.optimizer.optimizer_line_profiler` | Line profiler optimization |
| `/ai/testgen` | `testgen_api` | `core.shared.testgen_router` | Test generation — dispatches by language |
| `/ai/log_features` | `features_api` | `core.log_features.log_features` | Feature logging |
| `/ai/refinement` | `refinement_api` | `core.languages.python.optimizer.refinement` | Candidate refinement |
| `/ai/explain` | `explanations_api` | `core.languages.python.explanations.explanations` | Code explanations |
| `/ai/rank` | `ranker_api` | `core.shared.ranker.ranker` | Function ranking |
| `/ai/optimization_review` | `optimization_review_api` | `core.languages.python.optimization_review.optimization_review` | Optimization review |
| `/ai/code_repair` | `code_repair_api` | `core.languages.python.code_repair.code_repair` | Code repair for failed candidates |
| `/ai/adaptive_optimize` | `adaptive_optimize_api` | `core.languages.python.adaptive_optimizer.adaptive_optimizer` | Adaptive optimization |
| `/ai/workflow-gen` | `workflow_gen_api` | `core.shared.workflow_gen.workflow_gen` | Workflow generation |
| `/ai/rewrite_jit` | `jit_rewrite_api` | `core.languages.python.jit_rewrite.jit_rewrite` | JIT rewrite |

## Common Patterns

- All endpoints are `async def`
- Authentication via `AuthenticatedRequest` (HttpBearer + django_auth)
- Request schemas use `ninja.Schema` (Pydantic under the hood)
- Response schemas define typed success and error responses: `response={200: SuccessSchema, 400: ErrorSchema, 500: ErrorSchema}`
- Multi-language endpoints (optimize, testgen) dispatch by `data.language` field
- Python-only endpoints import directly from `core.languages.python.*`
