Frontend System Design: Design a News Feed
On this page
Learning Objective
Apply the whole course to a frontend system design problem using a structured approach: clarify requirements, define the component architecture, data model and API contract, choose rendering, state and caching strategies, and address performance, accessibility, security, internationalization, observability and trade-offs, using a news feed as the worked design.
Concept Explanation
Frontend system design is the skill of turning a vague product goal into an architecture that will hold up: in a design review, a technical planning document or an interview at many companies. It draws on every phase of this course. A common structure, sometimes called RADIO, keeps the discussion complete: Requirements, Architecture, Data model, Interface definition, and Optimizations and deep dives. The order matters: decisions about rendering or state make sense only once requirements and data are clear.
Requirements come first, and asking good questions is part of the skill. Functional requirements describe what users can do: view a feed, like and comment, create posts with images, load more as they scroll, see new posts. Non-functional requirements shape the architecture: who the users are and on what devices and networks, expected scale, performance targets such as Core Web Vitals, accessibility at WCAG 2.2 AA, supported languages and right-to-left support, offline expectations, SEO needs, security and privacy constraints. Stating assumptions explicitly, such as a mobile-heavy audience on mid-range Android phones, makes later trade-offs defensible.
Architecture describes the main pieces and their responsibilities: the rendering strategy per route (Day 71), the component tree with its main containers, the client-side layers such as a query cache for server state, a small store for UI state and the URL for view state (Day 61), and how the frontend talks to the backend, perhaps through a backend-for-frontend (Day 93). A simple diagram of components and data flow is worth more than lists of technologies.
The data model and interface definition make it concrete. Define the entities the client holds, such as Post, Author, Comment, and how they are stored: normalized by id in the cache, with a feed as an ordered list of ids, so that a like updates one post wherever it appears (Day 65). Define the API contract: cursor-based pagination rather than offsets, because new posts arriving at the top would shift offsets and cause duplicates or gaps; response shapes; real-time updates through server-sent events or polling (Day 69); and mutations with idempotency keys (Day 64). Define important component interfaces, such as the props of a PostCard and the events it emits.
Optimizations and deep dives show depth. For a feed: virtualized list rendering for long sessions (Day 89), image delivery with srcset, AVIF and lazy loading with the first image prioritized (Days 17 and 87), optimistic likes with rollback, prefetching the next page before the user reaches the end, a "new posts" pill instead of inserting posts above the reading position to avoid layout shift (Day 85), keyboard navigation between posts and announcing new content politely (Days 14 and 13), sanitizing user content and links (Day 91), a strict CSP (Day 92), offline reading of cached posts (Day 70), translations and relative times through Intl (Day 99), and RUM, error tracking and feature flags (Days 82 and 98). Each choice should name its trade-off: virtualization complicates find in page, optimism can mislead on failure, server rendering adds infrastructure. Good design is not about using every technique; it is about choosing the right ones for the stated requirements and explaining why.
| RADIO step | Questions to answer | Feed example |
|---|---|---|
| Requirements | What, for whom, how fast, constraints | Mobile-first, LCP under 2.5 s, WCAG 2.2 AA |
| Architecture | Rendering, layers, components | SSR first page, client feed with query cache |
| Data model | Entities, normalization, client state | Posts by id, feed as an id list |
| Interface | API contracts, component props | Cursor pagination, SSE for new posts |
| Optimizations | Performance, a11y, security, i18n, ops | Virtualization, optimistic likes, CSP, RUM |
| Trade-offs | What each choice costs | Virtualization versus find in page |
Worked Example: Designing a News Feed
A condensed design document for a social news feed, the kind of artifact a review or interview expects, with the key code-level contracts.
1. Requirements
Functional: read feed, infinite scroll, like, comment, create post with up to 4 images,
"new posts" indicator, open post detail with shareable URL.
Non-functional: 70% mobile on mid-range Android, LCP <= 2.5 s and INP <= 200 ms at p75,
WCAG 2.2 AA, English and Arabic (RTL), readable offline for cached posts,
feed is private (no SEO); post detail pages are public and indexable.
2. Architecture
/feed SSR shell + first page (fast LCP), then client-side infinite feed
/posts/:id SSR/ISR public page with Open Graph tags (shareable, indexable)
BFF session cookie auth, aggregates feed + author data, CSP nonce
Client layers query cache (posts, pages) | small store (composer draft) | URL (open post)
3. Data model (client)
posts: Record<PostId, Post> feedPages: { ids: PostId[], nextCursor }[]
A like updates posts[id] once; every view of that post re-renders from the same entry.
4. Interfaces
GET /api/feed?cursor=abc&limit=20 -> { items: Post[], nextCursor: string | null }
POST /api/posts/:id/like (Idempotency-Key) -> { likeCount, likedByMe }
SSE /api/feed/events -> event: post.created { id, createdAt } (shown as a "N new posts" pill)
5. Optimizations and trade-offs
Virtualized list (TanStack Virtual) + prefetch next page at 70% scroll; aria-setsize/posinset.
First image fetchpriority=high; others lazy, AVIF with srcset; skeletons with fixed heights.
Optimistic like with rollback; composer draft saved in IndexedDB.
DOMPurify for rich text, safeHref for links, strict CSP + Trusted Types.
Service worker: stale-while-revalidate for feed pages, offline banner.
Intl.RelativeTimeFormat for timestamps, logical CSS for RTL.
RUM (web-vitals), Sentry with releases, feature flags for gradual rollout.// The contracts that make the design concrete
type Post = { id: string; author: { id: string; name: string; avatarUrl: string }; text: string;
images: { url: string; width: number; height: number; alt: string }[];
likeCount: number; likedByMe: boolean; createdAt: string; version: number };
export function useFeed() {
return useInfiniteQuery({
queryKey: ['feed'],
queryFn: ({ pageParam, signal }) => api.feed({ cursor: pageParam, limit: 20, signal }),
initialPageParam: null as string | null,
getNextPageParam: (last) => last.nextCursor, // cursor, not offset: no duplicates or gaps
staleTime: 30_000,
});
}
// New posts never shift the reading position: they are counted, then shown on request
export function useNewPostsPill(onShow: () => void) {
const [count, setCount] = useState(0);
useEffect(() => {
const es = new EventSource('/api/feed/events', { withCredentials: true });
es.addEventListener('post.created', () => setCount((c) => c + 1));
return () => es.close();
}, []);
return { count, show: () => { setCount(0); onShow(); } }; // announced via role="status"
}The design ties each requirement to a decision and each decision to a trade-off. That traceability, more than any particular library, is what makes a frontend architecture convincing and maintainable.
Real-World Examples
- Meta's 2020 engineering post on rebuilding facebook.com with React and Relay described colocating each component's data needs, downloading code incrementally by priority so the first view loads only what it needs, and fetching data in parallel with code, the same considerations a frontend system design discussion covers.
- Frontend system design interviews at companies such as Meta, Google, Airbnb and Uber commonly ask candidates to design a news feed, autocomplete, image carousel or chat interface, and preparation resources such as GreatFrontEnd describe structured frameworks like RADIO for covering requirements, architecture, data, interfaces and optimizations.
Review Questions & Answers
Rendering, state, caching and performance decisions are only right or wrong relative to requirements such as audience devices, SEO needs, scale, offline expectations and accessibility targets. Clarifying them first makes the later choices justified rather than arbitrary.
New items arrive at the top of a feed constantly. With offsets, insertions shift every position, so the next page can repeat items or skip them. A cursor points to a specific position in the ordered data, so each page continues exactly where the previous one ended.
Inserting content above what the user is reading moves it, causing layout shift and lost reading position, and can be disorienting for screen reader users. An indicator, announced politely, lets users choose when to load new posts.
Clear requirements and assumptions, a simple architecture and data flow, concrete data models and contracts, and optimizations chosen for the stated requirements, with each decision's trade-offs explained, rather than a list of every technique or technology available.