# Frontend Architecture Patterns: A Visual Guide from SPA to Micro-Frontends

"Frontend architecture" sounds like one decision, but it's really four that people tend to blur together:

1.  **Rendering**: where does the HTML come from?
    
2.  **Code organization**: how is the codebase structured?
    
3.  **State and data flow**: how does data move through the UI?
    
4.  **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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNpNUsFu2zAM_RVOpxZwMAzYKTfXhbcCM1ZEWE65MBLtEJNEQ1LSpEX-fZBTO7vpPT6R70n8UEYsqbXyHKzHcRcAokh-eGijhEzBQh3NgTOZfIz0-FgEABsKliKH4QYB9GsNX6HRm5noXuuldme1_jEfX_5jcyT0HAbAYGGjm0WTHAabbrARS_A7Dhj4HTNLmFWN-FEChQx7TGRnus7i2cAzJR4WbUtYcoB2bO7SX3ihSHYa3zjCRd5tm4nsttvuxumMmSbuGTNC6-Rt6e2O51sCssfzEo6HgC4tkOKJIpwSNI6L51Qa3l-idPdoDhzo846-pEwetEG36Do2UaD__KKleSdBIo0y46e2XSKKQQc9x5RVpTxFj2zV-kPlA_myAJZ6PLpSnJgtRsa9o1Q0vYTcomd3UWu1wnF0tEqTrQqeHIe_HZqbzVZCrmCnNA1C8OdlpyrYyF6yVPCT3IkyG6ygjoyugoQhrRJF7lU1DdH8Xrx8-z6e1fVaqf3QiJOo1urLW1lCdf0HAePW7g?type=png)

* * *

## 1\. Rendering Patterns

The first question: **when and where is the HTML produced?**

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp9k8Fy2jAQhl9F3RyrTEsgMPUNCKHM0Ekjtc0B9yDbK1uDLFFJlNIM796RcQlm0uok_dpv99-19Qy5LRASkNru8kq4QJYsNYQQ4rdZ6cSmIuOHL6sUxhWKglhJgqoxhe_HoLg4n69S4HzeURecrVJYcHZS0RQXmdnscZXCgyEo8oo4_LFFHy5ysyY366iMT6MaHIpamZK8jUonYnY3n61SmBUlEv5fDxP2FH0aEiokmbM7j66Tanq08HlM3sX9RZPLCHstTOG7RY7bXAvv71CS0iEaIpXWyVVvKPoDQX1wdo3xOLztD2hutXXJlZTyAs30Flvy5nbYx-yFxMF7If9NbpRZt2SR3YxGoxP5oeiNBsXrZPygdMHZ0XP3glHGpzROt7F1fjnljC74sinazjjsNcbf56-HXOY4Ouu7GUProdfrnVNs9nhyjkLiiWpH8Do1YU8tFSvJ_olq23-hgEKNrhaqgOQZQoV1fAUFSrHVAehR-SacEplGH2OkNeFe1ErvIYFrsdlovPZ7H7CmZKKVWX8SOW_O99YESlLgWFokXxcpUMJsZoOl5CPqnxhULigZOyU0JV4Yf-3RKQm0KcLV7-ilN9j8gsOBQlZOo21I4M2uUgHh8AdKBiVz?type=png)

### SPA / 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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNptkEFPwkAQRv_KOCeN2yAVDvZA0hYUiKCx6InLtB1g43a37i4iGv67qTWYqMed9yXvZT-wMCVjhI5ftqwLHkpaW6qWGgCgJutlIWvSHhIgB4k1O8f2L00bmg7nf0nckPh-0pIkGAzSCG5GC-hQXbfHNAgGgySCUVX7PYwXs1s4h2kG-VaXituN5cKDXeenYb8nIOxdCuheXZ21cG48g3llC0kEQ7PTylApmgzHAuxWwzRrl6zLn5D4GCI7JXlqSfxdM83u5r_d4YWAsB8KCC-7_7kfWJds4XFytKHAim1FssToA_2Gq-a3S17RVnkU7eWJrKRcsWs2K6P9NVVS7THCgOpaceD2znMlIFFSP8-oyL7e10Z7AUvMeG24kaKAB5MbbwSMWb2ylwUJiK0kJcCRdoFjK1coviSZfG9aur36DQ8Hgfk6NcpYjPBkt5Ge8fAJYTKnLQ?type=png)

