Overview
Stack is a gamified learning app for engineers who already code. Instead of grinding problem sets, you take one short lesson a day: a swipeable deck of concept cards, worked examples, read-only code in your own language, native diagrams and predict-the-output questions, with hearts, XP and a streak that keep the habit going.
I designed and built it end to end: product, design system, a native SwiftUI app, a Kotlin/Compose Android app, a React web app, a NestJS + Postgres backend and a staff dashboard.
Highlights
- 01Daily card-deck lessons in seven tracks, code shown in your language
- 02Server-saved runs with Resume / Start over that survive republishing
- 03Native diagram renderers driven by JSON, in the active theme
- 04AI coach grounded in Stack's own lessons (RAG), with streaming replies and voice
- 05Mock interviews, a system design whiteboard and certification mock exams
- 06A ledger-backed economy (XP, Bits, Backups) that can't be farmed
Watch
The product
- Seven tracks, 30 lessons each. DSA, System Design, AI & ML, Backend, Frontend, Mobile and Data Science, ordered basic to advanced, about a month each at one lesson a day.
- Code in your language. Pick Python, JavaScript, Java or C++ once; code cards and predict-the-output questions carry a variant per language, each with its own options and answer, graded against the version you saw.
- Lessons survive anything. Position and answers are saved on the server as you go: kill the app and you get Resume or Start over. If a lesson is republished mid-run, unchanged cards keep their ids, so you land where you were.
- Practice and spaced review. Topic quizzes by difficulty, count and timer, graded on the server; every answer anywhere feeds an FSRS memory model, so questions come back right before you'd forget them.
- An AI coach. After a lesson you explain it back to your companion; replies stream in word by word, you can talk instead of typing (on-device speech recognition), and replies are read aloud.
- Interview prep. Timed mock interviews per target role (multiple choice plus spoken prompts, or an AI interviewer when it's switched on), a system design round on a native whiteboard, and a readiness score per role.
- Certification prep. Up to eight exams at once, full-length mock exams drawn by official domain weights, and a pass prediction from the learner's memory of the question bank.
- A reward economy that can't be farmed. XP and Bits are earned the first time only; interview rounds pay by graded score, never deducting; a store sells streak Backups and an extra AI interview. Every grant and purchase is a ledger entry.
- Companions with a voice. Four original characters narrate onboarding, react to answers and celebrate milestones, with lines pre-recorded once and captioned everywhere.
Architecture

Four clients talk to one NestJS API over HTTPS with short-lived JWTs and rotating refresh tokens; Coach replies stream back as server-sent events. The API owns every rule and reward, is the only thing that ever calls an LLM, and keeps its data in PostgreSQL (through Prisma) and private S3 storage. Content is written as JSON in git and loaded by a validating importer; staff edit it afterwards in the dashboard.
The AI layer
Every AI feature (the Coach, the mock interviewer, the system design interviewer) goes through one gateway in the backend. Staff choose Claude, GPT or Gemini in the dashboard; the features never know which one is running.
What happens when a learner messages the coach
- The app sends the message to our API, never to a model. The API checks the learner's daily limit and that AI is switched on.
- Retrieval looks for related material. It searches Stack's own lessons and questions and picks up to three notes from other lessons that match what the learner just said (say, a hash maps lesson when they mention lookups in a caching chat).
- The prompt is assembled in a fixed order. First come the parts every learner of that lesson shares (the coach's rules and the lesson's notes), then the companion's personality and a short note about this learner, then the conversation, with the retrieved notes on the latest message. Because the shared part comes first and never changes, the provider caches it, and most of each request is billed at a fraction of the price.
- The provider streams the reply word by word back to the app over server-sent events.
- The reply is checked and saved. If the model judged the learner has explained the idea, XP and Bits are granted once through the ledger. The tokens used are recorded per feature for the cost view.
The parts
- One identity on every provider. Learners talk to their companion, not to a vendor's chatbot. Every prompt carries the same identity rules, and every reply is checked for first-person slips like "I'm Claude" or "as a language model" (a lesson about GPT passes). A reply that slips is regenerated once with a reminder.
- Prompts are versioned files. Each prompt is a Markdown file with a name, a version and a note on what it's for, and a strict template body (a missing variable is an error, not a blank). Changing a prompt is a reviewed diff with a version bump, and eval reports record which versions they ran.
- Learner memory. A short note about the learner goes into the Coach and interviewer prompts: level, lessons finished, code language, strongest and weakest topics over 30 days. It never includes chats or interview answers, and it's computed once per day so it doesn't break caching mid-conversation.
- Retrieval (RAG). Lesson cards, questions (with the right answer and explanation), interview prompts and design problems are split into about 2,500 searchable chunks. Each chunk becomes a vector, a list of numbers that captures its meaning, using an open-source embeddings model (bge-small) that runs inside the backend for free. A search runs two ways at once: keywords (BM25, for exact terms like "LRU") and meaning (vector similarity, for "how do I avoid fetching the same thing twice"). The two rankings are merged by position (reciprocal rank fusion). The whole index sits in memory and searches in a few milliseconds, with no vector database to run. Only chunks whose text changed are embedded again, and the dashboard can switch embeddings to OpenAI later without code changes. On a fixed test set, the right lesson comes back in the top three 23 times out of 26 (keywords alone: 20).
- Provider fallback. If the active provider fails before any words arrive (a timeout, an outage, a bad key or no credits), the gateway retries once on another provider that's configured, so a learner sees a reply rather than an error.
- Evals. Fixed conversations are replayed against the real providers with the production prompts and graded by plain checks: does the companion stay in character when asked "are you ChatGPT?" or told to "ignore your instructions"? Does it judge a good explanation as understood and a vague one as not? Does it use the learner memory without reciting it? They run before any prompt change or provider switch. The first run caught one provider holding back its "understood" verdict; one wording fix in the prompt took it from 12 to 15 out of 15.
Engineering decisions
- Everything is data. Tracks, lessons, cards, questions, diagrams, themes, companions, onboarding options, quests and every tunable number live in Postgres and are served by the API. The clients hold only rendering code, so a new lesson, theme or reward amount is a database change, not an app release.
- The server owns every reward. Streaks, XP, hearts, Bits and Backups are decided by the backend and written to an append-only ledger with idempotency keys, so retries, double taps and replays can never pay twice.
- Diagrams drawn natively from a spec. Trees, graphs, arrays with pointers, stacks, queues, call stacks and architecture diagrams render from JSON in the active theme (SwiftUI Canvas, Compose Canvas), zoomable and exportable. No image hosting.
- LLMs behind the backend only. Staff pick the provider (Anthropic, OpenAI or Gemini) and model in the dashboard; keys are encrypted and never reach a client. Daily per-learner limits are business rules in the database, and token cost is tracked per feature (see The AI layer above).
- Privacy by design. Coach chats and interview answers are readable only by their owner and never shown in the dashboard; the interview camera check runs on the phone with Apple Vision and keeps no frames.
- An editorial workflow. Lessons are edited as drafts, validated by the same rules as the content importer, and published as versioned revisions.
- Tested where trust is at stake. XP math, streaks, milestone claims and heart deduction are unit tested; around 150 end-to-end tests run against a real database.
Tech stack
| Layer | Stack |
|---|---|
| iOS | Swift, SwiftUI, Swift Concurrency, SwiftData, Swift Charts, CoreHaptics, Vision, Speech, AVFoundation |
| Android | Kotlin, Jetpack Compose, OkHttp, kotlinx.serialization, DataStore |
| Web & admin | React, TypeScript, Vite, Tailwind CSS, TanStack Query, shadcn/ui, dnd-kit |
| Backend | NestJS, PostgreSQL, Prisma, JWT with rotating refresh tokens, Apple and Google sign-in, server-sent events, APNs |
| AI | Claude, OpenAI and Gemini SDKs, prompt caching, Handlebars prompt files, RAG (Transformers.js with bge-small-en-v1.5, BM25 + vector search), LLM evals, ElevenLabs (pre-rendered voices) |
| Testing & infra | Vitest, Swift Testing, JUnit, Railway, S3 |