Skip to main content
Skip to main content
Version 2 · Technical Deep Dive~10 min read

AI Resume Assistant v2: Ten Months in Production

The first version answered questions about my experience. This one has been reviewed against seven months of real visitor conversations, and it's more honest, more repeatable and much harder to break.

Nyiko Shabangu

Nyiko Shabangu

AI Engineer • • follows version 1

What the chat logs showed

Every conversation since April 2026 is logged, with personal details redacted. Reading those logs end to end, alongside a full code review, turned up four problems that no unit test had caught:

Answers with no sources

Some ordinary questions came back with zero retrieved notes, so the model answered from general knowledge instead of my actual experience.

Inflated job-fit scores

Scores drifted between runs for the same job description and listed gaps that my CV actually covers.

Raw errors reached visitors

Provider messages such as token-per-minute limits were shown to visitors as-is.

A slow tail

Most answers were quick, but some took 20 to 39 seconds: longer than the 25 seconds the site's proxy waits for a first byte.

The architecture today

It's still Retrieval-Augmented Generation on serverless infrastructure, but every hop now has a job: the proxy guards the API key and the visitor's identity, the backend enforces limits and time budgets, and every answer leaves a trace you can price and rate.

AI Resume Assistant architecture, version 2 (November 2026)The browser on www.nyiko.co.za sends chat, voice, job-fit and reaction requests to a same-origin Vercel proxy. The proxy only forwards allow-listed routes, injects the server-side API key, replaces X-Client-IP with the real visitor IP and signs it with HMAC-SHA256 over the method, path, IP and a timestamp, and applies its own per-route limits within Vercel's 25 second first-byte window. The FastAPI backend on Vercel checks the API key (failed keys are throttled per IP), trusts the visitor IP only if its signature verifies within 60 seconds and otherwise uses the socket address, applies per-route rate limits stored atomically in Upstash Redis, adds security headers to every response, and keeps every JSON route under a 24 second budget. Both the proxy and the backend fail over to a backup Upstash database in the same region on timeouts, server errors or auth and quota errors. A chat answer then goes through five steps: 1 load session history from Upstash, where turns are kept for 30 days and older turns are folded into a short topics-only summary once the history would pass 450 tokens; 2 embed the question with Gemini gemini-embedding-001 at 384 dimensions, cached in Upstash, failing over to a backup key from a second Google project that returns the same vectors; 3 search Supabase pgvector (HNSW index) with match_documents and a minimum similarity of 0.30; 4 build the prompt with trusted notes outside a context block that holds the retrieved CV text as data; 5 generate with Groq gpt-oss-20b, falling back to gpt-oss-120b when rate limited. The answer is streamed to the browser followed by its sources, with links checked against an allowlist. Alongside chat, job-fit analysis parses PDFs, text or links with size, page and time limits, fetches links only from validated public IPs, and scores against a fixed rubric at temperature 0 with the total computed in code. Contact requests are detected and stored as leads. Voice uses Groq Whisper for speech to text and ElevenLabs with an Edge TTS fallback, capped at 2,200 characters. After each answer the backend writes a chat_logs row with personal details redacted, stage timings and token cost; leads go to a leads table or webhook; thumbs up or down go to chat_reactions; errors go to Sentry with secrets scrubbed and analytics to PostHog without raw text.Browser (React)www.nyiko.co.zachat · voice · job fitthumbs up / downVercel proxyroute allowlistinjects X-API-Key (server only)signs X-Client-IP (HMAC-SHA256)own limits · backup Redis · 25 sFastAPI on Vercel (Python)API key (constant time) + failed-key throttlesigned IP verified within 60 s, else socket addressper-route limits in Upstash (Lua) · backup DB failoverfail-closed env · security headers · JSON routes < 24 sCHAT ANSWERSession history · Upstashsummary once over 450 tokensEmbed the questionGemini embedding-001 · 384 dimsbackup key, same vectors · cachedVector searchpgvector HNSW · min sim 0.30Build the prompttrusted notes outside <context>retrieved CV text = data onlyGenerate (Groq)gpt-oss-20b, low reasoning429 → gpt-oss-120b fallback12345Answer → browserstreamed tokens, then [[SOURCES]] · links checked against an allowlist · friendly errorsALSO BEHIND THE SAME GATEJob-fit analysis (PDF · text · link)bounded parsing: bytes, pages, characters and timelinks fetched only from validated public IPs, ports 80/443rubric v1: skills .45 · experience .20 · domain .20 · extras .15temperature 0 + fixed seed · total computed in codegaps the CV contradicts are droppedContact requestsspots contact details and CV requestshonest reply: never promises to send a CVlead saved to the leads table and/or a webhookVoicespeech to text: Groq Whisper (async jobs)speech: ElevenLabs → Edge TTS fallback · 2,200-char capFood bot demo (separate case study)Dialogflow → MCP server, own limits and circuit breakerAFTER EACH ANSWERchat_logsPII redactedstage timingstoken cost (USD)leadsservice role onlyor webhookchat_reactionsup / down + commentowner session onlySentry · PostHogsecrets scrubbedno raw chat textrelease = commit
November 2026: Vercel proxy → FastAPI → five-step chat pipeline, with job fit, contact requests and voice behind the same gate. On small screens the diagram scrolls sideways.
What changed in the stack between version 1 and version 2
Partv1v2
LLMGroq · Llama 3.1Groq · gpt-oss-20b, gpt-oss-120b on rate limit
EmbeddingsHugging Face, other providers as fallbackGemini embedding-001 (384) only, backup key from a 2nd project
Rate limitingSlowAPI, in memoryPer-route buckets in Upstash Redis, atomic Lua, backup database failover
Conversation memoryNot covered in v1Every turn in Redis for 30 days, older turns folded into a short summary
Vector searchSupabase pgvector, IVFFlat indexSupabase pgvector, HNSW index, extension in its own schema
CachingLRU cacheUpstash, key includes the model
Vercel proxyNot covered in v1Route allowlist, server-side key, signed visitor IP
API responsesNot covered in v1Security headers on every response
ObservabilityLogsSentry, PostHog, chat_logs timings, token cost, reactions

