salary-benchmark/app/routers/benchmarks.py
DJP da3f5faa91 Initial commit: Salary Benchmark Tool
FastAPI + React + PostgreSQL salary benchmarking tool with AI research pipeline.
- Seed data for 25+ New York roles (junior/mid/senior levels)
- Single + bulk lookup with location alias mapping (NYC -> New York, etc.)
- Research pipeline: Serper -> Firecrawl -> Cohere Rerank -> Claude analysis
- Editable validation UI for AI-proposed benchmarks
- CSV export, Montserrat font, black/white/#FFC407 design
- Fully Dockerized (app + db + frontend)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 22:47:32 -04:00

31 lines
1.1 KiB
Python

from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.ext.asyncio import AsyncSession
from app.database import get_db
from app.schemas import BenchmarkOut, BulkLookupRequest, BulkLookupResponse
from app.services.benchmark_service import lookup_benchmarks
router = APIRouter(tags=["benchmarks"])
@router.get("/benchmarks", response_model=list[BenchmarkOut])
async def get_benchmarks(
title: str, location: str, db: AsyncSession = Depends(get_db)
):
results = await lookup_benchmarks(db, title, location)
if not results:
raise HTTPException(status_code=404, detail="No benchmarks found")
return results
@router.post("/benchmarks/bulk", response_model=BulkLookupResponse)
async def bulk_lookup(req: BulkLookupRequest, db: AsyncSession = Depends(get_db)):
found = {}
not_found = []
for title in req.titles:
results = await lookup_benchmarks(db, title, req.location)
if results:
found[title] = results
else:
not_found.append(title)
return BulkLookupResponse(found=found, not_found=not_found)