Skip to content

Core Concepts

This guide covers the fundamental concepts of PyGo: modules, the pygo.toml config, the two entrypoints, and the Go↔Python interop.

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.

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 = 8080
socket = "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).

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.

When the Go web layer needs domain logic, it invokes a Python function through the interop layer. Conceptually:

// Go web layer
result, 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.default selects the default database (e.g. sqlite). PyGo uses database/sql on the Go side and Python stdlib DB access on the Python side.
  • i18n.locales_dir points to translation files; i18n.fallback is the fallback language (e.g. en).