Spaces:
Paused
Paused
File size: 43,367 Bytes
536efda | 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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 | import json
import os
import re
import tempfile
from datetime import datetime
from pathlib import Path
import gradio as gr
import pandas as pd
from reportlab.lib import colors
from reportlab.lib.enums import TA_CENTER
from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import mm
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak
)
APP_NAME = "OpenBrand AI"
APP_VERSION = "1.0.0"
ROLE_SKILLS = {
"Data Scientist": [
"Python", "SQL", "Statistics", "Machine Learning", "Data Visualization",
"Pandas", "Scikit-learn", "Experimentation", "Git", "Communication"
],
"AI/ML Engineer": [
"Python", "Machine Learning", "Deep Learning", "PyTorch", "TensorFlow",
"MLOps", "APIs", "Docker", "Git", "Cloud"
],
"Software Engineer": [
"Python", "JavaScript", "Data Structures", "Algorithms", "Git",
"APIs", "Testing", "Databases", "System Design", "Cloud"
],
"Product Manager": [
"Product Strategy", "User Research", "Roadmapping", "Analytics",
"A/B Testing", "Stakeholder Management", "Communication",
"Market Research", "Agile", "Prioritization"
],
"Mechanical Engineer": [
"CAD", "SolidWorks", "AutoCAD", "FEA", "Manufacturing",
"GD&T", "Thermodynamics", "Mechanics", "Project Management", "MATLAB"
],
"Robotics Engineer": [
"Python", "C++", "ROS", "Control Systems", "Computer Vision",
"Embedded Systems", "Sensors", "SLAM", "CAD", "Linux"
],
"Researcher": [
"Literature Review", "Research Design", "Statistics", "Data Analysis",
"Academic Writing", "Experimentation", "Visualization",
"Reproducibility", "Reference Management", "Presentation"
],
"Business Analyst": [
"Excel", "SQL", "Power BI", "Requirements Analysis", "Process Mapping",
"Stakeholder Management", "Data Analysis", "Presentation",
"Documentation", "Problem Solving"
],
"Digital Marketer": [
"SEO", "Content Strategy", "Google Analytics", "Meta Ads", "Google Ads",
"Email Marketing", "Copywriting", "Conversion Optimization",
"Social Media", "Marketing Analytics"
],
}
ACTION_VERBS = {
"achieved", "built", "created", "delivered", "designed", "developed",
"improved", "increased", "launched", "led", "managed", "optimized",
"reduced", "implemented", "automated", "published", "trained",
"validated", "deployed", "generated", "coordinated", "engineered"
}
DIGITAL_ITEMS = [
"Professional email address",
"Consistent name/headline across platforms",
"Privacy settings reviewed",
"Two-factor authentication enabled",
"Unprofessional public content reviewed/removed",
"Search-engine self-audit completed",
"Portfolio or GitHub available",
"Profile photo is professional",
"Public achievements/projects are visible",
]
LINKEDIN_ITEMS = [
"Professional profile photo",
"Relevant banner image",
"Custom LinkedIn URL",
"Keyword-rich headline",
"Complete About section",
"Experience entries with outcomes",
"Education section complete",
"At least 10 relevant skills",
"Projects / publications showcased",
"At least 2 recommendations",
"Recent professional activity/post/comment",
"CV and LinkedIn tell a consistent story",
]
NETWORK_GOALS = [
"Identify 3 alumni in target roles",
"Connect with 5 industry professionals",
"Join 2 relevant professional communities",
"Request one informational interview",
"Publish or comment on professional content",
"Reconnect with one dormant professional contact",
]
def clean(value):
return (value or "").strip()
def split_items(text):
if not text:
return []
parts = re.split(r"[,;\n]+", text)
return [p.strip() for p in parts if p.strip()]
def normalize_skill(skill):
return re.sub(r"[^a-z0-9+#]+", "", skill.lower())
def infer_role_skills(role):
role = clean(role)
if not role:
return []
for key, vals in ROLE_SKILLS.items():
if key.lower() in role.lower() or role.lower() in key.lower():
return vals
# General fallback that still makes the tool useful for custom roles.
return [
"Communication", "Problem Solving", "Digital Literacy",
"Project Management", "Data Literacy", "Collaboration",
"Presentation", "Research", "Adaptability", "Domain Knowledge"
]
def skill_gap(role, skills_text):
required = infer_role_skills(role)
current = {normalize_skill(x) for x in split_items(skills_text)}
missing = [s for s in required if normalize_skill(s) not in current]
matched = [s for s in required if normalize_skill(s) in current]
coverage = round(100 * len(matched) / max(1, len(required)))
return required, matched, missing, coverage
def positioning_feedback(role, industry, value_prop, strengths, goals):
score = 0
notes = []
if clean(role):
score += 20
else:
notes.append("Choose one primary target role.")
if clean(industry):
score += 15
else:
notes.append("Name the industry or sector you want to enter.")
if len(clean(value_prop).split()) >= 12:
score += 25
else:
notes.append("Expand the value proposition to roughly 12–35 words.")
if len(split_items(strengths)) >= 4:
score += 20
else:
notes.append("List at least four evidence-backed strengths.")
if len(clean(goals).split()) >= 12:
score += 20
else:
notes.append("Make your 12–24 month goal specific and measurable.")
status = "Strong" if score >= 80 else "Developing" if score >= 55 else "Needs focus"
if not notes:
notes.append("Your positioning is sufficiently specific to drive the rest of the profile.")
return score, f"### Positioning score: **{score}/100 — {status}**\n" + "\n".join(f"- {x}" for x in notes)
def generate_value_proposition(role, industry, strengths, skills):
role = clean(role) or "professional"
industry = clean(industry) or "my target sector"
strengths_list = split_items(strengths)[:3]
skills_list = split_items(skills)[:4]
strength_phrase = ", ".join(strengths_list) if strengths_list else "structured problem solving"
skill_phrase = ", ".join(skills_list) if skills_list else "relevant technical and professional skills"
return (
f"I am an aspiring {role} focused on {industry}, combining {strength_phrase} "
f"with {skill_phrase} to solve meaningful problems and deliver measurable outcomes."
)
def generate_summary(name, title, role, industry, strengths, skills, goals):
name = clean(name)
title = clean(title) or clean(role) or "Professional"
industry = clean(industry) or "the target industry"
strengths_list = split_items(strengths)[:3]
skills_list = split_items(skills)[:5]
parts = [
f"{title} targeting opportunities in {industry}.",
]
if strengths_list:
parts.append("Known for " + ", ".join(strengths_list) + ".")
if skills_list:
parts.append("Core capabilities include " + ", ".join(skills_list) + ".")
if clean(goals):
parts.append("Current direction: " + clean(goals).rstrip(".") + ".")
return " ".join(parts)
def ats_score(name, email, phone, title, summary, experience, education, projects, skills, role):
score = 0
notes = []
if clean(name):
score += 5
else:
notes.append("Add your full name.")
if re.search(r"[^@\s]+@[^@\s]+\.[^@\s]+", clean(email)):
score += 7
else:
notes.append("Use a valid professional email.")
if len(re.sub(r"\D", "", clean(phone))) >= 7:
score += 3
if clean(title):
score += 5
else:
notes.append("Add a clear professional title.")
if 35 <= len(clean(summary).split()) <= 120:
score += 12
elif clean(summary):
score += 6
notes.append("Keep the summary roughly 35–120 words.")
else:
notes.append("Add a concise professional summary.")
exp_words = clean(experience).split()
if len(exp_words) >= 35:
score += 18
elif exp_words:
score += 9
notes.append("Expand experience with actions, scope and outcomes.")
else:
notes.append("Add at least one experience entry.")
exp_lower = clean(experience).lower()
verbs_found = sum(1 for v in ACTION_VERBS if re.search(rf"\b{re.escape(v)}\b", exp_lower))
if verbs_found >= 3:
score += 7
elif verbs_found:
score += 3
notes.append("Start more bullets with strong action verbs.")
if re.search(r"\b\d+([.%xkKmM+]|\b)", clean(experience)):
score += 8
else:
notes.append("Quantify impact where possible (%, time, cost, scale, users, output).")
if len(clean(education).split()) >= 8:
score += 10
else:
notes.append("Add degree, institution and dates/status.")
if len(clean(projects).split()) >= 15:
score += 8
else:
notes.append("Add 1–3 relevant projects with outcomes.")
skill_list = split_items(skills)
if len(skill_list) >= 8:
score += 10
elif skill_list:
score += 5
notes.append("Aim for at least 8 relevant skills.")
else:
notes.append("Add role-relevant skills.")
_, matched, missing, coverage = skill_gap(role, skills)
if coverage >= 70:
score += 7
elif coverage >= 40:
score += 4
else:
notes.append("Increase skill alignment with the target role.")
score = min(100, score)
band = "Excellent foundation" if score >= 85 else "Competitive" if score >= 70 else "Developing" if score >= 50 else "Needs work"
missing_short = ", ".join(missing[:5]) if missing else "No major mapped gaps"
md = (
f"### ATS-style readiness: **{score}/100 — {band}**\n"
f"**Mapped role-skill coverage:** {coverage}% \n"
f"**Priority skill gaps:** {missing_short}\n\n"
+ ("\n".join(f"- {n}" for n in notes) if notes else "- Strong baseline. Tailor keywords and evidence for each vacancy.")
+ "\n\n*This is a transparent heuristic, not a guarantee of performance in any employer's ATS.*"
)
return score, md
def linkedin_headline(role, industry, skills, value_prop):
role = clean(role) or "Aspiring Professional"
industry = clean(industry)
top = split_items(skills)[:3]
pieces = [role]
if top:
pieces.append(" | ".join(top))
if industry:
pieces.append(industry)
headline = " | ".join(pieces)
return headline[:220]
def linkedin_about(name, role, industry, value_prop, strengths, skills, goals):
role = clean(role) or "professional"
intro = clean(value_prop) or f"I am building my career as a {role}."
strength_text = ", ".join(split_items(strengths)[:4])
skill_text = ", ".join(split_items(skills)[:6])
paras = [intro]
if strength_text:
paras.append(f"My strengths include {strength_text}.")
if skill_text:
paras.append(f"I am developing and applying skills in {skill_text}.")
if clean(goals):
paras.append(f"Right now, I am focused on {clean(goals).rstrip('.')}.")
paras.append("I welcome conversations with professionals, mentors, collaborators and teams working on meaningful problems.")
return "\n\n".join(paras)
def linkedin_score(headline, about, url, checklist):
score = 0
notes = []
if 40 <= len(clean(headline)) <= 220:
score += 20
elif clean(headline):
score += 10
notes.append("Strengthen the headline with role + keywords + value.")
else:
notes.append("Add a keyword-rich headline.")
if 80 <= len(clean(about).split()) <= 400:
score += 25
elif clean(about):
score += 12
notes.append("Develop the About section with evidence and direction.")
else:
notes.append("Add an About section.")
if "linkedin.com/in/" in clean(url).lower():
score += 10
elif clean(url):
score += 4
checked = len(checklist or [])
score += round(45 * checked / len(LINKEDIN_ITEMS))
score = min(100, score)
if checked < 8:
notes.append(f"Complete more profile items ({checked}/{len(LINKEDIN_ITEMS)} checked).")
if not notes:
notes.append("Strong LinkedIn foundation; keep it active and tailored to your target role.")
return score, f"### LinkedIn readiness: **{score}/100**\n" + "\n".join(f"- {x}" for x in notes)
def network_score(df, goals):
if df is None:
df = pd.DataFrame(columns=["Name", "Category", "Next action", "Status"])
try:
nonempty = df.fillna("").astype(str)
count = int((nonempty["Name"].str.strip() != "").sum()) if "Name" in nonempty.columns else 0
except Exception:
count = 0
goals_done = len(goals or [])
score = min(60, count * 6) + round(40 * goals_done / len(NETWORK_GOALS))
score = min(100, score)
return score, (
f"### Network-building score: **{score}/100**\n"
f"- Contacts mapped: **{count}**\n"
f"- Networking goals completed: **{goals_done}/{len(NETWORK_GOALS)}**\n"
f"- Next target: maintain a small number of meaningful, follow-up-ready relationships rather than collecting contacts."
)
def digital_score(items):
done = len(items or [])
score = round(100 * done / len(DIGITAL_ITEMS))
missing = [x for x in DIGITAL_ITEMS if x not in (items or [])]
md = f"### Digital footprint score: **{score}/100**\n"
if missing:
md += "\n".join(f"- Pending: {x}" for x in missing[:5])
else:
md += "- Core digital-footprint checks are complete. Re-audit every few months."
return score, md
def employability_assessment(role, skills, experience, projects, positioning_score, ats, linkedin_s, network_s, digital_s):
_, matched, missing, coverage = skill_gap(role, skills)
exp_score = min(100, len(clean(experience).split()) * 2)
proj_score = min(100, len(clean(projects).split()) * 3)
evidence_score = round((exp_score * 0.65) + (proj_score * 0.35))
overall = round(
positioning_score * 0.12 +
ats * 0.24 +
coverage * 0.20 +
evidence_score * 0.15 +
linkedin_s * 0.12 +
network_s * 0.09 +
digital_s * 0.08
)
if overall >= 80:
band = "Strong market readiness"
elif overall >= 65:
band = "Competitive, with targeted gaps"
elif overall >= 50:
band = "Developing readiness"
else:
band = "Foundation-building stage"
recs = []
if coverage < 70:
recs.append("Close the highest-priority role skill gaps: " + ", ".join(missing[:5]) + ".")
if evidence_score < 65:
recs.append("Create stronger evidence: projects, quantified achievements, case studies or work samples.")
if ats < 70:
recs.append("Improve CV structure, quantified results and vacancy-specific keywords.")
if linkedin_s < 70:
recs.append("Complete and align LinkedIn with the CV and target role.")
if network_s < 60:
recs.append("Build a deliberate networking routine with follow-up actions.")
if digital_s < 75:
recs.append("Finish the digital-footprint audit and professionalize public profiles.")
if not recs:
recs.append("Tailor applications by vacancy and keep collecting measurable evidence of impact.")
md = (
f"# Employability Readiness: **{overall}/100**\n"
f"### {band}\n\n"
f"**Role skill coverage:** {coverage}% \n"
f"**Evidence strength:** {evidence_score}% \n"
f"**ATS-style CV readiness:** {ats}% \n"
f"**LinkedIn readiness:** {linkedin_s}% \n"
f"**Network-building:** {network_s}% \n"
f"**Digital footprint:** {digital_s}%\n\n"
"### Priority actions\n" + "\n".join(f"{i+1}. {r}" for i, r in enumerate(recs)) +
"\n\n*This score is a coaching heuristic for self-improvement. It is not a psychometric test or hiring prediction.*"
)
return overall, md
def action_plan(role, skills, ats, linkedin_s, network_s, digital_s):
_, _, missing, coverage = skill_gap(role, skills)
gaps = missing[:4]
skill_actions = [f"Learn/practice **{g}** and produce one small proof-of-skill artifact." for g in gaps]
if not skill_actions:
skill_actions = ["Deepen one role-critical skill and publish a proof-of-skill artifact."]
week1 = [
"Finalize one target role and one target industry.",
"Rewrite the value proposition around problems you can solve.",
"Create a master achievement inventory with numbers and evidence.",
]
week2 = [
"Tailor the CV to one real target vacancy.",
"Rewrite experience bullets using action + task + measurable result.",
*skill_actions[:2],
]
week3 = [
"Align LinkedIn headline/About with the target role and CV.",
"Add or improve 2 projects/work samples.",
"Connect with 5 relevant professionals with personalized messages.",
]
week4 = [
"Apply to a focused set of roles/opportunities.",
"Request feedback from one mentor/peer.",
"Publish one useful professional post or project update.",
"Review scores and choose the next 30-day improvement cycle.",
]
if ats < 70:
week2.insert(0, "Raise ATS-style readiness above 70 before high-volume applications.")
if linkedin_s < 70:
week3.insert(0, "Raise LinkedIn readiness above 70 by completing missing profile items.")
if network_s < 60:
week3.append("Schedule at least one informational conversation.")
if digital_s < 75:
week1.append("Complete the digital-footprint audit before increasing public visibility.")
return (
f"# 30-Day Career Brand Sprint — {clean(role) or 'Target Role'}\n\n"
"## Week 1 — Position & Evidence\n" + "\n".join(f"- {x}" for x in week1) +
"\n\n## Week 2 — CV & Skills\n" + "\n".join(f"- {x}" for x in week2) +
"\n\n## Week 3 — Visibility & Network\n" + "\n".join(f"- {x}" for x in week3) +
"\n\n## Week 4 — Market Test\n" + "\n".join(f"- {x}" for x in week4) +
f"\n\n**Current role-skill coverage:** {coverage}%"
)
def html_meter(label, score):
score = int(max(0, min(100, score)))
return f"""
<div class="metric-card">
<div class="metric-label">{label}</div>
<div class="metric-value">{score}<span>/100</span></div>
<div class="meter"><div class="meter-fill" style="width:{score}%"></div></div>
</div>
"""
def dashboard_html(pos, ats, lin, net, dig, employ):
scores = [
("Positioning", pos), ("CV / ATS", ats), ("LinkedIn", lin),
("Network", net), ("Digital", dig), ("Employability", employ)
]
complete = round(sum(1 for _, s in scores[:-1] if s >= 60) / 5 * 100)
cards = "".join(html_meter(l, s) for l, s in scores)
return f"""
<div class="hero-dashboard">
<div>
<div class="eyebrow">CAREER BRAND CONTROL CENTER</div>
<h2>{complete}% foundation complete</h2>
<p>Improve each dimension, then regenerate your action plan and portfolio.</p>
</div>
</div>
<div class="metric-grid">{cards}</div>
"""
def dataframe_default():
return pd.DataFrame(
[["", "Mentor", "", "Planned"]],
columns=["Name", "Category", "Next action", "Status"]
)
def build_profile_dict(
target_role, industry, value_prop, strengths, goals,
name, title, email, phone, linkedin_url, website,
summary, experience, education, projects, publications, skills,
li_headline, li_about, li_custom_url, li_checklist,
network_df, network_goals, digital_items
):
if isinstance(network_df, pd.DataFrame):
network_records = network_df.fillna("").to_dict(orient="records")
else:
try:
network_records = pd.DataFrame(network_df, columns=["Name","Category","Next action","Status"]).fillna("").to_dict(orient="records")
except Exception:
network_records = []
return {
"meta": {
"app": APP_NAME,
"version": APP_VERSION,
"exported_at": datetime.utcnow().isoformat(timespec="seconds") + "Z",
},
"positioning": {
"target_role": clean(target_role),
"industry": clean(industry),
"value_proposition": clean(value_prop),
"strengths": clean(strengths),
"career_goals": clean(goals),
},
"cv": {
"name": clean(name),
"title": clean(title),
"email": clean(email),
"phone": clean(phone),
"linkedin_url": clean(linkedin_url),
"website": clean(website),
"summary": clean(summary),
"experience": clean(experience),
"education": clean(education),
"projects": clean(projects),
"publications": clean(publications),
"skills": clean(skills),
},
"linkedin": {
"headline": clean(li_headline),
"about": clean(li_about),
"custom_url": clean(li_custom_url),
"checklist": li_checklist or [],
},
"network": {
"contacts": network_records,
"goals": network_goals or [],
},
"digital_audit": {
"completed": digital_items or [],
},
}
def save_json(*args):
profile = build_profile_dict(*args)
fd, path = tempfile.mkstemp(prefix="openbrand_portfolio_", suffix=".json")
os.close(fd)
with open(path, "w", encoding="utf-8") as f:
json.dump(profile, f, ensure_ascii=False, indent=2)
return path
def bulletify(text):
lines = [x.strip(" •-\t") for x in clean(text).splitlines() if x.strip()]
if not lines and clean(text):
lines = [clean(text)]
return lines
def create_cv_pdf(name, title, email, phone, linkedin_url, website, summary, experience, education, projects, publications, skills):
fd, path = tempfile.mkstemp(prefix="openbrand_cv_", suffix=".pdf")
os.close(fd)
doc = SimpleDocTemplate(
path, pagesize=A4,
rightMargin=16*mm, leftMargin=16*mm,
topMargin=14*mm, bottomMargin=14*mm
)
styles = getSampleStyleSheet()
styles.add(ParagraphStyle(
name="CVName", parent=styles["Title"], fontSize=20, leading=24,
alignment=TA_CENTER, spaceAfter=4
))
styles.add(ParagraphStyle(
name="CVTitle", parent=styles["Normal"], fontSize=10.5, leading=13,
alignment=TA_CENTER, textColor=colors.HexColor("#334155"), spaceAfter=6
))
styles.add(ParagraphStyle(
name="Section", parent=styles["Heading2"], fontSize=11, leading=14,
textColor=colors.HexColor("#0f172a"), spaceBefore=8, spaceAfter=4
))
styles.add(ParagraphStyle(
name="BodySmall", parent=styles["BodyText"], fontSize=9.4, leading=13
))
story = []
story.append(Paragraph(clean(name) or "Your Name", styles["CVName"]))
story.append(Paragraph(clean(title) or "Professional Title", styles["CVTitle"]))
contact = " • ".join([x for x in [clean(email), clean(phone), clean(linkedin_url), clean(website)] if x])
if contact:
story.append(Paragraph(contact, styles["CVTitle"]))
story.append(Spacer(1, 4))
sections = [
("PROFESSIONAL SUMMARY", summary),
("EXPERIENCE", experience),
("EDUCATION", education),
("PROJECTS", projects),
("PUBLICATIONS", publications),
("SKILLS", skills),
]
for heading, content in sections:
if not clean(content):
continue
story.append(Paragraph(heading, styles["Section"]))
if heading in {"EXPERIENCE", "PROJECTS", "PUBLICATIONS"}:
for line in bulletify(content):
story.append(Paragraph("• " + line, styles["BodySmall"]))
story.append(Spacer(1, 2))
elif heading == "SKILLS":
story.append(Paragraph(", ".join(split_items(content)), styles["BodySmall"]))
else:
for line in bulletify(content):
story.append(Paragraph(line, styles["BodySmall"]))
story.append(Spacer(1, 2))
doc.build(story)
return path
def create_portfolio_pdf(profile):
fd, path = tempfile.mkstemp(prefix="openbrand_portfolio_", suffix=".pdf")
os.close(fd)
doc = SimpleDocTemplate(
path, pagesize=A4, rightMargin=18*mm, leftMargin=18*mm,
topMargin=16*mm, bottomMargin=16*mm
)
styles = getSampleStyleSheet()
styles.add(ParagraphStyle(name="PTitle", parent=styles["Title"], fontSize=22, leading=27, textColor=colors.HexColor("#0f172a")))
styles.add(ParagraphStyle(name="PSection", parent=styles["Heading2"], fontSize=13, leading=16, textColor=colors.HexColor("#4f46e5"), spaceBefore=10))
styles.add(ParagraphStyle(name="PSmall", parent=styles["BodyText"], fontSize=9.5, leading=13))
story = [
Paragraph("OpenBrand AI — Personal Brand Portfolio", styles["PTitle"]),
Paragraph(profile["cv"].get("name") or "Professional Portfolio", styles["Heading2"]),
Spacer(1, 8),
]
def add_section(title, rows):
story.append(Paragraph(title, styles["PSection"]))
data = []
for k, v in rows:
if isinstance(v, list):
v = ", ".join(map(str, v))
if v:
data.append([Paragraph(f"<b>{k}</b>", styles["PSmall"]), Paragraph(str(v).replace("\n", "<br/>"), styles["PSmall"])])
if data:
t = Table(data, colWidths=[42*mm, 118*mm])
t.setStyle(TableStyle([
("VALIGN", (0,0), (-1,-1), "TOP"),
("LINEBELOW", (0,0), (-1,-1), 0.25, colors.HexColor("#e2e8f0")),
("LEFTPADDING", (0,0), (-1,-1), 4),
("RIGHTPADDING", (0,0), (-1,-1), 4),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
]))
story.append(t)
pos = profile["positioning"]
cv = profile["cv"]
li = profile["linkedin"]
add_section("Strategic Positioning", [
("Target role", pos["target_role"]), ("Industry", pos["industry"]),
("Value proposition", pos["value_proposition"]), ("Strengths", pos["strengths"]),
("Career goals", pos["career_goals"])
])
add_section("CV Profile", [
("Professional title", cv["title"]), ("Email", cv["email"]), ("Phone", cv["phone"]),
("LinkedIn", cv["linkedin_url"]), ("Website", cv["website"]), ("Summary", cv["summary"]),
("Experience", cv["experience"]), ("Education", cv["education"]),
("Projects", cv["projects"]), ("Publications", cv["publications"]), ("Skills", cv["skills"])
])
add_section("LinkedIn", [
("Headline", li["headline"]), ("About", li["about"]),
("Custom URL", li["custom_url"]), ("Checklist completed", li["checklist"])
])
add_section("Digital Footprint", [("Completed checks", profile["digital_audit"]["completed"])])
doc.build(story)
return path
def save_portfolio_pdf(*args):
profile = build_profile_dict(*args)
return create_portfolio_pdf(profile)
def safeget(d, *keys, default=""):
x = d
try:
for k in keys:
x = x[k]
return x
except Exception:
return default
def import_profile(file_path):
if not file_path:
raise gr.Error("Choose an OpenBrand JSON portfolio file first.")
with open(file_path, "r", encoding="utf-8") as f:
p = json.load(f)
contacts = safeget(p, "network", "contacts", default=[])
if contacts:
df = pd.DataFrame(contacts)
for c in ["Name", "Category", "Next action", "Status"]:
if c not in df.columns:
df[c] = ""
df = df[["Name", "Category", "Next action", "Status"]]
else:
df = dataframe_default()
return (
safeget(p,"positioning","target_role"),
safeget(p,"positioning","industry"),
safeget(p,"positioning","value_proposition"),
safeget(p,"positioning","strengths"),
safeget(p,"positioning","career_goals"),
safeget(p,"cv","name"),
safeget(p,"cv","title"),
safeget(p,"cv","email"),
safeget(p,"cv","phone"),
safeget(p,"cv","linkedin_url"),
safeget(p,"cv","website"),
safeget(p,"cv","summary"),
safeget(p,"cv","experience"),
safeget(p,"cv","education"),
safeget(p,"cv","projects"),
safeget(p,"cv","publications"),
safeget(p,"cv","skills"),
safeget(p,"linkedin","headline"),
safeget(p,"linkedin","about"),
safeget(p,"linkedin","custom_url"),
safeget(p,"linkedin","checklist", default=[]),
df,
safeget(p,"network","goals", default=[]),
safeget(p,"digital_audit","completed", default=[]),
"✅ Portfolio loaded. Re-run the scoring buttons to refresh assessments."
)
CSS = """
:root {
--brand: #4f46e5;
--brand2: #7c3aed;
--ink: #0f172a;
--muted: #64748b;
--panel: #ffffff;
--line: #e2e8f0;
}
.gradio-container {max-width: 1250px !important; margin: 0 auto !important;}
.app-hero {
background: linear-gradient(135deg, #0f172a 0%, #312e81 55%, #4f46e5 100%);
color: white; border-radius: 22px; padding: 28px 30px; margin-bottom: 16px;
}
.app-hero h1 {font-size: 34px; margin: 0 0 8px 0;}
.app-hero p {opacity: .9; font-size: 16px; max-width: 850px;}
.badge {display:inline-block;background:rgba(255,255,255,.14);padding:6px 10px;border-radius:999px;font-size:12px;margin-bottom:10px;}
.metric-grid {display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin:12px 0 8px;}
.metric-card {border:1px solid var(--line);border-radius:16px;padding:14px;background:var(--panel);}
.metric-label {font-size:12px;color:var(--muted);font-weight:700;text-transform:uppercase;letter-spacing:.04em;}
.metric-value {font-size:28px;font-weight:800;color:var(--ink);margin:4px 0;}
.metric-value span {font-size:13px;color:var(--muted);font-weight:600;}
.meter {height:7px;background:#eef2ff;border-radius:999px;overflow:hidden;}
.meter-fill {height:100%;background:linear-gradient(90deg,var(--brand),var(--brand2));}
.eyebrow {font-size:11px;letter-spacing:.09em;color:#6366f1;font-weight:800;}
.hero-dashboard h2 {margin:4px 0;}
.section-note {background:#f8fafc;border:1px solid #e2e8f0;border-radius:12px;padding:12px;}
footer {display:none !important;}
@media (max-width: 750px) {.metric-grid {grid-template-columns:repeat(2,1fr);} .app-hero h1{font-size:28px;}}
"""
with gr.Blocks(title=f"{APP_NAME} — Open Source Career Toolkit") as demo:
gr.HTML(f"""
<div class="app-hero">
<div class="badge">OPEN SOURCE • HUGGING FACE SPACES • {APP_VERSION}</div>
<h1>OpenBrand AI</h1>
<p>Build a credible professional brand from career positioning to CV, LinkedIn, networking,
digital footprint, employability readiness and an exportable portfolio.</p>
</div>
""")
with gr.Tab("🏠 Dashboard"):
gr.Markdown("""
### Career Brand Control Center
Fill the modules, run each assessment, then click **Refresh dashboard**. Scores are designed to be transparent coaching heuristics—not hiring guarantees.
""")
dashboard = gr.HTML(dashboard_html(0,0,0,0,0,0))
refresh_dashboard = gr.Button("Refresh dashboard", variant="primary")
gr.Markdown("""
**Privacy-first design:** this Space does not require an account or database. Your profile is held in the current app session; use **Portfolio → Export JSON** to keep a portable copy.
""")
with gr.Tab("1️⃣ Positioning"):
gr.Markdown("## Strategic Positioning\nDefine the professional identity that every later section should support.")
with gr.Row():
target_role = gr.Textbox(label="Target role / position", placeholder="e.g., Robotics Engineer")
industry = gr.Textbox(label="Target industry / sector", placeholder="e.g., Industrial Automation")
value_prop = gr.Textbox(label="Professional value proposition", lines=3, placeholder="What problems can you solve, for whom, and with what strengths?")
strengths = gr.Textbox(label="Top strengths", placeholder="Problem solving, systems thinking, communication, leadership")
goals = gr.Textbox(label="12–24 month career goals", lines=3)
with gr.Row():
generate_vp = gr.Button("✨ Draft value proposition")
score_positioning_btn = gr.Button("Assess positioning", variant="primary")
positioning_score_num = gr.Number(value=0, visible=False)
positioning_result = gr.Markdown()
with gr.Tab("2️⃣ Skills & Employability"):
gr.Markdown("""
## Role-Skill Gap Analysis
The app compares your skills against a transparent role map. For custom roles, it uses a general professional-skills baseline.
""")
skills = gr.Textbox(
label="Skills (comma separated)",
lines=4,
placeholder="Python, ROS, C++, Control Systems, Computer Vision, Git..."
)
analyze_skills_btn = gr.Button("Analyze skill alignment", variant="primary")
skill_gap_output = gr.Markdown()
gr.Markdown("### Employability Readiness\nRun the other module assessments first for the most meaningful score.")
employ_btn = gr.Button("Calculate employability readiness", variant="primary")
employ_score_num = gr.Number(value=0, visible=False)
employ_output = gr.Markdown()
with gr.Tab("3️⃣ CV Builder"):
gr.Markdown("## ATS-Conscious CV Builder\nCreate a clean CV and receive a transparent readiness check.")
with gr.Row():
cv_name = gr.Textbox(label="Full name")
cv_title = gr.Textbox(label="Professional title")
with gr.Row():
cv_email = gr.Textbox(label="Email")
cv_phone = gr.Textbox(label="Phone")
with gr.Row():
cv_linkedin = gr.Textbox(label="LinkedIn URL")
cv_website = gr.Textbox(label="Portfolio / GitHub / website")
cv_summary = gr.Textbox(label="Professional summary", lines=5)
generate_summary_btn = gr.Button("✨ Draft summary from profile")
cv_experience = gr.Textbox(
label="Experience",
lines=9,
placeholder="One achievement per line. Example: Automated X process, reducing turnaround time by 30%."
)
cv_education = gr.Textbox(label="Education", lines=4)
cv_projects = gr.Textbox(label="Projects", lines=6)
cv_publications = gr.Textbox(label="Publications / research (optional)", lines=4)
with gr.Row():
ats_btn = gr.Button("Check ATS-style readiness", variant="primary")
cv_pdf_btn = gr.Button("Generate CV PDF")
ats_score_num = gr.Number(value=0, visible=False)
ats_output = gr.Markdown()
cv_pdf_file = gr.File(label="Download CV PDF")
with gr.Tab("4️⃣ LinkedIn"):
gr.Markdown("## LinkedIn Profile Builder\nKeep the profile consistent with your target role and CV.")
li_headline = gr.Textbox(label="Professional headline", max_lines=2)
li_about = gr.Textbox(label="About section", lines=10)
li_url = gr.Textbox(label="Custom LinkedIn URL")
with gr.Row():
li_headline_btn = gr.Button("✨ Draft headline")
li_about_btn = gr.Button("✨ Draft About section")
li_check = gr.CheckboxGroup(choices=LINKEDIN_ITEMS, label="Profile checklist")
li_score_btn = gr.Button("Assess LinkedIn readiness", variant="primary")
li_score_num = gr.Number(value=0, visible=False)
li_result = gr.Markdown()
with gr.Tab("5️⃣ Network"):
gr.Markdown("## Professional Network Map\nEdit the table directly; one row per relationship.")
network_df = gr.Dataframe(
value=dataframe_default(),
headers=["Name", "Category", "Next action", "Status"],
datatype=["str","str","str","str"],
row_count=(1, "dynamic"),
column_count=(4, "fixed"),
label="Network contacts"
)
network_goals = gr.CheckboxGroup(choices=NETWORK_GOALS, label="Networking goals")
network_score_btn = gr.Button("Assess network-building", variant="primary")
network_score_num = gr.Number(value=0, visible=False)
network_result = gr.Markdown()
with gr.Tab("6️⃣ Digital Audit"):
gr.Markdown("## Digital Footprint Audit\nReview security, consistency, professionalism and proof of work.")
digital_check = gr.CheckboxGroup(choices=DIGITAL_ITEMS, label="Completed checks")
digital_score_btn = gr.Button("Assess digital footprint", variant="primary")
digital_score_num = gr.Number(value=0, visible=False)
digital_result = gr.Markdown()
with gr.Tab("7️⃣ 30-Day Plan"):
gr.Markdown("## Personalized 30-Day Career Brand Sprint")
plan_btn = gr.Button("Generate 30-day plan", variant="primary")
plan_output = gr.Markdown()
with gr.Tab("8️⃣ Portfolio"):
gr.Markdown("""
## Portable Personal Brand Portfolio
Export JSON to continue later or move between devices. Export PDF for a human-readable portfolio.
""")
with gr.Row():
export_json_btn = gr.Button("Export JSON", variant="primary")
export_pdf_btn = gr.Button("Export Portfolio PDF")
with gr.Row():
json_file_out = gr.File(label="Portfolio JSON")
portfolio_pdf_out = gr.File(label="Portfolio PDF")
gr.Markdown("### Continue from an earlier export")
import_file = gr.File(label="Load OpenBrand JSON", file_types=[".json"], type="filepath")
import_btn = gr.Button("Load portfolio")
import_status = gr.Markdown()
with gr.Tab("ℹ️ About"):
gr.Markdown("""
## Why OpenBrand AI?
OpenBrand AI is an open-source, privacy-conscious personal-branding and employability toolkit designed for students, job seekers, educators and career-development programs.
**Core principles**
- Transparent scoring instead of opaque “AI says so” ratings.
- Works without paid APIs.
- Portable JSON data export/import.
- Role-skill gap mapping and a practical 30-day plan.
- ATS-conscious CV checks and PDF generation.
- Deployable as a Hugging Face Gradio Space.
- Easy to fork, translate and extend.
**Important:** employability, ATS and readiness scores are coaching heuristics. They are not validated psychometric instruments and do not predict hiring outcomes.
""")
# ---- Derived analyses ----
def analyze_skill_ui(role, skill_text):
required, matched, missing, coverage = skill_gap(role, skill_text)
return (
f"### Role-skill coverage: **{coverage}%**\n"
f"**Matched:** {', '.join(matched) if matched else 'None yet'}\n\n"
f"**Priority gaps:** {', '.join(missing) if missing else 'No mapped gaps'}\n\n"
f"**Reference skill map:** {', '.join(required)}"
)
generate_vp.click(
generate_value_proposition,
inputs=[target_role, industry, strengths, skills],
outputs=value_prop
)
score_positioning_btn.click(
positioning_feedback,
inputs=[target_role, industry, value_prop, strengths, goals],
outputs=[positioning_score_num, positioning_result]
)
analyze_skills_btn.click(
analyze_skill_ui,
inputs=[target_role, skills],
outputs=skill_gap_output
)
generate_summary_btn.click(
generate_summary,
inputs=[cv_name, cv_title, target_role, industry, strengths, skills, goals],
outputs=cv_summary
)
ats_btn.click(
ats_score,
inputs=[
cv_name, cv_email, cv_phone, cv_title, cv_summary,
cv_experience, cv_education, cv_projects, skills, target_role
],
outputs=[ats_score_num, ats_output]
)
cv_pdf_btn.click(
create_cv_pdf,
inputs=[
cv_name, cv_title, cv_email, cv_phone, cv_linkedin, cv_website,
cv_summary, cv_experience, cv_education, cv_projects, cv_publications, skills
],
outputs=cv_pdf_file
)
li_headline_btn.click(
linkedin_headline,
inputs=[target_role, industry, skills, value_prop],
outputs=li_headline
)
li_about_btn.click(
linkedin_about,
inputs=[cv_name, target_role, industry, value_prop, strengths, skills, goals],
outputs=li_about
)
li_score_btn.click(
linkedin_score,
inputs=[li_headline, li_about, li_url, li_check],
outputs=[li_score_num, li_result]
)
network_score_btn.click(
network_score,
inputs=[network_df, network_goals],
outputs=[network_score_num, network_result]
)
digital_score_btn.click(
digital_score,
inputs=[digital_check],
outputs=[digital_score_num, digital_result]
)
employ_btn.click(
employability_assessment,
inputs=[
target_role, skills, cv_experience, cv_projects,
positioning_score_num, ats_score_num, li_score_num,
network_score_num, digital_score_num
],
outputs=[employ_score_num, employ_output]
)
plan_btn.click(
action_plan,
inputs=[
target_role, skills, ats_score_num, li_score_num,
network_score_num, digital_score_num
],
outputs=plan_output
)
refresh_dashboard.click(
dashboard_html,
inputs=[
positioning_score_num, ats_score_num, li_score_num,
network_score_num, digital_score_num, employ_score_num
],
outputs=dashboard
)
portfolio_inputs = [
target_role, industry, value_prop, strengths, goals,
cv_name, cv_title, cv_email, cv_phone, cv_linkedin, cv_website,
cv_summary, cv_experience, cv_education, cv_projects, cv_publications, skills,
li_headline, li_about, li_url, li_check,
network_df, network_goals, digital_check
]
export_json_btn.click(save_json, inputs=portfolio_inputs, outputs=json_file_out)
export_pdf_btn.click(save_portfolio_pdf, inputs=portfolio_inputs, outputs=portfolio_pdf_out)
import_outputs = [
target_role, industry, value_prop, strengths, goals,
cv_name, cv_title, cv_email, cv_phone, cv_linkedin, cv_website,
cv_summary, cv_experience, cv_education, cv_projects, cv_publications, skills,
li_headline, li_about, li_url, li_check,
network_df, network_goals, digital_check, import_status
]
import_btn.click(import_profile, inputs=import_file, outputs=import_outputs)
if __name__ == "__main__":
demo.launch(css=CSS)
|