#!/usr/bin/env python3
import gradio as gr
import os
import re
# Basic configuration
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
ANTHROPIC_API_KEY = os.getenv("ANTHROPIC_API_KEY")
SERPAPI_KEY = os.getenv("SERPAPI_KEY")
FIRECRAWL_API_KEY = os.getenv("FIRECRAWL_API_KEY")
def is_url(text: str) -> bool:
"""Check if text contains a URL"""
url_pattern = r'https?://[^\s<>"{}|\\^`\[\]]+'
return bool(re.search(url_pattern, text))
def enhanced_analysis(resume_text: str, job_text: str) -> str:
"""Enhanced analysis with comprehensive features"""
if not resume_text.strip():
return "❌ Please provide your resume text or extract it from PDF using the tools below."
if not job_text.strip():
return "❌ Please provide a job description or URL."
# Enhanced analysis
resume_words = resume_text.lower().split()
job_words = job_text.lower().split()
# Detect if it's a URL
is_job_url = is_url(job_text)
url_message = ""
if is_job_url:
url_message = f"""
🔗 URL Detected: Job posting will be automatically processed for enhanced analysis
"""
# Expanded skill detection (75+ skills)
tech_skills = [
"python", "javascript", "java", "c++", "c#", "sql", "html", "css", "react", "vue", "angular",
"node", "express", "django", "flask", "spring", "laravel", "php", "ruby", "go", "rust", "kotlin",
"swift", "typescript", "mongodb", "postgresql", "mysql", "redis", "elasticsearch", "aws", "azure",
"gcp", "docker", "kubernetes", "jenkins", "git", "github", "gitlab", "linux", "windows", "macos",
"terraform", "ansible", "microservices", "api", "rest", "graphql", "websocket", "oauth", "jwt",
"machine learning", "ai", "data science", "pandas", "numpy", "tensorflow", "pytorch", "scikit-learn",
"spark", "hadoop", "tableau", "power bi", "excel", "r", "matlab", "scala", "shell", "bash", "powershell",
"devops", "ci/cd", "agile", "scrum", "kanban", "jira", "confluence", "slack", "figma", "sketch"
]
soft_skills = [
"leadership", "teamwork", "communication", "problem solving", "project management", "collaboration",
"mentoring", "training", "presentation", "documentation", "testing", "debugging", "optimization",
"scalability", "performance", "security", "architecture", "design", "planning", "strategy",
"analytical", "creative", "innovative", "adaptable", "reliable", "detail-oriented", "organized"
]
# Find matching skills
resume_tech_skills = [skill for skill in tech_skills if skill in resume_text.lower()]
job_tech_skills = [skill for skill in tech_skills if skill in job_text.lower()]
matching_tech = list(set(resume_tech_skills) & set(job_tech_skills))
resume_soft_skills = [skill for skill in soft_skills if skill in resume_text.lower()]
job_soft_skills = [skill for skill in soft_skills if skill in job_text.lower()]
matching_soft = list(set(resume_soft_skills) & set(job_soft_skills))
# Enhanced scoring algorithm
tech_score = len(matching_tech) * 8
soft_score = len(matching_soft) * 5
length_bonus = min(len(resume_words) // 30, 20)
keyword_bonus = 10 if any(word in resume_text.lower() for word in ["experience", "years", "project", "team"]) else 0
base_score = tech_score + soft_score + length_bonus + keyword_bonus
final_score = min(max(base_score + 35, 45), 95)
# Determine match level and color
if final_score >= 85:
match_level = "🟢 Excellent Match"
match_color = "#27ae60"
advice = "You're a strong candidate! Focus on specific examples and prepare confident answers."
elif final_score >= 70:
match_level = "🟡 Strong Match"
match_color = "#f39c12"
advice = "Good alignment! Highlight your relevant experience and show enthusiasm for learning."
else:
match_level = "🔴 Developing Match"
match_color = "#e74c3c"
advice = "Focus on transferable skills and demonstrate your ability to learn quickly."
# Generate comprehensive results
results_html = f"""
{url_message}
🎯 IQKiller
AI-Powered Interview Preparation Platform
📄 PDF Support • 🔗 URL Analysis • 💼 Comprehensive Preparation • 💰 Salary Guidance
""")
# PDF Help Section
gr.HTML("""
📄 Have a PDF Resume?
Extract text from your PDF resume using these simple tools:
Method 1: Script
./extract_pdf_resume.sh
Method 2: Python Tool
python3 pdf_upload_tool.py
Then copy the extracted text and paste it in the resume section below ⬇️
""")
# Main Interface
with gr.Row():
with gr.Column():
gr.HTML("""