/Tracks

Two-week programme · Day 8 of 14

Checkpoint: tell the whole story in 45 minutes

Study with AI

Part 1Basics

You don't need anything new today. This is a timed rehearsal of everything since Day 1, using the system you already followed from start to finish.

Interviewers mainly want to see you ask good questions, make decisions and give reasons. Knowing every detail matters less. Priya's edit gives you one clear example to talk through.

Words you need today

System design round
A 45-minute interview where you design a product out loud, usually on a whiteboard.
Key flow
One user action followed all the way through your design.
Trade-off
A choice where you gain one thing and give up another. Naming what you gave up shows judgement.

The story

The interviewer says: we're building an app for 200,000 field technicians who work underground for hours and capture large videos. You have heard this story already. You lived through it with Priya and Arjun, and every number on the board has a reason behind it.

Part 2Today's question

Can you design the whole system without notes, against a clock?

By the end of this lesson, you should be able to:

  • Deliver the offline-first design in 45 minutes
  • Name your weakest area with evidence

Part 3In detail

Step by step

  1. Clarify, 5 minutes. Who uses it, how long they stay offline, and how much data they create.
  2. Estimate, 5 minutes. Do the arithmetic aloud, and say what each number forces you to do.
  3. Draw the design, 10 minutes. Phone, local database, outbox, sync engine, server, change log, object storage.
  4. Walk the key flow, 15 minutes. Tell Priya's edit from tap to Dev's tablet, including the conflict. Then cover Arjun's video.
  5. Trade-offs and failures, 10 minutes. What you rejected, what breaks, and what you'd measure.

Week one maps onto the round

Clarify and estimate come from Day 1 and Day 6. The local schema comes from Day 2, background rules from Day 3, the sync run from Day 4, conflicts from Day 5, the server from Day 6, and media from Day 7. Telling Priya's edit as your key flow gives the panel one thing to follow.

Do it badly first, then compare

Close everything. Start the timer in the round, draw on paper and speak aloud. Open the reference only afterwards. Then score yourself below and go back to the day that covers your weakest line.

The code, explained

This is the real code, and our tests run it. Read each block, then the notes under it.

Priya's whole day, as a program

This runs the real engine against the real server code. The numbers in the story are what this function produces, and a test checks them.

PriyasDay.ktKotlin
1data class StoryResult(2  val firstRun: RunOutcome,3  val cursorAfterRun: Long,4  val ticks: Int,5  val amber: Int,6  val theirs: Theirs?,7  val writesBeforeRetry: Int,8  val writesAfterRetry: Int,9  val finalVersion: Int,10  val tabletSees: String?,11)12 13/** Priya's whole day, running against the real engine and the real server code. */14suspend fun priyasDay(): StoryResult {15  val server = SyncServer(startSeq = 88411)16  val jobIds = List(12) { "j-${73 + it}" }              // twelve jobs, including j-81 and j-8417  jobIds.forEach { server.seedJob(it, version = 4) }18 19  fun phone(prefix: String): Pair<LocalDb, JobRepository> {20    val db = LocalDb(cursor = 88411)21    db.transaction { jobs = jobIds.associateWith { Job(it, version = 4) } }22    var n = 023    return db to JobRepository(db, { "$prefix-${++n}" }, by = prefix)24  }25 26  val (priya, priyaRepo) = phone("priya")27  val (tablet, devRepo) = phone("dev")28  val priyaSync = SyncEngine(priya, server)29  val devSync = SyncEngine(tablet, server)30 31  // 2:40 pm, underground. 37 edits, with no network involved at all.32  priyaRepo.setAnswer("j-84", "valve_3", "leaking")33  priyaRepo.setAnswer("j-81", "valve_3", "leaking")34  var edits = 235  outer@ for (q in 1..4) for (job in jobIds - "j-84") {   // the other eleven jobs get the rest36    if (edits == 37) break@outer37    priyaRepo.setAnswer(job, "q$q", "ok")38    edits += 139  }40 41  // 3:30 pm, in the office. Dev changes one field she also changed, and one she did not.42  devRepo.setAnswer("j-84", "valve_3", "replaced")43  devRepo.setAnswer("j-81", "instructions", "Use the east stairs")44  devSync.run()45 46  // Everyone else's work during those hours: 102 more changes in the log.47  val others = List(102) { Op("other-$it", "j-other", "q$it", "ok", baseVersion = 0) }48  server.push(others)49 50  // 4:12 pm. Signal returns and the worker runs.51  val firstRun = priyaSync.run()52  val rows = jobIds.map { priya.jobs.value.getValue(it) }53  val ticks = rows.count { it.syncState == SyncState.SYNCED }54  val amber = rows.count { it.syncState == SyncState.CONFLICT }55  val theirs = priya.jobs.value.getValue("j-84").theirs56 57  // A lost reply: the same ops arrive again, and nothing is written twice.58  val writesBeforeRetry = server.writes59  val sentAgain = List(12) { i -> Op("priya-${i + 2}", "j-81", "q", "ok", 4) }60  server.push(sentAgain)61  val writesAfterRetry = server.writes62  val cursorAfterRun = priya.cursor63 64  // 4:14 pm. She looks at both values and keeps her own.65  priyaRepo.resolve("j-84", "leaking")66  priyaSync.run()67 68  // 4:15 pm. The push told Dev's tablet to look, so it pulls after its own cursor.69  devSync.run()70 71  return StoryResult(72    firstRun, cursorAfterRun, ticks, amber, theirs, writesBeforeRetry, writesAfterRetry,73    finalVersion = priya.jobs.value.getValue("j-84").version,74    tabletSees = tablet.jobs.value.getValue("j-84").answers["valve_3"],75  )76}
76 linesUTF-8Kotlin
SyncServer(startSeq = 88411)
The log starts where her cursor is, c_88411.
priyaRepo.setAnswer(...)
37 edits underground. Nothing here talks to a network.
devSync.run()
Dev's 3:30 pm edit reaches the server first, which sets up the conflict.
server.push(others)
102 changes from other people, which brings the pull to 140.
priyaSync.run()
The 4:12 pm run. A test asserts 36 applied, 1 conflict, 140 pulled and cursor c_88551.
priyaRepo.resolve(...)
Her choice is a new edit based on version 5, and it reaches version 6.

Compiled and tested by npm run test:mobile.

What can go wrong

You run out of time
You spent too long drawing. Move to the key flow by minute 20.
You go blank
Return to the three questions: where does it live, who runs the next step, and what if it runs twice?

Part 4Questions and answers

Answer out loud first, then open each one.

You scored 5 of 8. What now?
Repeat only the days behind the lines you missed, then re-run those sections of the round. Don't restart the week. Week 2 will reinforce what you already know.

Part 5Going further

Practise

Score yourself

Tick a line only if you did it without prompting.

0 of 8 Revisit the days behind what you missed, then run the round again.

Week 1 ends with the system working. Week 2 starts with what Priya actually saw on screen, then changes the product.

← Day 7: Arjun's 412 MB video

AI Engineer · Day 8 of 14