Commit f45619

2025-10-06 11:44:54 Meenakshi: uploading LLD
Projects/HireGenius/LLD.md ..
@@ 1,1 1,137 @@
# LLD
+ # AI-Powered Recruitment Automation System
+ ## Low-Level Design Document (LLD)
+
+ ### 📘 Table of Contents
+ 1. [System Overview](#1-system-overview)
+ 2. [Module Breakdown](#2-module-breakdown)
+ 3. [API Design](#3-api-design)
+ 4. [Database Design](#4-database-design)
+ 5. [Business Workflow](#5-business-workflow)
+ 6. [AI Integration Points](#6-ai-integration-points)
+ 7. [System Architecture](#7-system-architecture)
+
+ ## 1. System Overview
+
+ ### 1.1 🎯 Purpose
+ Automate the recruitment pipeline from resume ingestion to candidate ranking using **NLP-based parsing**, **vector embeddings**, and **AI-powered re-ranking**.
+
+ ---
+
+ ### 1.2 ⚙️ Key Capabilities
+ - **Incremental Resume Ingestion:** Fetch new resumes from Gmail on schedule
+ - **Automated Resume Parsing:** Extract structured data (skills, experience, education, contact)
+ - **Semantic Matching:** Use embeddings to find similar candidates to job descriptions
+ - **AI Re-Ranking:** Re-rank top candidates using GPT-4o-mini for better precision
+ - **Dashboard:** HR views ranked candidates with explainability
+
+ ---
+
+ ### 1.3 🧰 Technology Stack
+ | Layer | Technology |
+ |--------|-------------|
+ | **Frontend** | React.js + Tailwind CSS |
+ | **Backend** | Node.js + Express.js |
+ | **Database** | PostgreSQL 15+ with pgvector extension |
+ | **AI/ML** | OpenAI GPT-4o-mini |
+ | **Embeddings** | OpenAI `text-embedding-3-small` |
+ | **Email Integration** | Gmail API with OAuth 2.0 |
+ | **Scheduler** | node-cron |
+ ### 🧠 Additional Components
+
+ | Component | Technology |
+ |------------|-------------|
+ | **AI/ML** | OpenAI **GPT-4o-mini** |
+ | **Vector Embeddings** | OpenAI **text-embedding-3-small** |
+ | **Email Integration** | Gmail API with **OAuth 2.0** |
+ | **Scheduler** | **node-cron** |
+
+
+ ## Module Breakdown
+
+ ### 2.1 Module Architecture
+ ┌─────────────────────────────────────────────────────────┐
+ │ Frontend Layer (React) │
+ │ - Job Dashboard - Candidate Pipeline - Analytics │
+ └────────────────────┬────────────────────────────────────┘
+ │ REST API
+ ┌────────────────────▼────────────────────────────────────┐
+ │ Backend Layer (Node.js/Express) │
+ ├──────────────────────────────────────────────────────────┤
+ │ 1. Gmail Module - Email fetching & OAuth │
+ │ 2. Resume Parser Module - NLP extraction │
+ │ 3. Embedding Module - Vector generation │
+ │ 4. Database Module - Data persistence │
+ │ 5. Job Description Mod - JD management │
+ │ 6. Ranking Module - AI re-ranking │
+ │ 7. Application Control - Orchestration │
+ │ 8. HR UI Module - Dashboard APIs │
+ └────────────────────┬────────────────────────────────────┘
+
+ ┌────────────────────▼────────────────────────────────────┐
+ │ Data Layer (PostgreSQL + pgvector) │
+
+
+ ## 2.2 Detailed Module Specifications
+
+ ### Module 1: Gmail Module
+ **Responsibility:** Email integration and resume fetching
+
+ **Functions:**
+ - Authenticate with Gmail API using OAuth 2.0
+ - Fetch emails with attachments based on filters (date, keywords, labels)
+ - Download resume attachments (PDF, DOCX)
+ - Track last fetch timestamp for incremental processing
+
+ **Key Operations:**
+ - `fetchNewEmails(afterDate, filters)` → Returns array of email objects with attachments
+ - `downloadAttachment(messageId, attachmentId)` → Returns file buffer
+ - `getLastFetchTime(jobId)` → Returns timestamp of last successful fetch
+
+ **External Dependencies:** Gmail API, Google OAuth 2.0
+
+ ---
+
+ ### Module 2: Resume Parser Module
+ **Responsibility:** Extract structured data from resume text
+
+ **Parsing Strategy:** Rule-based NLP with regex patterns
+
+ **Extraction Details:**
+ - **Name:** First line heuristics, capitalization patterns
+ - **Email:** Regex pattern `[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}`
+ - **Phone:** Regex for various formats (`+1-XXX-XXX-XXXX`, `(XXX) XXX-XXXX`)
+ - **Skills:** Keyword matching against predefined skill database
+ - **Experience:** Section detection (keywords: "experience", "work history") + date parsing
+ - **Education:** Section detection + degree/institution extraction
+
+ **Functions:**
+ - `extractText(fileBuffer, format)` → Returns plain text from PDF/DOCX
+ - `parseResume(resumeText)` → Returns structured JSON object
+ - `validateParsedData(data)` → Returns boolean + error messages
+ - `normalizeSkills(skillArray)` → Returns deduplicated, lowercase skills
+
+ **Output Format (JSON):**
+ ```json
+ {
+ "name": "John Doe",
+ "email": "john@example.com",
+ "phone": "+1-555-0123",
+ "skills": ["javascript", "python", "sql"],
+ "experience": [
+ {
+ "title": "Software Engineer",
+ "company": "Tech Corp",
+ "duration": "2020-2023",
+ "description": "Built REST APIs..."
+ }
+ ],
+ "education": [
+ {
+ "degree": "B.S. Computer Science",
+ "institution": "MIT",
+ "year": 2018
+ }
+ ],
+ "total_experience_years": 5
+ }
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9