Skip to content

1. The module

A Kewos module declares. It does not build a screen, does not draw a form, does not write SQL.

Declaring a model gives you, with nothing more: the table, the API, the screens, search, audit, permissions, translation and export. The administration discovers everything from the server, so adding a module never requires redeploying the interface.

The skeleton

A module is a directory under modules/. Ours is called library.

modules/library/
├── module.json <- identity and dependencies
├── __init__.py <- the entry point the kernel calls
├── icon.svg <- the launcher icon
├── acl.json <- the permissions
├── models/
│ ├── __init__.py
│ ├── title.py <- the work
│ ├── copy.py <- the physical copy
│ ├── member.py <- the member
│ ├── loan.py <- the loan
│ └── workflow.py <- the loan lifecycle
├── reports/ <- the PDF documents
├── views/ <- fourteen screens, in JSON
└── i18n/
├── en.json
└── fr.json

The files appear as the steps go. For now, create the directory and the manifest.

The manifest

module.json:

{
"name": "library",
"depends": ["core"],
"summary": "Library management: catalogue, copies, members and loans.",
"version": "0.1.0",
"category": "operations"
}
KeyRole
nameThe technical name. It prefixes every one of your tables.
dependsThe modules yours needs. core at minimum.
versionA semantic version. Used for upgrades and migrations.
categoryThe launcher aisle: sales, assets, operations, hr, finance…
summaryOne sentence, shown in the module list.

The entry point

__init__.py, at the module’s root, exposes the function the kernel calls at boot.

"""``library`` -- catalogue, copies, members and loans."""
from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING
from kewos.orm import apply_module_acls
from kewos.pdf import register_reports_from_dir
from kewos.views import register_views_from_dir
from . import models
if TYPE_CHECKING:
from kewos.orm.registry import Registry
_MODULE_DIR = Path(__file__).parent
def register(registry: Registry) -> None:
"""Declare the module: models, permissions, screens, then documents."""
models.register_models(registry)
apply_module_acls(registry, _MODULE_DIR / "acl.json")
register_views_from_dir(_MODULE_DIR / "views")
register_reports_from_dir(_MODULE_DIR / "reports")

Four lines, in that order: what exists, who may touch it, how it is shown, what it prints. That is the reading order of a Kewos module, and it never changes.

Next

The data: declaring the four models.