P-Buddy
Personal practice and performance companion
A practice and performance companion that imports Markdown question banks into a structured bank for targeted practice, timed mock exams, explanation-first review and progress analytics. A new track is new content, not new code: SC-300 is live, with interview preparation and more certifications to follow.
- Period
- Status
- Live, sign-up open
- Role
- Software engineer and architect: architecture, content pipeline, practice and exam engine, identity, frontend and deployment
- Team
- Client project, built around owner-authored question sets
- Stack
- Next.js
- React
- TypeScript
- Tailwind CSS
- Drizzle ORM
- Turso (libSQL)
- SQLite FTS5
- Auth.js
- Microsoft Entra External ID
- Vercel
- Playwright
- Vitest
The problem
Exam and interview preparation often lives in static question files. They can hold good questions and explanations, but a file can’t remember a session, steer practice toward weak areas or show whether preparation is improving, so the learner keeps score by hand and guesses what to study next. P-Buddy turns those files into a loop: practise, track progress, evaluate performance, improve, and repeat. SC-300 is the first track; interview preparation and more certifications follow on the same engine.
The engineering challenge
- One engine for every track. A new certification such as SC-200, or an interview track, should arrive as new content, not as new application code.
- Learning and exam conditions. Practice should explain an answer at once; a mock exam has to keep answers hidden until submission and run on a clock the browser can’t change.
- A question bank worth trusting. Authored and community questions need validation, provenance and duplicate handling, with official material carrying the most weight.
- Honest progress. A recommendation or a readiness band needs enough evidence behind it, and has to say what that evidence is.
Architecture
Identity provider
- Entra External ID, Sign-up, sign-in, reset
Vercel
- Request proxy, Guards, CSP nonce, rate limit
- Domain core, Selection, scoring, scheduling
- Server actions and services, Access policy, sessions
- Content pipeline, Validate, preview, import
Production build
- Deploy gate, Schema before build
Runtime data
- Turso (libSQL), Questions, sessions, progress
Authoring source
- Content packs, Markdown banks in git
Practise and review
- Choose a session. Learner to Request proxy (HTTPS); Request proxy to Server actions and services (Allowed). The learner picks a quick session, or one by topic, difficulty, weak areas, due reviews, missed questions or bookmarks.
- Select questions. Server actions and services to Domain core (Select, score); Server actions and services to Turso (libSQL) (Read, write). The domain core picks questions from the learner’s history, due reviews and weak areas, and weights official material above community sets. It is plain logic with no database or React imports, so it is tested on its own.
- A safe question. Server actions and services to Learner (Question payload). The browser receives the question without its answer key. The service withholds the key, not only the interface.
- Explain, then point ahead. Server actions and services to Turso (libSQL) (Read, write); Server actions and services to Learner (Question payload). In practice the answer and its explanation appear as soon as the learner answers, and nothing moves on until they choose to. Results end in one recommended next step, shown only when there is enough history behind it.
Take a timed mock exam
- Start the exam. Learner to Request proxy (HTTPS); Request proxy to Server actions and services (Allowed); Server actions and services to Domain core (Select, score). Questions are spread across the exam’s domains by their published weights, and the server records when the exam expires.
- Answer without feedback. Server actions and services to Learner (Question payload); Server actions and services to Turso (libSQL) (Read, write). Answers and explanations stay on the server until submission. Progress is saved as the learner goes, so a refresh resumes the exam.
- Settle on the server. Server actions and services to Turso (libSQL) (Read, write). The countdown in the browser is only a display. Expiry is settled on the server whenever the session is read or submitted, and then the result and its review open.
Sign in and access
- Sign in. Learner to Entra External ID (Sign in (OIDC)). Sign-up, sign-in and password reset run on Microsoft Entra External ID over OpenID Connect, so P-Buddy never stores a password.
- Start a session. Entra External ID to Request proxy (Callback). The sign-in returns to the app, where Auth.js validates it and starts a database session. Signing out ends the Entra session too, so a shared computer does not sign the next person straight back in.
- Account in good standing. Permitted. Learner to Request proxy (HTTPS); Request proxy to Server actions and services (Allowed). The proxy guards each route, and the services check the account’s role and status on the server. Learning data is scoped to the signed-in user.
- Pending account or private track. Refused. Learner to Request proxy (HTTPS); Request proxy to Server actions and services (Allowed). Pending and disabled accounts are refused. A private track is hidden from the catalogue and refused by the session and study-plan services too, because a request can name a track directly.
Import a question bank
- Pick a file. Editors and admins to Request proxy (Admin actions); Request proxy to Server actions and services (Allowed); Server actions and services to Content pipeline (Import run). An editor picks a question file from the content root. The browser sends an identifier, never a path, so no request can reach another file on the server.
- Validate and preview. Content packs to Content pipeline (Markdown). Adapters parse each Markdown format. Validation reports every rejected question, and a preview shows what would change before anything is written.
- Import. Content pipeline to Turso (libSQL) (Validated content). Imports are idempotent and versioned. Duplicates are archived, never deleted, and every write leaves a version row and an audit entry.
Ship safely
- Compare the schema. Deploy gate to Turso (libSQL) (Check migrations). Before a production build, the deploy gate compares the migration history with the production database.
- Pending migration. Deploy gate to Turso (libSQL) (Check migrations). If a migration is still pending, the build fails and the previous deployment keeps serving. The gate exists because a release once shipped ahead of its migration, and sign-ups failed until it was applied.
View diagram
P-Buddy is a modular monolith: one Next.js application on Vercel, with Turso (libSQL) as its database. Its boundaries live in the code. Pages call server actions and services, services call repositories, and the selection, scoring and scheduling logic sits in a domain core with no React, ORM or database imports. A lint rule keeps components, pages and that core from reaching the database client directly.
Question content has two forms. Version-controlled Markdown is the source that people write and review; the database is the runtime form that practice reads. The content pipeline sits between them, and every question keeps its track, version, domain, difficulty, source set and provenance, so a track’s rules live in data rather than in the interface.
The diagram above is a simplified view. Every request passes the proxy before it reaches a service, and the deploy gate stands outside the application because it runs before a production build.
The learner’s loop
- Practice that fits the moment. A quick session, or one by topic, difficulty, weak areas, due reviews, missed questions or bookmarks. Question types run from single and multiple choice to ordering, matching, case studies and open responses that the learner rates against a model answer.
- Review that teaches. Each answer shows the choice made, the correct answer and the reasoning. Practice never moves on by itself, because the explanation is the point.
- Progress with its evidence. Scores, domain trends, a consistency calendar, personal bests and the most-missed topics. A readiness band (Building, Nearly there, Exam-ready) appears only once there is enough recent history, always shows its basis and is never a pass prediction.
- One next step. The dashboard ends in a single recommendation, such as a weak domain or the reviews that are due, and spaced repetition decides when a question comes back.
Motivation comes from real progress: a daily goal, a gentle streak and personal bests. There are no points, badges or leaderboards, and a broken streak is never announced as a loss.
Tracks today and next
Each track is a content pack: a taxonomy of domains and topics, the question files and the rules for each source. Every pack runs on the same session, review, scoring and progress engine.
- Today. SC-300 is open to learners.
- Next. DP-300 is built and reviewed. Resume-Based Interview Preparation is built too: spoken interview questions are answered in writing and rated against model answers, and it stays private to admins for now because it comes from a resume. Both open to learners next.
- Planned. SC-200, HashiCorp Certified: Terraform Associate (004), AWS Certified Solutions Architect - Associate (SAA-C03), AWS Certified AI Practitioner (AIF-C01), and many more. Each will arrive as a content pack and go through the same import and review as SC-300; none is imported yet.
A question bank worth trusting
Not every question is equally reliable, so sources carry trust tiers. Microsoft’s official practice assessments anchor each certification track: community sets are compared against them, answers and reasoning are corrected, duplicates are retired and matching questions are marked as corroborated. For DP-300, every flagged question was checked by hand against Microsoft Learn before the track went into practice. Selection then blends the tiers so official and corroborated material carries the most weight.
Key decisions
A new track is new content, not new code
Options considered: a separate application or module for each certification, or one engine with tracks, domains, topics, sources and questions modelled as data.
Why: the product has to grow beyond its first exam without collecting exam-specific screens and rules. Adapters absorb the differences between Markdown formats, and the importer, validator and reports all take a content pack, so DP-300 arrived as a taxonomy, question files and a review, running on the same engine as SC-300. The same path is planned for SC-200, Terraform and the AWS certifications.
Trade-off accepted: every new format needs an adapter and validation, and a bank that parses is not yet a bank to trust. Each track goes through the same review before its questions reach practice.
The server decides when answers appear and when an exam ends
Options considered: reveal answers and run the timer in the browser, or make the session mode and the clock server-side decisions.
Why: practice teaches by explaining at once, but a mock exam only simulates the real one if correctness stays hidden while the learner answers. A browser timer can be paused or edited, so the server stores the expiry and settles it whenever the session is read or submitted, which also lets a refreshed page resume without losing work.
Trade-off accepted: every question reaches the browser in a client-safe shape without its answer key, and the countdown on screen is only a display. The service, not the interface, decides what the learner may see.
Turso, with migrations applied by hand and a gate before deploy
Options considered: PostgreSQL, as the original specification proposed, or SQLite-compatible Turso with a local database file for development and tests.
Why: the same libSQL client runs in development, tests and production, so there is no driver split, and full-text question search comes from SQLite’s FTS5. Turso bills on rows read, so a query-plan regression test fails if any growing table is scanned in full.
Trade-off accepted: SQLite changes many columns by rebuilding the table, and the migration generator produced broken rebuilds, so migrations are reviewed, repaired where needed and applied explicitly. A deploy gate then refuses any production build that would run ahead of its schema.
Security and identity
Authentication and authorization have separate jobs. Sign-up, sign-in and password reset run on Microsoft Entra External ID, so P-Buddy never stores a password. Auth.js keeps a database session, and signing out also ends the Entra session, so a shared family computer does not sign the next person straight back in. Sign-up is open, and the owner can switch to approving each new account.
Inside the app, every account has a role (learner, content editor or admin) and a status (pending, active or disabled). Pages redirect and actions refuse when access is denied, and the API refuses pending and disabled accounts. Sessions, answers, bookmarks, goals and progress are scoped to the signed-in user. A private track is hidden from the catalogue and refused again by the session and study-plan services, because a request can name a track directly.
The answer key stays on the server until the session’s reveal policy allows it, and mock exam results wait for submission or expiry. The import screen sends a file identifier, never a path, so no request can reach a file outside the content root. The proxy sets a fresh content security policy nonce on every request and rate-limits sign-in attempts, the app sends strict framing, content type, referrer and permissions headers, and every admin change writes a version row and an audit entry.
Delivery and operations
The app deploys to Vercel, and the database runs on Turso. Before a production build, the deploy gate compares the migration history with the production database; if a migration is pending, the build fails and the previous deployment keeps serving. The gate exists because a release once shipped ahead of its migration, and sign-ups failed until the migration was applied.
A health endpoint reports liveness and schema status. Logs are structured, with a request ID on each request and optional error tracking. A backup script writes every table to JSON, and a status script shows applied and pending migrations for any target.
Testing runs in layers: unit tests for the domain core and the content adapters, integration tests against a throwaway database, and Playwright end-to-end tests against an isolated database with a fake Entra tenant. Axe checks accessibility across the main surfaces in both themes, Lighthouse CI asserts accessibility on the public pages, and a client bundle budget fails the build when it is exceeded. Motion is CSS only and icons render on the server, which keeps the app inside that budget.
The interface follows the same loop. Practice runs in a quiet Focus mode, while the dashboard, results and progress pages carry more energy so improvement is easy to see. It has light and dark themes and reduced motion support, status is never shown by colour alone, and the app installs as a PWA with a read-only offline cache.
Result
P-Buddy is live at pbuddy.study with sign-up open and SC-300 open to learners. DP-300 and Resume-Based Interview Preparation are built on the same engine and open next, and SC-200, Terraform Associate, the AWS Solutions Architect and AI Practitioner certifications and more are planned as content packs. It has no public usage figures, so the running app is the evidence. On the platform side, next is retiring the owner’s emailed sign-in link once the Entra cutover is complete, and tuning the readiness thresholds on real usage.
Demo
Open P-Buddy (opens in new tab). Practice needs an account, and sign-up is open.