-   **Pros:** 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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNptkUFv1DAQhf_K4NOu5KjadHsgh0iEsBREkagLp71M4tldC8cO40mWUO1_R2kEQrRHv-_J35PmUbXRkipUoh8DhZZqh0fGbh8AAHpkca3rMQhUgAkqjudE_JyamRri8SVYz7BGQUhx4JaWRpWVpSng_bsHuOo52qGVtBCTlWVdwJeBeFqSOlvK8ydLwtQK8LFZ5ZvXGvLrrYb8Zrte4OcoBHEkBlPAPQVLDLcPd58gBpATQfpnKAX7x5qVZVXAbvB-aa9Gl1zjCVzXkXUo5Kf1__qbfNZvNOTb62f6qoA6noOPaOGjAQwWTpNlFIJViGdwQYixFTfS-u8cpVVH3KGzqnhUcqJuPpClAw5elF6Sb8gOG09p7hxikB12zk-qUBn2vacsTUmo01B5F77fYWue3rsYRMNeGTpGgq8f9krDfWyiRA235EcS16KGN-zQa0gYUpaI3UHpJ4lxv-Ytm23_U10uWjXHt9FHVoV6dT45IXX5DSOAvWE?type=png)

-   **Pros:** 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).

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp10t2O2jAQBeBXcc1tkHD-Cr5oRVnttlJbVURUqkgvJs4kRDhxajtLWeDdKycptCtxGWs-z8mRT1SoHCmnhVQHsQNtyed12hBCyGab0jX-6tDYlP7knGeyQzKdviOr5SmlKxA7zEkLJZJCo9m9T-mFc35EKdVhuGK1dPPnH2jOJGHblCaon924qsnq4etwbakRm__mEwsSzyTxr8K4k2FXow6DUxqaEgeY-H2w9VOfucQGNVgkVUMyEPtSq67JB9V2upWjWj_1avNtm9JNmzsh3F8NkxZBpmMwIcGYByxI30FRScknfhQHmHnGarVHPmEYzqDwhJJK80lRFK_k0MtoCxCCRVcLLPZnb_9axtgr21c0UhZDEMJtbRxHQXh_7dDSaBGi-Uxc7QKCkPn37dDVaBdBEOBtb5z5DOb3rWtvlLN8Ec7nt8Qswmjxj6QerVHXUOWUn6jdYe0eZI4FdNJSbzj5DrqCTKJxM4Vq7CPUlTxSTqfQthKn5mgs1h75IKtm_wVE0n8_qsZ6xD2jUiHZfEqpR9YqU1Z55CPKZ7SVAI8sdQXSIwYaMzWoK5fJLUmqF5eFhe1verl4NCtXLjbl9M1hV1mklz-0Dg1C?type=png)

Great for product catalogs and news: thousands of pages that change occasionally.

### Streaming SSR and React Server Components

**Streaming** sends HTML in chunks as each `<Suspense>` 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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp9kU1LI0EQhv9KbeWi0ANG4-L2QTAjIQsRZBO9ZDxUuquTxp7p0F3RdSX_XSYTP1jU49s8T9VL9TOaaBk1uhAfzYqSwOyyagAArucVXtOS4SBzeuB0WOGd1roLUBTnMJ5XOGaynD5l9mN26KQdlqLdGJn4LK-8AsdiVpzBktAn9mRnl-92Scl-s63c8cN5hRfWzmJJSYYbkdjAgQmeG9k7XfjYcDSvcOSDcBpS-oLueBMo50t2sD-F8yHo3vHpzxNeqCwp3rPu9XlwRE6ZGGLSPefcf243cu8ynZ4dmTf3F50M-scfXFRYc6rJW9TPKCuu2y-z7GgTBFX3ckvJ0yJwbhkXGxlR7cMTaixovQ5c5KcsXCsYBt_cX5GZ7vIoNqKgwikvI8PN7woV_ImLKFHBmMMDizek4CJ5CgoyNbnInHzbqV0y9f_aLv3B-i9utwoXy7KtjRp_PK68MG5fAKFixxE?type=png)

