Overview and quickstart
Kigumi is a headless, schema-driven application framework written in Rust: a single model definition is the sole source of truth, and from it the framework generates the Postgres schema, the REST API, the OpenAPI specification, the agnostic JSON UI contract, and the security policy (ACLs and record rules). The core imposes neither a frontend nor an application protocol: everything is exposed through standards generated from the schema. Module composition is resolved and verified at compile time — the modules available in a binary are those whose crates are linked, and their dependency graph is validated before the database is ever touched. This page explains what Kigumi is, describes its architecture, and provides a complete quickstart to take an instance from zero to an authenticated REST API, with a reference web app.
What Kigumi is
The central principle is one model, one source of truth. You describe an entity once, in Rust, with the #[model] macro; from that description (ModelDescriptor) the framework projects:
| Generated artifact | Responsible crate | What it is for |
|---|---|---|
| Postgres schema (DDL + versioned migrations) | kigumi-schema / kigumi-db | tables, columns, FKs, constraints |
| Headless REST API | kigumi-server | secure CRUD and actions from the catalog |
| OpenAPI 3.1 specification | kigumi-schema | GET /openapi.json |
| Agnostic UI contract (JSON) | kigumi-schema | a generic frontend draws forms and tables from the contract |
| Security policy (ACLs + record rules) | kigumi-core | access enforced by the code path, not just by the data |
Core characteristics:
- Agnostic: the core knows nothing about the frontend or the transport; the web app is just a consumer of the UI contract and the REST API.
- Compile-time composition: a module is a Rust crate that auto-registers its own models, ACLs, and record rules in the compile-time registry (via
inventory). Only modules linked into the binary are available; the dependency graph is validated byresolve_modules, with a SemVer compatibility check against the framework version (check_compat/FRAMEWORK_VERSION). - Multi-company:
res.companyis the unit of data isolation; per-company scoping is enforced by the security layer (Ctxwith the active company plus a record rule). - Fail-fast on secrets: the instance refuses to start if a required secret is missing (
DATABASE_URL,KIGUMI_JWT_SECRET).
Architecture map
The Cargo workspace (Cargo.toml, members = ["crates/*", "modules/*", "apps/*"]) is organized in three layers: the framework crates, the business modules, and the executable apps. There is also a reference web app under web/.
Crates (crates/)
| Crate | Role |
|---|---|
kigumi-core | introspectable metamodel, AST domains, security (ACLs + record rules + sudo), compile-time registry, versioning |
kigumi-macros | #[model] / #[extend] proc-macros |
kigumi-schema | projections: Postgres DDL, JSON UI contract, OpenAPI 3.1 |
kigumi-db | Postgres persistence (sqlx): security-enforced CRUD + versioned migrations |
kigumi-auth | JWT HS256 auth (Bearer → trusted Ctx), password hashing |
kigumi-config | typed, validated boot-time configuration + reading secrets from the environment |
kigumi-storage | content-addressed blob store behind a trait (BlobStore) for attachments |
kigumi-server | headless axum server: metadata + CRUD from the catalog |
kigumi | facade (prelude): a module depends only on this crate |
kigumi-runtime | adopter wiring: migrate, admin bootstrap, workers, static-catalog serve in four calls |
kigumi-test | test kit: fingerprinted database reset (seconds, not minutes) + shared fixtures |
kigumi-mcp | the AI surface: MCP server derived from the catalog, tools under the impersonated user's ACLs |
The public prelude lives in crates/kigumi/src/lib.rs: a module opens its definition with
use kigumi::prelude::*;
and receives everything it needs — #[model], #[extend], Ctx, Domain, Model, ModelDescriptor, ModuleManifest, ModuleDep, the security types (Acl, RecordRule), and the registrars exposed as macros by the kigumi crate (register_module!, register_acls!, register_rules!, register_action!, register_service!, register_route!, register_job!, register_sequence!, register_seed!, register_migration!, and the like).
Modules (modules/)
Each module declares a MANIFEST (ModuleManifest) with a name, a version, a framework compatibility range (the framework field), and dependencies (depends), and auto-registers with kigumi::register_module!(MANIFEST).
| Module | Version | Depends on | Summary (from the manifest) |
|---|---|---|---|
base | 1.0.0 | — | Foundational models: currency, partner, company |
mail | 1.0.0 | base | Headless chatter: messages, tracking, followers, activities |
sales | 1.0.0 | base, mail | Sales order management |
account | 1.0.0 | base, mail | Double-entry general ledger |
stock | 1.0.0 | base, sales, mail | Inventory — locations, quants, pickings and moves |
base is the root of the graph (no dependencies) and cannot be uninstalled. All modules declare framework: ">=0.1, <0.2". The dependencies in the table are those declared in the MANIFEST; installing a module resolves its transitive closure (for example, installing stock pulls in sales, and therefore base and mail).
Apps (apps/)
| App | Binary | Role |
|---|---|---|
kigumi-cli | kigumi | the single CLI to operate an instance: serve, migrate, config, user, acl, rule, module, version |
renderer-demo | kigumi-renderer-demo | runnable demo: migrates + seeds a model and serves the API + a reference renderer |
The kigumi CLI links the module crates (kigumi-mod-base, kigumi-mod-mail, kigumi-mod-sales, kigumi-mod-account, kigumi-mod-stock); precisely because they are linked, their inventory registrations are present in the binary and the modules turn out to be available for installation. Only installed modules, however, are migrated and served.
Web (web/)
web/ is a Vite/React SPA: the reference web app for the admin UI. In development it runs as a separate process on port 5180 and proxies the /api, /auth, and /openapi.json paths to kigumi serve (default 127.0.0.1:8099), so the browser stays same-origin (no CORS). The Rust server is headless and does not serve static assets: the web app is a separate client of the UI contract and the REST API.
Quickstart
This path takes an instance from zero to an authenticated REST API, with a business module installed and the reference web app opened.
Prerequisites
- Rust toolchain (stable, edition 2021). Install with rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - PostgreSQL running and reachable, with the
createdb/psqlclient commands available. - Node.js + npm (only if you want to open the reference web app under
web/).
1. Build the kigumi binary
From the workspace root:
cargo build --release -p kigumi-cli
The produced binary is target/release/kigumi. In the examples below you can use cargo run -p kigumi-cli -- <command> during development, or kigumi <command> if the binary is on the PATH.
2. Create the database
kigumi connects to an already existing database (it does not create it): create it separately.
createdb kigumi
3. Configure the secrets (env)
Secrets are read only from the environment, never from the configuration file; the instance fails fast if a required one is missing. Required are DATABASE_URL (a complete Postgres DSN: the sole source of connection identity) and KIGUMI_JWT_SECRET (the HS256 secret for signing tokens).
export DATABASE_URL="postgres://kigumi:CHANGE_ME@127.0.0.1:5432/kigumi"
export KIGUMI_JWT_SECRET="$(openssl rand -hex 32)"
DATABASE_URL must be a valid postgres:// URL, otherwise secret validation fails at startup.
4. Prepare kigumi.toml
Non-secret boot-time settings live in kigumi.toml (default: ./kigumi.toml, or $KIGUMI_CONFIG, or --config <path>). The effective configuration is given by the layering defaults < kigumi.toml < environment variables with the KIGUMI_CONF_ prefix (nested with __, for example KIGUMI_CONF_SERVER__BIND=0.0.0.0:9000). The file is optional for commands that do not start the blob store, but serve requires storage.path when the storage backend is fs (the default): without it, validation fails fast. Start from the example:
cp kigumi.toml.example kigumi.toml
A minimal kigumi.toml for the quickstart:
[server]
bind = "127.0.0.1:8099"
[storage]
backend = "fs"
path = "/var/lib/kigumi/blobs"
In v1 only the
fsstorage backend is implemented (FsBlobStore, content-addressed files). Thes3value is foreseen by the configuration schema but not yet implemented.
Verify the effective configuration (secrets redacted) with:
kigumi config check
kigumi config print
config print prints the effective configuration with secrets masked and, at the end, the runtime settings read from the database.
5. Migrate the catalog
kigumi migrate
migrate ensures the framework schemas (auth, sequences, settings, accesses, modules) and, on a fresh database, automatically installs only base (plus its dependency closure). The other modules are opt-in. The migration creates the model tables of the installed modules in FK dependency order and seeds the reference data of base (a EUR currency and a default company).
6. Install a business module
The available modules are only those linked into the binary; installation resolves the dependency closure (dependencies before dependents) and migrates their tables, idempotently. List the modules and install sales:
kigumi module list
kigumi module install sales
Installing sales also pulls in mail (its dependency, in addition to base, which is already present). The output of module list shows, for each module, the name, version, status (installed/available), and summary.
7. Bootstrap the admin
On a fresh instance, the admin user is created from the KIGUMI_ADMIN_PASSWORD variable (no password is hardcoded). The bootstrap happens inside serve: if an admin user does not already exist and the variable is set, it is created with all the groups declared by the ACLs/record rules of the linked modules plus the base user/admin groups, and assigned to every existing company.
export KIGUMI_ADMIN_PASSWORD="$(openssl rand -base64 24)"
If
KIGUMI_ADMIN_PASSWORDis not set,servestill starts but prints a warning and no admin is created.
8. Start the server
kigumi serve
serve runs in sequence: migrate → admin bootstrap → starting the axum server. At startup it prints the listening URL and the number of models registered in the binary, for example:
kigumi serving on http://127.0.0.1:8099 (N models)
The printed number is the total of registered models (that is, of all linked modules). The API, however, serves only the models of installed modules: a model whose module is not installed does not appear in the catalog exposed by the router. The effective access is the union of the compiled baseline and any runtime overrides (ACLs and record rules) present in the database.
9. Call the REST API with curl
First obtain an access token by logging in (POST /auth/login, body {login, password}); the response is { access_token, refresh_token, token_type, expires_in } with token_type equal to "Bearer". Then use the token as Authorization: Bearer on the data routes.
# 1) login → extract the access token
TOKEN=$(curl -s -X POST http://127.0.0.1:8099/auth/login \
-H 'Content-Type: application/json' \
-d '{"login":"admin","password":"'"$KIGUMI_ADMIN_PASSWORD"'"}' \
| python3 -c 'import sys,json; print(json.load(sys.stdin)["access_token"])')
# 2) list the records of a model (envelope: data/total/limit/offset)
curl -s http://127.0.0.1:8099/api/res.partner \
-H "Authorization: Bearer $TOKEN"
The list responds with an envelope { "data": [...], "total": N, "limit": ..., "offset": ... }. Other useful routes, all mounted from the catalog:
| Route | Method | What it does |
|---|---|---|
/openapi.json | GET | generated OpenAPI 3.1 specification |
/api/models | GET | list of served models |
/api/:name/view | GET | UI contract of the model (form + table) |
/api/:name | GET / POST | list (paginated) / create |
/api/:name/:id | GET / PATCH / DELETE | read / update / delete a record |
/api/:name/:id/action/:action | POST | runs a registered state-transition action |
/auth/login, /auth/refresh, /auth/logout, /auth/me | — | JWT authentication flow |
10. Open the reference web app
The web app under web/ runs as a separate process and, in development, proxies to the running server:
cd web
npm install
npm run dev # http://localhost:5180
With kigumi serve running on 127.0.0.1:8099, the /api, /auth, and /openapi.json paths are proxied to the backend, so the web app's calls reach the real API from the same origin.
Guide index
| Page | Content |
|---|---|
| README.md | This page: framework overview and end-to-end quickstart. |
| architettura.md | Architecture in detail: crates, metamodel, artifact generation, compile-time composition flow. |
| installazione.md | Full installation: prerequisites, build, database creation, first run. |
| configurazione.md | Configuration: kigumi.toml, secrets via the environment, KIGUMI_CONF_* overrides, runtime settings in the database. |
| moduli.md | The included modules (base, mail, sales, account, stock): exposed models, dependencies, install/uninstall. |
| moduli-custom.md | How to write a module: #[model], manifest, ACLs, record rules, actions, registration in the catalog. |
| api.md | The REST API and OpenAPI: routes, response envelope, UI contract, JWT authentication. |
| sicurezza.md | Security model: ACLs, record rules, groups, sudo, multi-company, additive runtime overrides. |