Core Concepts
Core Concepts
Section titled “Core Concepts”This guide covers the fundamental concepts of PyGo: modules, the pygo.toml config, the two entrypoints, and the Go↔Python interop.
Modules
Section titled “Modules”A PyGo project is a set of modules. Each module is a directory with two sides:
- A Go side under
app/modules/<name>/that handles HTTP, routing, and middleware. - A Python side under
app/modules/<name>/app/that implements domain and business logic.
The framework ships internal modules: core, auth, i18n, admin, notifications, ui. These are listed in pygo.toml under modules.internal. Extra modules you add go under modules.installed and are installed with pygo module install.
The pygo.toml file
Section titled “The pygo.toml file”pygo.toml is the single project configuration file. A real example:
[project]name = "pygo-framework"version = "2.2.4"description = "PyGo Framework — dual-language web framework"
[framework]entrypoint_web = "app/modules/core/web/entry.go"entrypoint_python = "app/modules/core/app/main.py"python_path = "app"
[server]host = "127.0.0.1"port = 8080socket = "storage/.pygo.sock"
[python]interpreter = "python3"
[modules]internal = ["core","auth","i18n","admin","notifications","ui"]installed = []
[database]default = "sqlite"
[i18n]locales_dir = "app/modules/core/app/locales"fallback = "en"The two entrypoints tell the supervisor where to start:
framework.entrypoint_web— the Go file that serves HTTP.framework.entrypoint_python— the Python file that boots the domain layer.python_path— the importable Python root (app).
The UDS socket
Section titled “The UDS socket”server.socket is the path of the Unix Domain Socket used for interop (default storage/.pygo.sock). Go and Python communicate only through this socket — there is no network port for the interop channel.
How Go calls Python
Section titled “How Go calls Python”When the Go web layer needs domain logic, it invokes a Python function through the interop layer. Conceptually:
// Go web layerresult, err := pygo.Call("module.handler", map[string]any{ /* args */ })That call is encoded as MessagePack, written to the UDS, decoded in Python, executed by the domain layer, and the result is sent back the same way. From the Python side you just write ordinary Python functions in the standard library; the supervisor exposes them to Go.
# Python domain layer (app/modules/<name>/app/...)def handler(args): # business logic with the Python stdlib return {"ok": True}This keeps a clean boundary:
- Go = web transport, routing, response building.
- Python = domain rules, models, integration logic.
Database and i18n
Section titled “Database and i18n”database.defaultselects the default database (e.g.sqlite). PyGo usesdatabase/sqlon the Go side and Python stdlib DB access on the Python side.i18n.locales_dirpoints to translation files;i18n.fallbackis the fallback language (e.g.en).