Danial7 commited on
Commit
a937656
Β·
verified Β·
1 Parent(s): 2bd0c88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -123
app.py CHANGED
@@ -1,130 +1,78 @@
1
  import streamlit as st
2
- from PyPDF2 import PdfReader
3
- from fpdf import FPDF
4
- import os
5
-
6
  from utils import (
7
- extract_keywords,
8
- identify_field,
9
- is_technical_background,
10
- calculate_cv_score,
11
- suggest_upskilling,
12
- suggest_certifications,
13
- suggest_scholarships,
14
- suggest_education_opportunities,
15
- suggest_visa_opportunities,
16
- get_job_listings
17
  )
18
 
19
- st.set_page_config(page_title="Universal Smart CV Analyzer", layout="wide")
20
- st.title("πŸ“„ Universal Smart CV Analyzer & Career Roadmap")
21
- st.markdown("Upload your CV in PDF format to get a complete personalized analysis and roadmap.")
22
-
23
- # Upload PDF
24
- uploaded_file = st.file_uploader("Upload your CV", type="pdf")
25
-
26
- if uploaded_file:
27
- with st.spinner("Reading and analyzing your CV..."):
28
- pdf = PdfReader(uploaded_file)
29
- text = ""
30
- for page in pdf.pages:
31
- text += page.extract_text() or ""
32
-
33
- # Extract keywords
34
- keywords = extract_keywords(text)
35
- st.subheader("πŸ” Extracted Keywords")
36
- st.write(", ".join(keywords))
37
-
38
- # Identify field
39
- field = identify_field(keywords)
40
- st.subheader("🧠 Predicted Field")
41
- st.write(f"**{field}**")
42
-
43
- # Score the CV
44
- score = calculate_cv_score(text, keywords)
45
- st.subheader("πŸ“Š CV Score")
46
- st.metric(label="Skill Match Score", value=f"{score}/100")
47
-
48
- # Determine technical background
49
- background = is_technical_background(keywords)
50
- st.subheader("πŸ”§ Technical Background")
51
- st.write(f"**{background}**")
52
-
53
- # Suggestions Section
54
- st.subheader("πŸš€ Suggested Upskilling")
55
- upskills = suggest_upskilling(keywords)
56
- st.write(upskills if upskills else "No suggestions found.")
57
 
58
- st.subheader("πŸŽ“ Certifications")
59
- certifications = suggest_certifications(keywords)
60
- st.write(certifications if certifications else "No certifications found.")
61
 
62
- st.subheader("πŸ’Έ Scholarships")
63
- scholarships = suggest_scholarships(keywords)
64
- st.write(scholarships if scholarships else "No scholarships found.")
65
 
66
- st.subheader("🏫 Education Opportunities")
67
- education = suggest_education_opportunities(keywords)
68
- st.write(education if education else "No educational programs found.")
69
-
70
- st.subheader("🌍 Visa Opportunities")
71
- visas = suggest_visa_opportunities(keywords)
72
- st.write(visas if visas else "No visa opportunities found.")
73
-
74
- st.subheader("πŸ’Ό Job Listings")
75
- job_df = get_job_listings(keywords, location="Pakistan")
76
- if not job_df.empty:
77
- st.dataframe(job_df)
78
- else:
79
- st.write("No jobs found.")
80
-
81
- # PDF Report Generator
82
- st.subheader("πŸ“₯ Generate PDF Report")
83
-
84
- class PDF(FPDF):
85
- def chapter_title(self, title):
86
- self.set_font("Arial", "B", 12)
87
- self.set_fill_color(220, 220, 220)
88
- self.cell(0, 10, title, ln=True, fill=True)
89
-
90
- def chapter_body(self, body):
91
- self.set_font("Arial", "", 11)
92
- self.multi_cell(0, 10, body)
93
- self.ln()
94
-
95
- if st.button("Generate & Download Report"):
96
- with st.spinner("Generating PDF report..."):
97
- pdf = PDF()
98
- pdf.add_page()
99
- pdf.set_title("CV Analysis Report")
100
- pdf.chapter_title("πŸ“„ CV Analysis Report")
101
- pdf.chapter_title("Predicted Field:")
102
- pdf.chapter_body(field)
103
- pdf.chapter_title("Skill Match Score:")
104
- pdf.chapter_body(f"{score}/100")
105
- pdf.chapter_title("Technical Background:")
106
- pdf.chapter_body(background)
107
- pdf.chapter_title("Extracted Keywords:")
108
- pdf.chapter_body(", ".join(keywords))
109
- pdf.chapter_title("Suggested Upskilling:")
110
- pdf.chapter_body(", ".join(upskills))
111
- pdf.chapter_title("Certifications:")
112
- pdf.chapter_body(", ".join(certifications))
113
- pdf.chapter_title("Scholarships:")
114
- pdf.chapter_body(", ".join(scholarships))
115
- pdf.chapter_title("Education Opportunities:")
116
- pdf.chapter_body(", ".join(education))
117
- pdf.chapter_title("Visa Opportunities:")
118
- pdf.chapter_body(", ".join(visas))
119
-
120
- output_path = "cv_analysis_report.pdf"
121
- pdf.output(output_path)
122
-
123
- with open(output_path, "rb") as f:
124
- base64_pdf = f.read()
125
- st.download_button(
126
- label="πŸ“„ Download CV Report",
127
- data=base64_pdf,
128
- file_name="cv_analysis_report.pdf",
129
- mime="application/pdf",
130
- )
 
