-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapp.py
1564 lines (1355 loc) · 64.8 KB
/
app.py
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
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
Smart Resume AI - Main Application
"""
import streamlit as st
# Set page config at the very beginning
st.set_page_config(
page_title="Smart Resume AI",
page_icon="🚀",
layout="wide"
)
import json
import pandas as pd
import plotly.express as px
import traceback
from utils.resume_analyzer import ResumeAnalyzer
from utils.resume_builder import ResumeBuilder
from config.database import (
get_database_connection, save_resume_data, save_analysis_data,
init_database, verify_admin, log_admin_action
)
from config.job_roles import JOB_ROLES
from config.courses import COURSES_BY_CATEGORY, RESUME_VIDEOS, INTERVIEW_VIDEOS, get_courses_for_role, get_category_for_role
from dashboard.dashboard import DashboardManager
import requests
from streamlit_lottie import st_lottie
import plotly.graph_objects as go
import base64
import io
from docx import Document
from docx.shared import Inches, Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
from feedback.feedback import FeedbackManager
from ui_components import (
apply_modern_styles, hero_section, feature_card, about_section,
page_header, render_analytics_section, render_activity_section,
render_suggestions_section
)
from datetime import datetime
from jobs.job_search import render_job_search
from PIL import Image
class ResumeApp:
def __init__(self):
"""Initialize the application"""
if 'form_data' not in st.session_state:
st.session_state.form_data = {
'personal_info': {
'full_name': '',
'email': '',
'phone': '',
'location': '',
'linkedin': '',
'portfolio': ''
},
'summary': '',
'experiences': [],
'education': [],
'projects': [],
'skills_categories': {
'technical': [],
'soft': [],
'languages': [],
'tools': []
}
}
# Initialize navigation state
if 'page' not in st.session_state:
st.session_state.page = 'home'
# Initialize admin state
if 'is_admin' not in st.session_state:
st.session_state.is_admin = False
self.pages = {
"🏠 HOME": self.render_home,
"🔍 RESUME ANALYZER": self.render_analyzer,
"📝 RESUME BUILDER": self.render_builder,
"📊 DASHBOARD": self.render_dashboard,
"🎯 JOB SEARCH": self.render_job_search,
"💬 FEEDBACK": self.render_feedback_page,
"ℹ️ ABOUT": self.render_about
}
# Initialize dashboard manager
self.dashboard_manager = DashboardManager()
self.analyzer = ResumeAnalyzer()
self.builder = ResumeBuilder()
self.job_roles = JOB_ROLES
# Initialize session state
if 'user_id' not in st.session_state:
st.session_state.user_id = 'default_user'
if 'selected_role' not in st.session_state:
st.session_state.selected_role = None
# Initialize database
init_database()
# Load external CSS
with open('style/style.css') as f:
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
# Load Google Fonts
st.markdown("""
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Poppins:wght@400;500;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
""", unsafe_allow_html=True)
def load_lottie_url(self, url: str):
"""Load Lottie animation from URL"""
r = requests.get(url)
if r.status_code != 200:
return None
return r.json()
def apply_global_styles(self):
st.markdown("""
<style>
/* Custom Scrollbar */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: #1a1a1a;
border-radius: 4px;
}
::-webkit-scrollbar-thumb {
background: #4CAF50;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #45a049;
}
/* Global Styles */
.main-header {
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
padding: 2rem;
border-radius: 15px;
margin-bottom: 2rem;
box-shadow: 0 10px 20px rgba(0,0,0,0.2);
text-align: center;
position: relative;
overflow: hidden;
}
.main-header::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(45deg, transparent 0%, rgba(255,255,255,0.1) 100%);
z-index: 1;
}
.main-header h1 {
color: white;
font-size: 2.5rem;
font-weight: 600;
margin: 0;
position: relative;
z-index: 2;
}
/* Template Card Styles */
.template-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
gap: 2rem;
padding: 1rem;
}
.template-card {
background: rgba(45, 45, 45, 0.9);
border-radius: 20px;
padding: 2rem;
position: relative;
overflow: hidden;
backdrop-filter: blur(10px);
border: 1px solid rgba(255,255,255,0.1);
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.template-card:hover {
transform: translateY(-10px);
box-shadow: 0 20px 40px rgba(0,0,0,0.3);
border-color: #4CAF50;
}
.template-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(45deg, transparent 0%, rgba(76,175,80,0.1) 100%);
z-index: 1;
}
.template-icon {
font-size: 3rem;
color: #4CAF50;
margin-bottom: 1.5rem;
position: relative;
z-index: 2;
}
.template-title {
font-size: 1.8rem;
font-weight: 600;
color: white;
margin-bottom: 1rem;
position: relative;
z-index: 2;
}
.template-description {
color: #aaa;
margin-bottom: 1.5rem;
position: relative;
z-index: 2;
line-height: 1.6;
}
/* Feature List Styles */
.feature-list {
list-style: none;
padding: 0;
margin: 1.5rem 0;
position: relative;
z-index: 2;
}
.feature-item {
display: flex;
align-items: center;
margin-bottom: 1rem;
color: #ddd;
font-size: 0.95rem;
}
.feature-icon {
color: #4CAF50;
margin-right: 0.8rem;
font-size: 1.1rem;
}
/* Button Styles */
.action-button {
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
color: white;
padding: 1rem 2rem;
border-radius: 50px;
border: none;
font-weight: 500;
cursor: pointer;
width: 100%;
text-align: center;
position: relative;
overflow: hidden;
z-index: 2;
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.action-button:hover {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(76,175,80,0.3);
}
.action-button::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
transition: all 0.6s ease;
}
.action-button:hover::before {
left: 100%;
}
/* Form Section Styles */
.form-section {
background: rgba(45, 45, 45, 0.9);
border-radius: 20px;
padding: 2rem;
margin: 2rem 0;
backdrop-filter: blur(10px);
border: 1px solid rgba(255,255,255,0.1);
}
.form-section-title {
font-size: 1.8rem;
font-weight: 600;
color: white;
margin-bottom: 1.5rem;
padding-bottom: 0.8rem;
border-bottom: 2px solid #4CAF50;
}
.form-group {
margin-bottom: 1.5rem;
}
.form-label {
color: #ddd;
font-weight: 500;
margin-bottom: 0.8rem;
display: block;
}
.form-input {
width: 100%;
padding: 1rem;
border-radius: 10px;
border: 1px solid rgba(255,255,255,0.1);
background: rgba(30, 30, 30, 0.9);
color: white;
transition: all 0.3s ease;
}
.form-input:focus {
border-color: #4CAF50;
box-shadow: 0 0 0 2px rgba(76,175,80,0.2);
outline: none;
}
/* Skill Tags */
.skill-tag-container {
display: flex;
flex-wrap: wrap;
gap: 0.8rem;
margin-top: 1rem;
}
.skill-tag {
background: rgba(76,175,80,0.1);
color: #4CAF50;
padding: 0.6rem 1.2rem;
border-radius: 50px;
border: 1px solid #4CAF50;
font-size: 0.9rem;
transition: all 0.3s ease;
cursor: pointer;
}
.skill-tag:hover {
background: #4CAF50;
color: white;
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(76,175,80,0.2);
}
/* Progress Circle */
.progress-container {
position: relative;
width: 150px;
height: 150px;
margin: 2rem auto;
}
.progress-circle {
transform: rotate(-90deg);
width: 100%;
height: 100%;
}
.progress-circle circle {
fill: none;
stroke-width: 8;
stroke-linecap: round;
stroke: #4CAF50;
transform-origin: 50% 50%;
transition: all 0.3s ease;
}
.progress-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 1.5rem;
font-weight: 600;
color: white;
}
/* Animations */
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.animate-slide-in {
animation: slideIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
/* Responsive Design */
@media (max-width: 768px) {
.template-container {
grid-template-columns: 1fr;
}
.main-header {
padding: 1.5rem;
}
.main-header h1 {
font-size: 2rem;
}
.template-card {
padding: 1.5rem;
}
.action-button {
padding: 0.8rem 1.6rem;
}
}
</style>
""", unsafe_allow_html=True)
def load_image(self, image_name):
"""Load image from static directory"""
try:
image_path = f"c:/Users/shree/Downloads/smart-resume-ai/{image_name}"
with open(image_path, "rb") as f:
image_bytes = f.read()
encoded = base64.b64encode(image_bytes).decode()
return f"data:image/png;base64,{encoded}"
except Exception as e:
print(f"Error loading image {image_name}: {e}")
return None
def export_to_excel(self):
"""Export resume data to Excel"""
conn = get_database_connection()
# Get resume data with analysis
query = """
SELECT
rd.name, rd.email, rd.phone, rd.linkedin, rd.github, rd.portfolio,
rd.summary, rd.target_role, rd.target_category,
rd.education, rd.experience, rd.projects, rd.skills,
ra.ats_score, ra.keyword_match_score, ra.format_score, ra.section_score,
ra.missing_skills, ra.recommendations,
rd.created_at
FROM resume_data rd
LEFT JOIN resume_analysis ra ON rd.id = ra.resume_id
"""
try:
# Read data into DataFrame
df = pd.read_sql_query(query, conn)
# Create Excel writer object
output = io.BytesIO()
with pd.ExcelWriter(output, engine='openpyxl') as writer:
df.to_excel(writer, index=False, sheet_name='Resume Data')
return output.getvalue()
except Exception as e:
print(f"Error exporting to Excel: {str(e)}")
return None
finally:
conn.close()
def render_dashboard(self):
"""Render the dashboard page"""
self.dashboard_manager.render_dashboard()
def render_empty_state(self, icon, message):
"""Render an empty state with icon and message"""
return f"""
<div style='text-align: center; padding: 2rem; color: #666;'>
<i class='{icon}' style='font-size: 2rem; margin-bottom: 1rem; color: #00bfa5;'></i>
<p style='margin: 0;'>{message}</p>
</div>
"""
def analyze_resume(self, resume_text):
"""Analyze resume and store results"""
analytics = self.analyzer.analyze_resume(resume_text)
st.session_state.analytics_data = analytics
return analytics
def handle_resume_upload(self):
"""Handle resume upload and analysis"""
uploaded_file = st.file_uploader("Upload your resume", type=['pdf', 'docx'])
if uploaded_file is not None:
try:
# Extract text from resume
if uploaded_file.type == "application/pdf":
resume_text = extract_text_from_pdf(uploaded_file)
else:
resume_text = extract_text_from_docx(uploaded_file)
# Store resume data
st.session_state.resume_data = {
'filename': uploaded_file.name,
'content': resume_text,
'upload_time': datetime.now().isoformat()
}
# Analyze resume
analytics = self.analyze_resume(resume_text)
return True
except Exception as e:
st.error(f"Error processing resume: {str(e)}")
return False
return False
def render_builder(self):
st.title("Resume Builder 📝")
st.write("Create your professional resume")
# Template selection
template_options = ["Modern", "Professional", "Minimal", "Creative"]
selected_template = st.selectbox("Select Resume Template", template_options)
st.success(f"🎨 Currently using: {selected_template} Template")
# Personal Information
st.subheader("Personal Information")
col1, col2 = st.columns(2)
with col1:
# Get existing values from session state
existing_name = st.session_state.form_data['personal_info']['full_name']
existing_email = st.session_state.form_data['personal_info']['email']
existing_phone = st.session_state.form_data['personal_info']['phone']
# Input fields with existing values
full_name = st.text_input("Full Name", value=existing_name)
email = st.text_input("Email", value=existing_email, key="email_input")
phone = st.text_input("Phone", value=existing_phone)
# Immediately update session state after email input
if 'email_input' in st.session_state:
st.session_state.form_data['personal_info']['email'] = st.session_state.email_input
with col2:
# Get existing values from session state
existing_location = st.session_state.form_data['personal_info']['location']
existing_linkedin = st.session_state.form_data['personal_info']['linkedin']
existing_portfolio = st.session_state.form_data['personal_info']['portfolio']
# Input fields with existing values
location = st.text_input("Location", value=existing_location)
linkedin = st.text_input("LinkedIn URL", value=existing_linkedin)
portfolio = st.text_input("Portfolio Website", value=existing_portfolio)
# Update personal info in session state
st.session_state.form_data['personal_info'] = {
'full_name': full_name,
'email': email,
'phone': phone,
'location': location,
'linkedin': linkedin,
'portfolio': portfolio
}
# Professional Summary
st.subheader("Professional Summary")
summary = st.text_area("Professional Summary", value=st.session_state.form_data.get('summary', ''), height=150,
help="Write a brief summary highlighting your key skills and experience")
# Experience Section
st.subheader("Work Experience")
if 'experiences' not in st.session_state.form_data:
st.session_state.form_data['experiences'] = []
if st.button("Add Experience"):
st.session_state.form_data['experiences'].append({
'company': '',
'position': '',
'start_date': '',
'end_date': '',
'description': '',
'responsibilities': [],
'achievements': []
})
for idx, exp in enumerate(st.session_state.form_data['experiences']):
with st.expander(f"Experience {idx + 1}", expanded=True):
col1, col2 = st.columns(2)
with col1:
exp['company'] = st.text_input("Company Name", key=f"company_{idx}", value=exp.get('company', ''))
exp['position'] = st.text_input("Position", key=f"position_{idx}", value=exp.get('position', ''))
with col2:
exp['start_date'] = st.text_input("Start Date", key=f"start_date_{idx}", value=exp.get('start_date', ''))
exp['end_date'] = st.text_input("End Date", key=f"end_date_{idx}", value=exp.get('end_date', ''))
exp['description'] = st.text_area("Role Overview", key=f"desc_{idx}",
value=exp.get('description', ''),
help="Brief overview of your role and impact")
# Responsibilities
st.markdown("##### Key Responsibilities")
resp_text = st.text_area("Enter responsibilities (one per line)",
key=f"resp_{idx}",
value='\n'.join(exp.get('responsibilities', [])),
height=100,
help="List your main responsibilities, one per line")
exp['responsibilities'] = [r.strip() for r in resp_text.split('\n') if r.strip()]
# Achievements
st.markdown("##### Key Achievements")
achv_text = st.text_area("Enter achievements (one per line)",
key=f"achv_{idx}",
value='\n'.join(exp.get('achievements', [])),
height=100,
help="List your notable achievements, one per line")
exp['achievements'] = [a.strip() for a in achv_text.split('\n') if a.strip()]
if st.button("Remove Experience", key=f"remove_exp_{idx}"):
st.session_state.form_data['experiences'].pop(idx)
st.rerun()
# Projects Section
st.subheader("Projects")
if 'projects' not in st.session_state.form_data:
st.session_state.form_data['projects'] = []
if st.button("Add Project"):
st.session_state.form_data['projects'].append({
'name': '',
'technologies': '',
'description': '',
'responsibilities': [],
'achievements': [],
'link': ''
})
for idx, proj in enumerate(st.session_state.form_data['projects']):
with st.expander(f"Project {idx + 1}", expanded=True):
proj['name'] = st.text_input("Project Name", key=f"proj_name_{idx}", value=proj.get('name', ''))
proj['technologies'] = st.text_input("Technologies Used", key=f"proj_tech_{idx}",
value=proj.get('technologies', ''),
help="List the main technologies, frameworks, and tools used")
proj['description'] = st.text_area("Project Overview", key=f"proj_desc_{idx}",
value=proj.get('description', ''),
help="Brief overview of the project and its goals")
# Project Responsibilities
st.markdown("##### Key Responsibilities")
proj_resp_text = st.text_area("Enter responsibilities (one per line)",
key=f"proj_resp_{idx}",
value='\n'.join(proj.get('responsibilities', [])),
height=100,
help="List your main responsibilities in the project")
proj['responsibilities'] = [r.strip() for r in proj_resp_text.split('\n') if r.strip()]
# Project Achievements
st.markdown("##### Key Achievements")
proj_achv_text = st.text_area("Enter achievements (one per line)",
key=f"proj_achv_{idx}",
value='\n'.join(proj.get('achievements', [])),
height=100,
help="List the project's key achievements and your contributions")
proj['achievements'] = [a.strip() for a in proj_achv_text.split('\n') if a.strip()]
proj['link'] = st.text_input("Project Link (optional)", key=f"proj_link_{idx}",
value=proj.get('link', ''),
help="Link to the project repository, demo, or documentation")
if st.button("Remove Project", key=f"remove_proj_{idx}"):
st.session_state.form_data['projects'].pop(idx)
st.rerun()
# Education Section
st.subheader("Education")
if 'education' not in st.session_state.form_data:
st.session_state.form_data['education'] = []
if st.button("Add Education"):
st.session_state.form_data['education'].append({
'school': '',
'degree': '',
'field': '',
'graduation_date': '',
'gpa': '',
'achievements': []
})
for idx, edu in enumerate(st.session_state.form_data['education']):
with st.expander(f"Education {idx + 1}", expanded=True):
col1, col2 = st.columns(2)
with col1:
edu['school'] = st.text_input("School/University", key=f"school_{idx}", value=edu.get('school', ''))
edu['degree'] = st.text_input("Degree", key=f"degree_{idx}", value=edu.get('degree', ''))
with col2:
edu['field'] = st.text_input("Field of Study", key=f"field_{idx}", value=edu.get('field', ''))
edu['graduation_date'] = st.text_input("Graduation Date", key=f"grad_date_{idx}",
value=edu.get('graduation_date', ''))
edu['gpa'] = st.text_input("GPA (optional)", key=f"gpa_{idx}", value=edu.get('gpa', ''))
# Educational Achievements
st.markdown("##### Achievements & Activities")
edu_achv_text = st.text_area("Enter achievements (one per line)",
key=f"edu_achv_{idx}",
value='\n'.join(edu.get('achievements', [])),
height=100,
help="List academic achievements, relevant coursework, or activities")
edu['achievements'] = [a.strip() for a in edu_achv_text.split('\n') if a.strip()]
if st.button("Remove Education", key=f"remove_edu_{idx}"):
st.session_state.form_data['education'].pop(idx)
st.rerun()
# Skills Section
st.subheader("Skills")
if 'skills_categories' not in st.session_state.form_data:
st.session_state.form_data['skills_categories'] = {
'technical': [],
'soft': [],
'languages': [],
'tools': []
}
col1, col2 = st.columns(2)
with col1:
tech_skills = st.text_area("Technical Skills (one per line)",
value='\n'.join(st.session_state.form_data['skills_categories']['technical']),
height=150,
help="Programming languages, frameworks, databases, etc.")
st.session_state.form_data['skills_categories']['technical'] = [s.strip() for s in tech_skills.split('\n') if s.strip()]
soft_skills = st.text_area("Soft Skills (one per line)",
value='\n'.join(st.session_state.form_data['skills_categories']['soft']),
height=150,
help="Leadership, communication, problem-solving, etc.")
st.session_state.form_data['skills_categories']['soft'] = [s.strip() for s in soft_skills.split('\n') if s.strip()]
with col2:
languages = st.text_area("Languages (one per line)",
value='\n'.join(st.session_state.form_data['skills_categories']['languages']),
height=150,
help="Programming or human languages with proficiency level")
st.session_state.form_data['skills_categories']['languages'] = [l.strip() for l in languages.split('\n') if l.strip()]
tools = st.text_area("Tools & Technologies (one per line)",
value='\n'.join(st.session_state.form_data['skills_categories']['tools']),
height=150,
help="Development tools, software, platforms, etc.")
st.session_state.form_data['skills_categories']['tools'] = [t.strip() for t in tools.split('\n') if t.strip()]
# Update form data in session state
st.session_state.form_data.update({
'summary': summary
})
# Generate Resume button
if st.button("Generate Resume 📄", type="primary"):
print("Validating form data...")
print(f"Session state form data: {st.session_state.form_data}")
print(f"Email input value: {st.session_state.get('email_input', '')}")
# Get the current values from form
current_name = st.session_state.form_data['personal_info']['full_name'].strip()
current_email = st.session_state.email_input if 'email_input' in st.session_state else ''
print(f"Current name: {current_name}")
print(f"Current email: {current_email}")
# Validate required fields
if not current_name:
st.error("⚠️ Please enter your full name.")
return
if not current_email:
st.error("⚠️ Please enter your email address.")
return
# Update email in form data one final time
st.session_state.form_data['personal_info']['email'] = current_email
try:
print("Preparing resume data...")
# Prepare resume data with current form values
resume_data = {
"personal_info": st.session_state.form_data['personal_info'],
"summary": st.session_state.form_data.get('summary', '').strip(),
"experience": st.session_state.form_data.get('experiences', []),
"education": st.session_state.form_data.get('education', []),
"projects": st.session_state.form_data.get('projects', []),
"skills": st.session_state.form_data.get('skills_categories', {
'technical': [],
'soft': [],
'languages': [],
'tools': []
}),
"template": selected_template
}
print(f"Resume data prepared: {resume_data}")
try:
# Generate resume
resume_buffer = self.builder.generate_resume(resume_data)
if resume_buffer:
try:
# Save resume data to database
save_resume_data(resume_data)
# Offer the resume for download
st.success("✅ Resume generated successfully!")
st.download_button(
label="Download Resume 📥",
data=resume_buffer,
file_name=f"{current_name.replace(' ', '_')}_resume.docx",
mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
)
except Exception as db_error:
print(f"Warning: Failed to save to database: {str(db_error)}")
# Still allow download even if database save fails
st.warning("⚠️ Resume generated but couldn't be saved to database")
st.download_button(
label="Download Resume 📥",
data=resume_buffer,
file_name=f"{current_name.replace(' ', '_')}_resume.docx",
mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
)
else:
st.error("❌ Failed to generate resume. Please try again.")
print("Resume buffer was None")
except Exception as gen_error:
print(f"Error during resume generation: {str(gen_error)}")
print(f"Full traceback: {traceback.format_exc()}")
st.error(f"❌ Error generating resume: {str(gen_error)}")
except Exception as e:
print(f"Error preparing resume data: {str(e)}")
print(f"Full traceback: {traceback.format_exc()}")
st.error(f"❌ Error preparing resume data: {str(e)}")
def render_about(self):
"""Render the about page"""
# Apply modern styles
from ui_components import apply_modern_styles
import base64
import os
# Function to load image as base64
def get_image_as_base64(file_path):
try:
with open(file_path, "rb") as image_file:
encoded = base64.b64encode(image_file.read()).decode()
return f"data:image/jpeg;base64,{encoded}"
except:
return None
# Get image path and convert to base64
image_path = os.path.join(os.path.dirname(__file__), "assets", "124852522.jpeg")
image_base64 = get_image_as_base64(image_path)
apply_modern_styles()
# Add Font Awesome icons and custom CSS
st.markdown("""
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<style>
.profile-section, .vision-section, .feature-card {
text-align: center;
padding: 2rem;
background: rgba(45, 45, 45, 0.9);
border-radius: 20px;
margin: 2rem auto;
max-width: 800px;
}
.profile-image {
width: 200px;
height: 200px;
border-radius: 50%;
margin: 0 auto 1.5rem;
display: block;
object-fit: cover;
border: 4px solid #4CAF50;
}
.profile-name {
font-size: 2.5rem;
color: white;
margin-bottom: 0.5rem;
}
.profile-title {
font-size: 1.2rem;
color: #4CAF50;
margin-bottom: 1.5rem;
}
.social-links {
display: flex;
justify-content: center;
gap: 1.5rem;
margin: 2rem 0;
}
.social-link {
font-size: 2rem;
color: #4CAF50;
transition: all 0.3s ease;
padding: 0.5rem;
border-radius: 50%;
background: rgba(76, 175, 80, 0.1);
width: 60px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
text-decoration: none;
}
.social-link:hover {
transform: translateY(-5px);
background: #4CAF50;
color: white;
box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}
.bio-text {
color: #ddd;
line-height: 1.8;
font-size: 1.1rem;
margin-top: 2rem;
text-align: left;
}
.vision-text {
color: #ddd;
line-height: 1.8;
font-size: 1.1rem;
font-style: italic;
margin: 1.5rem 0;
text-align: left;
}
.vision-icon {
font-size: 2.5rem;
color: #4CAF50;
margin-bottom: 1rem;
}
.vision-title {
font-size: 2rem;
color: white;
margin-bottom: 1rem;
}
.features-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 2rem;
margin: 2rem auto;
max-width: 1200px;
}
.feature-card {
padding: 2rem;
margin: 0;
}
.feature-icon {
font-size: 2.5rem;
color: #4CAF50;
margin-bottom: 1rem;
}
.feature-title {
font-size: 1.5rem;
color: white;
margin: 1rem 0;
}
.feature-description {
color: #ddd;