EngineeringSenior DeveloperInterview Sessions

Interview Questions - Phase 2: Frontend & Full-Stack Integration

Trọng tâm: Architecture phía Frontend, Web Core Vitals, và cách kết hợp an toàn với Backend .NET. Câu hỏi scenario-based.


1. Web Frameworks (Next.js & React)

Câu hỏi lý thuyết

  1. [Senior] Phân biệt SSR, SSG, ISR và CSR trong Next.js. E-commerce có catalogue thay đổi giá hàng giờ thì bạn dùng cơ chế nào và tại sao?
  2. [Architect] Hydration Mismatch trong React SSR là gì? Nêu ví dụ và cách khắc phục triệt để.
  3. [Senior] React Render lifecycle và cơ chế Reconciliation. Khi nào bạn sử dụng useMemo và useCallback, và tại sao lạm dụng nó lại phản tác dụng?

🎯 Use Case 1: E-Commerce Product Page - Chọn Rendering Strategy

Bạn xây trang chi tiết sản phẩm cho e-commerce:

  • Product info thay đổi ít (tên, mô tả, ảnh)
  • Giá thay đổi hàng giờ (flash sale)
  • Stock count thay đổi realtime
  • Reviews user-generated, thay đổi liên tục
  1. [Senior] Bạn sẽ dùng kết hợp rendering strategies nào? (ISR cho shell + client-fetch cho dynamic parts?)
  2. [Architect] Nếu có 1 triệu SKU, build time cho SSG sẽ thế nào? Giải pháp generateStaticParams partial + fallback?

🎯 Use Case 2: Admin Dashboard với Complex State

Dashboard admin hiển thị:

  • Table 10,000 rows (virtual scroll)
  • 5 charts realtime (WebSocket)
  • Filters liên kết nhau (date range, category, status)
  • Mỗi filter thay đổi → refetch data
  1. [Senior] State management: Context API, Zustand, hay React Query? Tại sao React Query (TanStack Query) thường là best choice cho server state?
  2. [Senior] Table 10K rows render chậm. Bạn dùng virtualization library nào? React re-render cả table khi 1 row thay đổi - fix thế nào?

2. Vite & Architecture Frontend

Câu hỏi lý thuyết

  1. [Senior] Điểm cốt lõi khiến Vite có tốc độ Cold Start HMR ngay tức khắc so với Webpack? Vite lợi dụng công nghệ gì của trình duyệt?
  2. [Architect] Tổ chức Monorepo lớn chứa 3 Next.js apps, chung 1 design system layer, cùng kết nối .NET backend. Chia sẻ state và API clients mà không duplicate code bundling?

🎯 Use Case 3: Micro-Frontend cho Enterprise Portal

Enterprise portal có 4 modules (HR, Finance, Inventory, CRM), mỗi module 1 team phát triển. Cần deploy ĐỘC LẬP nhưng user thấy 1 app thống nhất.

  1. [Architect] Bạn chọn approach nào: Module Federation, iframe, hay route-based split? Trade-offs?
  2. [Architect] Shared authentication state giữa các micro-frontends: duplicated MSAL instance hay centralized auth shell?

3. Full-Stack Integration & Security

Câu hỏi lý thuyết

  1. [Senior] JWT Token lưu ở localStorage vi phạm tiêu chuẩn bảo mật nào và tại sao nguy hiểm? Phân tích cách lưu an toàn với HttpOnly Cookie.
  2. [Architect] Chuyển sang Cookie → vướng CSRF. Kiến trúc Anti-CSRF với Backend .NET và SPA React phối hợp thế nào?

🎯 Use Case 4: SSO Login Flow cho Multi-App Enterprise

Công ty có 3 web apps (Customer Portal, Admin Dashboard, Partner Portal). Cần SSO dùng Azure Entra ID. User login 1 lần → access cả 3 apps.

  1. [Senior] Flow OIDC Authorization Code + PKCE hoạt động thế nào? Tại sao Implicit Flow bị deprecated?
  2. [Architect] Refresh Token rotation strategy: khi Access Token hết hạn (15 phút), Next.js middleware intercept 401 và refresh - race condition khi 3 API calls cùng lúc gặp 401?

🎯 Use Case 5: Real-time Notifications trên 5 Pods

Backend SignalR có 5 pods. User connect pod 1, nhưng notification được publish từ pod 3.

  1. [Architect] Vấn đề gì xảy ra? Thiết kế Backplane Pattern (Redis/Azure SignalR Service) ra sao?
  2. [Senior] Client-side: khi WebSocket disconnect, reconnect strategy nào? Có cần queue missed messages?

⚠️ Anti-Patterns - Frontend & Fullstack

#Anti-PatternTại sao nguy hiểm
1JWT trong localStorageXSS script đọc được token → session hijacking
2API key trong frontend code - NEXT_PUBLIC_API_KEY=secretClient code visible. Ai cũng đọc được qua DevTools
3useEffect fetch loop - Missing dependency array hoặc setState trong useEffect trigger re-renderInfinite loop gọi API liên tục → DDoS chính backend mình
4Props drilling 10 levels - Pass props qua 10 componentsUnmaintainable. Dùng Context hoặc state management library
5No error boundary - 1 component crash → toàn app trắngUser mất toàn bộ work. Cần ErrorBoundary per feature module
6Fetch trong component, không cancel - Component unmount nhưng fetch resolve → setState on unmountedMemory leak warning, potential state corruption
7CORS wildcard production - AllowAnyOrigin() + AllowCredentials()Security hole. Browser block, hoặc mở cửa cho mọi domain
8Hardcode API URLs - fetch('https://prod.api.com/...')Chuyển environment phải sửa code. Dùng env variables

👉 Xem đáp án chi tiết tại: Answers/ans-02-frontend-fullstack.md