{"version":"v1.0","client_state":{"DocsNavigation.default":{"fields":{"query":""},"persist":"memory","send_to_server":true},"ColorScheme.default":{"fields":{"mode":"system"},"persist":"local","send_to_server":true}},"endpoints":{"action":"/_bretzel/action","sse":"/_bretzel/sse","refetch":"/_bretzel/refetch"},"csrf":"81afeb29cbadf27bab317fdda92c1cb4","page_id":"41ced33fad91420da51a51d30a2956a9","address":""}

How Bretzel works

Every web app has two halves: the browser (the client) and the server. Knowing where the code runs — and when one crosses from one to the other — is the frame that lights up everything else.

The two halves

HalfWhat it is
Clientthe browser, on the user's machine — it displays and reacts
Serveryour machine, where the Python runs — it holds the truth

Why on the server

The web's basic rule: the client is always wrong. Everything arriving from the browser can be tampered with. So what matters lives server side:
Security — the client is never trusted; the validation that protects happens here.
Source of truth — the data is stored and owned by the server, not by the tab.
Confidential logic — a price calculation, a business rule must not leave for the browser.
Sharing — a server state is seen by several users / tabs; a client state is not.

Why on the client

Going through the server costs a network request. For a purely visual interaction (opening a menu, ticking a box), it is waste. Staying client side means:
No request — it works with no round trip, hence instantly.
Lightening the server — it is the user's machine doing the work, not yours.

UI = f(state)

The interface is a function of the state. One does not manipulate the DOM by hand: one describes what the UI must be for a given state, one mutates the state, and the UI is recomputed.

Bretzel's cycle

1An interaction happens (a click, a keystroke).
2If it changes the truth, it goes server side: a Python function runs.
3This function mutates the state.
4The part of the interface that depends on that state is re-rendered and sent back to the browser.
An interaction that does NOT change the truth (opening a panel) short-circuits the server step and stays in the browser.

An event's routes

Concretely, an event takes one of these routes:
The event…tourneRound trip?
calls a Python functionserveuroui
drives a component / a client stateclientnon
It is the same boundary, applied everywhere: state, actions and reactivity each have a server side and a client side. The rest of the docs follows that plan.