Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Web App With Password Login

Lay out a web app where people sign in with a username and password, with a database-backed server behind a browser UI written in TypeScript, so the team that builds it can ship and run it safely.

Problem statement

Design the architecture of a new web app where people log in with a username and a password. Its back end keeps data in a database, and the part that runs in the browser is written in TypeScript. Show how the parts fit together so the team of developers can build, ship and run it.

For this exercise, assume the app is a private notes app. A visitor signs up by choosing a username and a password. A signed-up user logs in, stays logged in across page reloads and browser restarts for up to 7 days, creates, reads, edits and deletes their own notes, and logs out, which ends that session at once.

Usernames are unique, ignoring upper and lower case, and cannot be changed. Passwords must never be stored or written to logs in a form that can be read back.

Also assume the team has four developers who ship changes several times a week, keeps a test environment separate from production, and wants to deploy without taking the app down. You may choose any back-end language, database and hosting.

Password reset by email, social login, multi-factor login, admin roles, sharing notes between users and mobile apps are out of scope.

What to build

  1. A visitor creates an account with a password and a username that no other account uses, ignoring upper and lower case.
  2. A user logs in with username and password, stays logged in for up to 7 days across reloads and restarts, and logs out, which ends that session at once.
  3. A logged-in user creates, lists, edits and deletes their own notes and can never read or change another user's notes.

At scale

  • For this exercise, assume about 100,000 accounts holding about 20 million notes of about 1 KB each (about 20 GB), and up to about 200 API requests a second in a busy hour, about 10 of them logins.
  • For this exercise, assume pages should be usable within 2 seconds and API calls should answer within 300 ms at the 95th percentile, except login, which may take up to about 1 second.
  • For this exercise, assume the app must keep working when any one server fails, and if the database is lost, the team must have it back within 4 hours with at most the last 5 minutes of changes lost.