Feature #61
closedFeature #21: Enhance Matching Results and AI Assistant with Company Enrichment and Market Insights
[MatchingAgent] Market-insights aggregate endpoint (skills/location/work-mode demand)
0%
Description
**Surface:** MatchingAgent (`MatchingAgent/`, FastAPI, `src/api/`).
## Description
Add a FastAPI endpoint that computes market-insights aggregates over the active-offer corpus, scoped by role and optional filters (location, seniority):
- Top in-demand skills with offer counts (e.g. "Java (8,974 offers), Kubernetes (7,086)").
- Location trends (which locations have the most offers for the role).
- Work-mode distribution (e.g. "80% hybrid").
Requirements:
- New endpoint (e.g. `POST /v1/market-insights`) returning a typed JSON aggregate.
- Aggregation must be algorithmic (no LLM call), reusing the active-offer definition (isActive + extractedAt window + not expired) consistent with the rest of the corpus.
- Performance: respond within budget when serving a 100+ matching-result batch (cache/precompute as needed).
- pytest unit coverage for the aggregation logic (skills counts, location ranking, work-mode percentages).
Blocks #3 (GetYourJob proxy route).
## Acceptance criteria
- [ ] `POST /v1/market-insights` returns top skills with offer counts, location trends, and work-mode distribution for a given role/filter set.
- [ ] Aggregates use the active-offer definition and contain no LLM calls.
- [ ] Endpoint meets performance budget for a 100+ result batch (documented timing).
- [ ] pytest covers skill counts, location ranking, and work-mode percentages.
**Estimate:** M