# 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**