README / FILE_STRUCTURE.md
Vaidik001's picture
Upload 16 files
b76f181 verified
|
Raw History Blame Contribute Delete
13 kB
# Resume Analyzer Backend - Visual Structure & File Guide
## πŸ“¦ Complete File Tree
```
backend/
β”‚
β”œβ”€β”€ πŸ“‹ Documentation (Read These First!)
β”‚ β”œβ”€β”€ README.md ← START HERE (overview)
β”‚ β”œβ”€β”€ SETUP_GUIDE.md ← Installation & setup
β”‚ β”œβ”€β”€ ARCHITECTURE.md ← Technical details
β”‚ β”œβ”€β”€ QUICK_REFERENCE.md ← Quick commands
β”‚ β”œβ”€β”€ DEPLOYMENT.md ← Production deployment
β”‚ β”œβ”€β”€ DELIVERY_SUMMARY.md ← What was built
β”‚ └── FILE_STRUCTURE.md ← This file
β”‚
β”œβ”€β”€ 🐍 Application Code
β”‚ β”œβ”€β”€ main.py ← FastAPI app (250+ lines)
β”‚ β”œβ”€β”€ requirements.txt ← Python dependencies
β”‚ β”œβ”€β”€ .env.example ← Environment template
β”‚ β”œβ”€β”€ skills.json ← Skill database (250+ skills)
β”‚ └── test_api.py ← Testing & demo script (300+ lines)
β”‚
β”œβ”€β”€ πŸ“ models/
β”‚ └── response_models.py ← Pydantic schemas (2 models)
β”‚ β”œβ”€β”€ ResumeAnalysisResponse ← Main response model
β”‚ └── ErrorResponse ← Error response model
β”‚
└── πŸ“ services/
β”œβ”€β”€ resume_parser.py ← File parsing service (150+ lines)
β”‚ β”œβ”€β”€ ResumeParser class
β”‚ β”œβ”€β”€ parse_pdf() ← PDF extraction
β”‚ └── parse_docx() ← DOCX extraction
β”‚
β”œβ”€β”€ skill_extractor.py ← Skill extraction (200+ lines)
β”‚ β”œβ”€β”€ SkillExtractor class
β”‚ β”œβ”€β”€ extract_skills() ← Main extraction
β”‚ └── _fuzzy_match() ← Typo tolerance
β”‚
β”œβ”€β”€ matcher.py ← Semantic matching (200+ lines)
β”‚ β”œβ”€β”€ ResumeMatcher class
β”‚ β”œβ”€β”€ compute_match_score() ← Main matching
β”‚ └── batch_match() ← Batch processing
β”‚
└── utils.py ← Utilities (100+ lines)
β”œβ”€β”€ setup_logging()
β”œβ”€β”€ clean_text()
β”œβ”€β”€ normalize_skill()
└── validate_file_path()
```
---
## πŸ“Š Line Count Summary
```
main.py 250 lines ⭐ Core application
services/resume_parser.py 150 lines ⭐ File parsing
services/skill_extractor.py 200 lines ⭐ Skill extraction
services/matcher.py 200 lines ⭐ Semantic matching
services/utils.py 100 lines βœ“ Utilities
models/response_models.py 80 lines βœ“ Validation
test_api.py 300 lines βœ“ Testing
Total Code 1280 lines
β”œβ”€β”€ Documentation 600 lines
└── Comments & Docstrings 400 lines
Combined Total 2280 lines
```
---
## 🎯 File-by-File Guide
### 1. main.py (The Heart)
**What it does:**
- Sets up FastAPI application
- Initializes ML models on startup
- Defines API endpoints
- Handles errors
**Key sections:**
```python
# Configuration (lines 1-20)
app = FastAPI(...)
app.add_middleware(CORSMiddleware, ...)
# Startup event (lines 30-50)
@app.on_event("startup")
async def startup_event():
# Initialize resume_parser, skill_extractor, resume_matcher
# Health endpoint (lines 60-75)
@app.get("/health")
# Main endpoint (lines 85-200)
@app.post("/analyze")
async def analyze_resume(file: UploadFile, job_description: str)
# Error handlers (lines 210-240)
@app.exception_handler(HTTPException)
```
**Dependencies:**
- FastAPI, Uvicorn
- All service classes
- Pydantic models
---
### 2. services/resume_parser.py (File Handler)
**What it does:**
- Extracts text from PDF files
- Extracts text from DOCX files
- Validates files
- Handles errors gracefully
**Key class:**
```python
class ResumeParser:
@staticmethod
def parse_pdf(file_path: str) -> str
@staticmethod
def parse_docx(file_path: str) -> str
@staticmethod
def parse_resume(file_path: str, file_type: str) -> str
```
**Dependencies:**
- pdfplumber (PDF parsing)
- python-docx (Word parsing)
- Logging utilities
---
### 3. services/skill_extractor.py (NLP Engine)
**What it does:**
- Loads spaCy NLP model
- Loads skill database from JSON
- Extracts skills with fuzzy matching
- Handles typos with 85% threshold
**Key class:**
```python
class SkillExtractor:
def __init__(self, skills_json_path: str = None)
def extract_skills(self, text: str) -> List[str]
def _fuzzy_match(self, text: str, skill: str) -> bool
```
**Dependencies:**
- spacy (NLP)
- difflib (fuzzy matching)
- skills.json (skill database)
---
### 4. services/matcher.py (AI Matching)
**What it does:**
- Loads sentence-transformers model
- Generates embeddings for text
- Computes cosine similarity
- Returns match scores (0-100%)
**Key class:**
```python
class ResumeMatcher:
def __init__(self, model_name: str = "all-MiniLM-L6-v2")
def compute_match_score(self, resume: str, jd: str) -> float
def batch_match(self, resume: str, jds: List[str]) -> list
```
**Dependencies:**
- sentence-transformers (embeddings)
- scikit-learn (cosine similarity)
- torch (deep learning)
---
### 5. services/utils.py (Helpers)
**What it does:**
- Sets up logging
- Cleans text
- Normalizes skills
- Validates files
**Key functions:**
```python
def setup_logging(log_level: str) -> logging.Logger
def clean_text(text: str) -> str
def normalize_skill(skill: str) -> str
def validate_file_path(file_path: str, ...) -> bool
```
**No external dependencies** (uses stdlib)
---
### 6. models/response_models.py (Data Schemas)
**What it does:**
- Defines response data structures
- Validates data with Pydantic
- Generates OpenAPI docs
**Key classes:**
```python
class ResumeAnalysisResponse(BaseModel):
match_score: float
resume_skills: List[str]
jd_skills: List[str]
missing_skills: List[str]
class ErrorResponse(BaseModel):
error: str
detail: str
status_code: int
```
**Dependencies:**
- Pydantic (validation)
---
### 7. skills.json (Data)
**What it contains:**
- 250+ predefined skills
- Organized by category:
- Programming languages (Python, Java, etc.)
- Web frameworks (FastAPI, Django, React, etc.)
- Databases (PostgreSQL, MongoDB, etc.)
- Cloud platforms (AWS, Azure, GCP)
- Tools (Docker, Kubernetes, etc.)
- Soft skills (Leadership, Communication, etc.)
**Format:**
```json
{
"skills": [
"Python",
"FastAPI",
"PostgreSQL",
...
]
}
```
---
### 8. test_api.py (Testing)
**What it does:**
- Tests API endpoints
- Provides interactive testing
- Batch testing capability
- Sample job descriptions
**Key functions:**
```python
def check_api_health() -> bool
def analyze_resume(file_path: str, job_description: str) -> dict
def interactive_test()
def batch_test(resume_dir: str)
```
**Usage:**
```bash
python test_api.py # Interactive
python test_api.py --file resume.pdf # File mode
python test_api.py --batch ./dir/ # Batch mode
```
---
### 9. requirements.txt (Dependencies)
**What it contains:**
```
fastapi==0.104.1 # Web framework
uvicorn[standard]==0.24.0 # ASGI server
pdfplumber==0.10.3 # PDF extraction
python-docx==0.8.11 # DOCX parsing
spacy==3.7.2 # NLP
sentence-transformers==2.2.2 # Embeddings
torch==2.1.1 # Deep learning
scikit-learn==1.3.2 # ML utilities
pydantic==2.5.0 # Validation
...
```
---
### 10. Documentation Files
| File | Purpose | Length |
|------|---------|--------|
| **README.md** | Main overview & features | 400 lines |
| **SETUP_GUIDE.md** | Installation & deployment | 500 lines |
| **ARCHITECTURE.md** | Technical design | 600 lines |
| **QUICK_REFERENCE.md** | Commands & API reference | 250 lines |
| **DEPLOYMENT.md** | Production deployment | 400 lines |
| **DELIVERY_SUMMARY.md** | What was delivered | 350 lines |
| **FILE_STRUCTURE.md** | This file (guide) | 300 lines |
---
## πŸ”„ Data Flow
```
User Request
↓
FastAPI (main.py)
β”œβ”€ Validate inputs
β”‚ └─ Check file type, size, content length
β”‚
β”œβ”€ Parse Resume
β”‚ └─ services/resume_parser.py
β”‚ β”œβ”€ If PDF: pdfplumber
β”‚ β”œβ”€ If DOCX: python-docx
β”‚ └─ Return: Clean text
β”‚
β”œβ”€ Extract Skills (Resume)
β”‚ └─ services/skill_extractor.py
β”‚ β”œβ”€ Load spaCy model
β”‚ β”œβ”€ Load skills.json
β”‚ β”œβ”€ Fuzzy match skills
β”‚ └─ Return: [Skill1, Skill2, ...]
β”‚
β”œβ”€ Extract Skills (Job Description)
β”‚ └─ services/skill_extractor.py
β”‚ └─ Return: [Skill1, Skill2, ...]
β”‚
β”œβ”€ Skill Gap Analysis
β”‚ └─ Find: JD skills - Resume skills
β”‚
β”œβ”€ Semantic Matching
β”‚ └─ services/matcher.py
β”‚ β”œβ”€ Load sentence-transformers
β”‚ β”œβ”€ Generate embeddings
β”‚ β”œβ”€ Compute cosine similarity
β”‚ └─ Return: Match score (0-100)
β”‚
β”œβ”€ Build Response
β”‚ └─ models/response_models.py
β”‚ β”œβ”€ Validate with Pydantic
β”‚ └─ Return: JSON response
β”‚
└─ Return JSON
{
"match_score": 85.5,
"resume_skills": [...],
"jd_skills": [...],
"missing_skills": [...]
}
```
---
## πŸ› οΈ Technology Stack
### Backend Framework
- **FastAPI** - Modern, async, automatic API docs
### File Processing
- **pdfplumber** - PDF text extraction
- **python-docx** - Word document parsing
### Natural Language Processing
- **spaCy** - Entity recognition, text processing
- **sentence-transformers** - Semantic embeddings
### Machine Learning
- **torch** - Deep learning backend
- **scikit-learn** - Cosine similarity
### Data Validation
- **Pydantic** - Type checking, validation
### Server
- **Uvicorn** - ASGI server
- **Gunicorn** - Production server (optional)
---
## πŸ“ˆ Complexity Breakdown
```
Simple (read-only)
β”œβ”€β”€ utils.py ← Text cleaning, helpers
β”œβ”€β”€ response_models.py ← Data schemas
└── skills.json ← Skill database
Medium (processing)
β”œβ”€β”€ resume_parser.py ← File extraction
└── test_api.py ← Testing script
Complex (ML/AI)
β”œβ”€β”€ skill_extractor.py ← spaCy + fuzzy matching
└── matcher.py ← Embeddings + cosine similarity
Orchestration
└── main.py ← Coordinates all services
```
---
## πŸš€ Getting Started by File
**1. First time?**
- Read: README.md
- Run: `python main.py`
- Test: Open http://localhost:8000/docs
**2. Installation issues?**
- Read: SETUP_GUIDE.md
- Check: requirements.txt
**3. Want to understand how it works?**
- Read: ARCHITECTURE.md
- Review: main.py, then services/
**4. Need quick commands?**
- Read: QUICK_REFERENCE.md
- Check: test_api.py examples
**5. Ready for production?**
- Read: DEPLOYMENT.md
- Check: DELIVERY_SUMMARY.md
---
## βœ… Verification Checklist
Before using, verify all files exist:
```bash
cd backend
# Core code files
[ -f main.py ] βœ“
[ -f requirements.txt ] βœ“
[ -f skills.json ] βœ“
[ -f test_api.py ] βœ“
[ -f .env.example ] βœ“
# Service files
[ -f services/resume_parser.py ] βœ“
[ -f services/skill_extractor.py ] βœ“
[ -f services/matcher.py ] βœ“
[ -f services/utils.py ] βœ“
# Model files
[ -f models/response_models.py ] βœ“
# Documentation
[ -f README.md ] βœ“
[ -f SETUP_GUIDE.md ] βœ“
[ -f ARCHITECTURE.md ] βœ“
[ -f QUICK_REFERENCE.md ] βœ“
[ -f DEPLOYMENT.md ] βœ“
[ -f DELIVERY_SUMMARY.md ] βœ“
```
---
## πŸ“ Notes
- All files include comprehensive docstrings
- All code is type-hinted for clarity
- All documentation is thorough and organized
- All dependencies are in requirements.txt
- All skills are in skills.json
- Code is production-ready with proper error handling
---
**For detailed explanation of each file, see ARCHITECTURE.md**
**For quick commands, see QUICK_REFERENCE.md**
**For setup, see SETUP_GUIDE.md**