Skip to content

Why Alpyne

Every business app needs the same backend before it does anything useful: a database layer, background jobs, permissions and reports. You build it again for each app, and then you keep it running.

Alpyne is that backend, already built. You declare what your app stores, what it does and who may do it, in TypeScript. Alpyne runs it.

Each row is something you hand-build today and declare in a line or two with Alpyne.

You hand-build With Alpyne
Tables, migrations and an ORM Templates and Properties
Status columns and the code that guards them States and transitions
An outbox, a queue and workers Events and Listeners
A cron service Schedules
Permission checks scattered through handlers Roles and Grants
tenant_id on every query Workspaces
Reporting queries Metrics

Every fragment below comes from one leave-request App.

const leaveRequest = app.addTemplate('leaveRequest');
leaveRequest.addProperty('reason', 'string');
leaveRequest.addProperty('days', 'integer');

That is the whole storage layer. Alpyne stores every leave request and hands it to your code as an Item. You write no SQL, and a new Property needs no migration.

const pending = leaveRequest.addState('pending').setDefault();
const approved = leaveRequest.addState('approved');
pending.addTransition('approve', approved);

A leave request moves from pending to approved, and only along a transition you declared. Two approvals at the same moment produce one approval, never two.

const approvedEvent = leaveRequest.addEvent('approved');
approvedEvent.addListener('tellRequester', async (_event, item) => {
await notify(`Your leave "${item.properties.reason}" is approved`);
});

Approving a request publishes approved. Alpyne commits the Event together with the state change, then runs the Listener in a transaction of its own. notify is your code: an email, a chat message, a calendar entry.

const reminderDue = leaveRequest.addEvent('reminderDue');
reminderDue.addSchedule('weekdays', '0 9 * * 1-5').state(['pending']);

Each weekday morning, Alpyne publishes reminderDue for every request still pending. A Listener on that Event sends the reminder.

const employee = app.addRole('employee', { label: 'Employee' });
const manager = app.addRole('manager', { label: 'Manager' });
manager.extend(employee);
request.addGrant(employee);
approve.addGrant(manager);
const staff = leaveRequest.addRole('staff', async () => [employee.prn]);
leaveRequest.addGrant(staff, Object.values(leaveRequest.properties));

Employees request leave and managers approve it. Alpyne refuses a call without a Grant before your handler runs. Grants on a Template decide which Properties each Role reads.

There is nothing to declare. Each customer gets a Workspace, and every Item, Event and Metric belongs to exactly one. Your handlers never filter by customer, and no query reaches across.

const approvals = app.addMetric('approvals');
approvals.addEvent(approvedEvent);
const byRequest = app.addMetricDimension('request', [leaveRequest]);
approvals.addDimension(byRequest, 1, async (event) => event.itemId);

Every approval counts once, under the request it approved. Read the Metric for any span of time. Alpyne builds it from the Events your App already publishes.

An App is a unit you import. A people App already holds your staff, so the leave App imports it and builds on it.

const people = app.addDependency('people', peopleApp);
const person = people.templates.person;
leaveRequest.addRelation('requester', 'many-to-one', person, { toKey: 'leave' });

Now a leave request points at a person. The same import lets the leave App react to the people App’s Events and reuse its Roles. Small Apps compose into bigger applications.

The same App runs on PostgreSQL and on SQLite, with no change to your code. Your tests run it in memory, with the clock under your control.

Alpyne is open source. The code is on GitHub.