← All videos

Engineering video

35:41 · 22 November 2024

Frotnend System Design: Design ChatGPT like a Senior Engineer

Chapters 5 sections

  1. 0:00Introduction and Functional Requirements
  2. 4:08Wireframing and State Management
  3. 16:00Streaming Data and Server-Sent Events
  4. 21:46Performance, Accessibility, and Security

Key concepts in this video:

1. Functional Requirements and Scope Definition

Defining user stories such as typing a query and receiving a streamed answer, while scoping out complex features like model switching or file uploads to fit a standard interview timeframe.

Watch section from 1:02 →

2. UI Wireframing and State Extraction

Sketching a simplified chat interface layout to extract core state requirements and demonstrate UX pattern familiarity without prior designs.

Watch section from 4:08 →

3. State Management Variables and Transitions

Structuring state variables like user queries and conversation objects, and defining state transitions driven by user interactions and backend synchronization.

Watch section from 7:04 →

4. Polling vs Web Sockets vs Server-Sent Events

Comparing data-fetching patterns and choosing Server-Sent Events (SSE) over polling and WebSockets for scalable, one-way LLM text chunk streaming.

Watch section from 16:00 →

5. Virtualized Lists for Performance

Using virtualized lists powered by the Intersection Observer API to render only viewport replies and prevent memory issues with long conversations.

Watch section from 21:46 →

6. Non-Functional Requirements: Web Performance and React Fiber

Discussing CDN asset delivery and how React Fiber uses priority queues and requestIdleCallback to keep rendering fluid.

Watch section from 24:43 →

7. Accessibility and Security via Markdown Sanitization

Emphasizing semantic HTML for accessibility and utilizing libraries like React Markdown to prevent cross-site scripting (XSS) attacks from malicious LLM output.

Watch section from 26:56 →

Transcript

A few days ago, one of our menties got hired by a startup building an alternative version to chat GPT. So, today, together with Bogdan, we said, why not let's system design chat GPT's front-end and show you exactly how you can approach complex UI development like a senior dev. We're going to mention things like React fiber, Vlized list, rate limiting, web sockets and server sent events. Keep in mind, chat GPT had around 2 billion monthly users in April 2024 alone, which means that our system has to be highly scalable, probably one of the most scalable in the world.