Production-oriented deterministic-first matching module for a Smart University Suggestion System.
- Accepts a minimal student profile payload
- Retrieves relevant US universities from a structured datastore (mock JSON repository in v1)
- Applies deterministic hard filters (eligibility and affordability)
- Computes deterministic comparison features
- Uses a bounded LLM evaluator/reranker input contract (with deterministic fallback)
- Returns top 20 candidates with score breakdown, reasons, and traceability
- Produces downstream consultant-friendly JSON payload
Layered design with strict responsibility boundaries:
app/api/: FastAPI routes only (no business logic)app/components/: system components grouped by responsibilitymatching/: stage-1 matching component (top-20 university IDs)summary/: stage-2 analysis component (moved from top-levelsummary/)pipeline/: orchestration component combining stage 1 + stage 2
app/schemas/: request/response contracts (Pydantic)app/domain/: internal typed models and enumsapp/repositories/: datastore abstraction + mock repository implementationapp/services/: deterministic pipeline stages + orchestrationapp/prompts/: isolated LLM prompt templatesapp/data/: mock universities and rubric configapp/tests/: unit tests for core behavior
Main orchestration is in app/services/matching_service.py.
- Deterministic code computes facts: eligibility, thresholds, budget checks, and numeric feature comparisons.
- This prevents LLM hallucinations in areas where exact computation is required.
- The LLM is bounded to holistic evaluation/reranking from provided evidence only.
- Strict JSON schema + parser + fallback ensure robust production behavior.
- If LLM is unavailable or returns invalid output, deterministic scoring continues service operation.
profile_normalizercandidate_retrievalhard_filter_enginefeature_builderexpert_rubricllm_scorer(bounded, replaceable)rerankerconsultant_payload_builder
python -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
uvicorn app.main:app --reloadHealth check:
curl http://127.0.0.1:8000/healthMerged system pipeline endpoint:
curl -X POST http://127.0.0.1:8000/v1/pipeline/match-and-analyze \
-H "Content-Type: application/json" \
-d @app/data/sample.jsonMatching request:
curl -X POST http://127.0.0.1:8000/v1/matching/universities \
-H "Content-Type: application/json" \
-d '{
"student_id": "u001",
"gpa": 3.6,
"gpa_scale": 4.0,
"ielts": 7.0,
"intended_major": "Computer Science",
"profile_text": "Won a provincial math prize, leader of coding club, volunteer teaching children.",
"annual_budget_usd": 30000
}'{
"top_candidates": [
{
"university_id": "asu",
"name": "Arizona State University",
"overall_match": 79,
"bucket": "target",
"score_breakdown": {
"academic_fit": 82,
"competitiveness_fit": 55,
"affordability_fit": 70,
"profile_alignment": 60
},
"strengths": [
"Student meets academic threshold for the university"
],
"concerns": [
"Program competitiveness creates significant admission uncertainty"
],
"hard_filter_trace": [
{
"rule": "international_allowed",
"pass": true
}
]
}
],
"meta": {
"retrieved_count": 12,
"hard_filter_pass_count": 8,
"scored_count": 8,
"returned_count": 8,
"rubric_version": "v1"
}
}pytest -qCovered tests include:
- input validation
- profile normalization
- hard filter rules
- feature calculation
- ranking and consultant payload
- LLM JSON parsing and validation
- route-level integration check
The response contract in app/schemas/response.py is directly usable by consultant components:
top_candidates[*].score_breakdownfor explanation UIstrengths/concernsfor counseling narrativeshard_filter_tracefor transparent audit and objection handlingmetafor analytics and monitoring
- Add richer input fields (SAT/GRE, coursework rigor, target states, preferred climate, deadlines)
- Wrap
MatchingServiceas an MCP tool without changing core internals - Add optional RAG for expert guidance retrieval or supplemental school facts while keeping core deterministic pipeline unchanged