import { useState } from "react"; import "./App.css"; const API = import.meta.env.VITE_API_URL || (import.meta.env.PROD ? "" : "http://localhost:8000"); const EXAMPLES = [ "Become a Data Scientist", "Switch from Marketing to Product Management", "Become a Full Stack Developer", "Break into AI/ML Engineering", "Become a UX Designer", ]; const LOADING_MESSAGES = [ "Mapping your career path...", "Building your steps...", "Crafting macro & micro views...", "Adding nano-level tasks...", "Almost ready...", ]; const STEP_ACCENTS = ["#1a9e75", "#3b82f6", "#8b5cf6", "#f59e0b", "#ec4899", "#06b6d4"]; export default function App() { const [goal, setGoal] = useState(""); const [loading, setLoading] = useState(false); const [loadingMsg, setLoadingMsg] = useState(""); const [data, setData] = useState(null); const [error, setError] = useState(""); const [activeStep, setActiveStep] = useState(null); async function generate(overrideGoal) { const g = (overrideGoal || goal).trim(); if (!g) return; setLoading(true); setError(""); setData(null); setActiveStep(null); let i = 0; setLoadingMsg(LOADING_MESSAGES[0]); const interval = setInterval(() => { i = (i + 1) % LOADING_MESSAGES.length; setLoadingMsg(LOADING_MESSAGES[i]); }, 1800); try { const res = await fetch(`${API}/api/path`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ goal: g }), }); const json = await res.json(); if (!res.ok) throw new Error(json.detail || "Something went wrong"); setData(json); } catch (e) { setError( e.message.includes("fetch") ? "Cannot connect to backend. Run: uvicorn main:app --reload --port 8000" : e.message ); } finally { clearInterval(interval); setLoading(false); } } function openSearch(query) { const url = `https://www.google.com/search?q=${encodeURIComponent(query)}`; window.open(url, "_blank", "noopener,noreferrer"); } async function copyNanoTask() { if (!activeStep?.nano?.what_you_do) return; await navigator.clipboard.writeText(activeStep.nano.what_you_do); } function handleKey(e) { if (e.key === "Enter") generate(); } function handleChip(ex) { setGoal(ex); generate(ex); } function openStep(step) { setActiveStep(step); } function closeStep() { setActiveStep(null); } const activeIdx = activeStep ? data?.steps.findIndex((s) => s.id === activeStep.id) : -1; const activeAccent = activeIdx >= 0 ? STEP_ACCENTS[activeIdx % STEP_ACCENTS.length] : "#1a9e75"; return (
{/* ── Nav ── */} {/* ── Hero ── */} {!data && !loading && (

Education and Career Path Engine

Turn an education goal into a{" "} step-by-step path.

Enter a career, exam, or skill goal. Naaviverse maps the macro strategy, micro skills, and nano tasks.

)} {/* ── Input ── */}
setGoal(e.target.value)} onKeyDown={handleKey} placeholder="e.g. Become a Data Scientist" disabled={loading} />
{EXAMPLES.map((ex) => ( ))}
{/* ── Loading ── */} {loading && (

{loadingMsg}

)} {/* ── Error ── */} {error &&
⚠ {error}
} {/* ── Result ── */} {data && (
{/* Path header — always visible */}

{data.path_name}

{data.path_description}

{data.total_steps} TOTAL STEPS
{/* ══ MODE A: Step grid (no active step) ══ */} {!activeStep && (
ALL STEPS
{data.total_steps} Steps · click any to explore
{data.steps.map((step, idx) => { const accent = STEP_ACCENTS[idx % STEP_ACCENTS.length]; return ( ); })}
)} {/* ══ MODE B: Expanded view (active step) ══ */} {activeStep && (
{/* Top bar: back + step number pills */}
{/* Step intro */}
Step {activeStep.id} of {data.total_steps}

{activeStep.title}

{activeStep.description}

{/* 3 view cards */}
MACRO VIEW FREE

{activeStep.macro.title}

WHY THIS STEP MATTERS

{activeStep.macro.why_it_matters}

MICRO VIEW MICRO PLAN

{activeStep.micro.title}

HOW IT'S DONE

{activeStep.micro.how_its_done}

NANO VIEW NANO PLAN

{activeStep.nano.title}

LIVE MENTOR GUIDANCE

{activeStep.nano.what_you_do}

{/* Disabled: users should return to All Steps before opening another step.
*/}
)} {/* Footer */}
)}
); }