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"""
{label}
{score}/100
""" 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"""
CAREER BRAND CONTROL CENTER

{complete}% foundation complete

Improve each dimension, then regenerate your action plan and portfolio.

{cards}
""" 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"{k}", styles["PSmall"]), Paragraph(str(v).replace("\n", "
"), 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"""
OPEN SOURCE • HUGGING FACE SPACES • {APP_VERSION}

OpenBrand AI

Build a credible professional brand from career positioning to CV, LinkedIn, networking, digital footprint, employability readiness and an exportable portfolio.

""") 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)