Frontend system design müsahibəsinə yanaşma
Frontend system design raundunu beş mərhələdə necə aparmaq olar: tələbləri dəqiqləşdirməkdən və klient arxitekturasını çəkməkdən məlumat modelinə, komponent və şəbəkə API-lərinə, optimallaşdırmaya, trade-off-lara və vaxtın bölüşdürülməsinə qədər.
Oxu səviyyəsi
Seçilmiş səviyyəyə qədər olan bölmələr göstərilir.
Başlamazdan əvvəl
İlkin şərt yoxdur.
Bu mövzu Middle səviyyəsindən başlayır.
Raund nəyi yoxlayır və backend dizaynından nə ilə fərqlənir
Frontend system design raundunda məhsulu və ya komponenti brauzer tərəfdən dizayn edirsən: istifadəçi nə görür, klient necə qurulub, məlumat API-dən piksellərə qədər necə gəlir və nəticə real cihazlarda necə sürətli, əlçatan və dayanıqlı qalır. Server əsasən qara qutudur: UI-a lazım olan API müqaviləsini sən müəyyən edirsən, amma heç kim səndən verilənlər bazasının sharding-ini gözləmir.
| Frontend raundu | Backend raundu | |
|---|---|---|
| Fokus | Klient arxitekturası, komponentlər, state, render, şəbəkə müqaviləsi | Servislər, saxlama, miqyaslanma, ardıcıllıq |
| "Miqyas" nədir | Bir ekrandakı məlumat, zəif cihaz və şəbəkələr, bundle ölçüsü, çoxlu tab | Saniyədəki sorğular, məlumatın həcmi, replikalar |
| Nə təqdim edirsən | Komponent ağacı, state-in sahibləri, API formaları, performans və əlçatanlıq planı | Servis diaqramı, sxemlər, tutum hesablamaları |
Suallar iki növ olur. Tətbiq sualları (xəbər lenti, chat tətbiqi, checkout) genişdir: ən çox arxitektura və məlumat axını önəmlidir. Komponent sualları (autocomplete, şəkil karuseli, video pleyer) dardır və komponent API-sinə, vəziyyətlərə, klaviatura və ekran oxuyucusu dəstəyinə dərindən gedir.
Beş mərhələ
Platformadakı System Design Board hər məsələni eyni beş mərhələdən keçirir; bu ardıcıllıq RADIO framework-ü adı ilə geniş tanınır:
- Tələblər: nə qurulur, kim üçün, hansı keyfiyyətdə və nə əhatəyə daxil deyil.
- Arxitektura: klientin hissələri və onların serverlə necə danışdığı.
- Məlumat modeli: entity-lər və state-in hər parçasının harada yaşadığı.
- İnterfeys: komponent API-ləri və şəbəkə API-si.
- Optimallaşdırma: performans, əlçatanlıq, i18n, offline, təhlükəsizlik.
Mərhələlər ssenari yox, yoxlama siyahısıdır. İnterfeys məlumat modelində bir sahənin çatışmadığını göstərəndə geri qayıt, onu düzəlt və bunu ucadan de.
45 dəqiqəlik vaxt planı
| Dəqiqə | Mərhələ | Sonda lövhədə nə olur |
|---|---|---|
| 0-5 | Tələblər | Funksional və qeyri-funksional tələblər, fərziyyələr |
| 5-15 | Arxitektura | Klient diaqramı və onun serverlə təmas nöqtələri |
| 15-22 | Məlumat modeli | Entity-lər, klient və server state-i, cache açarları |
| 22-32 | İnterfeys | Props-ları ilə əsas komponentlər, cavab formaları ilə endpoint-lər |
| 32-42 | Optimallaşdırma | Bu məhsul üçün vacib olan iki-üç dərin analiz |
| 42-45 | Yekun | Xülasə, açıq risklər, sənin sualların |
60 dəqiqə olanda əlavə vaxtı interfeysə və dərin analizlərə ver. Geri qalırsansa, növbəti nəyi əhatə edəcəyini de və irəli keç: aydın planı olan yarımçıq diaqram mükəmməl tələblər siyahısından və başqa heç nədən daha yüksək qiymətləndirilir.
In a frontend system design round you design a product or a component from the browser's side: what the user sees, how the client is structured, how data travels from the API to the pixels, and how the result stays fast, accessible and robust on real devices. The server is mostly a black box: you define the API contract the UI needs, but nobody expects database sharding.
| Frontend round | Backend round | |
|---|---|---|
| Focus | Client architecture, components, state, rendering, network contract | Services, storage, scaling, consistency |
| "Scale" means | Data on one screen, slow devices and networks, bundle size, many tabs | Requests per second, data volume, replicas |
| You deliver | A component tree, state ownership, API shapes, a performance and accessibility plan | A service diagram, schemas, capacity estimates |
Questions come in two kinds. Application questions (a news feed, a chat app, a checkout) are broad: architecture and data flow matter most. Component questions (an autocomplete, an image carousel, a video player) are narrow and go deep into the component API, states, keyboard and screen reader support.
Five stages
The platform's System Design Board walks every problem through the same five stages, an order that is widely known as the RADIO framework:
- Requirements: what to build, for whom, how well, and what is out of scope.
- Architecture: the client's parts and how they talk to the server.
- Data model: entities, and where each piece of state lives.
- Interface: component APIs and the network API.
- Optimizations: performance, accessibility, i18n, offline, security.
The stages are a checklist, not a script. When the interface shows that the data model is missing a field, go back and fix it, and say so out loud.
A time plan for 45 minutes
| Minutes | Stage | What is on the board at the end |
|---|---|---|
| 0-5 | Requirements | Functional and non-functional requirements, assumptions |
| 5-15 | Architecture | The client diagram and its server touch points |
| 15-22 | Data model | Entities, client vs server state, cache keys |
| 22-32 | Interface | Main components with props, endpoints with shapes |
| 32-42 | Optimizations | Two or three deep dives that matter for this product |
| 42-45 | Wrap-up | Recap, open risks, your questions |
For 60 minutes, give the extra time to the interface and the deep dives. If you are behind, say what you would cover next and move on; an unfinished diagram with a clear plan scores better than a perfect requirements list and nothing else.
Mərhələ 1: Tələblər
Tapşırıq qəsdən qeyri-müəyyən verilir. İlk beş dəqiqə doğru şeyi qurub-qurmadığını göstərir, ona görə çəkməzdən əvvəl soruş, sonra cavabları müsahibəçinin görə biləcəyi yerdə yaz.
Funksional tələblər: istifadəçilər nə edə bilir. Əsas axınları sadala və nəyin əhatədən kənarda qaldığını razılaşdır ("göndərilmiş mesajlar redaktə olunmur").
Qeyri-funksional tələblər: hansı keyfiyyətdə. Performans hədəfləri, cihazlar (telefonlar, zəif Android), brauzerlər, şəbəkənin keyfiyyəti, offline iş, əlçatanlıq, dillər və sağdan sola yazılar, SEO, məxfilik.
İstifadəçilər və miqyas: ekranda neçə element var, məlumat nə qədər tez-tez dəyişir, eyni məlumat üzərində eyni anda neçə nəfər işləyir. Frontend raundunda miqyas serverlər yox, "cədvəldə 10 000 sətir" və ya "bir chat-da dəqiqədə 200 mesaj" deməkdir.
Məhdudiyyətlər: API var, yoxsa onu sən dizayn edirsən; hansı framework və dizayn sistemi işlənir; səhifə açıqdır, yoxsa login arxasındadır.
Nümunə: autocomplete
Funksional
- İstifadəçi yazdıqca, 2 simvoldan başlayaraq təkliflər görünür.
- Ox düymələri təkliflər arasında hərəkət etdirir, Enter seçir, Escape bağlayır.
- Təklif başlıq və kateqoriya göstərir; onu seçmək məhsulu açır.
Qeyri-funksional
- İstifadəçi yazmağa ara verəndən sonra təxminən 200 ms ərzində təkliflər görünür.
- Telefonlarda və ekran oxuyucuları ilə işləyir.
- İnterfeys azərbaycan və ingilis dillərindədir.
Fərziyyələr
- Axtarış endpoint-i mövcuddur; onun müqaviləsini mən müəyyən edirəm.
- Ən çox 10 təklif, açılan siyahının içində səhifələmə yoxdur.
- Son axtarışlar hesab üzrə yox, cihaz üzrə saxlanılır.
Fərziyyələr cavabın bir hissəsidir
Müsahibəçi "sənin seçimindir" deyəndə qərar ver, fərziyyəni yaz və başqa cür olsaydı nəyin dəyişəcəyini bir cümlə ilə əlavə et: "Offline dəstəyin lazım olmadığını fərz edirəm; lazım olsaydı, axtarış cache-i IndexedDB-yə keçərdi." Bu, dizaynı irəli aparır və alternativi gördüyünü göstərir.
Mərhələni prioritetlərini adlandıraraq bitir: "Yazarkən gecikməyə və klaviatura ilə idarəyə fokuslanacağam, analitikaya isə sonda qısaca toxunacağam." Bu, müsahibəçiyə dərin analizlərin harada olacağını deyir, sənə isə qalan vaxt üçün plan verir.
The brief is vague on purpose. The first five minutes show whether you build the right thing, so ask before you draw, then write the answers down where the interviewer can see them.
Functional requirements: what users can do. List the core flows and agree on what is out of scope ("no editing of sent messages").
Non-functional requirements: how well. Performance targets, devices (phones, low-end Android), browsers, network quality, offline use, accessibility, languages and right-to-left scripts, SEO, privacy.
Users and scale: how many items on a screen, how often data changes, how many people act on the same data at once. In a frontend round, scale means "10,000 rows in a table" or "200 messages a minute in one chat", not servers.
Constraints: does the API exist or do you design it, which framework and design system are in place, is the page public or behind a login.
Example: autocomplete
Functional
- Suggestions appear while the user types, from 2 characters.
- Arrow keys move through suggestions, Enter selects, Escape closes.
- A suggestion shows a title and a category; selecting one opens the product.
Non-functional
- Suggestions within about 200 ms after the user pauses typing.
- Works on phones and with screen readers.
- Interface in Azerbaijani and English.
Assumptions
- A search endpoint exists; I define its contract.
- At most 10 suggestions, no paging inside the dropdown.
- Recent searches are kept per device, not per account.
Assumptions are part of the answer
When the interviewer says "up to you", decide, write the assumption down, and add one sentence on what would change if it were different: "I assume no offline support; if we needed it, the search cache would move into IndexedDB." This keeps the design moving and shows you saw the alternative.
Finish the stage by naming your priorities: "I'll focus on typing latency and keyboard access, and cover analytics briefly at the end." It tells the interviewer where the deep dives will be and gives you a plan for the remaining time.
Mərhələ 2: Klientin arxitekturası
Hər birinin bir məsuliyyəti olan qutular və məlumatın hansı istiqamətdə axdığını göstərən oxlar çək. Məlumatla zəngin tətbiq üçün tipik klient:
CDN: HTML, JS, CSS, images
|
Browser -----------------------------------------------------
App shell + router Service worker
|
Route /feed (lazy chunk) -> component tree
| |
Client state store Server-state cache
|
API layer
|
Server ------------------------------------------------------
REST / GraphQL API (BFF) Real-time gateway (WebSocket / SSE)Hər qutu nə üçündür:
- App shell: ilk render olunan çərçivə (header, naviqasiya, layout, error boundary) və router. Hər route ayrıca chunk-dır, ona görə
/feed-ə girən ziyarətçi ayarlar səhifəsini endirmir. - Komponent ağacı: məlumatı yükləyən və ya bağlayan komponentlərə və yalnız props-u render edən komponentlərə bölünür. Hansı state-in hansı komponentə məxsus olduğunu de.
- Server-state cache: serverə məxsus olan, klientdə sorğu açarı ilə saxlanılan məlumat; təkrarlanan sorğuların birləşdirilməsi, fonda yenidən yükləmə və invalidation ilə. Bunu TanStack Query, SWR, Apollo Client və ya Relay kimi kitabxanalar edir; birinin adını çəkmək olar, amma nə etdiyini izah etmək daha vacibdir.
- Klient state store-u: yalnız brauzerdə mövcud olan state: qaralama, seçilmiş tab, panelin açıq olub-olmaması. Çox vaxt komponent state-i və ya context bəs edir.
- API qatı: bütün sorğuların keçdiyi bir modul. Baza URL-i, auth, xətaların normallaşdırılması, təkrar cəhdlər və
AbortControllerilə ləğv bir dəfə burada yazılır, hər komponentdə yox. - Service worker və CDN: statik fayllar uzun cache müddəti ilə CDN-dən gəlir; service worker isə yalnız offline iş və ya background sync tələb olunanda lazımdır.
Serverlə təmas nöqtələri
Klientin serverlə görüşdüyü hər yeri adlandır: əsas API (backend-for-frontend cavabları ekranlara uyğun formalaşdıra bilər), real-time kanal, şəkilləri ölçüləndirən image CDN, auth endpoint-i, analitika endpoint-i. Onları sən dizayn etmirsən, hər birindən nə gözlədiyini deyirsən.
Bir cümlədə məlumat axını
Bunu açıq de: "Server məlumatı cache-ə gəlir, komponentlər onu hook-lar vasitəsilə oxuyur; istifadəçi əməliyyatları mutation çağırır, mutation cache-i optimistik yeniləyir və təsirlənən açarları invalidate edir." Bu cümlə ardıcıllıqla bağlı sonrakı sualların yarısına cavab verir.
Draw boxes with one responsibility each, and arrows that show which way data flows. A typical client for a data-heavy app:
CDN: HTML, JS, CSS, images
|
Browser -----------------------------------------------------
App shell + router Service worker
|
Route /feed (lazy chunk) -> component tree
| |
Client state store Server-state cache
|
API layer
|
Server ------------------------------------------------------
REST / GraphQL API (BFF) Real-time gateway (WebSocket / SSE)What each box is for:
- App shell: the frame that renders first (header, navigation, layout, an error boundary) and the router. Each route is a separate chunk, so a visitor of
/feeddoes not download the settings page. - Component tree: split into components that fetch or connect data and components that only render props. Say which component owns which state.
- Server-state cache: data the server owns, kept on the client by request key, with deduplication, background refetch and invalidation. Libraries such as TanStack Query, SWR, Apollo Client or Relay do this; naming one is fine, explaining what it does matters more.
- Client state store: state that exists only in the browser: a draft, the selected tab, whether a panel is open. Often small enough for component state or context.
- API layer: one module that every request goes through. Base URL, auth, error normalization, retries and
AbortControllercancellation live here once, not in every component. - Service worker and CDN: static assets from the CDN with long cache lifetimes; a service worker only if offline use or background sync is a requirement.
Server touch points
Name each place where the client meets the server: the main API (a backend-for-frontend can shape responses for the screens), a real-time channel, an image CDN that resizes images, an auth endpoint, an analytics endpoint. You do not design them; you state what you need from each.
Data flow in one sentence
Say it explicitly: "Server data flows into the cache, components read it through hooks; user actions call mutations, which update the cache optimistically and invalidate the affected keys." That sentence answers half of the follow-up questions about consistency.
Mərhələ 3: Məlumat modeli
Ekranlardan başla: hər birinin nə göstərdiyini sadala və bunu sahələri olan entity-lərə çevir. Sonra state-in hər parçasının harada yaşadığına qərar ver:
- Server state-i: serverə məxsusdur, klientdə cache-lənir: mesajlar, istifadəçilər, məhsullar.
- Klient state-i: yalnız brauzerdə mövcuddur: qaralama mətni, açıq dialoq, vurğulanmış təklif.
- URL state-i: səhifə yenilənəndə qalmalı və paylaşıla bilən olmalıdır: axtarış sorğusu, filtrlər, sıralama, seçilmiş elementin id-si, səhifə.
- Törəmə state: qalanından hesablanır və ayrıca saxlanılmır: filtrlənmiş siyahı, ümumi qiymət.
Nümunə: chat-app
type User = { id: string; name: string; avatarUrl: string };
type Message = {
id: string;
clientId: string;
chatId: string;
authorId: string;
text: string;
sentAt: string;
status: "sending" | "sent" | "failed";
};
type Chat = { id: string; title: string; memberIds: string[]; unreadCount: number };
type ChatStore = {
users: Record<string, User>;
messages: Record<string, Message>;
messageIdsByChat: Record<string, string[]>;
nextCursorByChat: Record<string, string | null>;
};Store normallaşdırılıb: hər istifadəçi və mesaj id üzrə bir dəfə saxlanılır, siyahılar isə id-ləri saxlayır. Avatarını dəyişən istifadəçi bir yerdə yenilənir və bütün mesajlar yeni avatarı göstərir; heç bir yerdə eyni entity-nin iki versiyası görünə bilməz. Bunun qiyməti render zamanı axtarışdır (messageIds.map((id) => messages[id])), adətən selector-a bükülür.
clientId və status interfeysə görə var: mesaj dərhal müvəqqəti id və status: "sending" ilə göstərilir, təsdiq gələndə isə serverdəki nüsxə ilə clientId üzrə uyğunlaşdırılır.
Cache açarları
Server-state cache-i hər cavabı bir açar altında saxlayır və açar cavabı dəyişən bütün girişləri ehtiva etməlidir:
["chats"]
["messages", chatId, { before: cursor }]
["search", { q: "laptop", locale: "az" }]Açarlar üç şeyi həll edir: hansı komponentlər bir sorğunu bölüşür (təkrarların birləşdirilməsi), mutation-dan sonra nə yenidən yüklənir (mesaj gələndə ["chats"]-ı invalidate et) və nəyi təkrar istifadə etmək olar (axtarışa qayıdanda cache-dəki nəticə dərhal görünür). Açarda bir girişin, məsələn dilin olmaması klassik bug-dır: Azərbaycan dilindəki səhifə cache-dən ingiliscə nəticələr göstərir.
Komponent sualında məlumat modeli kiçikdir, amma onu demək yenə də vacibdir: autocomplete-də query (klient state-i, axtarış səhifəsində URL-də də əks olunur), suggestions (sorğu üzrə açarlanan server state-i) və activeIndex (klient state-i) var.
Start from the screens: list what each one shows, and turn that into entities with fields. Then decide where every piece of state lives:
- Server state: owned by the server, cached on the client: messages, users, products.
- Client state: exists only in the browser: draft text, an open dialog, the highlighted suggestion.
- URL state: what should survive a reload and be shareable: search query, filters, sort order, the selected item's id, the page.
- Derived state: computed from the rest and never stored separately: a filtered list, a total price.
Example: chat-app
type User = { id: string; name: string; avatarUrl: string };
type Message = {
id: string;
clientId: string;
chatId: string;
authorId: string;
text: string;
sentAt: string;
status: "sending" | "sent" | "failed";
};
type Chat = { id: string; title: string; memberIds: string[]; unreadCount: number };
type ChatStore = {
users: Record<string, User>;
messages: Record<string, Message>;
messageIdsByChat: Record<string, string[]>;
nextCursorByChat: Record<string, string | null>;
};The store is normalized: each user and message is stored once, by id, and lists hold ids. A user who changes their avatar is updated in one place and every message shows the new one; nothing can show two versions of the same entity. The cost is a lookup when rendering (messageIds.map((id) => messages[id])), usually wrapped in a selector.
clientId and status exist because of the interface: a message is shown immediately with a temporary id and status: "sending", then matched with the server's copy by clientId when the confirmation arrives.
Cache keys
A server-state cache stores each response under a key, and the key must contain every input that changes the response:
["chats"]
["messages", chatId, { before: cursor }]
["search", { q: "laptop", locale: "az" }]Keys decide three things: which components share one request (deduplication), what is refetched after a mutation (invalidate ["chats"] when a message arrives), and what can be reused (going back to a search shows the cached result at once). A missing input in the key, such as the locale, is a classic bug: the Azerbaijani page shows English results from the cache.
For a component question the data model is smaller but still worth stating: the autocomplete has query (client state, mirrored in the URL on a search page), suggestions (server state keyed by query) and activeIndex (client state).
Mərhələ 4: İnterfeys: komponent API-si və şəbəkə API-si
Komponent API-si
Əsas komponentləri müqavilə kimi təsvir et: hansı props-lar daxil olur, hansı hadisələr çıxır, hansı vəziyyətləri render edir (yüklənmə, boş, xəta, uğur), controlled, yoxsa uncontrolled-dir. Komponent sualında cavabın özəyi budur:
<Autocomplete
label="Search products"
minQueryLength={2}
debounceMs={200}
fetchSuggestions={(query, { signal }) => searchProducts(query, { signal })}
renderItem={(item) => <ProductRow product={item} />}
onSelect={(item) => openProduct(item.id)}
/>Ucadan deməyə dəyən seçimlər: fetchSuggestions AbortSignal alır ki, köhnəlmiş sorğunu ləğv etmək mümkün olsun; renderItem komponenti başqa məlumat üçün də təkrar istifadə oluna bilən edir; label məcburidir, çünki input-un əlçatan adı olmalıdır. Sorğunu özü idarə edən formalar üçün controlled variantı da qeyd et (value və onChange).
Şəbəkə API-si
Hər endpoint-i metodu, parametrləri və cavab forması ilə yaz:
GET /api/search?q=lap&limit=10
200 OK
{ "query": "lap", "items": [{ "id": "p1", "title": "Laptop stand", "category": "Desks" }] }
GET /api/feed?cursor=eyJpZCI6MTQzfQ&limit=20
200 OK
{ "items": [{ "id": "143", "text": "..." }], "nextCursor": "eyJpZCI6MTIzfQ" }REST, yoxsa GraphQL. REST sadədir və GET cavabları URL üzrə həm brauzerdə, həm CDN-də cache-lənə bilir. GraphQL klientə ekranın ehtiyacı olan sahələri dəqiq istəməyə və iç-içə məlumatı bir sorğu ilə almağa imkan verir, tipli sxemi də var; qiyməti klientdə daha çox alət və POST sorğularının HTTP cache-lərində cache-lənməməsidir (GET üzərindən persisted query-lər kömək edir). Birini seç və səbəbini de; hər ikisi qəbul olunan cavabdır.
Səhifələmə.
- Offset (
?offset=40&limit=20): sadədir, 7-ci səhifəyə birbaşa keçmək olur. Amma yuxarıya yeni elementlər əlavə olunanda bütün səhifələr sürüşür: istifadəçi təkrarları görür və ya elementləri buraxır. Böyük offset-lər bir çox verilənlər bazası üçün həm də yavaşdır. - Cursor (
?cursor=...): server sonuncu elementə qeyri-şəffaf göstərici qaytarır. Məlumat dəyişəndə də səhifələr sabit qalır, sorğu da sürətli olur. 7-ci səhifəyə birbaşa keçmək olmur. - Sonsuz lentlər və chat-lar cursor işlədir; səhifə nömrələri olan admin cədvəlləri isə çox vaxt offset.
Xəta müqaviləsini də adlandır: status kodları, maşının oxuya biləcəyi xəta kodu və UI-ın hansı xətaları sahənin yanında (validasiya), hansılarını təkrar cəhd düyməsi olan banner kimi (şəbəkə) göstərdiyi.
Component API
Describe the main components as a contract: props in, events out, which states they render (loading, empty, error, success), and whether they are controlled or uncontrolled. For a component question this is the core of the answer:
<Autocomplete
label="Search products"
minQueryLength={2}
debounceMs={200}
fetchSuggestions={(query, { signal }) => searchProducts(query, { signal })}
renderItem={(item) => <ProductRow product={item} />}
onSelect={(item) => openProduct(item.id)}
/>Choices worth saying out loud: fetchSuggestions receives an AbortSignal, so a stale request can be cancelled; renderItem keeps the component reusable for other data; label is required because the input needs an accessible name. Mention the controlled option (value and onChange) for forms that own the query.
Network API
Write each endpoint with its method, parameters and response shape:
GET /api/search?q=lap&limit=10
200 OK
{ "query": "lap", "items": [{ "id": "p1", "title": "Laptop stand", "category": "Desks" }] }
GET /api/feed?cursor=eyJpZCI6MTQzfQ&limit=20
200 OK
{ "items": [{ "id": "143", "text": "..." }], "nextCursor": "eyJpZCI6MTIzfQ" }REST or GraphQL. REST is simple, and GET responses can be cached by URL in the browser and on a CDN. GraphQL lets the client ask for exactly the fields a screen needs and fetch nested data in one round trip, with a typed schema; the costs are more client tooling and the fact that POST queries are not cached by HTTP caches (persisted queries over GET help). Pick one and say why; both are acceptable answers.
Pagination.
- Offset (
?offset=40&limit=20): easy, and you can jump to page 7. But when new items are inserted at the top, every page shifts: the user sees duplicates or misses items. Deep offsets are also slow for many databases. - Cursor (
?cursor=...): the server returns an opaque pointer to the last item. Pages stay stable while data changes, and the query stays fast. You cannot jump to page 7. - Infinite feeds and chats use cursors; admin tables with page numbers often use offsets.
Also name the error contract: status codes, a machine-readable error code, and which errors the UI shows inline (validation) versus as a retryable banner (network).
Real-time yeniləmələr, optimistik yeniləmələr və xətalar
Serverdən yeniləmələri almaq
| Short polling | Server-Sent Events | WebSocket | |
|---|---|---|---|
| İstiqamət | Klient hər N saniyədən bir soruşur | Serverdən klientə | Hər iki tərəfə |
| Ötürmə üsulu | Adi HTTP sorğuları | Bir uzun HTTP cavabı (EventSource) | Upgrade olunmuş bağlantı, öz frame-ləri |
| Yenidən qoşulma | Qoşulmağa ehtiyac yoxdur | Avtomatik; Last-Event-ID serverə davam etməyə imkan verir | Sən yazırsan: backoff, heartbeat, yenidən sinxronizasiya |
| Nəyə uyğundur | Hər 30-60 saniyədən bir yenilənən dashboard-lar | Lentlər, bildirişlər, canlı nəticələr | Chat, onlayn status, birgə redaktə |
Bir dəqiqəlik gecikmə qəbul olunandırsa, polling dürüst defolt seçimdir, analytics-dashboard məsələsində olduğu kimi. SSE adi HTTP-dir və özü yenidən qoşulur, amma yalnız mətn daşıyır, HTTP/1.x üzərində isə brauzer bütün tab-lar üzrə bir domenə cəmi 6 açıq bağlantıya icazə verir, ona görə HTTP/2 və ya bir ortaq bağlantı lazımdır. İkitərəfli trafik üçün (chat-app, collaborative-editor) cavab WebSocket-dir və növbəti sual həmişə belədir: "bağlantı qopanda nə olur?" Backoff ilə yenidən qoşul, sonra sonuncu məlum mesaj id-sindən bəri buraxılanları yüklə.
Optimistik yeniləmələr
Nəticəni server təsdiqləməzdən əvvəl göstər və onu geri qaytarmaq üçün lazım olanı saxla:
async function toggleLike(post) {
const previous = cache.get(post.id);
cache.set(post.id, {
...previous,
liked: !previous.liked,
likes: previous.likes + (previous.liked ? -1 : 1),
});
try {
cache.set(post.id, await api.setLike(post.id, !previous.liked));
} catch {
cache.set(post.id, previous);
notifyError("like-failed");
}
}Bunu ucuz və demək olar ki, həmişə uğurlu olan əməliyyatlar üçün işlət: like, mesaj göndərmək (status: "sending" ilə), sıranı dəyişmək. Yalançı "hazırdır" pula və ya etibara başa gələn yerdə işlətmə: product-checkout-da ödəniş düyməsi gözləmə vəziyyəti göstərir, uğuru isə yalnız serverin cavabı göstərir.
Xətalar və təkrar cəhdlər
- Şəbəkə xətalarını və 5xx cavablarını eksponensial backoff, jitter və limitlə təkrarla. 4xx-ləri təkrarlama, 408 və 429 istisnadır (
Retry-After-ə əməl et). - Yalnız təkrarlamaq təhlükəsiz olan sorğuları təkrarla: GET və ya idempotency açarı olan yazma sorğuları ki, server dublikatı ata bilsin. Ödəniş API-ləri adətən belə açarı sorğu başlığında qəbul edir.
- Cavabı artıq lazım olmayan sorğuları ləğv et. autocomplete-də "lap" üçün cavab "laptop" üçün olandan sonra gələ bilər; köhnə sorğunu
AbortControllerilə ləğv et və ya cari sorğuya uyğun gəlməyən hər cavabı nəzərə alma. - Hər asinxron görünüşə uğurdan başqa üç vəziyyət də ver: yüklənmə, boş, təkrar cəhd düyməsi olan xəta.
Getting updates from the server
| Short polling | Server-Sent Events | WebSocket | |
|---|---|---|---|
| Direction | Client asks every N seconds | Server to client | Both ways |
| Transport | Plain HTTP requests | One long HTTP response (EventSource) | Upgraded connection, own framing |
| Reconnection | Nothing to reconnect | Automatic; Last-Event-ID lets the server resume | Yours to write: backoff, heartbeats, resync |
| Fits | Dashboards refreshed every 30-60 s | Feeds, notifications, live scores | Chat, presence, collaborative editing |
Polling is the honest default when a delay of a minute is fine, as in the analytics-dashboard problem. SSE is plain HTTP and reconnects on its own, but it carries text only, and over HTTP/1.x a browser allows only 6 open connections per domain across all tabs, so it needs HTTP/2 or one shared connection. WebSocket is the answer for two-way traffic (chat-app, collaborative-editor), and the follow-up is always "what happens when it drops?": reconnect with backoff, then fetch what was missed since the last known message id.
Optimistic updates
Show the result before the server confirms, and keep what you need to undo it:
async function toggleLike(post) {
const previous = cache.get(post.id);
cache.set(post.id, {
...previous,
liked: !previous.liked,
likes: previous.likes + (previous.liked ? -1 : 1),
});
try {
cache.set(post.id, await api.setLike(post.id, !previous.liked));
} catch {
cache.set(post.id, previous);
notifyError("like-failed");
}
}Use it for cheap actions that almost always succeed: likes, sending a message (with status: "sending"), reordering. Do not use it where a false "done" costs money or trust: in product-checkout, the payment button shows a pending state and only the server's answer shows success.
Errors and retries
- Retry network errors and 5xx responses with exponential backoff and jitter, and a limit. Do not retry 4xx, except 408 and 429 (respect
Retry-After). - Retry only requests that are safe to repeat: GET, or writes with an idempotency key so the server can drop the duplicate. Payment APIs commonly accept such a key in a request header.
- Cancel requests whose answer is no longer needed. In an autocomplete, the response for "lap" can arrive after the one for "laptop"; abort the old request with
AbortController, or ignore any response that does not match the current query. - Give every async view three more states besides success: loading, empty, error with a retry.
Mərhələ 5: Optimallaşdırma
Bu məhsul üçün ən vacib olan iki-üç sahəni seç və onlara dərindən gir; bildiyin bütün texnikaların siyahısı prioritet olmaması kimi oxunur. Hər seçimi tələbə və ya metrikaya bağla.
Render strategiyası. Login arxasında (dashboard, redaktor) CSR yaxşıdır. SSR açıq və fərdiləşdirilmiş səhifələrə sürətli ilk paint və SEO verir, qiyməti server işi və -dır. SSG və ya fonda yenidən generasiya olunan statik səhifələr az dəyişən məzmuna uyğundur (məhsul təsvirləri, məqalələr). Mağaza üçün geniş yayılmış qarışıq: məhsul məzmunu serverdə render olunur, səbət və tövsiyələr isə klientdə hydrate olunur.
Yükləmə. Kodu route-lar üzrə böl və ağır widget-ləri (zəngin mətn redaktoru, qrafiklər, video pleyer) lazy yüklə. Statik faylları uzun cache müddəti və hash-li fayl adları ilə CDN-dən ver. İlk ekrana lazım olanı preload et.
Şəkillər. Responsiv ölçülər üçün srcset və sizes, AVIF və ya WebP, görünən hissədən aşağıda loading="lazy", heç nə sürüşməsin deyə açıq width və height, ehtimal olunan elementi olan şəkil üçün fetchpriority="high".
Uzun siyahılar. Virtualizasiya et: yalnız görünən sətirləri və kiçik ehtiyatı render et; minlərlə elementi olan infinite-feed üçün bu, məcburidir. Sətir hündürlüklərini sabit saxla və ya ölç, geri naviqasiyada scroll mövqeyini bərpa et.
Core Web Vitals. LCP ən çox 2.5 s, INP ən çox 200 ms, CLS ən çox 0.1, real səhifə yükləmələrinin 75-ci persentilində ölçülür. INP 2024-cü ildə Core Web Vital kimi FID-in yerini tutub. Yalnız Lighthouse-da yox, real istifadəçilərdə (RUM) ölç.
Əlçatanlıq. Əvvəlcə semantik HTML; autocomplete üçün WAI-ARIA combobox pattern-i; yeni chat mesajları üçün live region; dialoqlarda və route dəyişəndən sonra fokusun idarəsi; karusel üçün pauza düyməsi və prefers-reduced-motion; video üçün subtitrlər.
i18n. Kodda sətir yoxdur, hər dil üçün cəm qaydaları, tarix, rəqəm və valyutalar üçün Intl, sağdan sola layout-lar üçün CSS logical property-ləri, daha uzun tərcümələr üçün yer.
Offline və zəif şəbəkələr. Service worker app shell-i cache-ləyir; yazma əməliyyatları outbox-a düşür və bağlantı qayıdanda yenidən göndərilir; UI bağlantının vəziyyətini göstərir.
Təhlükəsizlik. Etibarsız mətn mətn kimi render olunur (React onu escape edir, dangerouslySetInnerHTML istisnadır); zəngin məzmun sanitizasiya olunur; Content Security Policy skriptlərin haradan gələ biləcəyini məhdudlaşdırır. Sessiya token-lərini istənilən inject olunmuş skriptin oxuya bildiyi localStorage-da yox, HttpOnly, Secure, SameSite cookie-lərdə saxla; cookie ilə autentifikasiya olunan yazma sorğularını CSRF-dən qoru.
Pick the two or three areas that matter most for this product and go deep; a list of every technique you know reads as a lack of priorities. Tie each choice to a requirement or a metric.
Rendering strategy. CSR is fine behind a login (a dashboard, an editor). SSR gives a fast first paint and SEO for public, personalized pages, at the cost of server work and . SSG, or static pages regenerated in the background, suits content that changes rarely (product descriptions, articles). A common mix for a store: product content rendered on the server, cart and recommendations hydrated on the client.
Loading. Split code per route and lazy-load heavy widgets (rich text editor, charts, video player). Serve static assets from a CDN with long cache lifetimes and hashed file names. Preload what the first screen needs.
Images. srcset and sizes for responsive sizes, AVIF or WebP, loading="lazy" below the fold, explicit width and height so nothing shifts, and fetchpriority="high" for the image that is likely the element.
Long lists. Virtualize: render only the visible rows plus a small buffer, which is mandatory for an infinite-feed with thousands of items. Keep row heights stable or measured, and restore scroll position on back navigation.
Core Web Vitals. LCP at most 2.5 s, INP at most 200 ms, CLS at most 0.1, measured at the 75th percentile of real page loads. INP replaced FID as a Core Web Vital in 2024. Measure in the field (RUM), not only in Lighthouse.
Accessibility. Semantic HTML first; the WAI-ARIA combobox pattern for autocomplete; a live region for new chat messages; focus management in dialogs and after route changes; a pause button and prefers-reduced-motion for a carousel; captions for video.
i18n. No strings in code, plural rules per language, Intl for dates, numbers and currencies, CSS logical properties for right-to-left layouts, room for longer translations.
Offline and bad networks. A service worker caches the app shell; writes go to an outbox and are replayed when the connection returns; the UI shows the connection state.
Security. Untrusted text is rendered as text (React escapes it, except dangerouslySetInnerHTML); rich content is sanitized; a Content Security Policy limits where scripts can come from. Keep session tokens in HttpOnly, Secure, SameSite cookies rather than localStorage, which any injected script can read; protect cookie-authenticated writes against CSRF.
Klassik məsələlər və onların dərin analizləri
Raundların çoxu kiçik bir məsələlər dəstindən istifadə edir. Hər birinin özəyi var: müsahibəçinin dərinlik gözlədiyi hissə. Platformadakı System Design Board-da bunların hamısı var:
| Məsələ | Əvvəlcə nəyi dəqiqləşdirməli | Gözlənilən dərin analiz |
|---|---|---|
| autocomplete | Məlumat mənbəyi, minimal sorğu, zəngin nəticələr, cihazlar | Debounce, köhnəlmiş sorğuların ləğvi, sorğu üzrə cache, combobox-un klaviatura və ekran oxuyucusu dəstəyi |
| image-carousel | Autoplay, şəkillərin sayı, toxunuş, miniatürlər | Komponent API-si (controlled indeks), qonşu şəkillərin lazy yüklənməsi, layout-un sabitliyi, pauza və reduced motion |
| infinite-feed | Məzmun növləri, real-time yeniləmələr, miqyas | Cursor səhifələməsi, virtualizasiya, sürüşən məzmun əvəzinə "yeni postlar" banneri, scroll-un bərpası |
| chat-app | 1:1, yoxsa qruplar, tarixçənin həcmi, offline, fayllar | WebSocket və yenidən qoşulma, normallaşdırılmış store, clientId ilə optimistik göndərmə, sıra, oxunmamışların sayı |
| collaborative-editor | Eyni anda neçə redaktor, offline redaktə, zəngin mətn | Konfliktlərin həlli (operational transformation və ya Yjs, Automerge kimi CRDT-lər), onlayn status və kursorlar, hər istifadəçi üçün ayrıca undo |
| product-checkout | Ödəniş üsulları, qeydiyyatsız alış, bazarlar | Formaların validasiyası və xətalar, idempotent ödəniş sorğuları, optimistik uğurun olmaması, hosted ödəniş sahələri, əlçatan formalar |
| video-player | Canlı, yoxsa tələb üzrə, DRM, subtitrlər, cihazlar | Adaptiv streaming (Media Source Extensions üzərindən HLS və ya DASH), buferləmə vəziyyətləri, klaviatura ilə idarə, <track> subtitrləri |
| analytics-dashboard | Yenilənmə tezliyi, widget-lərin sayı, məlumatın həcmi | Hər widget üçün ayrıca yükləmə, polling və SSE, qrafiklərin render-i (SVG və ya canvas), virtualizasiya olunmuş cədvəllər, saat qurşaqları |
| multi-brand-design-system | Brendlərin sayı, nəyin fərqləndiyi, buraxılış prosesi | Design token-lər, runtime və build vaxtı theming, funksiyalar və bazarlar üçün brend konfiqurasiyası, hər brend üçün ayrıca bundle |
Hökm yox, trade-off de
Hər dərin analiz variantlar arasında seçimdir və cavab variantın özü yox, əsaslandırmadır. Faydalı cümlə quruluşu:
A variantı bizə X verir, amma Y-yə başa gəlir. Z tələbini nəzərə alaraq A-nı seçirəm. Z dəyişsəydi (məsələn, SEO lazım olsaydı), B-yə keçərdim.
Məsələn: "Hər 30 saniyədən bir polling-i qurmaq və saxlamaq SSE-dən sadədir. Dashboard-un tələbi bir dəqiqədən köhnə olmayan məlumatdır, ona görə polling seçirəm. Treyderlərə saniyəbəsaniyə qiymətlər lazım olsaydı, qiymət widget-lərini SSE-yə keçirərdim."
Rəqəmlər trade-off-ları konkretləşdirir. "Hər biri təxminən 100 bayt olan on təklif 1 KB edir, ona görə son 50 sorğunu yaddaşda cache-ləmək demək olar ki, pulsuzdur" arqumenti "cache yaxşıdır"-dan qat-qat güclüdür.
Most rounds reuse a small set of problems. Each one has a crux, the part where the interviewer wants depth. The platform's System Design Board has all of these:
| Problem | Clarify first | Expected deep dive |
|---|---|---|
| autocomplete | Data source, minimum query, rich results, devices | Debounce, cancelling stale requests, caching by query, combobox keyboard and screen reader support |
| image-carousel | Autoplay, number of images, touch, thumbnails | Component API (controlled index), loading neighbors lazily, layout stability, pause and reduced motion |
| infinite-feed | Content types, real-time updates, scale | Cursor pagination, virtualization, "new posts" banner instead of jumping content, scroll restoration |
| chat-app | 1:1 or groups, history size, offline, attachments | WebSocket and reconnection, normalized store, optimistic send with clientId, ordering, unread counts |
| collaborative-editor | Concurrent editors, offline editing, rich text | Conflict resolution (operational transformation or CRDTs such as Yjs or Automerge), presence and cursors, undo per user |
| product-checkout | Payment methods, guest checkout, markets | Form validation and errors, idempotent payment requests, no optimistic success, hosted payment fields, accessible forms |
| video-player | Live or on demand, DRM, captions, devices | Adaptive streaming (HLS or DASH through Media Source Extensions), buffering states, keyboard controls, <track> captions |
| analytics-dashboard | Refresh rate, number of widgets, data size | Fetching per widget, polling vs SSE, chart rendering (SVG or canvas), virtualized tables, time zones |
| multi-brand-design-system | Number of brands, what differs, release process | Design tokens, runtime vs build-time theming, brand configuration for features and markets, per-brand bundles |
State trade-offs, not verdicts
Each deep dive is a choice between options, and the answer is the reasoning, not the option. A useful sentence shape:
Option A gives us X, but costs Y. Given requirement Z, I choose A. If Z changed (for example, we needed SEO), I would switch to B.
For example: "Polling every 30 seconds is simpler to build and operate than SSE. The dashboard's requirement is data no older than a minute, so I choose polling. If traders needed second-by-second prices, I would move the price widgets to SSE."
Numbers make trade-offs concrete. "Ten suggestions of about 100 bytes each is 1 KB, so caching the last 50 queries in memory is free" is a stronger argument than "caching is good".
Müsahibə üçün məsləhətlər
Planla başla. "Tələblərdən başlayacağam, sonra klient arxitekturasını çəkəcəyəm, ardınca məlumat modeli, komponent və API dizaynı gələcək, sonda isə burada ən vacib olan optimallaşdırmalarla bitirəcəyəm." Bu, bir cümlədə struktur göstərir və müsahibəçiyə istiqamət vermək üçün xəritə verir.
Müsahibəçilər nəyə baxır
Middle səviyyə: ağlabatan defoltları olan tam, işlək dizayn. Aydın tələblər, hər qutunun işi olan diaqram, normallaşdırılmış məlumat modeli, real props-ları olan komponentlər və real cavab formaları olan endpoint-lər. Yüklənmə, boş və xəta vəziyyətləri əhatə olunub. Standart alətlərdən düzgün istifadə: debounce, cursor səhifələməsi, server-state cache-i, lazy yükləmə.
Senior səviyyə: yuxarıdakıların hamısı, üstəlik söhbəti idarə etmək. Bu məhsul üçün vacib olanı prioritetləşdirmək, trade-off-ları rəqəmlərlə ifadə etmək, uğursuzluq hallarını (qopmuş bağlantı, ikiqat ödəniş, köhnəlmiş cache) və onların həllini adlandırmaq, əlçatanlığı, i18n-i və təhlükəsizliyi soruşulmadan qaldırmaq, mürəkkəbliyi nə vaxt əlavə etməmək lazım olduğunu bilmək ("burada polling bəs edir"). Senior-lar həm də çatdırılmadan danışır: feature flag-lər, buraxılışdan sonra izlənəcək metrikalar, real istifadəçi monitorinqi.
Bal itirdən səhvlər
- Bir sual da verməmiş çəkməyə başlamaq və ya kitabxana adları saymaq.
- Klient əvəzinə backend-i (verilənlər bazaları, sharding) dizayn etmək.
- Uzun sükut. Əmin olmayanda da ucadan düşün: "Cursor və offset səhifələməsi arasında seçim edirəm; lent tez-tez dəyişir, ona görə…"
- Prioritet və tələblərlə əlaqə olmadan bütün optimallaşdırmaları sadalamaq.
- Uğursuz yolları unutmaq: zəif şəbəkə, xətalar, boş nəticələr, offline.
- Fərziyyələri yazmaq əvəzinə başda saxlamaq.
- Müsahibəçi seçimini sındıran yeni tələb əlavə edəndən sonra da onu müdafiə etmək. Dizaynı dəyiş və səbəbini de.
Board-da məşq et
System Design Board-dakı hər məsələdə hər mərhələ üçün sahələr və müqayisə üçün nümunə dizayn var. Özünə 45 dəqiqə vaxt qoy, sonra mərhələ-mərhələ müqayisə et: hansı tələbləri buraxdın, məlumat modelin hansı vəziyyətləri ifadə edə bilmədi, hansı trade-off-ları demədən keçdin.
Open with a plan. "I'll start with requirements, then draw the client architecture, then the data model, component and API design, and finish with the optimizations that matter most here." It shows structure in one sentence and gives the interviewer a map to steer with.
What interviewers look for
Middle level: a complete, working design with sensible defaults. Clear requirements, a diagram where every box has a job, a normalized data model, components with real props and endpoints with real shapes. Loading, empty and error states covered. Correct use of standard tools: debounce, cursor pagination, a server-state cache, lazy loading.
Senior level: everything above, plus driving the conversation. Prioritizing what matters for this product, stating trade-offs with numbers, naming failure modes (a dropped connection, a duplicate payment, a stale cache) and their handling, raising accessibility, i18n and security without being asked, and knowing when not to add complexity ("polling is enough here"). Seniors also talk about delivery: feature flags, metrics to watch after launch, real-user monitoring.
Mistakes that cost points
- Drawing or naming libraries before asking a single question.
- Designing the backend (databases, sharding) instead of the client.
- Long silences. Think out loud, even when unsure: "I'm deciding between cursor and offset pagination; the feed changes often, so..."
- Listing every optimization without priorities or a link to the requirements.
- Forgetting the unhappy paths: slow networks, errors, empty results, offline.
- Keeping assumptions in your head instead of writing them down.
- Defending a choice after the interviewer has added a requirement that breaks it. Change the design and say why.
Practise on the Board
Each problem on the System Design Board has fields for every stage and a reference design to compare with. Time yourself for 45 minutes, then compare stage by stage: which requirements you missed, which states your data model could not express, which trade-offs you left unstated.
Frontend system design-ı review edərkən nəyi yoxlamalı
Bu siyahını özün yazmadığın frontend dizaynını review edəndə işlət: komanda yoldaşının dizayn sənədi, kitabxananın nümunə arxitekturası və ya AI assistentin təklifi. Sahibi olmayan state və ya unudulmuş xəta vəziyyəti kimi boşluqlar kağız üzərində ucuz düzəlir, build-dən sonra isə kodun yenidən yazılmasını tələb edir.
- Tələblər, fərziyyələr və əhatədən kənar qalanlar rəqəmlərlə yazılıbmı? Cihazları, şəbəkəni, əlçatanlığı, dilləri və miqyası (ekrandakı elementlərin sayı, məlumatın yenilənmə tezliyi) axtar. Kitabxana və ya service worker kimi hər seçim bir tələbə bağlanmalıdır.
- State-in hər parçasının yalnız bir yeri varmı? Ekrandakı hər şey üçün qərar ver: server state-i (cache-də), klient state-i, URL state-i, yoxsa törəmə state. Ayrıca saxlanan törəmə dəyərləri və səhifə yenilənəndən sonra qalmalı olduğu halda komponent state-ində saxlanan filtrləri qeyd et.
- Hər entity id üzrə bir dəfə saxlanılırmı? Eyni istifadəçi obyekti hər elementin içinə köçürülübsə, yeniləmədən sonra ekranda iki versiya qalır. Normallaşdırılmış store-da siyahılar id-ləri saxlayır, ona görə bir dəyişiklik bir yeri yeniləyir.
- Hər cache açarı cavabı dəyişən bütün girişləri ehtiva edirmi? Hər endpoint-in parametrlərini onun açarı ilə tutuşdur:
["products", category]yox,["products", { category, locale }], yoxsa cache-dən başqa dildə nəticələr gəlir. Hər mutation-un hansı açarları invalidate etdiyini də yoxla. - Hər endpoint-in metodu, parametrləri, cavab forması və xəta müqaviləsi varmı? Offset səhifələməsində yuxarıya yeni elementlər əlavə olunanda bütün səhifələr sürüşür, təkrarlar və ya buraxılmış elementlər yaranır; cursor bunun qarşısını alır. Xətalara status kodları, maşının oxuya biləcəyi kod və UI-da yer lazımdır: sahənin yanında, yoxsa təkrar cəhd düyməsi olan banner-də.
- Uğursuz yollar dizayn olunubmu? Hər asinxron görünüşə yüklənmə, boş və təkrar cəhd düyməli xəta vəziyyətləri lazımdır. Təkrar cəhdlərin limiti və backoff-u olmalıdır, təkrarlanan sorğular isə yalnız təhlükəsiz olanlardır (GET və ya idempotency açarı olan yazma sorğuları); köhnəlmiş sorğular
AbortSignalilə ləğv olunur; optimistik yeniləmələr geri qaytarmaq üçün əvvəlki dəyəri saxlayır.
Use this list for a frontend design you did not write: a teammate's design doc, a library's reference architecture or an AI assistant's proposal. Gaps such as state with no owner or a missing error state are cheap to fix on paper and cost a rewrite after the build.
- Are requirements, assumptions and out-of-scope items written down, with numbers? Look for devices, network, accessibility, languages and scale (items on a screen, update rate). Every choice, such as a library or a service worker, should trace back to a requirement.
- Does every piece of state have exactly one home? For each thing on screen, decide: server state (in the cache), client state, URL state or derived. Flag derived values stored separately, and filters kept in component state that should survive a reload.
- Is each entity stored once, by id? If the same user object is copied into every item, an update leaves two versions on screen. In a normalized store lists hold ids, so one change updates one place.
- Does every cache key contain every input that changes the response? Compare each endpoint's parameters with its key:
["products", { category, locale }], not["products", category], or cached results show in the wrong language. Check which keys each mutation invalidates. - Does each endpoint have a method, parameters, a response shape and an error contract? With offset pagination, items inserted at the top shift every page, giving duplicates or gaps; cursors avoid that. Errors need status codes, a machine-readable code and a place in the UI: inline or a retry banner.
- Are the unhappy paths designed? Every async view needs loading, empty and error-with-retry states. Retries are limited, back off, and repeat only safe requests (GET, or writes with an idempotency key); stale requests are cancelled with an
AbortSignal; optimistic updates keep the previous value to roll back.
Özünü yoxla
Təcrübədə sına
Bu mövzudan istifadə edən praktiki işlər.