Core DevAlpha
Sumeru layered architecture
Sumeru is a modular ERP built as a Go monolith with PostgreSQL, XML-defined UI and metadata, and a hybrid web client (SWC SPA inside a server-rendered shell). This document maps the six runtime layers, how requests flow through them, and how modules extend each other without forking core code.
Six layers
flowchart TB
subgraph ui [User interface]
SWC["core/swc — FormView, ListView, widgets"]
Web["core/server/web — /web, /web/swc/workspace"]
Render["core/engine/render — HTML shell"]
end
subgraph logic [Business logic]
RPC["core/server/api — POST /api/rpc"]
ORM["core/orm — CRUD, domain, compute, onchange"]
SDK["core/sdk — addon-facing API"]
Actions["orm.RegisterObjectAction — object buttons"]
end
subgraph modules [Modules]
Manifest["manifest.json — depends, data"]
Install["core/module/install.go — deps, schema, XML sync"]
Discovery["core/module/discovery.go — addons_path"]
end
subgraph security [Security]
ACL["sys.access CSV/XML"]
Rules["sys.rule record rules"]
Groups["core.group + implied_ids"]
FieldACL["sys.field.access"]
end
subgraph integrations [Integrations]
Mail["addons/mail — chatter, PostMessage"]
Export["/web/export, bulk import"]
Bus["/web/swc/bus WebSocket"]
I18n["i18n export/import CLI"]
end
subgraph db [Database]
PG["PostgreSQL"]
Schema["core/orm/schema_sync.go — additive DDL"]
Registry["orm.Registry + modelreg"]
end
SWC --> RPC
Web --> ORM
RPC --> ORM
ORM --> security
Install --> Schema
ORM --> PG
Schema --> PG
SDK --> ORM
Manifest --> Install| Layer | Primary paths | Request flow |
|---|---|---|
| UI | core/swc/src/views/, core/server/web/workspace.go, core/engine/parser/view_xml.go | Browser → GET /web/swc/workspace (arch + records JSON) → SWC renders; mutations → POST /api/rpc |
| Business logic | core/orm/, core/server/api/dispatch.go, core/sdk/ | RPC → dispatchRPC → model methods → ORM with ACL/rules applied |
| Modules | core/module/, addons/*/manifest.json | -i module → resolve depends → syncModuleSchema → load data XML (two-pass for view inherits) |
| Security | core/orm/model_acl.go, core/orm/record_rules.go, addon security/ | Checked on every CRUD/search; rules compiled into SQL WHERE |
| Integrations | addons/mail/, core/server/web/export_handlers.go, core/event/ | Chatter, exports, event bus, cron — invoked from Go hooks, not XML alone |
| Database | core/orm/schema_sync.go, core/orm/registry.go | SyncModels / SyncRegistrySchemaForModule on startup and install |
End-to-end traces
Open partner form
- User opens Contacts → partner list → clicks a row.
core/server/webserves the workspace shell;core/swcloads via/static/swc/swc.js.- Client requests workspace JSON with model
core.partner, view typeform, and record id. - Server loads
sys.view.arch(merged if view inherits were applied), fetches the row viacore/orm, applies field ACL and record rules. - SWC
FormViewrenders fields from arch + record values.
Save via RPC
- Client posts to
POST /api/rpc(writeorcreateoncore.partner). core/server/api/dispatch.govalidates session/API key, resolves the model fromorm.Registry, runs ACL and record rules.core/ormbuilds SQL UPDATE/INSERT;schema_synchas already ensured columns exist from field definitions.- Optional hooks: mail chatter,
event.Subscribelisteners in addonhooks.go.
Install contacts module
- CLI:
go run ./cmd/sumeru -- -c sumeru.conf -i contacts --stop-after-init core/module/install.goresolvesdepends: ["base"], installs base first if needed.SyncRegistrySchemaForModule("contacts")runs additive DDL for models owned by contacts and models extended by contacts (model inherit).core/module/data_sync.goloads manifestdataXML: security, actions, inline views, then second pass forinherit_idview records.- View inherit merges xpath into the parent
sys.view.archrow.
Inheritance catalog
| Mechanism | Status | Where |
|---|---|---|
View inherit (inherit_id + xpath) | Implemented | core/engine/viewinherit/, core/module/data_sync_views.go. Example: sumeru/addons/contacts/views/core_partner_form_inherit_views.xml |
Model inherit (inherit= struct tag) | Implemented | core/modelmeta/model_spec.go, core/modelreg/register.go. Example: sumeru/addons/contacts/models/partner_extend.go |
| Module depends | Implemented | manifest.depends + topological install |
| Field extension without inherit | Implemented | related=, compute= tags in core/orm/related.go |
| Bridge modules | Pattern | Small addon with depends on two apps — see cross-module flows |
| Events | Pattern | event.Subscribe in addon hooks.go instead of copying Go code |
View inherit (example)
The contacts addon adds customer_rank to the partner form:
<record id="view_core_partner_form_contacts_inherit" model="sys.view">
<field name="inherit_id" ref="contacts.view_core_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='phone']" position="after">
<field name="customer_rank" string="Customer Rank"/>
</xpath>
</field>
</record>Model inherit (example)
Extend core.partner with a new stored field:
type PartnerContacts struct {
sdk.Model `sumeru:"inherit=core.partner"`
CustomerRank sdk.Integer `sumeru:"string=Customer Rank,default=0"`
}Run make generate so models/zmodels.go registers the struct. On -u contacts, schema sync adds the customer_rank column to core_partner.