venkataashok commited on
Commit
8d59936
·
verified ·
1 Parent(s): 390ef92

Upload 4 files

Browse files
Files changed (4) hide show
  1. app.py +244 -0
  2. domains%2Cprojects.xlsx +0 -0
  3. jobs_dataset.json +258 -0
  4. requirements.txt +10 -0
app.py ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ import re
4
+ import base64
5
+ import tempfile
6
+ import requests
7
+ from fastapi import FastAPI, UploadFile, File, Form
8
+ from fastapi.middleware.cors import CORSMiddleware
9
+ from models.ocr import extract_text
10
+ from models.skill_extractor import SkillExtractor
11
+ import uvicorn
12
+ from sklearn.feature_extraction.text import TfidfVectorizer
13
+ from sklearn.metrics.pairwise import cosine_similarity
14
+
15
+ # ------------------------------
16
+ # Adzuna API credentials
17
+ # ------------------------------
18
+ ADZUNA_APP_ID = os.getenv("ADZUNA_APP_ID")
19
+ ADZUNA_API_KEY = os.getenv("ADZUNA_API_KEY")
20
+ COUNTRY = "gb" # Keep as 'gb' to avoid 404
21
+ RESULTS_LIMIT = 5
22
+
23
+ # ------------------------------
24
+ # Skill extractor & job data
25
+ # ------------------------------
26
+ skill_extractor = SkillExtractor()
27
+
28
+ with open("jobs_dataset.json", "r") as f:
29
+ JOBS_DATA = json.load(f)
30
+
31
+ # ------------------------------
32
+ # Helper functions
33
+ # ------------------------------
34
+ def clean_skills(skills):
35
+ return list({s.lower().strip() for s in skills if s.strip()})
36
+
37
+ def predict_role_from_skills(user_skills):
38
+ if not user_skills:
39
+ return "Software Developer", 0.0
40
+
41
+ user_skills = clean_skills(user_skills)
42
+ user_text = " ".join(user_skills)
43
+
44
+ job_texts = []
45
+ job_titles = []
46
+
47
+ for job in JOBS_DATA:
48
+ skills = clean_skills(job.get("skills", []))
49
+ if skills:
50
+ job_texts.append(" ".join(skills))
51
+ job_titles.append(job.get("job_title"))
52
+
53
+ if not job_texts:
54
+ return "Software Developer", 0.0
55
+
56
+ vectorizer = TfidfVectorizer().fit([user_text] + job_texts)
57
+ user_vector = vectorizer.transform([user_text])
58
+ job_vectors = vectorizer.transform(job_texts)
59
+
60
+ similarities = cosine_similarity(user_vector, job_vectors)[0]
61
+ best_idx = similarities.argmax()
62
+ best_score = similarities[best_idx]
63
+ best_match = job_titles[best_idx]
64
+
65
+ if best_score < 0.1 or not best_match:
66
+ return "Software Developer", best_score
67
+
68
+ return best_match, best_score
69
+
70
+ def get_missing_skills(user_skills, predicted_role):
71
+ user_skills = set(clean_skills(user_skills))
72
+
73
+ for job in JOBS_DATA:
74
+ if job.get("job_title") == predicted_role:
75
+ required_skills = set(clean_skills(job.get("skills", [])))
76
+ missing = required_skills - user_skills
77
+ return list(missing)
78
+
79
+ return []
80
+
81
+ # ------------------------------
82
+ # GitHub / LinkedIn extraction
83
+ # ------------------------------
84
+ GITHUB_REGEX = r"(https?://github\.com/[a-zA-Z0-9_-]+)"
85
+ LINKEDIN_REGEX = r"(https?://(www\.)?linkedin\.com/in/[a-zA-Z0-9_-]+)"
86
+
87
+ def extract_urls(text):
88
+ github_urls = list(dict.fromkeys(re.findall(GITHUB_REGEX, text)))
89
+ linkedin_urls = list(dict.fromkeys(re.findall(LINKEDIN_REGEX, text)))
90
+ return github_urls, linkedin_urls
91
+
92
+ def fetch_github_readme(github_url):
93
+ try:
94
+ parts = github_url.replace("https://github.com/", "").split("/")
95
+ if len(parts) < 2:
96
+ return ""
97
+ user, repo = parts[0], parts[1]
98
+ api_url = f"https://api.github.com/repos/{user}/{repo}/readme"
99
+ response = requests.get(api_url)
100
+ if response.status_code != 200:
101
+ return ""
102
+ data = response.json()
103
+ content = base64.b64decode(data["content"]).decode("utf-8")
104
+ return content
105
+ except Exception as e:
106
+ print("GitHub fetch error:", e)
107
+ return ""
108
+
109
+ # ------------------------------
110
+ # Adzuna API Integration
111
+ # ------------------------------
112
+ def get_jobs_from_adzuna(job_title):
113
+ if not ADZUNA_APP_ID or not ADZUNA_API_KEY:
114
+ return [{
115
+ "title": "API Not Configured",
116
+ "company": "Check HuggingFace Secrets",
117
+ "location": "-",
118
+ "link": "#"
119
+ }]
120
+
121
+ url = f"https://api.adzuna.com/v1/api/jobs/{COUNTRY}/search/1"
122
+ params = {
123
+ "app_id": ADZUNA_APP_ID,
124
+ "app_key": ADZUNA_API_KEY,
125
+ "results_per_page": RESULTS_LIMIT,
126
+ "what": job_title
127
+ }
128
+
129
+ try:
130
+ response = requests.get(url, params=params)
131
+ if response.status_code != 200:
132
+ return [{"title": f"HTTP Error {response.status_code}", "company": "-", "location": "-", "link": "#"}]
133
+
134
+ data = response.json()
135
+ results = data.get("results", [])
136
+ jobs = []
137
+ for job in results:
138
+ jobs.append({
139
+ "title": job.get("title", "N/A"),
140
+ "company": job.get("company", {}).get("display_name", "N/A"),
141
+ "location": job.get("location", {}).get("display_name", "N/A"),
142
+ "link": job.get("redirect_url", "#")
143
+ })
144
+ if not jobs:
145
+ jobs.append({"title": "No jobs found", "company": "-", "location": "-", "link": "#"})
146
+ return jobs
147
+ except Exception as e:
148
+ return [{"title": "Exception occurred", "company": str(e), "location": "-", "link": "#"}]
149
+
150
+ # ------------------------------
151
+ # Resume processing
152
+ # ------------------------------
153
+ def process_resume(file_path):
154
+ try:
155
+ text = extract_text(file_path)
156
+ if not text.strip():
157
+ return {"error": "No text found."}
158
+
159
+ # Extract URLs
160
+ github_urls, linkedin_urls = extract_urls(text)
161
+
162
+ # Extract skills from resume
163
+ resume_skills = clean_skills(skill_extractor.extract_skills(text))
164
+
165
+ # Fetch README text from GitHub
166
+ github_text = ""
167
+ for url in github_urls:
168
+ github_text += fetch_github_readme(url) + "\n"
169
+
170
+ github_skills = clean_skills(skill_extractor.extract_skills(github_text)) if github_text else []
171
+
172
+ # Predict roles
173
+ role_resume, score_resume = predict_role_from_skills(resume_skills)
174
+ role_github, score_github = predict_role_from_skills(github_skills)
175
+
176
+ # Missing skills
177
+ missing_skills_resume = get_missing_skills(resume_skills, role_resume)
178
+ missing_skills_github = get_missing_skills(github_skills, role_github)
179
+
180
+ # Jobs suggestions from Adzuna
181
+ jobs = get_jobs_from_adzuna(role_resume)
182
+
183
+ return {
184
+ "resume_skills": resume_skills,
185
+ "github_skills": github_skills,
186
+ "predicted_role_resume": role_resume,
187
+ "predicted_role_github": role_github,
188
+ "similarity_score_resume": round(float(score_resume) * 100, 2),
189
+ "similarity_score_github": round(float(score_github) * 100, 2),
190
+ "missing_skills_resume": missing_skills_resume,
191
+ "missing_skills_github": missing_skills_github,
192
+ "github_urls": github_urls,
193
+ "linkedin_urls": linkedin_urls,
194
+ "jobs": jobs
195
+ }
196
+ except Exception as e:
197
+ return {"error": str(e)}
198
+
199
+ # ------------------------------
200
+ # FastAPI App
201
+ # ------------------------------
202
+ app = FastAPI()
203
+
204
+ app.add_middleware(
205
+ CORSMiddleware,
206
+ allow_origins=["*"],
207
+ allow_credentials=True,
208
+ allow_methods=["*"],
209
+ allow_headers=["*"],
210
+ )
211
+
212
+ @app.post("/analyze")
213
+ async def analyze(file: UploadFile = File(None), role: str = Form(None)):
214
+ if file:
215
+ tmp = tempfile.NamedTemporaryFile(delete=False)
216
+ tmp.write(await file.read())
217
+ tmp.close()
218
+ result = process_resume(tmp.name)
219
+ os.remove(tmp.name)
220
+ elif role:
221
+ jobs = get_jobs_from_adzuna(role)
222
+ result = {
223
+ "resume_skills": [],
224
+ "github_skills": [],
225
+ "predicted_role_resume": role,
226
+ "predicted_role_github": role,
227
+ "similarity_score_resume": 0.0,
228
+ "similarity_score_github": 0.0,
229
+ "missing_skills_resume": [],
230
+ "missing_skills_github": [],
231
+ "github_urls": [],
232
+ "linkedin_urls": [],
233
+ "jobs": jobs
234
+ }
235
+ else:
236
+ result = {"error": "No file or role provided."}
237
+
238
+ return result
239
+
240
+ # ------------------------------
241
+ # Run App
242
+ # ------------------------------
243
+ if __name__ == "__main__":
244
+ uvicorn.run(app, host="0.0.0.0", port=7860)
domains%2Cprojects.xlsx ADDED
Binary file (11.5 kB). View file
 
