You have inherited a repository.
🎁 What You Inherit
A Next.js portfolio with seven views (Hero, About, Projects, Experience, Skills, Stats, Contact) and a dual-engine AI Guide. Everything reads from a single source of truth: src/lib/data.ts (CONFIG).
Stack: Next.js, WebGPU (optional), Web Speech API, ElevenLabs TTS proxy, Vercel.
⚡ TL;DR
Traditional portfolios make visitors hunt through static pages. This one is a conversation: ask by text or voice, get instant answers, and optionally turn on an in-browser LLM that runs on the visitor's GPU. The design constraint was that the AI must never be the only path to an answer. A deterministic intent engine answers in single-digit milliseconds on any device. The WebGPU model is a progressive upgrade on top.
🎉 Fun Things You Can Do
- ✨ Make your portfolio answer questions out loud - visitors ask, it speaks back
- ✨ Turn on a local AI that runs on the visitor's GPU (no server bill)
- ✨ Navigate your own site by voice: "show me your projects"
- ✨ Watch a 1.5B model stream a personalized explanation of your work in real time
- ✨ Works offline after first load - share the link, it just works
🤔 The Problem
Traditional portfolios make visitors hunt through static pages to find projects, tech stacks, or experience. I wanted mine to be a conversation. Two hard requirements shaped it:
- It must work on a recruiter's locked-down laptop. No API keys, no backend LLM bill, no CORS surprises. If the site needs a server to answer questions, it will break exactly when someone is evaluating it.
- It must answer before the visitor loses interest. A 1.5B model loading ~950 MB of weights is not a first-paint experience.
🏗️ Architecture
sequenceDiagram
participant V as Visitor
participant R as Command router
participant E1 as Engine 1 (patterns)
participant W as Web Worker
participant E2 as Engine 2 (Qwen 1.5B)
participant T as TTS
V->>R: text or speech
R->>E1: normalise + score intents
E1-->>V: answer + suggestion chips (~0-5 ms)
opt Local AI enabled
R->>W: messages + system prompt
W->>E2: stream completions
E2-->>W: token deltas
W-->>V: progressive text (~1 s to first token)
end
V->>T: click speak (never automatic)
The two engines run in parallel rather than in sequence. Engine 1's answer appears immediately; Engine 2's stream replaces/enriches it underneath. If Engine 2 fails, nothing breaks — the fast answer is already on screen.
📁 Project Layout
your-portfolio/
├── src/
│ ├── app/ # 7 routes: / /about /projects /experience /skills /stats /contact
│ │ ├── api/tts/route.ts # ElevenLabs proxy (key stays server-side)
│ │ ├── layout.tsx
│ │ ├── sitemap.ts
│ │ └── robots.ts
│ ├── components/ # layout, view shells, chat dock
│ ├── hooks/
│ ├── lib/
│ │ ├── data.ts # CONFIG — single source of truth
│ │ ├── experience-model.ts # CAREER_STATES, VIEW_GOALS
│ │ ├── fallback-engine.ts # Engine 1: 17 intents, 0 deps
│ │ ├── worker.ts # Engine 2: WebGPU Web Worker
│ │ └── types.ts
│ └── types/
├── e2e/ # Playwright
├── public/
└── scripts/
💡 Core Ideas
Engine 1: weighted intent scoring
Each intent declares keywords, optional exclusive terms that veto a false positive, a weight, and an answer function:
Scoring is deliberately boring: normalise, filter short tokens, count hits, multiply by weight, sort, keep the top three.
The exclusive list is the part that earns its keep. A question like "do you have contact experience?" contains contact, but it is about work history. The contact intent lists experience as exclusive, so it is disqualified and experience_career wins instead. Without that guard, keyword counting always loses to the loudest word.
The 17 intents: resume_cv, greeting, who_is, hire_synthesis, strengths_qualities, project_detail, projects_overview, skill_lookup, compare, role_fit, contact, experience_career, recruiter_path, skills_tools, education_certs, languages, vision_principles.
Engine 2: a Web Worker that streams tokens
The model runs off the main thread, inside a worker. The worker owns the model instance and posts five message types back: progress, ready, stream, complete, error.
Three details worth copying:
-
Singleton with a promise guard.
CreateMLCEngineis expensive and non-idempotent. The static instance means N messages share one model load. -
stream: true+ accumulate. Posting the full text each time (not just the delta) keeps the UI stateless — the component renders the last message it received. -
warmupmessage. The UI fires this when the visitor opts in, so the progress bar starts before they ask a question.
The system prompt is a contract, not a vibe
The local model is pinned to portfolio facts. It is told to decline code generation and to speak about the portfolio owner in the third person. It must keep answers under 150 words and emit a single navigation command on its own line:
INITIATING_NAVIGATION: projects
The UI parses that trailing line and drives the router. This is a small, reliable alternative to function calling that works with a 1.5B model.
Voice: opt-in, always
Speech-to-text uses the browser's Web Speech API. Text-to-speech goes through /api/tts (an ElevenLabs proxy, so the key never reaches the bundle) and falls back to SpeechSynthesis when the proxy is unconfigured or rate-limited. Audio never auto-plays; the visitor clicks a speaker icon per response.
🔄 Pipeline / Flow
- Visitor asks a question (text or voice).
- Command router + AI Guide handle guided navigation if the question is a command.
- Engine 1 returns an answer in 0–5 ms with follow-up suggestion chips.
- If Local AI is enabled, Qwen streams a deeper, context-aware explanation underneath.
- The system prompt embeds a local context pack (
buildContextPack) built fromCONFIGfor the active view, so the model answers about this portfolio, not generic knowledge.
🧭 Key Decisions
- Fallback-first dual engine. Engine 1 answers instantly on every device; Engine 2 is an optional deep upgrade. The baseline stays fast for everyone.
- Cooperative streaming. Even with Local AI on, the instant engine answers first while Qwen streams a deeper explanation underneath.
- Single CONFIG. Both the seven UI views and the local AI prompt reflect updates with zero duplicate editing.
- WebGPU in a secure context only. HTTPS or localhost required; the app degrades gracefully otherwise.
- Audio never auto-plays. The visitor is always in control.
-
Static export.
NEXT_OUTPUT=export npm run buildproduces a bundle for GitHub Pages or Cloudflare Pages.
🚫 Mistakes I Avoided
- Gating the baseline on WebGPU. The instant engine works on every device; WebGPU is a progressive upgrade.
- Auto-playing audio. TTS is opt-in per response.
-
Duplicated content. A single
CONFIGfeeds both UI and AI prompt. - Assuming model load is fast. A progress callback + a warmup message make the 950 MB download visible instead of looking like a hang.
- Letting the small model roam. A pinned system prompt plus a hard word limit keeps a 1.5B model from inventing credentials.
🔨 Recreate It
- [ ] Define
CONFIGinsrc/lib/data.ts(profile, projects, experience, skills, heroStats). - [ ] Build the 7 routes; each one renders from
CONFIGonly. - [ ] Write
IntentPattern+ the 17 intents withkeywords,exclusive,weight,answer. - [ ] Implement the scorer: normalise → tokenise → weight → sort → top 3.
- [ ] Add the command router for
INITIATING_NAVIGATION:and direct "show me X" requests. - [ ] Create the Web Worker with a singleton
CreateMLCEngine+initProgressCallback. - [ ] Stream with
stream: true, post the accumulated text, and handleerrorwithout killing the UI. - [ ] Build
buildContextPack(userText, activeView, profile, memory)and inject it into the system prompt. - [ ] Add
/api/ttsproxy +SpeechSynthesisfallback; require a click before any audio. - [ ] Add an in-app toggle for Local AI; persist it; only then request
warmup. - [ ] Verify static export:
NEXT_OUTPUT=export npm run buildand serveout/over HTTP.
🚀 Quick Start
git clone <your-repo-url> portfolio
cd portfolio
npm install
npm run dev # → http://localhost:3000
Customize: edit src/lib/data.ts (CONFIG.name, taglines, profile, projects, experience, skills).
Optional: add ELEVENLABS_API and ELEVENLABS_VOICE_ID to .env for neural TTS. Static export: NEXT_OUTPUT=export npm run build.
✅ Verification
- WebGPU requires a secure context (HTTPS or localhost).
- TTS is rate-limited; the fallback keeps it working.
- Engine 1: ask "who is the developer" with Local AI off — expect an answer and chips in under 10 ms.
- Engine 2: enable Local AI and confirm the progress callback reports percentages, not a frozen spinner.
- Voice: confirm no audio plays until the speaker icon is clicked.
📌 Takeaways
- Fallback-first beats "works only on high-end devices."
- A single CONFIG beats duplicated content across views and prompts.
- Exclusive keyword vetoes matter more than keyword counts.
- Progressive enhancement (voice, LLM) keeps the baseline fast for everyone.
🔗 Links
Repo: MyPortfolio-AI (private)
Related posts: Building a Fully Local RAG App Over 6,000 German Federal Laws, One Pane of Glass for Windows: Local AI, Zero Telemetry


Top comments (0)