image
Akan.js
English
DocsConventionsReferencesCheatsheet
image
Akan.js
Akan.js v2 docs are now available.View the v1 docs
DocsConventionsReferencesCheatsheet
Released under the MIT License
Official Akan.js Consulting onAkansoft
Copyright © 2026 Akan.js All rights reserved.
System managed bybassman
Workspace Convention
• Structure
• Format & Lint
App & Library Convention
• Assets (public/ private/)
• Components (ui/)
• Server Utils (srvkit/)
• Web Utils (webkit/)
• Common Utils (common/)
• akan.config.ts
Domain Convention
• Overview
• model.constant.ts
• model.dictionary.ts
• model.document.ts
• model.service.ts
• model.signal.ts
• model.store.ts
• Model.Template.tsx
• Model.Unit.tsx
• Model.Util.tsx
• Model.View.tsx
• Model.Zone.tsx
Scalar Convention
• Overview
• scalar.constant.ts
• scalar.dictionary.ts
• scalar.document.ts
• Scalar.Template.tsx
• Scalar.Unit.tsx
Service Convention
• Overview
• service.dictionary.ts
• service.service.ts
• service.signal.ts
• service.store.ts
• Service.Util.tsx
• Service.Zone.tsx
Workspace Convention
• Structure
• Format & Lint
App & Library Convention
• Assets (public/ private/)
• Components (ui/)
• Server Utils (srvkit/)
• Web Utils (webkit/)
• Common Utils (common/)
• akan.config.ts
Domain Convention
• Overview
• model.constant.ts
• model.dictionary.ts
• model.document.ts
• model.service.ts
• model.signal.ts
• model.store.ts
• Model.Template.tsx
• Model.Unit.tsx
• Model.Util.tsx
• Model.View.tsx
• Model.Zone.tsx
Scalar Convention
• Overview
• scalar.constant.ts
• scalar.dictionary.ts
• scalar.document.ts
• Scalar.Template.tsx
• Scalar.Unit.tsx
Service Convention
• Overview
• service.dictionary.ts
• service.service.ts
• service.signal.ts
• service.store.ts
• Service.Util.tsx
• Service.Zone.tsx
Next
Structure

model.signal.ts

Signals define the external interface of a module. They connect service logic to generated client APIs, list stores, realtime channels, and server-side jobs.
Internal
Server-only work such as resolved fields, cron jobs, lifecycle hooks, and background processes.
Endpoint
Public APIs and realtime handlers exposed through fetch, websocket message, or pubsub.
Slice
Frontend-facing list surfaces used by generated stores, pagination, and insight loading.
story.signal.ts

Extending Generated Signals

When an app domain extends generated or library behavior, spread inherited signals at the end. This keeps base internals, slices, and endpoints while adding app-specific methods.
user.signal.ts

Defining Internal Tasks

Use internal() for work that belongs to the server runtime rather than a direct page call. This includes resolved fields, scheduled tasks, lifecycle hooks, and queue jobs.
methodDescriptionExample
resolveField(ReturnType)Calculates a resolved field declared in the constant model. The parent document is passed to exec by default.
interval(ms)Runs a recurring server task every given number of milliseconds.
cron(expression)Runs scheduled work with a cron expression. Commonly used with serverMode options for batch jobs.
initialize(options?) / destroy(options?)Runs setup or teardown logic when the server process starts or stops.
process(ReturnType)Defines a background queue job. Use msg(...) to describe the job payload.
resolveField(ReturnType)

Calculates a resolved field declared in the constant model. The parent document is passed to exec by default.

interval(ms)

Runs a recurring server task every given number of milliseconds.

cron(expression)

Runs scheduled work with a cron expression. Commonly used with serverMode options for batch jobs.

initialize(options?) / destroy(options?)

Runs setup or teardown logic when the server process starts or stops.

process(ReturnType)

Defines a background queue job. Use msg(...) to describe the job payload.

story.signal.ts

Defining Public APIs

Use endpoint() for API methods that the client can call. Endpoint builders cover read/write APIs and realtime surfaces.
Method Types
methodDescriptionExample
query(ReturnType, options?)Read API. Use it for loading one model, computed data, or public files.
mutation(ReturnType, options?)Write API. Use it for create, update, delete, or business actions.
message(ReturnType, options?)WebSocket message handler. Use msg(...) for incoming payload fields.
pubsub(ReturnType, options?)Realtime subscription channel. Use room(...) to describe the subscription room.
query(ReturnType, options?)

Read API. Use it for loading one model, computed data, or public files.