jobs_dataset.json ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "job_title": "Backend Developer",
4
+ "skills": ["python", "django", "flask", "fastapi", "node.js", "sql", "postgresql", "mongodb", "rest api", "git"]
5
+ },
6
+ {
7
+ "job_title": "Frontend Developer",
8
+ "skills": ["html", "css", "javascript", "react", "vue", "angular", "typescript", "redux", "tailwind", "ui"]
9
+ },
10
+ {
11
+ "job_title": "Full Stack Developer",
12
+ "skills": ["python", "django", "react", "node.js", "mongodb", "sql", "rest api", "javascript", "html", "css"]
13
+ },
14
+ {
15
+ "job_title": "Data Scientist",
16
+ "skills": ["python", "machine learning", "pandas", "numpy", "scikit-learn", "tensorflow", "data analysis", "statistics", "deep learning"]
17
+ },
18
+ {
19
+ "job_title": "Data Analyst",
20
+ "skills": ["excel", "sql", "power bi", "tableau", "data visualization", "python", "statistics", "reporting"]
21
+ },
22
+ {
23
+ "job_title": "Machine Learning Engineer",
24
+ "skills": ["python", "tensorflow", "pytorch", "machine learning", "deep learning", "model deployment", "mlops"]
25
+ },
26
+ {
27
+ "job_title": "DevOps Engineer",
28
+ "skills": ["docker", "kubernetes", "aws", "azure", "ci/cd", "jenkins", "linux", "terraform", "git"]
29
+ },
30
+ {
31
+ "job_title": "Cloud Engineer",
32
+ "skills": ["aws", "azure", "gcp", "cloud computing", "docker", "kubernetes", "networking", "linux"]
33
+ },
34
+ {
35
+ "job_title": "Cyber Security Analyst",
36
+ "skills": ["network security", "penetration testing", "ethical hacking", "firewalls", "siem", "risk assessment", "linux"]
37
+ },
38
+ {
39
+ "job_title": "Mobile App Developer",
40
+ "skills": ["flutter", "react native", "android", "ios", "kotlin", "swift", "firebase", "dart"]
41
+ },
42
+ {
43
+ "job_title": "UI/UX Designer",
44
+ "skills": ["figma", "adobe xd", "wireframing", "prototyping", "user research", "ui design", "ux design"]
45
+ },
46
+ {
47
+ "job_title": "QA Engineer",
48
+ "skills": ["manual testing", "automation testing", "selenium", "jira", "test cases", "bug tracking"]
49
+ },
50
+ {
51
+ "job_title": "Blockchain Developer",
52
+ "skills": ["solidity", "ethereum", "web3", "smart contracts", "blockchain", "cryptography"]
53
+ },
54
+ {
55
+ "job_title": "AI Engineer",
56
+ "skills": ["python", "machine learning", "deep learning", "nlp", "tensorflow", "pytorch", "llms"]
57
+ },
58
+ {
59
+ "job_title": "Business Analyst",
60
+ "skills": ["requirement gathering", "documentation", "sql", "stakeholder communication", "data analysis"]
61
+ },
62
+ {
63
+ "job_title": "Software Engineer",
64
+ "skills": ["java", "c++", "python", "oop", "data structures", "algorithms", "git"]
65
+ },
66
+ {
67
+ "job_title": "Embedded Systems Engineer",
68
+ "skills": ["c", "c++", "microcontrollers", "arduino", "raspberry pi", "embedded systems"]
69
+ },
70
+ {
71
+ "job_title": "Game Developer",
72
+ "skills": ["unity", "unreal engine", "c#", "c++", "game design", "3d modeling"]
73
+ },
74
+ {
75
+ "job_title": "Network Engineer",
76
+ "skills": ["networking", "routing", "switching", "cisco", "firewalls", "tcp/ip"]
77
+ },
78
+ {
79
+ "job_title": "Database Administrator",
80
+ "skills": ["mysql", "postgresql", "oracle", "database management", "sql tuning", "backup and recovery"]
81
+ },
82
+ {
83
+ "job_title": "Site Reliability Engineer",
84
+ "skills": ["sre", "monitoring", "prometheus", "grafana", "ci/cd", "incident response"]
85
+ },
86
+ {
87
+ "job_title": "Technical Support Engineer",
88
+ "skills": ["troubleshooting", "customer support", "linux", "windows", "networking", "ticketing"]
89
+ },
90
+ {
91
+ "job_title": "IT Project Manager",
92
+ "skills": ["project planning", "scrum", "agile", "stakeholder communication", "risk management"]
93
+ },
94
+ {
95
+ "job_title": "Scrum Master",
96
+ "skills": ["scrum", "agile coaching", "jira", "team facilitation", "conflict resolution"]
97
+ },
98
+ {
99
+ "job_title": "Solutions Architect",
100
+ "skills": ["system design", "aws", "azure", "gcp", "scalability", "integration"]
101
+ },
102
+ {
103
+ "job_title": "Product Manager",
104
+ "skills": ["roadmap planning", "stakeholder communication", "market research", "agile", "requirements"]
105
+ },
106
+ {
107
+ "job_title": "Security Engineer",
108
+ "skills": ["network security", "encryption", "vulnerability assessment", "siem", "incident response"]
109
+ },
110
+ {
111
+ "job_title": "Penetration Tester",
112
+ "skills": ["ethical hacking", "metasploit", "burp suite", "vulnerability scanning"]
113
+ },
114
+ {
115
+ "job_title": "Cloud Security Specialist",
116
+ "skills": ["cloud security", "aws security", "gcp security", "iam", "compliance"]
117
+ },
118
+ {
119
+ "job_title": "Big Data Engineer",
120
+ "skills": ["hadoop", "spark", "sql", "python", "data pipelines", "etl"]
121
+ },
122
+ {
123
+ "job_title": "Data Architect",
124
+ "skills": ["data modeling", "sql", "etl", "big data", "data governance"]
125
+ },
126
+ {
127
+ "job_title": "Business Intelligence Developer",
128
+ "skills": ["power bi", "tableau", "sql", "data visualization", "etl"]
129
+ },
130
+ {
131
+ "job_title": "DevSecOps Engineer",
132
+ "skills": ["ci/cd", "security automation", "docker", "kubernetes", "aws", "linux"]
133
+ },
134
+ {
135
+ "job_title": "Computer Vision Engineer",
136
+ "skills": ["opencv", "python", "deep learning", "tensorflow", "image processing"]
137
+ },
138
+ {
139
+ "job_title": "NLP Engineer",
140
+ "skills": ["nlp", "python", "transformers", "spacy", "bert", "deep learning"]
141
+ },
142
+ {
143
+ "job_title": "Robotics Engineer",
144
+ "skills": ["robotics", "ros", "c++", "python", "control systems"]
145
+ },
146
+ {
147
+ "job_title": "Augmented Reality Developer",
148
+ "skills": ["arcore", "arkit", "unity", "3d modeling", "c#"]
149
+ },
150
+ {
151
+ "job_title": "Virtual Reality Developer",
152
+ "skills": ["unity", "vr hardware", "c#", "3d graphics"]
153
+ },
154
+ {
155
+ "job_title": "Systems Analyst",
156
+ "skills": ["system requirements", "uml", "business analysis", "testing"]
157
+ },
158
+ {
159
+ "job_title": "IT Consultant",
160
+ "skills": ["business analysis", "solution design", "stakeholder communication"]
161
+ },
162
+ {
163
+ "job_title": "Hardware Engineer",
164
+ "skills": ["electronics", "circuit design", "pcb", "embedded systems"]
165
+ },
166
+ {
167
+ "job_title": "Firmware Engineer",
168
+ "skills": ["c", "c++", "embedded firmware", "rtos", "microcontrollers"]
169
+ },
170
+ {
171
+ "job_title": "Test Automation Engineer",
172
+ "skills": ["selenium", "cypress", "python", "javascript", "automation frameworks"]
173
+ },
174
+ {
175
+ "job_title": "Performance Test Engineer",
176
+ "skills": ["jmeter", "loadrunner", "performance tuning"]
177
+ },
178
+ {
179
+ "job_title": "DevOps Architect",
180
+ "skills": ["ci/cd", "cloud", "docker", "kubernetes", "terraform"]
181
+ },
182
+ {
183
+ "job_title": "Network Security Engineer",
184
+ "skills": ["firewalls", "vpn", "ids/ips", "network monitoring", "linux"]
185
+ },
186
+ {
187
+ "job_title": "SAP Consultant",
188
+ "skills": ["sap fico", "sap mm", "sap abap", "business processes"]
189
+ },
190
+ {
191
+ "job_title": "Oracle Developer",
192
+ "skills": ["oracle", "pl/sql", "sql tuning", "database design"]
193
+ },
194
+ {
195
+ "job_title": "Salesforce Developer",
196
+ "skills": ["salesforce", "apex", "lightning", "soql"]
197
+ },
198
+ {
199
+ "job_title": "Cloud Solutions Engineer",
200
+ "skills": ["aws", "azure", "gcp", "infrastructure design", "automation"]
201
+ },
202
+ {
203
+ "job_title": "Kubernetes Administrator",
204
+ "skills": ["kubernetes", "docker", "helm", "cluster management"]
205
+ },
206
+ {
207
+ "job_title": "Site Reliability Architect",
208
+ "skills": ["sre principles", "monitoring", "auto scaling", "cloud"]
209
+ },
210
+ {
211
+ "job_title": "Mobile UI Designer",
212
+ "skills": ["figma", "adobe xd", "responsive design", "interaction design"]
213
+ },
214
+ {
215
+ "job_title": "Frontend Architect",
216
+ "skills": ["react", "vue", "angular", "performance", "scalability"]
217
+ },
218
+ {
219
+ "job_title": "Web Designer",
220
+ "skills": ["html", "css", "javascript", "ui/ux", "responsive"]
221
+ },
222
+ {
223
+ "job_title": "Product Designer",
224
+ "skills": ["figma", "user research", "prototyping", "interaction design"]
225
+ },
226
+ {
227
+ "job_title": "Technical Writer",
228
+ "skills": ["documentation", "rest api docs", "markdown", "communication"]
229
+ },
230
+ {
231
+ "job_title": "Localization Engineer",
232
+ "skills": ["translation", "internationalization", "tooling"]
233
+ },
234
+ {
235
+ "job_title": "Cloud Network Engineer",
236
+ "skills": ["aws networking", "gcp networking", "vpn", "security"]
237
+ },
238
+ {
239
+ "job_title": "IT Auditor",
240
+ "skills": ["compliance", "risk assessment", "audit reporting"]
241
+ },
242
+ {
243
+ "job_title": "Help Desk Technician",
244
+ "skills": ["support", "troubleshooting", "ticketing", "communication"]
245
+ },
246
+ {
247
+ "job_title": "Security Operations Center Analyst",
248
+ "skills": ["siem", "incident response", "monitoring"]
249
+ },
250
+ {
251
+ "job_title": "AI Research Scientist",
252
+ "skills": ["deep learning", "nlp", "python", "research"]
253
+ },
254
+ {
255
+ "job_title": "Augmented Analytics Specialist",
256
+ "skills": ["ai analytics", "data visualization", "python"]
257
+ }
258
+ ]
requirements.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ gradio
2
+ spacy
3
+ huggingface_hub
4
+ PyMuPDF
5
+ easyocr
6
+ scikit-learn
7
+ fastapi
8
+ uvicorn
9
+ python-multipart
10
+ PyPDF2