Architecture
moon-spa is a Python-first SPA framework that blends server-side rendering with client-side hydration. It has no JavaScript build step — the browser runtime is a single self-contained script embedded at build time.
High-level architecture
Request lifecycle
Module map
Design principles
- No build step — The Python package ships a self-contained JS runtime. Users never run
npm. - SSR first — Every page load starts as server-rendered HTML. JavaScript enhances, not replaces.
- Python is the authority — Component logic lives in Python. JavaScript is generated automatically.
- Server-driven callables — Callable actions/lifecycle run through
POST /__moon_spa_actionand patch state/props deterministically. - Inference by default —
setup(self, props)may omit return mapping; server infers props/state/data/actions/lifecycle. - Zero client dependencies — The browser runtime has no external npm dependencies.