mutation(ReturnType, options?)

Write API. Use it for create, update, delete, or business actions.

message(ReturnType, options?)

WebSocket message handler. Use msg(...) for incoming payload fields.

pubsub(ReturnType, options?)

Realtime subscription channel. Use room(...) to describe the subscription room.

Parameter Builders
Parameter builders describe where each value comes from. The order becomes the order of exec arguments. Put nullable arguments near the end because required arguments cannot follow nullable ones.
fieldDescriptionExample
.param(name, Type, options?)Required path-style argument. Common in query, mutation, and slice list methods.
.search(name, Type, options?)Optional search/query argument. It is nullable by default.
.body(name, Type, options?)Request body value, commonly used by mutation APIs.
.msg(name, Type, options?)Message or process payload argument.
.room(name, Type, options?)Realtime room key for pubsub subscription channels.
.with(InternalArg, options?)Server-derived context such as Self, Req, Res, Ws, or custom internal args.
.param(name, Type, options?)

Required path-style argument. Common in query, mutation, and slice list methods.

.search(name, Type, options?)

Optional search/query argument. It is nullable by default.

.body(name, Type, options?)

Request body value, commonly used by mutation APIs.

.msg(name, Type, options?)

Message or process payload argument.

Endpoint Example
story.signal.ts
Realtime Example
chatRoom.signal.ts
Public Path Endpoints
Use endpoint options when a method should be exposed at a public path, such as sitemap.xml or other non-standard API routes.
site.signal.ts
Client Usage (fetch)
Generated fetch methods call endpoint methods from page loaders, components, stores, or client actions.
page.tsx

Standard Model APIs

Akan generates standard model APIs for common view, edit, and merge flows. You usually add custom endpoints only when the business action needs its own name or behavior.
methodDescriptionExample
view[Model](id)Fetch detail-view data generated from the model module.
edit[Model](id)Fetch edit-view data generated from the model module.
merge[Model](id, data)Create or update model data through the generated module API.
view[Model](id)

Fetch detail-view data generated from the model module.

edit[Model](id)

Fetch edit-view data generated from the model module.

merge[Model](id, data)

Create or update model data through the generated module API.

Defining Slices And Stores

Use slice() to define list surfaces for pages. A slice starts from init(), receives params, search values, or internal args, and returns a service query.
Root guards apply to the generated slice surface. Method guards passed to init({ guards }) narrow a specific list.
Server Definition
story.signal.ts
Slice Auto-Generated Methods
A slice definition generates list, insight, and init fetch methods. These methods are usually consumed by store and zone UI code.
methodDescriptionExample
[model]List[Suffix](...args, skip, limit, sort)Loads a paginated list for a slice definition.
[model]Insight[Suffix](...args)Loads aggregation data for the same slice query.
init[Model](query?, option?)Initializes the default model list with list and insight data.
init[Model][Suffix](...args)Initializes a named slice list with args declared in signal.ts.
[model]List[Suffix](...args, skip, limit, sort)

Loads a paginated list for a slice definition.

[model]Insight[Suffix](...args)

Loads aggregation data for the same slice query.

init[Model](query?, option?)

Initializes the default model list with list and insight data.

init[Model][Suffix](...args)

Initializes a named slice list with args declared in signal.ts.

Client Usage
page.tsx

Builder Function Types

The builder functions above map directly to framework types: endpoint builders create EndpointInfo, slice init creates SliceInfo, and internal builders create InternalInfo.
Endpoint builders
query(Return), mutation(Return), message(Return), pubsub(Return)
Slice builder
init(signalOption?)
Internal builders
resolveField(Return), interval(ms), cron(expr), timeout(ms), initialize(), destroy(), process(Return)

Practical Rules

Use Internal for server-only jobs, resolved fields, queue processes, and lifecycle hooks.
Use Endpoint for explicit client calls, mutations, websocket messages, and pubsub subscriptions.
Use Slice for list surfaces that need generated stores, pagination, or insight loading.
Use ...model.internals, ...model.slices, and ...model.endpoints when extending generated or library domains.
Use srv.model.with(otherSrv) when the signal needs another service in this.*Service.
Put nullable arguments near the end because required arguments cannot follow nullable ones.
model.signal.ts
Extending Generated Signals
Defining Internal Tasks
Defining Public APIs
Standard Model APIs
Defining Slices And Stores
Builder Function Types
Practical Rules
.room(name, Type, options?)

Realtime room key for pubsub subscription channels.

.with(InternalArg, options?)

Server-derived context such as Self, Req, Res, Ws, or custom internal args.