sveltejs/svelte architecture diagram
How sveltejs/svelte is built, drawn from its code at c60f6e1 on 2026-11-08 by Plotix's agent.
Overview
What the svelte repo is made of and how the packages depend on each other. Start here.
Open the picture for full size (SVG).
Parts
- Svelte developer
- Compiler
parse, analyze, transform · emits JS module and CSS - Client runtime
DOM updates and reactivity · mount, hydrate, blocks - Server renderer
renders HTML strings · SSR output - Shared helpers
attributes, clone, context · dev errors and warnings - Public API
svelte and svelte/compiler · client and server entry points - Test suites
runtime-runes, runtime-legacy · compiler snapshots, SSR, hydration - Documentation site
docs markdown · runes, template, reference - Sandbox playground
manual testing app - Browser DOM
How they connect
- Svelte developer → Compiler compiles .svelte files
- Compiler → Client runtime
- Compiler → Server renderer
- Public API → Compiler
- Public API → Client runtime
- Public API → Server renderer
- Client runtime → Shared helpers
- Server renderer → Shared helpers
- Client runtime → Browser DOM
- Test suites → Compiler
- Test suites → Client runtime
- Sandbox playground → Public API
Compile pipeline
What the compiler does to a .svelte file, phase by phase.
Open the picture for full size (SVG).
Parts
- Svelte source
- Parse to AST
phases/1-parse · template, script, style · TypeScript stripped - Analyze scopes
phases/2-analyze · bindings, runes, a11y · CSS pruning - Target?
- Client transform
phases/3-transform/client · DOM calls and effects - Server transform
phases/3-transform/server · string template output - Print JS and CSS
- Compiled module
How they connect
- Svelte source → Parse to AST
- Parse to AST → Analyze scopes
- Analyze scopes → Target?
- Target? → Client transform client
- Target? → Server transform server
- Client transform → Print JS and CSS
- Server transform → Print JS and CSS
- Print JS and CSS → Compiled module
Runtime reactivity
How state changes reach the DOM in the client runtime.
Open the picture for full size (SVG).
Parts
- Signals
source: writable state · set and update · version counter - Deriveds
lazy computed values · re-run when deps change - Effects
render and user effects · teardown on destroy - Batch scheduler
groups updates per tick · flushes effects - DOM blocks
if, each, await, key · snippet, boundary, html - Element bindings
attributes, class, style · events, bind, transitions - Hydration
reuses server HTML · matches nodes to template - Browser DOM
How they connect
- Deriveds → Signals reads state
- Effects → Signals reads state
- Effects → Deriveds
- Signals → Batch scheduler schedules effects
- Batch scheduler → Effects runs effects
- DOM blocks → Effects
- Element bindings → Effects
- Hydration → DOM blocks
- DOM blocks → Browser DOM
- Element bindings → Browser DOM
Update sequence
One click on a component, from state write to DOM text update.
Open the picture for full size (SVG).
Parts
- Compiled component
- Client runtime
- Signals
- Batch scheduler
- Browser DOM
How they connect
- Compiled component → Client runtime mount(target)
- Client runtime → Browser DOM create nodes
- Client runtime → Signals read state in effect
- Compiled component → Signals set(count)
- Signals → Batch scheduler schedule effects
- Batch scheduler → Browser DOM update text node
- Browser DOM → Batch scheduler done
Data model
Core internal records the compiler and runtime pass around.
Open the picture for full size (SVG).
Parts
- Component analysis
runes: boolean · css: stylesheet · instance and module scope - Scope
parent: Scope · declarations by name - Binding
name: string · kind: state, prop, derived · reassigned: boolean - Template node
type: element, block, text · attributes · children - Signal
value · version: number · reactions - Effect
flags: bitmask · deps · teardown
How they connect
- Component analysis → Scope
- Scope → Binding
- Template node → Binding
- Effect → Signal
Draw your own repo
Plotix's agent reads your code and draws its architecture, and the diagram warns you when the code moves on.
Try Plotix