{"schemaVersion":"1.0","type":"TechArticle","types":["Article","TechArticle"],"slug":"frontend-architecture-patterns-a-visual-guide-from-spa-to-micro-frontends-5a25w","url":"https://zyvop.com/frontend-architecture-patterns-a-visual-guide-from-spa-to-micro-frontends-5a25w","title":"Frontend Architecture Patterns: A Visual Guide from SPA to Micro-Frontends","subtitle":"A visual guide to rendering, code structure, state management, and system-scale patterns, with a decision flowchart for choosing the right one.","tldr":"Frontend architecture is really four decisions: where HTML is rendered, how code is organized, how state flows, and how teams ship together. This guide maps every major pattern, from SPA and SSR to islands, micro-frontends, and local-first, with colorful diagrams.","keywords":["State Management","System Design","SSR","frontend architecture","micro-frontends","Architecture"],"entities":["Shobit Singh","State Management","System Design","SSR","frontend architecture","micro-frontends","Architecture","ZyVOP"],"keyTakeaways":["This post walks through the main patterns in each group: what problem it solves, how it works, and where it hurts.","Patterns aren't mutually exclusive.","A real app usually mixes several from each group."],"headings":["1. Rendering Patterns","SPA / CSR (Client-Side Rendering)","MPA (Multi-Page Application)","SSR (Server-Side Rendering)","SSG (Static Site Generation)","ISR (Incremental Static Regeneration)","Streaming SSR and React Server Components","Islands and Resumability","Quick Comparison","2. Code Organization Patterns","Component-Based Architecture","Atomic Design","Feature-Based and Feature-Sliced Design","Layered, Clean, and Hexagonal Frontend","MVC, MVP, and MVVM","3. State and Data Flow Patterns","Unidirectional Data Flow (Flux / Redux)","Reactive State and Signals","Server State vs Client State","State Machines and Statecharts","4. System-Scale Patterns","Micro-Frontends","Monorepo with Shared Packages","Backend for Frontend (BFF)"],"outboundLinks":["https://web.dev/articles/rendering-on-the-web","https://www.patterns.dev/","https://jasonformat.com/islands-architecture/","https://atomicdesign.bradfrost.com/","https://feature-sliced.design/","https://martinfowler.com/articles/micro-frontends.html","https://samnewman.io/patterns/architectural/bff/","https://www.inkandswitch.com/local-first/"],"contentText":"\"Frontend architecture\" sounds like one decision, but it's really four that people tend to blur together: Rendering: where does the HTML come from? Code organization: how is the codebase structured? State and data flow: how does data move through the UI? System scale: how do many teams ship one product? This post walks through the main patterns in each group: what problem it solves, how it works, and where it hurts. Patterns aren't mutually exclusive. A real app usually mixes several from each group. mindmap root((Frontend Architecture)) Rendering SPA / CSR MPA SSR SSG ISR Streaming and RSC Islands Code Organization Component based Atomic Design Feature Sliced Layered and Clean MVC and MVVM State and Data Flow Flux and Redux Signals Server vs Client state State machines System Scale Micro frontends Monorepo BFF Local first1. Rendering Patterns The first question: when and where is the HTML produced? flowchart LR subgraph AOT[\"Ahead of time\"] SSG[\"SSG\"] ISR[\"ISR\"] end subgraph REQ[\"On each request\"] SSR[\"SSR\"] RSC[\"Streaming + RSC\"] EDGE[\"Edge SSR\"] end subgraph BRW[\"In the browser\"] CSR[\"SPA / CSR\"] ISL[\"Islands\"] end classDef green fill:#16a34a,stroke:#166534,color:#fff classDef blue fill:#2563eb,stroke:#1e40af,color:#fff classDef pink fill:#db2777,stroke:#9d174d,color:#fff class SSG,ISR green class SSR,RSC,EDGE blue class CSR,ISL pink style AOT fill:#dcfce7,stroke:#16a34a,color:#111 style REQ fill:#dbeafe,stroke:#2563eb,color:#111 style BRW fill:#fce7f3,stroke:#db2777,color:#111SPA / CSR (Client-Side Rendering) The server returns an empty HTML shell and a JavaScript bundle. The browser builds the UI and fetches data on its own. sequenceDiagram participant B as Browser participant C as CDN participant A as API B-&gt;&gt;C: GET /app C--&gt;&gt;B: Empty HTML + JS bundle rect rgb(254, 243, 199) Note over B: Download, parse, run JS end B-&gt;&gt;A: GET /api/data A--&gt;&gt;B: JSON rect rgb(220, 252, 231) Note over B: Render UI endPros: instant in-app navigation, rich interactivity, simple static hosting. Cons: slow first paint, weaker SEO unless you add SSR or pre-rendering, large bundles. Use for: dashboards, admin panels, anything behind a login. MPA (Multi-Page Application) Every navigation is a full request that returns a ready-made HTML page. It's the original web model, and it's having a comeback through HTML-over-the-wire tools like htmx and Hotwire, plus the View Transitions API for smooth page changes. Pros: simple, SEO-friendly, works without JavaScript. Cons: full reloads, hard to carry client state across pages. Use for: content sites and form-heavy apps. SSR (Server-Side Rendering) The server renders HTML on every request, then JavaScript hydrates it to make it interactive. sequenceDiagram participant B as Browser participant S as Server participant D as Data source B-&gt;&gt;S: GET /products S-&gt;&gt;D: Query D--&gt;&gt;S: Data rect rgb(219, 234, 254) Note over S: Render HTML on the server end S--&gt;&gt;B: Full HTML (visible immediately) rect rgb(252, 231, 243) Note over B: Download JS and hydrate (now interactive) endPros: fast first paint, great SEO, always-fresh data. Cons: server cost, slower time to first byte, and a hydration gap where the page looks ready but isn't clickable yet. Edge SSR is the same idea running on CDN nodes close to the user, which cuts latency. SSG (Static Site Generation) Pages are rendered once at build time and served from a CDN. It's the fastest and cheapest option, but content is only as fresh as the last build, and build times grow with page count. Perfect for docs, blogs, and marketing sites. ISR (Incremental Static Regeneration) SSG with an expiry date. Pages are served from cache and regenerated in the background when they go stale (stale-while-revalidate). flowchart LR U[\"Request\"]:::blue --&gt; CA{\"Cached page fresh?\"}:::yellow CA --&gt;|Yes| S1[\"Serve from CDN\"]:::green CA --&gt;|Stale| S2[\"Serve stale page now\"]:::orange S2 --&gt; RG[\"Regenerate in background\"]:::purple RG --&gt; UP[\"Update cache\"]:::teal classDef blue fill:#2563eb,stroke:#1e40af,color:#fff classDef yellow fill:#facc15,stroke:#a16207,color:#111 classDef green fill:#16a34a,stroke:#166534,color:#fff classDef orange fill:#ea580c,stroke:#9a3412,color:#fff classDef purple fill:#9333ea,stroke:#6b21a8,color:#fff classDef teal fill:#0d9488,stroke:#115e59,color:#fffGreat for product catalogs and news: thousands of pages that change occasionally. Streaming SSR and React Server Components Streaming sends HTML in chunks as each &lt;Suspense&gt; boundary resolves, so one slow query doesn't block the whole page. React Server Components (RSC) go further. Server components run only on the server and ship zero JavaScript. Only components marked as client components get hydrated. flowchart TD P[\"Page (server)\"]:::server --&gt; H[\"Header (server)\"]:::server P --&gt; L[\"ProductList (server, fetches data)\"]:::server L --&gt; C[\"ProductCard (server)\"]:::server C --&gt; B[\"AddToCartButton (client)\"]:::client P --&gt; F[\"FilterBar (client)\"]:::client classDef server fill:#2563eb,stroke:#1e40af,color:#fff classDef client fill:#ea580c,stroke:#9a3412,color:#fffBlue = server only, orange = hydrated in the browser. The trade-off is a new mental model: you have to think about the server/client boundary and what can cross it (only serializable props). Islands and Resumability Islands (Astro, Fresh): a page is mostly static HTML with small interactive \"islands\" that hydrate independently, often only when they scroll into view. flowchart TB PG[\"HTML page\"]:::blue PG --&gt; H[\"Header&lt;br/&gt;static\"]:::gray PG --&gt; A[\"Article&lt;br/&gt;static\"]:::gray PG --&gt; S[\"Search box&lt;br/&gt;island\"]:::orange PG --&gt; CM[\"Comments&lt;br/&gt;island\"]:::orange PG --&gt; F[\"Footer&lt;br/&gt;static\"]:::gray classDef blue fill:#2563eb,stroke:#1e40af,color:#fff classDef gray fill:#9ca3af,stroke:#4b5563,color:#111 classDef orange fill:#ea580c,stroke:#9a3412,color:#fffResumability (Qwik) goes one step further. App state is serialized into the HTML, so the browser can resume where the server left off with no hydration step. Code is lazy-loaded as the user interacts. Quick Comparison Pattern HTML is made First load SEO Good for Common tools SPA / CSR In the browser Slower Weaker by default Dashboards, internal tools Vite + React/Vue, Angular MPA On the server, per page Fast Great Content sites, forms Rails, Laravel, Django, htmx SSR On the server, per request Fast Great Personalized pages, e-commerce Next.js, Nuxt, SvelteKit, React Router SSG At build time Fastest Great Docs, blogs, marketing Astro, Eleventy, Hugo ISR At build, refreshed in background Fastest Great Catalogs, news Next.js, Nuxt Streaming + RSC On the server, in chunks Fast, progressive Great Data-heavy pages Next.js (App Router) Islands At build or request, JS only where needed Fast Great Content sites with some interactivity Astro, Fresh 2. Code Organization Patterns The second question: how do you structure the code so it stays maintainable? Component-Based Architecture The foundation of React, Vue, Angular, and Svelte. The UI is a tree of small, reusable, encapsulated components: props flow down, events flow up. flowchart TD App:::blue --&gt; Layout:::purple Layout --&gt; Sidebar:::teal Layout --&gt; Page:::teal Page --&gt; Table:::green Page --&gt; Chart:::green Table --&gt; Row:::orange classDef blue fill:#2563eb,stroke:#1e40af,color:#fff classDef purple fill:#9333ea,stroke:#6b21a8,color:#fff classDef teal fill:#0d9488,stroke:#115e59,color:#fff classDef green fill:#16a34a,stroke:#166534,color:#fff classDef orange fill:#ea580c,stroke:#9a3412,color:#fffA common refinement is separating logic from presentation (the old container/presentational split, today usually done with custom hooks or composables). Atomic Design A shared vocabulary for component levels, from smallest to largest. flowchart LR A[\"Atoms&lt;br/&gt;Button, Input\"]:::pink --&gt; M[\"Molecules&lt;br/&gt;Search field\"]:::orange --&gt; O[\"Organisms&lt;br/&gt;Header, Product grid\"]:::yellow --&gt; T[\"Templates&lt;br/&gt;Page layout\"]:::green --&gt; P[\"Pages&lt;br/&gt;Real content\"]:::blue classDef pink fill:#db2777,stroke:#9d174d,color:#fff classDef orange fill:#ea580c,stroke:#9a3412,color:#fff classDef yellow fill:#facc15,stroke:#a16207,color:#111 classDef green fill:#16a34a,stroke:#166534,color:#fff classDef blue fill:#2563eb,stroke:#1e40af,color:#fffGreat for design systems. Less helpful for deciding where business logic lives. Feature-Based and Feature-Sliced Design Group code by feature, not by file type. Instead of components/, hooks/, and services/ folders that scatter one feature across the tree, each feature owns its UI, state, and API code. src/ features/ cart/ ui/ model/ api/ checkout/ entities/ product/ shared/Feature-Sliced Design formalizes this into layers with one strict rule: imports only go downward. flowchart TD APP[\"app: init, providers, routing\"]:::red --&gt; PAGES[\"pages: route screens\"]:::orange PAGES --&gt; WIDGETS[\"widgets: large UI blocks\"]:::yellow WIDGETS --&gt; FEATURES[\"features: user actions, e.g. add to cart\"]:::green FEATURES --&gt; ENTITIES[\"entities: business objects, e.g. Product\"]:::blue ENTITIES --&gt; SHARED[\"shared: UI kit, utils, API client\"]:::purple classDef red fill:#dc2626,stroke:#991b1b,color:#fff classDef orange fill:#ea580c,stroke:#9a3412,color:#fff classDef yellow fill:#facc15,stroke:#a16207,color:#111 classDef green fill:#16a34a,stroke:#166534,color:#fff classDef blue fill:#2563eb,stroke:#1e40af,color:#fff classDef purple fill:#9333ea,stroke:#6b21a8,color:#fffLayered, Clean, and Hexagonal Frontend Keep business rules independent of the framework and the backend. The UI calls use cases, use cases talk to ports (interfaces), and adapters (REST client, GraphQL, localStorage) implement them. flowchart LR UI[\"UI layer&lt;br/&gt;components\"]:::blue --&gt; APP[\"Application layer&lt;br/&gt;hooks, use cases\"]:::green APP --&gt; DOM[\"Domain&lt;br/&gt;entities, rules\"]:::yellow INF[\"Infrastructure&lt;br/&gt;API client, storage\"]:::purple --&gt;|implements ports| APP classDef blue fill:#2563eb,stroke:#1e40af,color:#fff classDef green fill:#16a34a,stroke:#166534,color:#fff classDef yellow fill:#facc15,stroke:#a16207,color:#111 classDef purple fill:#9333ea,stroke:#6b21a8,color:#fffIt pays off in long-lived apps with complex domain logic or several clients. For a marketing site it's overkill. MVC, MVP, and MVVM Older patterns that separate data, display, and glue code. They're still the mental model behind many frameworks. Pattern Glue layer How the view updates Seen in MVC Controller handles input and updates the model View reads from the model Backbone, server-rendered frameworks MVP Presenter drives a passive view Presenter calls view methods GWT, older mobile apps MVVM ViewModel exposes observable state Data binding Angular, Vue, Knockout 3. State and Data Flow Patterns The third question: how does data move, and who owns it? Unidirectional Data Flow (Flux / Redux) Data moves in one direction in a loop, so every change is traceable. flowchart LR V[\"View\"]:::blue --&gt;|dispatch| A[\"Action\"]:::orange A --&gt; R[\"Reducer\"]:::purple R --&gt; ST[(\"Store / State\")]:::green ST --&gt;|subscribe| V classDef blue fill:#2563eb,stroke:#1e40af,color:#fff classDef orange fill:#ea580c,stroke:#9a3412,color:#fff classDef purple fill:#9333ea,stroke:#6b21a8,color:#fff classDef green fill:#16a34a,stroke:#166534,color:#fffRedux Toolkit and NgRx follow this model strictly; Zustand and Pinia are lighter store-based cousins. The cost is boilerplate; the payoff is predictability and great devtools. Reactive State and Signals Instead of re-rendering a component tree, fine-grained reactivity tracks which DOM nodes depend on which values and updates only those. Solid and Svelte 5 work this way by default, and Preact Signals can too when a signal is bound directly in JSX. Vue and Angular use the same dependency-tracking idea (refs, signals) but still update at the component level. flowchart LR S1([\"count (signal)\"]):::orange --&gt; D[\"double (computed)\"]:::purple S1 --&gt; T1[\"Text node A\"]:::teal D --&gt; T2[\"Text node B\"]:::teal classDef orange fill:#ea580c,stroke:#9a3412,color:#fff classDef purple fill:#9333ea,stroke:#6b21a8,color:#fff classDef teal fill:#0d9488,stroke:#115e59,color:#fffIn a Solid-style framework, when count changes only the two text nodes update and no component function re-runs. Server State vs Client State Most \"global state\" is really cached server data. Treat the two separately. Let TanStack Query, SWR, or RTK Query handle fetching, caching, deduping, and revalidation, and keep only true UI state (modals, form drafts) in a client store. flowchart LR API[\"Server / API\"]:::blue &lt;--&gt; QC[\"Query cache&lt;br/&gt;TanStack Query, SWR\"]:::green QC --&gt; UI[\"UI\"]:::pink CS[\"Client store&lt;br/&gt;Zustand, Context, useState\"]:::orange --&gt; UI classDef blue fill:#2563eb,stroke:#1e40af,color:#fff classDef green fill:#16a34a,stroke:#166534,color:#fff classDef pink fill:#db2777,stroke:#9d174d,color:#fff classDef orange fill:#ea580c,stroke:#9a3412,color:#fffThis one split deletes a surprising amount of Redux code in most apps. State Machines and Statecharts Model the UI as explicit states and allowed transitions (XState is the popular library), so impossible combinations like \"loading and error at the same time\" can't exist. flowchart LR I([\"idle\"]):::gray --&gt;|FETCH| L([\"loading\"]):::blue L --&gt;|SUCCESS| OK([\"success\"]):::green L --&gt;|FAILURE| E([\"error\"]):::red E --&gt;|RETRY| L classDef gray fill:#9ca3af,stroke:#4b5563,color:#111 classDef blue fill:#2563eb,stroke:#1e40af,color:#fff classDef green fill:#16a34a,stroke:#166534,color:#fff classDef red fill:#dc2626,stroke:#991b1b,color:#fffOther styles you'll meet: atomic stores (Jotai, Recoil), proxy-based mutable state (MobX, Valtio), and the URL itself as state for filters and pagination. 4. System-Scale Patterns The fourth question: how do many people and many apps fit together? Micro-Frontends Split a large UI into independently built and deployed slices owned by different teams, composed by a shell. flowchart TB SH[\"Shell / Host app&lt;br/&gt;routing, auth, layout\"]:::blue SH --&gt; MF1[\"Catalog&lt;br/&gt;Team A\"]:::green SH --&gt; MF2[\"Checkout&lt;br/&gt;Team B\"]:::orange SH --&gt; MF3[\"Account&lt;br/&gt;Team C\"]:::purple classDef blue fill:#2563eb,stroke:#1e40af,color:#fff classDef green fill:#16a34a,stroke:#166534,color:#fff classDef orange fill:#ea580c,stroke:#9a3412,color:#fff classDef purple fill:#9333ea,stroke:#6b21a8,color:#fffIntegration options include Module Federation (runtime), iframes, Web Components, server or edge composition, and plain build-time npm packages. The costs are duplicated dependencies, inconsistent UX, and operational complexity. It's worth it only when team autonomy is the real bottleneck, not as a default. Monorepo with Shared Packages Keep several apps and shared libraries (UI kit, utils, config) in one repo using Nx, Turborepo, or pnpm workspaces. You get atomic changes across apps, easier dependency alignment, and cached builds. It's the pragmatic middle ground before micro-frontends. Backend for Frontend (BFF) A thin server per client type that aggregates and reshapes backend APIs, so each UI makes fewer, simpler calls. It's also a good place to handle sessions and cookies, keeping tokens out of the browser. flowchart LR WEB[\"Web app\"]:::blue --&gt; BW[\"Web BFF\"]:::purple MOB[\"Mobile app\"]:::pink --&gt; BM[\"Mobile BFF\"]:::purple BW --&gt; U[\"Users service\"]:::green BW --&gt; O[\"Orders service\"]:::green BM --&gt; U BM --&gt; O classDef blue fill:#2563eb,stroke:#1e40af,color:#fff classDef pink fill:#db2777,stroke:#9d174d,color:#fff classDef purple fill:#9333ea,stroke:#6b21a8,color:#fff classDef green fill:#16a34a,stroke:#166534,color:#fffOffline-First and Local-First The local database is the source of truth. The UI reads and writes locally and syncs with the server in the background. Service workers and IndexedDB power offline PWAs, and CRDTs enable conflict-free multi-device editing. flowchart LR UI[\"UI\"]:::blue &lt;--&gt; DB[(\"Local DB&lt;br/&gt;IndexedDB / SQLite\")]:::green DB &lt;--&gt;|background sync| SY[\"Sync engine&lt;br/&gt;queue / CRDT\"]:::purple SY &lt;--&gt; SRV[\"Server\"]:::orange classDef blue fill:#2563eb,stroke:#1e40af,color:#fff classDef green fill:#16a34a,stroke:#166534,color:#fff classDef purple fill:#9333ea,stroke:#6b21a8,color:#fff classDef orange fill:#ea580c,stroke:#9a3412,color:#fffUse it for editors, note apps, and field tools that must work with bad connectivity. 5. How to Choose Start with rendering, since it shapes the rest of your stack. flowchart TD Q1{\"Behind login,&lt;br/&gt;no SEO needed?\"}:::yellow Q1 --&gt;|Yes| SPA[\"SPA / CSR\"]:::pink Q1 --&gt;|No| Q2{\"Content mostly static?\"}:::yellow Q2 --&gt;|Yes| Q3{\"Changes often?\"}:::yellow Q3 --&gt;|No| SSG[\"SSG + islands\"]:::green Q3 --&gt;|Yes| ISR[\"ISR\"]:::teal Q2 --&gt;|No| SSR[\"SSR or MPA&lt;br/&gt;streaming, RSC\"]:::blue classDef yellow fill:#facc15,stroke:#a16207,color:#111 classDef pink fill:#db2777,stroke:#9d174d,color:#fff classDef green fill:#16a34a,stroke:#166534,color:#fff classDef teal fill:#0d9488,stroke:#115e59,color:#fff classDef blue fill:#2563eb,stroke:#1e40af,color:#fffRules of thumb: Pick the simplest rendering model that meets your SEO and performance needs. Organize by feature before reaching for layered or clean architecture. Separate server state from client state early. Reach for micro-frontends only when organizational problems, not technical ones, demand it. Every pattern here trades simplicity for something else. Adopt one when you can name the specific pain it removes. Further Reading Rendering on the Web (web.dev) Patterns.dev Islands Architecture (Jason Miller) Atomic Design (Brad Frost) Feature-Sliced Design Micro Frontends (Martin Fowler) Backend for Frontend (Sam Newman) Local-first software (Ink &amp; Switch)","contentHash":"sha256:f050b7df5cde747ea80610746b5eeb9cc4f861a01e026ddd8722332999e79f59","authorName":"Shobit Singh","authorUrl":"https://zyvop.com/author/shobit","authorSameAs":[],"category":"Architecture","tags":["State Management","System Design","SSR","frontend architecture","micro-frontends"],"audience":"Senior software engineers, systems architects, and technical leads working with Architecture","tone":"Instructional, practical, code-first","readingTimeMinutes":11,"wordCount":2828,"faqs":null,"primaryTopic":"Architecture","publishedAt":"2026-11-22T07:04:47.645Z","updatedAt":"2026-11-22T07:04:47.645Z","canonicalUrl":"https://zyvop.com/frontend-architecture-patterns-a-visual-guide-from-spa-to-micro-frontends-5a25w"}