_Blue = 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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNqNkdFKIzEUQH_levuaQce2omEp1EqtYGGxui8zPtzJ3EyDmUlJ4mqV_rvEqbIKy-5jknOSE-4rKlczStTWPak1-Qi352UHAPDzsihxcbu8hg01XOK9lLKyj_xxClk2gUVimGr2Pyp_OAmRolE923jafmGnRYlTH42y_G94VZS4YvJqDZV7fudNsNTVPe88dc3XlNmyKHHm2pa7GP5HmBclzp2Lf23vaWUphAvWkD4P2lgrB8fjkyFXIkTvHlgOch4dkRbKWeflQGv9zUzX7c0zRUPSn-aoGo9Phh9mnuffzD577zKNT4_Up3tGw1F-_MerKLBl35KpUb5iXHObJluzpkcbUfQ7v8gbqiyHxGjXxTm1xm5RYkabjeUsbEPkVsC5Nd3DktTqfT13XRSQZtI4hrurEgXcuMpFJ2DB9jdHo0jA1BuyAgJ1IQvsTWpKj6zMS2rJR5tn3O0EVs0sZaPEg6e1iYy7Nyd30OU?type=png)

**Resumability** (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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp1kU1v2zAMhv-KxlxlII4_kPBQoGtRbMAKDE23Uy60TTlCZcuQlKVZkf8-yDbatUWO4sMHfEm9QG0bBgRl7LHekwvi8XbXCyHE9TAgYmUOLJLkSvygkz0ERBwObjA89UzFkW91wxU5RAxM5hP-SS2_Y7EwkkeqTEStY-4_sJuY6D0b20f4YI-IaB31Le9mWhvy_paVGHMrbQwuVkWZcSV9cPaJcZFyviQla2usw4VS6oM57Te7myzLmF7dslqltL7sxvVmc9ls8vX6bWpacLG5bI4bzmpaUpa_DU3Lssjyy-p0gdllKtbL-tXdUJanq_9ckNCx60g3gC8Q9tzF329Y0cEEkFPlNzkdz-xjj7J9uKNOmxMgJDQMhhN_8oE7Kb4a3T_dU70d33e2D1LsYMutZfHr-w6keLCVDVaKb2z-cNA1SXHtNBkpPPU-8ex0zBSHbPXfmCXNh2c4nyVU7U2MDQhfjnsdGM7_ADMX3MU?type=png)

A 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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp1ktFu2jAUhl_FO9wajUCALZoq0U1VKw21gm43ZBcnznGwOLEj2xljFe8-haTtVKmXtr_P5_8tP4FyJUEGmt1R7dFH8X2TWyGEWO1yWEVXhy-F_3h13cborBR3tmljDr-yLGuMPYjx-EqsdzmsHZNqmXp6S-jVXmhDXPaw82gruuD3uxzufYXWhOHyW8KSvBQP3pWtiqLyZtBOxOyOF-1xl8Mj1Q1jHKY8YEWC8eSeE1WeyF7gh10O3XEPbghZKGcj2YEsuKXc9kUVYwjfSItLIW2Ys1FZTJfLpQzRuwNlo89lskxLqRw7n4201m_MoV3vEs4_TdSri7M0mb7vDhV7V6NSyfzFxWQxnSyf3SRJ3rh94V5NFjhL8UVNFov5LH1_bPcCgzmdL2ZUvJqUTlD_Z4KEmnyNpoTsCeKe6u7HlKSx5Qiy3_mJ3mDBFDpGOxtvsDZ8ggzG2DRM43AKkWoprtnYwxrV9rK-cTZKkcOWKkfix10OUmxc4aKT4pb4N0WjUIqVN8hSBLRhHMibLlM3ZGv-dlmStPkD57OEovraxYYMPhz3JhKc_wGBE_K1?type=png)

Great 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.

