Design an AI Chat App

18 min read

You will design a ChatGPT-style app for 10 lakh users each day. You follow the same steps as in an interview. First come requirements and estimates, then the request path, then the parts that save time and money. An AI app is special because every answer is slow and costs real money.

New words

LLM API
A service you call over the internet to get an answer from a language model.
Streaming
Sending the answer in small pieces, as soon as each piece is ready.
Context limit
The most text, counted in tokens, that a model can read at once.
Rate limit
A rule that says how many requests one user can send in a given time.
Message queue
A waiting line of jobs that workers pick up one by one.
Time to first word
The wait before the first word of the answer appears.
Model routing
Sending easy questions to a cheap model and hard ones to a strong model.

What you will learn

  1. The problem: board result night
  2. Step 1: Requirements
  3. Step 2: Estimates
  4. The request path
  5. Streaming the answer
  6. Storing the chat history
  7. The context limit
  8. A queue for slow jobs, and rate limits
  9. Try it: switch the parts on and off
  10. Saving cost and time
  11. What can go wrong?
  12. Trade-offs
  13. In a real system
  14. Interview tip
  15. Key takeaways

10 quiz questions at the end.

Start this lesson

The full lesson, with interactive demos and the quiz, opens after you sign in with Google. It is free.

All lessons · Back to the roadmap