1
  import streamlit as st
 
 
 
 
2
  from utils import (
3
+ get_skills_suggestions,
4
+ get_certification_recommendations,
5
+ get_scholarship_suggestions,
6
+ get_education_opportunities,
7
+ get_visa_pathways,
8
+ get_job_recommendations,
9
+ get_cv_score,
10
+ get_field_classification,
11
+ get_personalized_advice,
 
12
  )
13
 
14
+ st.set_page_config(page_title="Smart CV Analyzer & Career Roadmap", layout="wide")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ st.title("πŸ“„ Universal Smart CV Analyzer & 🌍 Career Roadmap Generator")
17
+ st.markdown("Upload your CV and get a detailed analysis including personalized job suggestions, skill-building advice, education and visa guidance, and a tailored career roadmap.")
 
18
 
19
+ uploaded_file = st.file_uploader("Upload your CV (.txt or .pdf)", type=["txt", "pdf"])
 
 
20
 
21
+ if uploaded_file:
22
+ file_ext = uploaded_file.name.split('.')[-1]
23
+ if file_ext == "txt":
24
+ cv_text = uploaded_file.read().decode("utf-8")
25
+ elif file_ext == "pdf":
26
+ import PyPDF2
27
+ reader = PyPDF2.PdfReader(uploaded_file)
28
+ cv_text = "\n".join(page.extract_text() for page in reader.pages if page.extract_text())
29
+ else:
30
+ st.error("Unsupported file format.")
31
+ st.stop()
32
+
33
+ with st.spinner("Analyzing your CV..."):
34
+ score = get_cv_score(cv_text)
35
+ field = get_field_classification(cv_text)
36
+ skills = get_skills_suggestions(cv_text)
37
+ certs = get_certification_recommendations(cv_text)
38
+ scholarships = get_scholarship_suggestions(cv_text)
39
+ education = get_education_opportunities(cv_text)
40
+ visa = get_visa_pathways(cv_text, country="USA")
41
+ jobs = get_job_recommendations(cv_text, location="USA")
42
+ advice = get_personalized_advice(cv_text)
43
+
44
+ st.header("πŸ“Š CV Summary")
45
+ st.write(f"**Score:** {score}/100")
46
+ st.write(f"**Field/Domain:** {field}")
47
+
48
+ st.header("πŸ’‘ Personalized Career Advice")
49
+ st.success(advice)
50
+
51
+ st.header("🧠 Recommended Skills to Learn")
52
+ for skill in skills:
53
+ st.markdown(f"- {skill}")
54
+
55
+ st.header("πŸŽ“ Recommended Certifications")
56
+ for cert in certs:
57
+ st.markdown(f"- {cert}")
58
+
59
+ st.header("🎯 Scholarship Opportunities")
60
+ for s in scholarships:
61
+ st.markdown(f"- {s}")
62
+
63
+ st.header("🏫 Education Paths")
64
+ for edu in education:
65
+ st.markdown(f"- {edu}")
66
+
67
+ st.header("πŸ›‚ Visa Pathways")
68
+ for v in visa:
69
+ st.markdown(f"- {v}")
70
+
71
+ st.header("πŸ’Ό Job Opportunities (USA)")
72
+ for job in jobs:
73
+ st.subheader(job.get("title", "N/A"))
74
+ st.markdown(f"**Company:** {job.get('company', 'Unknown')}")
75
+ st.markdown(f"**Location:** {job.get('location', 'Unknown')}")
76
+ st.markdown(f"**Description:** {job.get('description', '')[:300]}...")
77
+ st.markdown(f"[Apply Here]({job.get('url', '#')})")
78
+ st.markdown("---")