LoveShah/srrss-ai-service
0
๐ฏ Resume Ranker โ ML-Powered Candidate Ranking System
A production-ready ML pipeline that parses resumes, generates semantic embeddings with Sentence-BERT, and ranks candidates against a job description using a three-component weighted scoring system.
๐ Project Structure
resume_ranker/
โ
โโโ app.py # Phase 9 โ FastAPI server (all endpoints)
โโโ demo.py # Standalone demo (no server needed)
โโโ requirements.txt # All dependencies
โ
โโโ models/
โ โโโ __init__.py
โ โโโ resume_parser.py # Phase 1 โ PDF/DOCX/TXT text extraction
โ โโโ preprocessor.py # Phase 2 โ Cleaning, stopwords, lemmatization
โ โโโ embedder.py # Phase 3 โ Sentence-BERT embeddings
โ โโโ scorer.py # Phase 4-7 โ Similarity, skills, exp, final score
โ โโโ ranker.py # Phase 8 โ Full pipeline orchestrator
โ
โโโ utils/
โโโ __init__.py
โโโ skill_dict.py # Master skill dictionary + normalizationโ๏ธ Setup
1. Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate2. Install dependencies
pip install -r requirements.txt2.1 Optional: Redis for durable multi-step sessions
docker run -d --name srrss-redis -p 6379:6379 redis:7-alpineSet:
export REDIS_URL=redis://localhost:6379/0
export SESSION_TTL_SECONDS=864003. Download spaCy model
python -m spacy download en_core_web_smSentence-BERT model (all-MiniLM-L6-v2) downloads automatically on first run (~85 MB).๐ Quick Start
Option A โ Standalone demo (no server)
python demo.pyUses 3 built-in sample resumes ranked against a sample Python backend JD.
With your own files:
python demo.py --jd path/to/job_description.txt --resumes cv1.pdf cv2.docx cv3.pdfOption B โ Run the API server
uvicorn app:app --reload --host 0.0.0.0 --port 8000Open API docs at: http://localhost:8000/docs
Run automated tests
pytest tests/ -v --cov=. --cov-report=term-missing๐ก API Usage (Phase 9)
Workflow
POST /upload_jd โ get job_id
POST /upload_resume โ attach resumes to job_id
POST /get_rankings โ run ML pipeline, get ranked results
GET /results/{id} โ fetch cached results
DELETE /clear/{id} โ clean up sessionStep 1 โ Upload Job Description
curl -X POST http://localhost:8000/upload_jd \
-F "jd_text=We are hiring a Python engineer with 4+ years of experience in FastAPI, PostgreSQL, Docker, and AWS." \
-F "job_title=Senior Python Engineer"Response:
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"job_title": "Senior Python Engineer",
"message": "Job description saved. Now upload resumes via /upload_resume."
}Step 2 โ Upload Resumes
curl -X POST http://localhost:8000/upload_resume \
-F "job_id=550e8400-e29b-41d4-a716-446655440000" \
-F "files=@alice_cv.pdf" \
-F "files=@bob_cv.docx"Step 3 โ Get Rankings
curl -X POST http://localhost:8000/get_rankings \
-F "job_id=550e8400-e29b-41d4-a716-446655440000"Response:
{
"job_id": "550e8400-...",
"total_resumes": 2,
"rankings": [
{
"rank": 1,
"candidate_name": "Alice Johnson",
"filename": "alice_cv.pdf",
"final_score_pct": 84.3,
"similarity_score": 0.8712,
"skill_match": {
"jd_skills": ["python", "fastapi", "postgresql", "docker", "aws"],
"resume_skills": ["python", "fastapi", "postgresql", "docker", "aws", "redis"],
"matched_skills": ["python", "fastapi", "postgresql", "docker", "aws"],
"missing_skills": [],
"skill_score": 1.0
},
"experience_match": {
"jd_years_required": 4.0,
"resume_years_found": 5.0,
"experience_score": 1.0,
"note": "Meets requirement (5 โฅ 4 yrs)."
}
},
...
]
}๐ง Scoring Formula (Phase 7)
final_score = (0.60 ร similarity_score)
+ (0.25 ร skill_score)
+ (0.15 ร experience_score)๐ ๏ธ Tech Stack
๐ Integration with Your Group Project
Your group's platform should call these three endpoints in order:
- When a company posts a job โ
POST /upload_jdโ storejob_id - When resumes are submitted โ
POST /upload_resume(withjob_id) - When the company views candidates โ
POST /get_rankingsโ display ranked list
The ML module is fully decoupled โ it just needs text in, rankings out.
