Download SETUP_GUIDE.md from Neworg001/README: direct link, hf CLI and curl.
- Browser
- Download file 12.4 kB
-
https://huggingface.co/spaces/Neworg001/README/resolve/main/SETUP_GUIDE.md
- Command line
-
hf download hf://spaces/Neworg001/README/SETUP_GUIDE.md
-
curl -L -o SETUP_GUIDE.md https://huggingface.co/spaces/Neworg001/README/resolve/main/SETUP_GUIDE.md
Resume Analyzer API - Setup & Installation Guide
Overview
This is a production-ready FastAPI backend for AI-powered resume analysis. The API:
- π Accepts PDF/DOCX resume uploads
- π§ Extracts skills using spaCy NLP
- π― Matches resume against job descriptions using semantic similarity (sentence-transformers)
- π Provides match scores and skill gap analysis
- π Built with FastAPI, async-ready
Quick Start (5 Minutes)
1. Create Virtual Environment
# Windows
python -m venv venv
venv\Scripts\activate
# macOS/Linux
python -m venv venv
source venv/bin/activate
2. Install Dependencies
pip install -r requirements.txt
3. Download spaCy Model
python -m spacy download en_core_web_sm
4. Run the Server
python main.py
You should see:
INFO: Uvicorn running on http://0.0.0.0:8000
5. Test the API
Open browser: http://localhost:8000/docs
You'll see the interactive API documentation (Swagger UI).
Installation Details
System Requirements
- Python 3.10+
- 4GB RAM minimum (for ML models)
- ~500MB disk space (for models)
Virtual Environment Setup
Windows:
python -m venv venv
venv\Scripts\activate
macOS/Linux:
python -m venv venv
source venv/bin/activate
Install Python Packages
pip install -r requirements.txt
If you get a NumPy compilation error on Windows, run this instead:
pip install --only-binary :all: numpy
pip install -r requirements.txt
This installs:
- fastapi - Modern, fast web framework
- uvicorn - ASGI server
- pdfplumber - PDF text extraction
- python-docx - Word document reading
- spacy - NLP for skill extraction
- sentence-transformers - Semantic similarity
- torch - Deep learning library
- scikit-learn - Machine learning utilities
Download spaCy NLP Model
python -m spacy download en_core_web_sm
This downloads ~40MB English language model (one-time only).
Running the Server
Development Mode (with auto-reload)
python main.py
The server automatically reloads when you modify files.
Production Mode (with Gunicorn)
pip install gunicorn
gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app --bind 0.0.0.0:8000
-w 4: Use 4 worker processes-k uvicorn.workers.UvicornWorker: Use Uvicorn worker class
Access the API
- API Endpoint: http://localhost:8000
- Interactive Docs: http://localhost:8000/docs (Swagger UI)
- Alternative Docs: http://localhost:8000/redoc (ReDoc)
- Health Check: http://localhost:8000/health
API Endpoints
1. Health Check
GET /health
Response:
{
"status": "ok",
"services": {
"resume_parser": true,
"skill_extractor": true,
"resume_matcher": true
}
}
2. Main Analysis Endpoint
POST /analyze
Request (multipart/form-data):
file: Resume file (PDF or DOCX)job_description: Job description text (min 50 characters)
Response:
{
"match_score": 85.5,
"resume_skills": ["Python", "FastAPI", "PostgreSQL", "Docker"],
"jd_skills": ["Python", "FastAPI", "PostgreSQL", "Docker", "Kubernetes"],
"missing_skills": ["Kubernetes"]
}
Usage Examples
Using cURL
curl -X POST "http://localhost:8000/analyze" \
-F "file=@resume.pdf" \
-F "job_description=We are looking for a Python FastAPI developer with PostgreSQL experience..."
Using Python
import requests
with open('resume.pdf', 'rb') as f:
files = {'file': f}
data = {
'job_description': 'We need a Python developer with FastAPI and PostgreSQL...'
}
response = requests.post(
'http://localhost:8000/analyze',
files=files,
data=data
)
result = response.json()
print(f"Match Score: {result['match_score']}%")
print(f"Missing Skills: {result['missing_skills']}")
Using JavaScript/React
const formData = new FormData();
formData.append('file', resumeFile); // File from input
formData.append('job_description', jobDescriptionText);
const response = await fetch('http://localhost:8000/analyze', {
method: 'POST',
body: formData,
// No Content-Type header - browser sets it automatically
});
const result = await response.json();
console.log(`Match Score: ${result.match_score}%`);
console.log(`Missing Skills: ${result.missing_skills.join(', ')}`);
Project Structure
backend/
βββ main.py # FastAPI app, endpoints, startup
βββ requirements.txt # Python dependencies
βββ skills.json # Database of extractable skills
β
βββ models/
β βββ response_models.py # Pydantic response schemas
β
βββ services/
βββ resume_parser.py # PDF/DOCX text extraction
βββ skill_extractor.py # spaCy-based skill extraction
βββ matcher.py # Semantic similarity matching
βββ utils.py # Helper functions
How It Works
1. Resume Parsing
- Accepts PDF or DOCX files
- Extracts text using pdfplumber (PDF) or python-docx (DOCX)
- Handles corrupted files gracefully
- Returns clean text for processing
2. Skill Extraction
- Uses spaCy NLP for entity recognition
- Matches against predefined skills database (
skills.json) - Fuzzy matching for typo tolerance (e.g., "Pyton" β "Python")
- Returns unique, sorted skills
3. Semantic Matching
- Uses sentence-transformers (all-MiniLM-L6-v2 model)
- Generates 384-dimensional embeddings for resume and job description
- Computes cosine similarity between embeddings
- Returns match score as 0-100%
Why sentence-transformers?
- Understands semantic meaning, not just keywords
- Pre-trained on semantic similarity tasks
- Fast inference (~100ms per request)
- Memory efficient (~80MB model)
Example:
- "Python developer" vs "Software engineer with Python" β ~95% match
- "Java developer" vs "JavaScript developer" β ~60% match
- "Frontend engineer" vs "Backend engineer" β ~40% match
4. Skill Gap Analysis
- Compares resume skills with job description skills
- Identifies missing skills
- Returns both matched and missing skills
Configuration
Modify Model Used for Matching
In matcher.py, change the model_name:
# Use a different model
resume_matcher = ResumeMatcher(
model_name="all-mpnet-base-v2" # More accurate but slower
)
Available models (from Hugging Face):
all-MiniLM-L6-v2(80MB) - DEFAULT, fastestall-mpnet-base-v2(420MB) - More accurateall-roberta-large-v1(700MB) - Highest quality
Add Custom Skills
Edit skills.json to add domain-specific skills:
{
"skills": [
"Python",
"FastAPI",
"YourCustomSkill",
...
]
}
Change Logging Level
In main.py, modify startup:
setup_logging("DEBUG") # DEBUG, INFO, WARNING, ERROR
Troubleshooting
Issue: NumPy compilation error on Windows (GCC >= 8.4 required)
This is a common Windows issue. NumPy tries to compile from source.
Solution:
pip install --only-binary :all: numpy scikit-learn
pip install -r requirements.txt
This installs pre-compiled wheels instead of compiling from source.
Issue: spaCy model not found
Solution:
python -m spacy download en_core_web_sm
Issue: Out of memory
Solution:
- Increase available RAM
- Or use a smaller sentence-transformers model:
ResumeMatcher("distiluse-base-multilingual-cased-v2")
Issue: Slow first request
Solution:
- First request loads models (~3-5 seconds)
- Subsequent requests are fast (~100-500ms)
- This is normal behavior
Issue: CORS errors from frontend
Solution:
CORS is already enabled in main.py. If you still get errors:
- Ensure frontend sends requests to
http://localhost:8000 - Add your frontend URL to
allow_originsin main.py
allow_origins=[
"http://localhost:3000", # Your React app
"http://yourfrontend.com", # Production URL
]
Testing
Test with Swagger UI
- Open http://localhost:8000/docs
- Click "Try it out" on the
/analyzeendpoint - Upload a resume
- Paste a job description
- Click "Execute"
Test with cURL
# Test with a real PDF (download a sample resume first)
curl -X POST "http://localhost:8000/analyze" \
-F "file=@your_resume.pdf" \
-F "job_description=We are looking for a talented Python developer with experience in FastAPI, PostgreSQL, and Docker. You should have strong problem-solving skills and experience working in agile teams."
Performance & Optimization
Response Times
| Operation | Time |
|---|---|
| Resume parsing (2 pages PDF) | ~200ms |
| Skill extraction | ~50ms |
| Semantic matching | ~100ms |
| Total | ~350-500ms |
Memory Usage
- spaCy model: ~100MB
- sentence-transformers model: ~80MB
- Runtime overhead: ~50MB
- Total: ~230MB
Scaling Recommendations
For Production (multiple requests):
# Use multiple workers
gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app
- Each worker gets its own model instances
- Handle 4-10 concurrent requests
- Monitor memory usage
For High Traffic:
# Load balance with Nginx
# Deploy multiple instances behind Nginx
# Use Redis for caching results
Development Tips
Debugging
Enable debug logging:
# In main.py
setup_logging("DEBUG")
Then check console output for detailed logs.
Adding Custom Endpoints
@app.post("/custom-endpoint")
async def custom_endpoint(data: dict):
# Your logic here
return {"result": "success"}
Testing Locally
# Create test_api.py
import requests
response = requests.post(
'http://localhost:8000/analyze',
files={'file': open('resume.pdf', 'rb')},
data={'job_description': 'Test JD...'}
)
print(response.json())
Deployment
Deploy on Heroku
# Create Procfile
echo "web: gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app" > Procfile
# Push to Heroku
git push heroku main
Deploy on AWS (EC2)
# 1. SSH into instance
ssh -i key.pem ubuntu@instance
# 2. Clone repo, setup venv, install deps
git clone <repo>
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python -m spacy download en_core_web_sm
# 3. Run with systemd
sudo systemctl start resume-analyzer
Deploy with Docker
FROM python:3.10
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN python -m spacy download en_core_web_sm
COPY . .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
Interview Talking Points
β Architecture: Clean, modular design with separate services β NLP: spaCy for extraction, sentence-transformers for semantic matching β Performance: ~500ms end-to-end, optimized for production β Error Handling: Graceful error handling with proper HTTP status codes β Documentation: Comprehensive code comments, auto-generated API docs β Scalability: Can handle multiple concurrent requests with workers β Testing: Easy to test with Swagger UI or cURL
Support & Further Reading
- FastAPI Docs: https://fastapi.tiangolo.com/
- spaCy Docs: https://spacy.io/
- Sentence-Transformers: https://www.sbert.net/
- scikit-learn (Cosine Similarity): https://scikit-learn.org/
License
MIT - Feel free to use for projects and interviews!