Architecture, Internals & Migration Questions
1. What is vertical-slice architecture?β
Organizing code around product capabilities/use cases rather than only technical folders such as components, services and utils.
2. Why should route files be composition roots?β
They should assemble route context, data and feature UI while durable business rules live in owned modules that can be reused and tested independently.
3. What is dependency direction?β
Higher-level delivery/framework code depends on application/domain capabilities, while domain policy should avoid unnecessary dependence on Next.js route/runtime APIs.
4. Why use a DAL?β
To centralize secure data access, tenant/resource scope, field projection and reusable server reads rather than scattering query/auth rules across pages.
5. Why use DTOs?β
To expose only the fields a consumer needs and prevent database entities/secrets/internal fields from leaking across server/client or API boundaries.
6. Query vs command?β
Queries read state; commands own state-changing business operations, authorization, transactions, idempotency, audit/outbox and invalidation.
7. Why are package exports useful in a monorepo?β
They define explicit public package APIs and stop consumers from deep-importing internal implementation paths.
8. What does transpilePackages solve?β
It lets Next.js transpile/bundle selected local or external packages correctly. It is a build integration mechanism, not a trust/security boundary.
9. Why create server/client package entry points?β
To prevent browser consumers from accidentally importing server-only dependencies and to keep environment ownership explicit.
10. When should code become a shared package?β
When it has stable cross-application ownership and reuse value. Product-specific logic should remain with its capability rather than entering a generic shared dumping ground.
11. How do you model multi-tenancy?β
Carry tenant identity through session/membership, DAL queries, caches, jobs, search, storage, events and telemetry; ingress tenant hints are not authorization.
12. Permission vs entitlement vs feature flag?β
Permission answers whether the actor may perform an action; entitlement whether the account/plan includes it; feature flag whether the capability is enabled/rolling out.
13. Is Next.js a full backend replacement?β
Its server features can form an effective BFF/API layer, but dedicated services may still be appropriate for independent scaling, realtime protocols, workflows, specialized runtimes or organizational boundaries.
14. When use an event instead of a direct call?β
When a completed business fact can be consumed asynchronously and eventual consistency is acceptable. Required synchronous invariants should remain synchronous.
15. When use a durable job?β
For work that must survive request/process failure, be retried, tracked or rate-controlledβexports, imports, email, AI processing and reconciliation are common examples.
16. When split a service?β
When a real constraint appears: independent scaling, failure isolation, regulatory/data boundary, runtime mismatch or strong team release autonomy.
17. What are Multi-Zones?β
A Next.js architecture where separate applications own unique path sets and can deploy independently behind coordinated routing.
18. Main Multi-Zone trade-off?β
Cross-zone navigation is a hard document navigation rather than seamless same-router client navigation, and assets/auth/version compatibility need coordination.
19. Why use ADRs?β
To record context, options, decision and consequences for durable/high-cost architectural choices so teams understand why a design exists.
20. What is an architecture fitness function?β
An automated check that continuously enforces an architectural invariant such as import boundaries, bundle budgets or tenant-safe interfaces.
21. What is RSC/Flight at a senior level?β
A server-render representation/transport that carries Server Component results and client references. The concept matters; private wire bytes/headers are not application APIs.
22. What are client references?β
Build-generated references that let server-render output identify Client Components/chunks for the browser without executing those components as server-only code.
23. What are Server Function references?β
Build-generated identities linking client-invokable server references to executable server functions. Their private IDs/transport are framework internals.
24. Why can separate builds be incompatible during rollout?β
Generated assets, route data, Action references and encrypted closure material can differ even when source looks similar. Treat a build as an immutable coherent artifact.
25. What does Turbopack do in current Next.js?β
It is the default bundler for dev/build, analyzing the dependency graph and producing environment-specific client/server outputs with framework transforms.
26. What are .next manifests?β
Serialized framework/compiler/runtime metadata used internally for routing, references, prerender/build assets and other orchestration. Unless documented, their schemas are private.
27. Why not import next/dist/*?β
Those are private internals without normal public API stability and can change across releases.
28. What is Output File Tracing?β
Build-time analysis that determines server runtime file dependencies so minimal production artifacts such as standalone output can be created.
29. Router Cache and route-tree reconciliation?β
The client router stores route/RSC segment data and merges new navigation payloads with the existing tree, preserving compatible layouts and client state.
30. Node vs Edge runtime decision?β
Choose based on APIs/packages/latency/deployment constraints. Current Proxy uses Node runtime; do not assume Edge is universally faster or the default for every server concern.
31. Why is a custom Next server an escape hatch?β
It takes ownership of lifecycle/routing/server integration that Next normally manages and can disable or complicate framework deployment optimizations such as generated standalone behavior.
32. What is the first step of a major upgrade?β
Freeze and inventory the current system: Next/React/Node versions, config, deprecated APIs, runtime assumptions, critical routes and production baselines.
33. What is next upgrade?β
The first-party CLI upgrade workflow available in modern Next.js (16.1+), combining version updates and relevant migration tooling.
34. What are codemods good for?β
Mechanical API/config transformations. They do not prove semantic correctness, security, cache behavior or production compatibility.
35. Which request APIs require modern async access?β
cookies, headers, draftMode, and framework route values such as params/searchParams in their applicable contexts.
36. Why migrate middleware.ts to proxy.ts?β
The current convention better communicates request-front-door semantics and replaces the deprecated Middleware naming/model.
37. What happened to next lint?β
It was removed in Next.js 16. Run ESLint/Biome directly and keep linting as an explicit CI gate.
38. What happened to serverRuntimeConfig/publicRuntimeConfig?β
They are removed from the modern model. Use environment variables and explicit server/public runtime configuration patterns.
39. How do you migrate old PPR/dynamicIO cache assumptions?β
Move to current Cache Components, explicit cache identity/lifetimes/tags, request-time boundaries and Suspense shell/hole composition; keep old flags only as migration history.
40. How do you migrate a client-heavy SPA?β
Incrementally: establish App Router routing, preserve behavior, move canonical reads server-side, narrow client islands, migrate mutations/auth/cache/resources, then delete duplicated legacy paths.
41. Why can a migration pass tests and still fail production?β
Production build, proxy/CDN topology, multiple replicas, real databases/native packages, rolling version skew and real user devices can expose behavior test environments do not model.
42. What is the migration completion rule?β
Target stable version deployed, deprecated compatibility removed, green production evidence, security/performance healthy, rollout observed and rollback/legacy cleanup completed.
43. Senior architecture answer pattern?β
State capability owner, public boundary, data owner, security invariant, consistency/cache model, failure domain, deployment owner and evolution path.