How it got here

The year in short, from the backend's commit history:

  1. Jan–Feb 2026

    Rebuilt the backend as FastAPI on Vercel: API-key auth, CORS, provider configuration.

  2. Mar 2026

    Sentry and PostHog, the keep-alive cron, and job analysis from a link as well as a PDF.

  3. Apr 2026

    The big refactor: modular routes with ports and adapters, domain errors with request ids, Upstash for sessions and rate limits, token budgets, sources in stream headers, chat logging to Supabase, job-fit score breakdowns and timeouts, and voice (speech to text plus ElevenLabs with an Edge TTS fallback).

  4. May–Jun 2026

    Refactored the RAG service and added route-wiring integration tests.

  5. Aug 2026

    Updated the LLM setup and fixed truncated and weak answers.

  6. Oct 2026

    FAQ rules, a contact fast path and a re-embedding script.

  7. Nov 2026

    Added the food bot demo, then a full review of the chat logs and the code: the hardening described below, plus per-answer cost and thumbs up or down, and a reseed of the knowledge base from the whole site and the 2026 CV. The month closed with a signed visitor IP, a backup Redis database, security headers on the API and history compaction, all live in production.

What changed, and why

The real reason some answers had no sources

When the Gemini embedding call failed, the old code quietly fell back to Cloudflare or Hugging Face models. They also produce 384-dimensional vectors, so nothing crashed, but their vectors live in a different space from the stored documents. Cosine similarity against the knowledge base dropped below the threshold and retrieval returned nothing.

Queries now use exactly one embedding model, the cache key includes the model name, and the seed scripts record which model embedded each row. I re-embedded a sample from every source with the live model and compared it with what was stored: each one came back with a cosine of 1.0000, so the 51 chunks stored at the time didn't need re-embedding. For resilience there is a backup key from a second Google project instead of a second model. Same model, same vectors, separate quota.

When nothing relevant is found, the bot is now told so explicitly, so it says it doesn't have that information instead of improvising.

Job-fit scoring you can repeat

The model no longer invents a single score. It fills in a rubric (required skills 45%, experience 20%, domain 20%, nice-to-haves 15%) at temperature 0 with a fixed seed, and the total is computed in code. Each skill comes with the evidence from the job and from my CV, and gaps that the CV contradicts are dropped.

The response keeps every existing field and adds score_breakdown and rubric_version. In testing, the same job description scored exactly the same on repeated runs.

Time budgets that fit the edge

The function itself may run for 60 seconds, but browser traffic passes through a proxy that gives up if no first byte arrives within 25 seconds. So every JSON route has a budget under 24 seconds: 4 s for the embedding, 4 s for the vector search, 15 s for an LLM call, 23 s for a whole analysis. Streaming chat starts sending early, so it isn't affected. A test fails if anyone raises a budget past the limit.

A knowledge base that covers the whole site

The site is a React app, so the old seeder only ever saw the shared fallback text and stored every page with the same content. Long pages were saved in one piece, but the chatbot only reads about 1,800 characters of each chunk, so most of a page was never used. The old sanitiser also deleted every number along with contact details, which removed results like latency and accuracy figures.

The seeder now reads each page's prerendered copy without the menu and footer, splits everything into chunks of at most 1,500 characters that keep their page title, and removes only emails and phone numbers. The knowledge base was reseeded from the whole site, the project list and the 2026 CV: 227 chunks from one seed run. The vector index moved from IVFFlat, which only probed about 1% of the rows, to HNSW, which searches all of them. A question about the Volkswagen benchmark went from no match to five sources.

Fallbacks that don't change the answer

Groq's free tier allows about 8,000 tokens a minute on gpt-oss-20b, and a burst of chats can use that up. Short retry-afters are retried; longer ones go straight to gpt-oss-120b, which has its own quota. On a test burst of six parallel questions, the rate-limited ones were answered by the fallback and every visitor got a real answer with sources.

