PyGo Architecture
Architecture
Section titled “Architecture”PyGo is a monolithic-but-modular web framework. One process, two languages, one socket.
The split
Section titled “The split”| Concern | Language | What it does |
|---|---|---|
| Web / HTTP layer | Go | Serves HTTP with the native net/http package (no gin). |
| Domain / logic | Python | Implements business logic with the Python standard library (no SQLAlchemy). |
| Interop | both | Communicate over a local Unix Domain Socket using MessagePack. |
The key idea: Go and Python never speak over the network. They share a Unix Domain Socket (UDS) on the same machine and serialize calls with MessagePack — binary, fast, sub-millisecond.
Sequence diagram
Section titled “Sequence diagram” Browser / client │ HTTP (net/http, native Go) ▼┌──────────────────────────────┐│ Go web layer (entry.go) ││ - routes, middleware, HTML ││ - calls domain logic │└──────────┬───────────────────┘ │ MessagePack request │ over local UDS (storage/.pygo.sock) ▼┌──────────────────────────────┐│ Python domain layer (main.py)││ - business rules, models ││ - Python stdlib only ││ - returns result │└──────────┬───────────────────┘ │ MessagePack response over UDS ▼┌──────────────────────────────┐│ Go web layer ││ - builds HTTP response │└──────────┬───────────────────┘ │ HTTP response ▼ Browser / clientHow pygo dev works
Section titled “How pygo dev works”pygo dev starts a Go supervisor. The supervisor:
- Boots the Python runtime and connects to it over the UDS.
- Serves HTTP requests in Go.
- Forwards domain calls to Python over MessagePack and streams the response back.
- Watches source files and reloads on change (hot reload).
No separate message broker, no gRPC, no TCP port for interop — just a filesystem socket.
How pygo build works
Section titled “How pygo build works”# Single static binary (Go only)pygo build
# Single static binary with Python bundled inpygo build --embed-pythonpygo build --embed-python embeds the Python runtime into the one executable so you can deploy a single file with no external Python install.
Modules
Section titled “Modules”A module is a pair of:
- Go packages under
app/modules/<name>/(web/HTTP side) - Python code under
app/modules/<name>/app/(domain side)
The framework ships internal modules (core, auth, i18n, admin, notifications, ui). Additional modules are registered in pygo.toml under modules.installed and managed with pygo module install.
Design principles
Section titled “Design principles”- Native only. Go uses
net/http+database/sql; Python uses the stdlib. No heavy frameworks. - Local interop. MessagePack over a UDS — fast, secure, no network exposure.
- One process. A Go supervisor owns the Python runtime; deployment is a single binary.
- Modular. Features live in
app/modules/*, split into a Go side and a Python side.