```css
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**.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp1k9FO2zAUhl_lzNy6iDRtBr6Y1K0FerGpast2QXZx4pykXl07sh06QLz75CSFCYlLW-f7_uNfyTOTtiQmWKXtUe7QBdjOcwMAMFut7nOGTSNAGRU4NM4-qJKc5-BsG5Spc_ZbCOGohNHoC6xmN4vNfc4arMmLbobAS0dkfD9pHZqaen033XG_lvObxTaSR1XWFLwAja4muFtCoa3cD_QjaW2PPT0wHX-9mG3v1l10RRhaF9NbTw5QBmWN50Dn9TlgWUKwINGFXljH1XrfydEJFz-2y-2yE5IJKqgoLFqvDHkPtvhDMpykK2fLVg7CQrfD606Kzre5na0X8_uc-R06KkV82D422galPYfZaglSKzKDpmldoykfVpMavZ9TBbHnSmktzko5zsYZ98HZPYmzq6ukSAourbZOnFVV9Q7sax9YwunlhXxjMZ0k44_ZvvSBrVDKZPrKYpKNLz6f2CRJ3rFdvwOaZJhO8BVNsmyaTj6OjU0O5HiapVS8kTS5wOpjsi9vYK_SNKW31KwYJ3j5H8s4O5A7oCqZeGZhR4f4L5RUYasD4_3NT3QKC00-zlTWhGs8KP3IBBth02ga-Ucf6MDhq1Zm_x3lpjtfWxM45GxDtY3fcs44rG1hg-VwS_qBgpLIYeYUag4ejR95ciruFEM26inukkyav-zlhbOi_hbXZoJ9Ou5UIPbyD0RwNQ0?type=png)

### Layered, 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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp10tFu0zAUBuBXMae3rliaNkCEJhWqikgMqlXlpuHixD1urZ7Yke1QytZ3R0k6Nk3i0pY_n_-3_ADK7Qhy0OxO6oA-iq_3pRVCiE2xLWFTCMYz-Y-Vf3urXN04SzaGEn7meV5xS2I8vhXz1Wpbwrxp2CiMxtkX6ODcMUjRBhIKA13p3hPZYc58teovWXy_25awcDUa20uy0URDQQrf8hM8E7M7DbL4ttyWUFjtMUTfqth66uV8VQjFhmyUIkTncU-DblrfcJ_50dQNU92VEY3zMTx2QcprJsUYwoK06Ctqw5yPJrMspUqG6N2R8lFC0xvUUjl2Ph9prV_JvuGVJhmmU3ymWTZLp_-nQ8er1ahUMvtnMckmN--ebJIkr-y14WA_pGlKz3OzapLg-xdzQUJNvkazg_wB4oHq7ivsSGPLEeSw8wO9wYopdGe0s3GJteEz5DDGpmEah3OIVEvxiY093qFa9-ul616_hDXtHYlNUYIU965y0UnxhfgXRaNQirk3yFIEtGEcyJsuUzdkbf50WZJp8xsuFwnV_nMXG3J4czqYSHD5C17P57E?type=png)

It 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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp1kU1r3DAQQP-KOntpQSbx2msSHQrbltBCe7HTvaxyGMujXRHZMpLcbZrd_x78QVoKOUp6j3mDnkG5hkCAtu6kjugj-17KjjHGdnsJO0MnCQ9CiNoOxJLk47kxoceojme23UvYqmhcNyPOY3egWd6OLCv3EkpqBkV-RvrB93ZBygmp7vfvJVTReWJXrIoYScKHkT14om5Gq_tpdBjqoLyp6cx2cnlSFkP4QppNgdpYK1brTZFRzUP07pHEKqX8GjVXzjovVlrr_8y5e3EJNzfX6tW9xSxP12-780KLe5tlGeGrW9TrFG_edqcFFzUtMMv_qmlRbLL8HxU4tORbNA2IZ4hHasdPa0jjYCPw-WaH3mBtKYyMdl28w9bYJxCQYN9bSsJTiNRy9sma7vEHqmo637kuciahooMj9vObBM5KV7voOPtK9hdFo5CzrTdoOQvYhSSQN2PTOKQyf8aWNO9_w-XCoT58HrNBwLvT0USCywuxw8au?type=png)

Redux 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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp1kE1LAzEQQP_KOL20kAW3H9LmIKilKOjFqpeuh9nsbBvMJkuS9ZP-d9luLVXwOOG9zGO-ULmCUWJp3JvakI9we59ZAIBl2l9lqFxjI_SDXlsygwyfB1JK58muGZLkHOarDAvX5Iahr1xVN5GLFpNS1o2vDf98tqMf0lWGD_wewbqC4aIDI5PpsHlHDX9Rl8dUxylDIcy5hH1JqY2RPabJ9FSJEL17Ydmb0WicDoVyxnnZK8vyj9v17d3ZaDRiOrhn-TCl6f9uG7M3T4vZeDo9mGk64cnsyESBFfuKdIHyC-OGq_beBZfUmIiie3kiryk3HFqmdDYuqNLmAyUmVNeGk_ARIlcCLo22L3eklrt54WwUkOGS147h8SZDAfcud9EJuGbzylErEnDhNRkBgWxIAnvdNrVLlvqzbUnH9TtutwLz9VWbjRJP3jY6Mm6_Afygr08?type=png)

In 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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp1kmFr2zAQhv_K7fJVpnXiJKsohc6jbLDBEq8dLN6Hs31ORGQpSHLbrOS_D8VmHYN-PN097_uepBesbcMosdX2qd6RC_BlXRoAgNtvnzclFuwe2cFFLEv8JaWsdM9wnSQ3sMo3Ja56dkeoqd7xdeUubr6TKQLVezg3BBQ_1gO3dcxmkF7lEPn7aHA_yh6U2Q_dvNiUmGvFJoAP1g26P3sfyDQCcmsCPwcBveciUOCBt47MlkfdcjSqNXn_kVs4h26V1nIynS9mXAkfnN2znKScXVIraqutk5O2bf8jz7FHNF3QLKNXdLGYz7K30bjSSDbVdLlc_iWvmnSZNW-T4zIDyzR_f1m_sjTL0uk_LArs2HWkGpQvGHbcxQdtuKVeBxTDyQM5RZVmH2daa8IddUofUWJCh4PmxB994E7AB63M_ivVxbm-syYIiN9gazleLApY28oGK-AT60cOqiYBt06RFuDJ-MSzUzFTNCnU75glzQ7PeDoJrLZ5jI0S3z3tVGA8_QER7M-k?type=png)

This 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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp1kdFq2zAUQH9FU146kGGOHUP0UGhTh4Z5DOxmMOo9XMtXiahsBUlZl9X596LEzcrGHiWdo3vgvlBhWqScSm2exRasJ0VZ94QQsrp6rKlqNdb0x0fO-cbCgUTR9bDMHxb3AynCuzbQqn4zIo3e41kuTmS1XizyqhrI188Bdnsh0LnLf4j9e3p5syrWZT6QPMBorbEjarE9g_kJLPOH8vtAinrUhQbn7lCSU6JUWvPJXEACkjlvzRPySdrMZlnChNHG8kkcx3-ZoXw0p7MsweZixph-AvlmSin_mYnYj2qcQZLCHzXLZkn6f9ViO4qtmGbT7CLO53ETN-9EymiHtgPVUv5C_Ra7sLMWJey1p-x88w2sgkajC4w0vV9Cp_SBchrBbqcxcgfnsWPkVqv-6QuI6nRemt4zUtMKNwbJelVTRkrTGG8YuUf9E70SwMiNVaAZcdC7yKFVoSkMqdTv0BKnu1_0eGS02SxCNuX0w_NWeaTHV4ZGwso?type=png)

**Other 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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp10VFr2zAUBeC_cnfzKtM6dkwrRiHJCNlDX-ZuL_EerpVrW0S2jCSvy0r--3CcLSXQR4nzcY7QGyq7Z5RYGfuqGnIBXlZFBwCQb3cF5g0bA3ewtT4A9f3n0t09OTsE3dUCaAiNAENHO4QCf0opSzPwPw5R9ATPm3hX4JoCGVuf9QtTC8spXjvm7iY_H_MNq4MdwhWsJmAddfVtQ7IrcKmUHbp3YD2BfnC94eJSogx5_4UrGHdCpY2Rs_kiS7gUPjh7YDmLOb2nSihrrJOzqqpu5HnyhcYZJSldaZYtkvRjOo2_WKbFw736bx8pSeP5x3Z6x8U-JknC196snMf08M6iwJZdS3qP8g1Dw-34xXuuaDABxXTzg5ym0rAfM5XtwoZabY4oMaK-Nxz5ow_cClgZ3R2eSeXn88Z2QUCBOdeW4fvXAgV8s6UNVsCWzS8OWpGApdNkBHjqfOTZ6XHTWJLrP-OWOO1_4-kksKzX42yU-Om10YHx9BddUNSZ?type=png)

Integration 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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp90d9r2zAQB_B_Rbu8ylDHrtPqYTBvCxvUBBrSPMR7ONmnRES2jKT0J_nfi-3QrKPr4-m-H-kOvUBlawIBytiHaocusJvbsmWMsfXPfFPCmiTDrivhjxBCmgOxKPrK8vWplc_nY6s7uM7QKItFLwsrtaEz7nS7H3Fx7n7o8_WQW21KWHlynnly97qiMbl1RO274GJTwsLVnyaL8cp31aI8dSuD3v8gxYYFlTZGTKaXWUKS--DsnsQkpvQCFa-ssU5MlFL_yGG7UdZyOpvN3uR1Hc_S-hM5bH6y10mSEL7ZTE5jvPq_HTY80TjDJD3TOMsuk_QvChwacg3qGsQLhB01_b_XpPBgAvDx5A6dRmnI9xll2zDHRpsnEBBh1xmK_JMP1HCWG93uC6yWQz23beCshCVtLbHV7xI4u7XSBsvZLzL3FHSFnH1zGg1nHlsfeXK6n6l_ZKmf-1nitHuE45GD3H7vxwYBXx52OhAcXwEn89fR?type=png)

### Offline-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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp1klFr2zAQx7_KTXnZQCZ17JjWlMJcUxbIHhavhRLv4SyfHRFZ8mS5bdrmuw_boS2DPkrc73-_O-mFCVMSi1mlzKPYoXWw3uQaAOB2tc3Z7Spnf-I4LlRPcOl5V5Am2685WxuBCtLksrDzq5Uu6YnKNIE5ZL_W0lHOvg1UbYn0lJYmI_5aoNjX1vS6hO6gxStk99ucZQctgHQtNY2Jf3vqCeZwvUl_TwJtb1tFU1Z2P6lkm7uBJftAdqoyFnVN-amnUNh1KVUw2ldSqXi2WEYBFbxz1uwpnvkUnmHFhVHGxrOqqv4jxwlOqB9hEOI7GkXLIPwcnYxP7EUQBPTORsXCx_PP2WmOE0u4PD8Tb-wFBqG_-MAyzhqyDcqSxS_M7agZHrSkCnvlGJ9u7tBKLBR1Q01ltLvBRqoDi5mHbavI6w6do4ZDoqTe_0SRjecbox2HYcm1IRh-A4eNKYwzHH6QeiAnBXL4biUqDh3qzuvIysFpaJLJ58HFD9sndjxyVtTXgzaL2ZfHnXTEjv8AGuDPTA?type=png)

Use 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.

![Mermaid Diagram](https://mermaid.ink/img/pako:eNp10t9v2jAQB_B_5XY8zqgEAhRr6kTp2vHQDeJt0tTswUkuwcKxUeyOMeB_n8LPUbWPtu5z9_XJa0xtRsgx13aZzmTl4dtdbAAApsE6xluaKZOBtoUy7ENSXd0YC-LTVzBEGWUfY9xyzlektV0eGTSbN5uf5DYgJsOnGMVkCFcwElGMvzjnC2XmF6Vf7Aam7XWMI2s8GQ-ldV6vwHnpVfraiPZ5xLRTw5k0BTmwuSfzGuicBgnxUEcSD_AelNPSZG4fq6iIzEX5rv9YRE8xjo_hPUl9EWLfM9r1jMBW8DgZ7vbkfEWyVKZgEInRXif6meLDkFRL5-4oh31QyJXWvJHLNA26zPnKzok3ZNBrt_ostdpWvBEEwQtb7_Igs6Td7_dPcpAF_TA7yjzPX8jdcw806MlOKE806PW6nfBtWu_gIFvZILy-PsugS93B27J-_0G2u70OJWdJYUvm_0lkWFJVSpUhX6OfUVn_0oxy-aw9sv3ND1kpmWhydU1ujb-XpdIr5NiUi4Wmpls5TyWDW63M_FGmYne-t8YziFFQYQm-j2NkENnEesvgM-nf5FUqGQwrJTUDJ41rOqpUnakeItTfOksQLv7gdsswKUZ1bOT4bjlTnnD7D-X4EPE?type=png)

**Rules 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)](https://web.dev/articles/rendering-on-the-web)
    
-   [Patterns.dev](https://www.patterns.dev)
    
-   [Islands Architecture (Jason Miller)](https://jasonformat.com/islands-architecture/)
    
-   [Atomic Design (Brad Frost)](https://atomicdesign.bradfrost.com/)
    
-   [Feature-Sliced Design](https://feature-sliced.design)
    
-   [Micro Frontends (Martin Fowler)](https://martinfowler.com/articles/micro-frontends.html)
    
-   [Backend for Frontend (Sam Newman)](https://samnewman.io/patterns/architectural/bff/)
    
-   [Local-first software (Ink & Switch)](https://www.inkandswitch.com/local-first/)

---

*Published via [ZyVOP](https://zyvop.com/frontend-architecture-patterns-a-visual-guide-from-spa-to-micro-frontends-5a25w?utm_source=hashnode&utm_medium=crosspost&utm_campaign=syndication) — Write once in Markdown, auto-backup to GitHub, and syndicate to Dev.to, Medium & Hashnode in 1 click.*
