-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_single.py
More file actions
794 lines (704 loc) Β· 34.3 KB
/
app_single.py
File metadata and controls
794 lines (704 loc) Β· 34.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
"""
SmartResume AI - AI-Powered Resume Builder
Single-file version with all features integrated
"""
import streamlit as st
import os
from dotenv import load_dotenv
import google.generativeai as genai
from fpdf import FPDF
# Load environment variables
load_dotenv()
# Configure Gemini API
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
if GEMINI_API_KEY:
genai.configure(api_key=GEMINI_API_KEY)
# Page configuration
st.set_page_config(
page_title="SmartResume AI - AI-Powered Resume Builder",
page_icon="π",
layout="wide",
initial_sidebar_state="expanded"
)
# Custom CSS
st.markdown("""
<style>
.main-header {
font-size: 2.8rem;
font-weight: 700;
color: #1f77b4;
text-align: center;
margin-bottom: 0.5rem;
}
.sub-header {
font-size: 1.2rem;
color: #666;
text-align: center;
margin-bottom: 2rem;
}
.section-header {
font-size: 1.5rem;
font-weight: 600;
color: #2c3e50;
margin-top: 1.5rem;
margin-bottom: 1rem;
border-bottom: 2px solid #1f77b4;
padding-bottom: 0.5rem;
}
.stButton>button {
background-color: #1f77b4;
color: white;
font-weight: 600;
border-radius: 8px;
border: none;
padding: 0.5rem 2rem;
transition: all 0.3s ease;
}
.stButton>button:hover {
background-color: #155a8a;
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.preview-box {
border: 2px solid #e0e0e0;
border-radius: 10px;
padding: 2rem;
background-color: #ffffff;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
font-family: Arial, sans-serif;
}
.resume-name {
font-size: 2rem;
font-weight: 700;
color: #2c3e50;
text-align: center;
margin-bottom: 0.5rem;
}
.resume-contact {
text-align: center;
color: #666;
font-size: 0.95rem;
margin-bottom: 1.5rem;
}
.resume-section-title {
font-size: 1.2rem;
font-weight: 600;
color: #1f77b4;
border-bottom: 2px solid #1f77b4;
margin-top: 1.5rem;
margin-bottom: 0.8rem;
padding-bottom: 0.3rem;
}
.success-box {
background-color: #d4edda;
border-left: 4px solid #28a745;
padding: 1rem;
border-radius: 4px;
margin: 1rem 0;
}
</style>
""", unsafe_allow_html=True)
# Initialize session state
if 'resume_data' not in st.session_state:
st.session_state.resume_data = {
'personal': {},
'summary': '',
'education': [],
'skills': [],
'experience': [],
'projects': [],
'certifications': []
}
# AI Generation Function
def generate_with_ai(prompt):
"""Generate content using Gemini AI"""
if not GEMINI_API_KEY:
return "β οΈ Please configure your Gemini API key in the .env file"
# Try multiple models in order of preference
models_to_try = ['gemini-2.5-flash', 'gemini-2.0-flash-exp', 'gemini-1.5-flash', 'gemini-pro']
for model_name in models_to_try:
try:
model = genai.GenerativeModel(model_name)
response = model.generate_content(
prompt,
generation_config={
"temperature": 0.7,
"top_p": 0.95,
"max_output_tokens": 1024,
}
)
return response.text.strip()
except Exception as e:
error_str = str(e).lower()
print(f"Tried {model_name}, Error: {str(e)}")
# If it's not a model availability issue, return the error
if "quota" in error_str or "resource_exhausted" in error_str:
return "β οΈ API rate limit reached. Please wait a minute and try again."
elif "api" in error_str and "key" in error_str:
return f"β οΈ API Key Error: {str(e)}"
# Otherwise, try the next model
continue
return "β οΈ All models failed. Please check your API key and internet connection."
# PDF Generation
def generate_pdf(data):
"""Generate ATS-friendly resume PDF"""
pdf = FPDF()
pdf.add_page()
pdf.set_auto_page_break(auto=True, margin=15)
# Name (Large and Bold)
pdf.set_font("Arial", "B", 20)
pdf.set_text_color(31, 119, 180)
pdf.cell(0, 10, data['personal'].get('name', 'Your Name').upper(), ln=True, align='C')
# Contact Info
pdf.set_font("Arial", size=10)
pdf.set_text_color(0, 0, 0)
contact_parts = [
data['personal'].get('email', ''),
data['personal'].get('phone', ''),
data['personal'].get('location', '')
]
if data['personal'].get('linkedin'):
contact_parts.insert(2, 'LinkedIn')
if data['personal'].get('portfolio'):
contact_parts.insert(-1, 'Portfolio')
contact = " | ".join([p for p in contact_parts if p])
pdf.cell(0, 5, contact, ln=True, align='C')
pdf.ln(5)
# Professional Summary
if data.get('summary'):
pdf.set_font("Arial", "B", 12)
pdf.set_text_color(31, 119, 180)
pdf.cell(0, 6, "PROFESSIONAL SUMMARY", ln=True)
pdf.set_draw_color(31, 119, 180)
pdf.line(10, pdf.get_y(), 200, pdf.get_y())
pdf.ln(3)
pdf.set_font("Arial", size=11)
pdf.set_text_color(0, 0, 0)
pdf.multi_cell(0, 5, data['summary'])
pdf.ln(3)
# Education
if data.get('education'):
pdf.set_font("Arial", "B", 12)
pdf.set_text_color(31, 119, 180)
pdf.cell(0, 6, "EDUCATION", ln=True)
pdf.line(10, pdf.get_y(), 200, pdf.get_y())
pdf.ln(3)
pdf.set_text_color(0, 0, 0)
for edu in data['education']:
pdf.set_font("Arial", "B", 11)
pdf.cell(0, 6, f"{edu.get('degree', '')} - {edu.get('field', '')}", ln=True)
pdf.set_font("Arial", "I", 10)
pdf.set_text_color(100, 100, 100)
pdf.cell(0, 5, f"{edu.get('institution', '')} | {edu.get('year', '')} | CGPA: {edu.get('cgpa', '')}", ln=True)
pdf.set_text_color(0, 0, 0)
pdf.ln(2)
pdf.ln(2)
# Skills
if data.get('skills'):
pdf.set_font("Arial", "B", 12)
pdf.set_text_color(31, 119, 180)
pdf.cell(0, 6, "SKILLS", ln=True)
pdf.line(10, pdf.get_y(), 200, pdf.get_y())
pdf.ln(3)
pdf.set_font("Arial", size=11)
pdf.set_text_color(0, 0, 0)
skills_text = " - ".join(data['skills'])
pdf.multi_cell(0, 5, skills_text)
pdf.ln(3)
# Work Experience
if data.get('experience'):
pdf.set_font("Arial", "B", 12)
pdf.set_text_color(31, 119, 180)
pdf.cell(0, 6, "WORK EXPERIENCE", ln=True)
pdf.line(10, pdf.get_y(), 200, pdf.get_y())
pdf.ln(3)
pdf.set_text_color(0, 0, 0)
for exp in data['experience']:
pdf.set_font("Arial", "B", 11)
pdf.cell(0, 6, f"{exp.get('title', '')} | {exp.get('company', '')}", ln=True)
pdf.set_font("Arial", "I", 10)
pdf.set_text_color(100, 100, 100)
pdf.cell(0, 5, f"{exp.get('duration', '')} | {exp.get('location', '')}", ln=True)
pdf.set_text_color(0, 0, 0)
pdf.set_font("Arial", size=11)
if exp.get('responsibilities'):
for line in exp['responsibilities'].split('\n'):
line = line.strip()
if line:
# Add bullet point
pdf.cell(10, 5, "-") # Dash instead of bullet
pdf.multi_cell(0, 5, line)
pdf.ln(2)
pdf.ln(2)
# Projects
if data.get('projects'):
pdf.set_font("Arial", "B", 12)
pdf.set_text_color(31, 119, 180)
pdf.cell(0, 6, "PROJECTS", ln=True)
pdf.line(10, pdf.get_y(), 200, pdf.get_y())
pdf.ln(3)
pdf.set_text_color(0, 0, 0)
for proj in data['projects']:
pdf.set_font("Arial", "B", 11)
pdf.cell(0, 6, f"{proj.get('title', '')} | {proj.get('duration', '')}", ln=True)
pdf.set_font("Arial", "I", 10)
pdf.set_text_color(100, 100, 100)
pdf.cell(0, 5, f"Technologies: {proj.get('technologies', '')}", ln=True)
pdf.set_text_color(0, 0, 0)
pdf.set_font("Arial", size=11)
if proj.get('description'):
pdf.multi_cell(0, 5, proj['description'])
pdf.ln(2)
pdf.ln(2)
# Certifications
if data.get('certifications'):
pdf.set_font("Arial", "B", 12)
pdf.set_text_color(31, 119, 180)
pdf.cell(0, 6, "CERTIFICATIONS & ACHIEVEMENTS", ln=True)
pdf.line(10, pdf.get_y(), 200, pdf.get_y())
pdf.ln(3)
pdf.set_text_color(0, 0, 0)
pdf.set_font("Arial", size=11)
for cert in data['certifications']:
pdf.cell(10, 5, "-") # Dash instead of bullet
pdf.multi_cell(0, 5, cert)
return pdf.output(dest='S').encode('latin-1')
# Main Application
def main():
# Header
st.markdown('<div class="main-header">π― SmartResume AI</div>', unsafe_allow_html=True)
st.markdown('<div class="sub-header">Build Your Professional Resume with AI in Minutes</div>', unsafe_allow_html=True)
# Sidebar
with st.sidebar:
st.image("https://img.icons8.com/fluency/96/000000/resume.png", width=80)
st.title("π Navigation")
st.markdown("---")
st.markdown("### β¨ Features")
st.markdown("""
- π€ AI-Powered Content
- π ATS-Friendly Format
- β‘ Instant PDF Download
- π¨ Professional Design
- π Real-Time Preview
""")
st.markdown("---")
st.markdown("### π‘ Quick Tips")
st.markdown("""
1. Fill in your details
2. Use AI enhancement
3. Review the preview
4. Download PDF
""")
st.markdown("---")
if not GEMINI_API_KEY:
st.warning("β οΈ AI features disabled. Configure .env file with your Gemini API key.")
else:
st.success("β
AI features enabled!")
# Two-column layout
col1, col2 = st.columns([1, 1])
with col1:
st.markdown('<div class="section-header">π Resume Information</div>', unsafe_allow_html=True)
# Personal Information
with st.expander("π€ Personal Information", expanded=True):
name = st.text_input("Full Name *",
value=st.session_state.resume_data['personal'].get('name', ''),
placeholder="John Doe")
email = st.text_input("Email *",
value=st.session_state.resume_data['personal'].get('email', ''),
placeholder="john.doe@email.com")
phone = st.text_input("Phone Number *",
value=st.session_state.resume_data['personal'].get('phone', ''),
placeholder="+91-9876543210")
linkedin = st.text_input("LinkedIn URL",
value=st.session_state.resume_data['personal'].get('linkedin', ''),
placeholder="https://linkedin.com/in/johndoe")
portfolio = st.text_input("Portfolio/Website",
value=st.session_state.resume_data['personal'].get('portfolio', ''),
placeholder="https://yourportfolio.com")
location = st.text_input("Location *",
value=st.session_state.resume_data['personal'].get('location', ''),
placeholder="Bangalore, India")
st.session_state.resume_data['personal'] = {
'name': name, 'email': email, 'phone': phone,
'linkedin': linkedin, 'portfolio': portfolio, 'location': location
}
# Professional Summary
with st.expander("πΌ Professional Summary", expanded=True):
target_role = st.text_input("Target Job Role",
placeholder="e.g., Software Engineer, Data Analyst")
experience_years = st.number_input("Years of Experience",
min_value=0, max_value=50, value=0)
key_skills_input = st.text_input("Key Skills (comma-separated)",
placeholder="Python, JavaScript, React, SQL")
col_ai1, col_ai2 = st.columns([1, 1])
with col_ai1:
if st.button("π€ Generate AI Summary", use_container_width=True):
if target_role:
with st.spinner("π Generating professional summary..."):
prompt = f"""Generate a compelling professional summary for a resume:
- Name: {name}
- Target Role: {target_role}
- Experience: {experience_years} years
- Key Skills: {key_skills_input}
Requirements:
1. Write 3-4 lines (50-70 words)
2. Professional and confident tone
3. Include relevant keywords for ATS
4. Focus on value and expertise
5. Do not use first-person pronouns
Generate only the summary text:"""
summary = generate_with_ai(prompt)
if not summary.startswith("β οΈ"):
st.session_state.resume_data['summary'] = summary
st.success("β
Summary generated!")
st.rerun()
else:
st.error(summary)
else:
st.warning("β οΈ Please enter a target job role first")
summary_text = st.text_area("Professional Summary",
value=st.session_state.resume_data.get('summary', ''),
height=120,
placeholder="Enter your professional summary or use AI to generate...")
st.session_state.resume_data['summary'] = summary_text
# Education
with st.expander("π Education"):
st.write("**Add Education Entry:**")
degree = st.selectbox("Degree/Qualification",
["B.Tech", "M.Tech", "BCA", "MCA", "B.Sc", "M.Sc",
"MBA", "BBA", "B.Com", "M.Com", "BA", "MA", "PhD", "Other"],
key="edu_degree")
field = st.text_input("Field of Study",
placeholder="Computer Science",
key="edu_field")
institution = st.text_input("Institution Name",
placeholder="ABC University",
key="edu_inst")
year = st.text_input("Graduation Year",
placeholder="2024",
key="edu_year")
cgpa = st.text_input("CGPA/Percentage",
placeholder="8.5/10.0 or 85%",
key="edu_cgpa")
if st.button("β Add Education", use_container_width=True):
if degree and field and institution:
st.session_state.resume_data['education'].append({
'degree': degree, 'field': field, 'institution': institution,
'year': year, 'cgpa': cgpa
})
st.success("β
Education added!")
st.rerun()
else:
st.error("β οΈ Please fill in degree, field, and institution")
# Display added education
if st.session_state.resume_data['education']:
st.write("**Added Education:**")
for idx, edu in enumerate(st.session_state.resume_data['education']):
col_e1, col_e2 = st.columns([4, 1])
with col_e1:
st.write(f"β’ {edu['degree']} in {edu['field']} - {edu['institution']}")
with col_e2:
if st.button("ποΈ", key=f"del_edu_{idx}"):
st.session_state.resume_data['education'].pop(idx)
st.rerun()
# Skills
with st.expander("π‘ Skills"):
new_skill = st.text_input("Add a skill",
placeholder="Python, JavaScript, React...",
key="new_skill")
col_s1, col_s2 = st.columns([1, 1])
with col_s1:
if st.button("β Add Skill", use_container_width=True):
if new_skill:
skills = [s.strip() for s in new_skill.split(',')]
for skill in skills:
if skill and skill not in st.session_state.resume_data['skills']:
st.session_state.resume_data['skills'].append(skill)
st.success(f"β
Added {len(skills)} skill(s)!")
st.rerun()
with col_s2:
if st.button("π€ Suggest Skills", use_container_width=True):
if target_role:
with st.spinner("π Suggesting relevant skills..."):
current_skills = ", ".join(st.session_state.resume_data['skills'])
prompt = f"""Suggest 5-8 relevant skills for a {target_role} position.
Current skills: {current_skills}
Suggest additional technical and professional skills that would be valuable.
Return only skill names, comma-separated, no explanations:"""
suggestions = generate_with_ai(prompt)
if not suggestions.startswith("β οΈ"):
st.info(f"π‘ Suggested: {suggestions}")
else:
st.error(suggestions)
else:
st.warning("β οΈ Please enter a target job role first")
# Display skills
if st.session_state.resume_data['skills']:
st.write("**Current Skills:**")
st.write(", ".join(st.session_state.resume_data['skills']))
if st.button("ποΈ Clear All Skills"):
st.session_state.resume_data['skills'] = []
st.rerun()
# Work Experience
with st.expander("πΌ Work Experience"):
st.write("**Add Work Experience:**")
exp_title = st.text_input("Job Title",
placeholder="Software Engineer",
key="exp_title")
exp_company = st.text_input("Company Name",
placeholder="ABC Technologies",
key="exp_company")
exp_duration = st.text_input("Duration",
placeholder="Jan 2022 - Present",
key="exp_duration")
exp_location = st.text_input("Location",
placeholder="Bangalore, India",
key="exp_location")
exp_resp = st.text_area("Responsibilities (basic description)",
height=100,
placeholder="Describe your key responsibilities and achievements...",
key="exp_resp")
col_exp1, col_exp2 = st.columns([1, 1])
with col_exp1:
if st.button("π€ Generate Bullet Points", use_container_width=True):
if exp_title and exp_resp:
with st.spinner("π Generating professional bullet points..."):
prompt = f"""Transform these job responsibilities into 3-5 professional bullet points:
Job Title: {exp_title}
Company: {exp_company}
Responsibilities: {exp_resp}
Requirements:
1. Start with strong action verbs (Led, Developed, Implemented, etc.)
2. Include quantifiable metrics where possible
3. Show impact and results
4. Use past tense
5. Make each point concise and impactful
Generate bullet points (one per line, starting with β’):"""
bullets = generate_with_ai(prompt)
if not bullets.startswith("β οΈ"):
st.session_state.exp_bullets = bullets
st.success("β
Bullet points generated! Review below.")
st.rerun()
else:
st.error(bullets)
else:
st.warning("β οΈ Please enter job title and responsibilities first")
# Show generated bullets if available
if hasattr(st.session_state, 'exp_bullets'):
exp_resp_enhanced = st.text_area("Enhanced Responsibilities (Edit if needed)",
value=st.session_state.exp_bullets,
height=150,
key="exp_resp_edit")
else:
exp_resp_enhanced = exp_resp
with col_exp2:
if st.button("β Add Experience", use_container_width=True):
if exp_title and exp_company:
st.session_state.resume_data['experience'].append({
'title': exp_title,
'company': exp_company,
'duration': exp_duration,
'location': exp_location,
'responsibilities': exp_resp_enhanced
})
# Clear generated bullets
if hasattr(st.session_state, 'exp_bullets'):
delattr(st.session_state, 'exp_bullets')
st.success("β
Experience added!")
st.rerun()
else:
st.error("β οΈ Please fill in job title and company")
# Display added experiences
if st.session_state.resume_data['experience']:
st.write("**Added Experiences:**")
for idx, exp in enumerate(st.session_state.resume_data['experience']):
col_ex1, col_ex2 = st.columns([4, 1])
with col_ex1:
st.write(f"β’ {exp['title']} at {exp['company']}")
with col_ex2:
if st.button("ποΈ", key=f"del_exp_{idx}"):
st.session_state.resume_data['experience'].pop(idx)
st.rerun()
# Projects
with st.expander("π Projects"):
st.write("**Add Project:**")
proj_title = st.text_input("Project Title",
placeholder="AI Chatbot Application",
key="proj_title")
proj_duration = st.text_input("Duration",
placeholder="Jan 2023 - Mar 2023",
key="proj_duration")
proj_tech = st.text_input("Technologies Used",
placeholder="Python, TensorFlow, React",
key="proj_tech")
proj_desc = st.text_area("Description",
height=100,
placeholder="Describe what the project does and your role...",
key="proj_desc")
col_p1, col_p2 = st.columns([1, 1])
with col_p1:
if st.button("π€ Enhance Description", use_container_width=True):
if proj_title and proj_desc:
with st.spinner("π Enhancing project description..."):
prompt = f"""Enhance this project description for a resume:
Title: {proj_title}
Technologies: {proj_tech}
Description: {proj_desc}
Create a professional 2-3 line description (40-60 words) that:
1. Clearly explains the project purpose
2. Highlights technical complexity
3. Mentions key technologies
4. Shows impact or results
Generate only the enhanced description:"""
enhanced = generate_with_ai(prompt)
if not enhanced.startswith("β οΈ"):
st.session_state.proj_enhanced = enhanced
st.success("β
Description enhanced! Review below.")
st.rerun()
else:
st.error(enhanced)
else:
st.warning("β οΈ Please enter project title and description first")
# Show enhanced description if available
if hasattr(st.session_state, 'proj_enhanced'):
proj_desc_final = st.text_area("Enhanced Description (Edit if needed)",
value=st.session_state.proj_enhanced,
height=100,
key="proj_desc_edit")
else:
proj_desc_final = proj_desc
with col_p2:
if st.button("β Add Project", use_container_width=True):
if proj_title:
st.session_state.resume_data['projects'].append({
'title': proj_title,
'duration': proj_duration,
'technologies': proj_tech,
'description': proj_desc_final
})
# Clear enhanced description
if hasattr(st.session_state, 'proj_enhanced'):
delattr(st.session_state, 'proj_enhanced')
st.success("β
Project added!")
st.rerun()
else:
st.error("β οΈ Please enter project title")
# Display added projects
if st.session_state.resume_data['projects']:
st.write("**Added Projects:**")
for idx, proj in enumerate(st.session_state.resume_data['projects']):
col_pr1, col_pr2 = st.columns([4, 1])
with col_pr1:
st.write(f"β’ {proj['title']}")
with col_pr2:
if st.button("ποΈ", key=f"del_proj_{idx}"):
st.session_state.resume_data['projects'].pop(idx)
st.rerun()
# Certifications
with st.expander("π Certifications & Achievements"):
cert = st.text_input("Add certification or achievement",
placeholder="AWS Certified Solutions Architect (2023)",
key="new_cert")
if st.button("β Add Certification", use_container_width=True):
if cert:
st.session_state.resume_data['certifications'].append(cert)
st.success("β
Certification added!")
st.rerun()
# Display certifications
if st.session_state.resume_data['certifications']:
st.write("**Added Certifications:**")
for idx, c in enumerate(st.session_state.resume_data['certifications']):
col_c1, col_c2 = st.columns([4, 1])
with col_c1:
st.write(f"β’ {c}")
with col_c2:
if st.button("ποΈ", key=f"del_cert_{idx}"):
st.session_state.resume_data['certifications'].pop(idx)
st.rerun()
# Preview Column
with col2:
st.markdown('<div class="section-header">ποΈ Live Preview</div>', unsafe_allow_html=True)
data = st.session_state.resume_data
# Resume Preview
st.markdown('<div class="preview-box">', unsafe_allow_html=True)
# Name and Contact
st.markdown(f'<div class="resume-name">{data["personal"].get("name", "Your Name")}</div>',
unsafe_allow_html=True)
contact_parts = [
data["personal"].get("email", ""),
data["personal"].get("phone", ""),
data["personal"].get("location", "")
]
if data["personal"].get("linkedin"):
contact_parts.insert(2, 'LinkedIn')
if data["personal"].get("portfolio"):
contact_parts.insert(-1, 'Portfolio')
contact_text = " | ".join([p for p in contact_parts if p])
st.markdown(f'<div class="resume-contact">{contact_text}</div>', unsafe_allow_html=True)
# Professional Summary
if data.get('summary'):
st.markdown('<div class="resume-section-title">PROFESSIONAL SUMMARY</div>',
unsafe_allow_html=True)
st.write(data['summary'])
# Education
if data.get('education'):
st.markdown('<div class="resume-section-title">EDUCATION</div>', unsafe_allow_html=True)
for edu in data['education']:
st.markdown(f"**{edu.get('degree', '')} - {edu.get('field', '')}**")
st.write(f"*{edu.get('institution', '')} | {edu.get('year', '')} | CGPA: {edu.get('cgpa', '')}*")
st.write("")
# Skills
if data.get('skills'):
st.markdown('<div class="resume-section-title">SKILLS</div>', unsafe_allow_html=True)
st.write(" β’ ".join(data['skills']))
# Work Experience
if data.get('experience'):
st.markdown('<div class="resume-section-title">WORK EXPERIENCE</div>', unsafe_allow_html=True)
for exp in data['experience']:
st.markdown(f"**{exp.get('title', '')} | {exp.get('company', '')}**")
st.write(f"*{exp.get('duration', '')} | {exp.get('location', '')}*")
if exp.get('responsibilities'):
for line in exp['responsibilities'].split('\n'):
line = line.strip()
if line and not line.startswith('β’'):
st.write(f"β’ {line}")
elif line:
st.write(line)
st.write("")
# Projects
if data.get('projects'):
st.markdown('<div class="resume-section-title">PROJECTS</div>', unsafe_allow_html=True)
for proj in data['projects']:
st.markdown(f"**{proj.get('title', '')} | {proj.get('duration', '')}**")
st.write(f"*Technologies: {proj.get('technologies', '')}*")
st.write(proj.get('description', ''))
st.write("")
# Certifications
if data.get('certifications'):
st.markdown('<div class="resume-section-title">CERTIFICATIONS & ACHIEVEMENTS</div>',
unsafe_allow_html=True)
for cert in data['certifications']:
st.write(f"β’ {cert}")
st.markdown('</div>', unsafe_allow_html=True)
# Download Button
st.markdown("---")
if st.button("π₯ Download PDF Resume", use_container_width=True, type="primary"):
if not data['personal'].get('name') or not data['personal'].get('email'):
st.error("β οΈ Please fill in at least Name and Email to generate PDF")
else:
try:
with st.spinner("π Generating your professional resume..."):
pdf_bytes = generate_pdf(data)
filename = f"{data['personal'].get('name', 'Resume').replace(' ', '_')}_Resume.pdf"
st.download_button(
label="πΎ Click Here to Download PDF",
data=pdf_bytes,
file_name=filename,
mime="application/pdf",
use_container_width=True
)
st.markdown('<div class="success-box">β
<strong>Resume generated successfully!</strong> Click the button above to download.</div>',
unsafe_allow_html=True)
except Exception as e:
st.error(f"β οΈ Error generating PDF: {str(e)}")
if __name__ == "__main__":
main()