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
| Half | What it is |
|---|---|
| Client | the browser, on the user's machine — it displays and reacts |
| Server | your 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: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: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
1 An interaction happens (a click, a keystroke).
2 If it changes the truth, it goes server side: a Python function runs.
3 This function mutates the state.
4 The part of the interface that depends on that state is re-rendered and sent back to the browser.
An event's routes
Concretely, an event takes one of these routes:| The event… | tourne | Round trip? |
|---|---|---|
| calls a Python function | serveur | oui |
| drives a component / a client state | client | non |