Become a Pro / website · becomeapro.ai / src / lib / roadmap.ts
| 1 | // Builds a user's roadmap from their onboarding answers and the site's published tutorials. |
| 2 | // Pure and client-safe, so the roadmap updates by itself as tutorials are added. |
| 3 | import { GOALS, WEEKLY_TIMES, type GoalId, type LearningProfile } from "@/lib/onboarding"; |
| 4 | import { getTrack, type TrackSlug } from "@/lib/tracks"; |
| 5 | import { tutorialKey, type Level, type TutorialMeta } from "@/lib/tutorial-types"; |
| 6 | |
| 7 | export type RoadmapStep = { |
| 8 | tutorial: TutorialMeta; |
| 9 | key: string; |
| 10 | // Why it's on the roadmap, e.g. "Make AI video" |
| 11 | reason: string; |
| 12 | }; |
| 13 | |
| 14 | export type RoadmapPhase = { |
| 15 | level: Level; |
| 16 | title: string; |
| 17 | summary: string; |
| 18 | // True when the phase sits below the user's level: worth a skim, not required |
| 19 | optional: boolean; |
| 20 | steps: RoadmapStep[]; |
| 21 | minutes: number; |
| 22 | weeks: number; |
| 23 | milestone: string; |
| 24 | }; |
| 25 | |
| 26 | export type Roadmap = { |
| 27 | tracks: TrackSlug[]; |
| 28 | phases: RoadmapPhase[]; |
| 29 | totalSteps: number; |
| 30 | totalMinutes: number; |
| 31 | }; |
| 32 | |
| 33 | const RANK: Record<Level, number> = { Beginner: 0, Intermediate: 1, Advanced: 2 }; |
| 34 | |
| 35 | const PHASES: Record<Level, { title: string; summary: string; skim: string }> = { |
| 36 | Beginner: { |
| 37 | title: "Foundations", |
| 38 | summary: "Get set up and finish a first real task.", |
| 39 | skim: "Skim these if you already know the basics. They set up what comes next.", |
| 40 | }, |
| 41 | Intermediate: { |
| 42 | title: "Build", |
| 43 | summary: "Turn the basics into workflows you can repeat.", |
| 44 | skim: "Quick refreshers before the advanced material.", |
| 45 | }, |
| 46 | Advanced: { |
| 47 | title: "Go further", |
| 48 | summary: "Push the tools to their limits on your own projects.", |
| 49 | skim: "", |
| 50 | }, |
| 51 | }; |
| 52 | |
| 53 | // What finishing a phase in each track looks like |
| 54 | const MILESTONES: Record<TrackSlug, Record<Level, string>> = { |
| 55 | claude: { |
| 56 | Beginner: "Claude Code runs in your project and follows a CLAUDE.md you wrote", |
| 57 | Intermediate: "Claude handles multi-step work with the tools you've connected", |
| 58 | Advanced: "You run Claude agents on tasks end to end", |
| 59 | }, |
| 60 | chatgpt: { |
| 61 | Beginner: "Codex works in your repo with an AGENTS.md to guide it", |
| 62 | Intermediate: "Codex finishes tasks on its own and you review the result", |
| 63 | Advanced: "Codex runs parallel cloud tasks across your projects", |
| 64 | }, |
| 65 | "computer-use": { |
| 66 | Beginner: "An agent completes a browser task while you watch", |
| 67 | Intermediate: "You hand an agent repeat chores with guardrails in place", |
| 68 | Advanced: "Agents drive real apps for you, with a human check where it matters", |
| 69 | }, |
| 70 | "ai-video": { |
| 71 | Beginner: "You have a GPU pod running and know what it costs", |
| 72 | Intermediate: "You generate clips with an open model you chose", |
| 73 | Advanced: "You tune models and workflows for your own style", |
| 74 | }, |
| 75 | }; |
| 76 | |
| 77 | function goalFor(t: TutorialMeta, goals: GoalId[]): string { |
| 78 | const goal = GOALS.find((g) => goals.includes(g.id) && g.id !== "current" && g.tracks.includes(t.track)); |
| 79 | return goal?.label ?? getTrack(t.track)?.name ?? t.track; |
| 80 | } |
| 81 | |
| 82 | function score(t: TutorialMeta, p: LearningProfile): number { |
| 83 | let s = 0; |
| 84 | if (t.video && p.format === "video") s += 2; |
| 85 | if (!t.video && p.format === "written") s += 2; |
| 86 | if (t.video) s += 1; |
| 87 | // Earlier-chosen tracks first |
| 88 | s -= p.tracks.indexOf(t.track) * 0.5; |
| 89 | return s; |
| 90 | } |
| 91 | |
| 92 | export function buildRoadmap(profile: LearningProfile, tutorials: TutorialMeta[]): Roadmap { |
| 93 | const tracks = profile.tracks.length ? profile.tracks : GOALS.flatMap((g) => g.tracks); |
| 94 | const pool = tutorials.filter((t) => !t.draft && tracks.includes(t.track)); |
| 95 | const userRank = RANK[profile.level]; |
| 96 | const weekly = WEEKLY_TIMES.find((w) => w.id === profile.weeklyTime)?.minutes ?? 180; |
| 97 | |
| 98 | const phases = (Object.keys(RANK) as Level[]) |
| 99 | .map((level): RoadmapPhase | null => { |
| 100 | const steps = pool |
| 101 | .filter((t) => t.level === level) |
| 102 | .sort((a, b) => score(b, profile) - score(a, profile) || a.minutes - b.minutes) |
| 103 | .map((t) => ({ tutorial: t, key: tutorialKey(t), reason: goalFor(t, profile.goals) })); |
| 104 | if (steps.length === 0) return null; |
| 105 | const optional = RANK[level] < userRank; |
| 106 | const minutes = steps.reduce((sum, s) => sum + s.tutorial.minutes, 0); |
| 107 | // Practice time on top of the tutorials themselves: trying each one out takes about as long again |
| 108 | const weeks = Math.max(1, Math.ceil((minutes * 2) / weekly)); |
| 109 | const phaseTracks = tracks.filter((tr) => steps.some((s) => s.tutorial.track === tr)); |
| 110 | const milestone = phaseTracks.map((tr) => MILESTONES[tr][level]).join(". "); |
| 111 | const def = PHASES[level]; |
| 112 | return { |
| 113 | level, |
| 114 | title: optional ? `${def.title} (refresher)` : def.title, |
| 115 | summary: optional ? def.skim : def.summary, |
| 116 | optional, |
| 117 | steps, |
| 118 | minutes, |
| 119 | weeks, |
| 120 | milestone, |
| 121 | }; |
| 122 | }) |
| 123 | .filter((p): p is RoadmapPhase => p !== null); |
| 124 | |
| 125 | return { |
| 126 | tracks, |
| 127 | phases, |
| 128 | totalSteps: phases.reduce((n, p) => n + p.steps.length, 0), |
| 129 | totalMinutes: phases.reduce((n, p) => n + p.minutes, 0), |
| 130 | }; |
| 131 | } |