Friendly messages replace raw provider errors, but the stream keeps the Error: marker the frontend relies on.

Limits sized to the model's real quota

gpt-oss-20b has a 131,072-token context window, but the free tier only allows 8,000 tokens a minute, so the per-minute quota is the limit that matters. Each answer call has a 2,600-token budget with completions capped at 600 tokens, retrieved notes are fitted to between 500 and 1,800 characters, and a visitor's message can be at most 500 characters.

Text to speech is capped at 2,200 characters, the longest possible answer, up from 1,000, so a full answer can be read aloud.

Long conversations without long prompts

Every turn is saved per session in Redis for 30 days. When the history replayed into a prompt would pass 450 tokens, the older turns are folded into a short rolling summary that keeps only the topics, written by gpt-oss-20b with a 5-second timeout. The summary goes into the context block and is treated as untrusted data, like the retrieved notes.

In a six-turn test against production, compaction ran on turn 5 in about 750 ms and the summary was used to answer turn 6.

A backup for Redis

Sessions, rate limits and caches all live in Upstash Redis, so both the backend and the proxy can now fail over to a second Upstash database. They switch on timeouts, 5xx responses and auth or quota errors, and a 30-second circuit breaker stops them hammering a database that is down. A transaction is never split across the two databases.

To be honest about its limits: every database is in the same AWS region (af-south-1), so this covers a database failing, not the whole region going down.

Security hardening

Unknown environments are treated as production, so API docs and the debug route are off and CORS never allows a wildcard in production. The API key is compared in constant time, and repeated wrong keys from one IP are throttled while the right key keeps working. Rate limits are per route and per visitor: the proxy strips any X-Client-IP a browser sends and sets the real one, then signs it with HMAC-SHA256 over the method, path, IP and a timestamp, using a secret separate from the API key. The backend only trusts the header if the signature checks out within 60 seconds either way; otherwise it uses the socket address. So even a caller holding the API key, but not the signing secret, can't choose their own bucket: a forged IP sent straight to the backend with the real key was ignored in a live test.

Every API response carries security headers: nosniff, HSTS, Referrer-Policy no-referrer, and X-Frame-Options DENY with a frame-ancestors 'none' policy, so the API can't be framed. The legacy Vercel routes configuration was removed so those header rules apply.

Link analysis resolves the host, blocks private and internal ranges, allows only ports 80 and 443, and connects to the exact IP it validated, with TLS still checked against the hostname. Bodies are streamed with a byte cap, and HTML is scanned in linear time. Uploads and PDF parsing have byte, page, character and time limits. Retrieved notes and job text are wrapped as data, and links in answers must be on an allowlist or come from my notes.

The Gemini key moved from the URL to a header, and logs and Sentry events are scrubbed of keys. Expected rejections, such as a link to a private IP being blocked, are logged as warnings rather than errors, so real errors stand out. The Supabase security advisor warnings are fixed: match_documents has a fixed search_path and the vector extension lives in its own schema. Dependencies were upgraded to current releases, with no known vulnerabilities reported as of 23 November 2026.

Knowing what each answer costs

Every Groq call made while answering is counted, streamed answers included, and priced from Groq's list prices. A typical chat answer is about 2,000 tokens, roughly $0.00014. Totals are stored with each chat log, and a daily view adds up requests, tokens and cost, leaving out test traffic.

Asking visitors how it did

The thumbs under each answer now save a reaction (and an optional comment, with personal details redacted). A reaction is tied to the answer's request id and session, so nobody can change someone else's rating, even by leaving the session out. A click that arrives before the answer has finished saving is still linked to that answer.

By the numbers

From the live system and CI after the November deploy, not estimates:

227

knowledge chunks

Gemini · 384 dims · HNSW

878

backend tests

up from 128

<24 s

JSON route budget

25 s proxy timeout

~$0.00014

per chat answer

~2k tokens

Lessons from version 2

  • A fallback that changes the vector space is worse than no fallback. Same model, different quota, is the safe way to be resilient.

  • Read your own logs. A real visitor conversation found the most important bug in the system.

  • Let the model judge criteria and let code do the arithmetic. Scores became repeatable overnight.

  • Budget for the strictest hop, not the function limit. Here that's the proxy's 25-second first-byte timeout.

  • Fail closed. If the environment isn't explicitly development, treat it as production.

  • Test against real SDKs and a real Preview. An SDK upgrade broke every Supabase call while the mocked tests stayed green; tests that build the real clients caught it before it shipped.

Still on the list

  • A small evaluation set of real visitor questions, run on every deploy.
  • Better matches for broad questions like "Tell me about yourself", which can still match my poetry and interests note first.
  • All the databases are still in one AWS region (af-south-1), so the Redis failover covers a database failure, not a regional outage.
  • Decided: chat logs are kept, with emails and phone numbers redacted. Text to speech is capped at 2,200 characters rather than tied to a signed token.

Try it, then rate it

Ask about my skills, paste a job description for a fit score, and use the thumbs to tell me how it did.

Read version 1