DEV Community

Cover image for I built a workflow engine (in Rust) with idiomatic TypeScript binding
Yacine
Yacine

Posted on

I built a workflow engine (in Rust) with idiomatic TypeScript binding

I got tired of the complexity of existing workflow engines — the operational overhead, the learning curve, the mental model you have to internalize just to fit your code into their framework. So I built my own! Sayiir.

The idea: checkpoint each step's output as it completes. On crash, skip what's done, pick up where you left off. Your tasks are just normal async functions — no determinism rules, no special wrappers. Just write code.

  import { task, workflow, Runner, PostgresBackend } from 'sayiir';

  const fetchUser = task({
    name: 'fetch_user',
    timeout: '30s',
    retries: 3,
    run: async (id: string) => {
      return await db.getUser(id); // just normal code
    }
  });

  const sendEmail = task({
    name: 'send_email',
    run: async (user: User) => {
      await emailService.sendWelcome(user);
    }
  });

  const welcome = workflow({
    name: 'welcome',
    steps: [fetchUser, sendEmail]
  });

  const runner = new Runner(
    await PostgresBackend.connect('postgres://...')
  );
  await runner.run(welcome, 'welcome-42', userId);
Enter fullscreen mode Exit fullscreen mode

Why it feels like home

  • Fully typed end-to-end — task inputs/outputs are inferred, mistakes caught at compile time
  • Idiomatic TypeScript API — no decorators, no classes to extend, just functions and objects
  • No external services to run — your app + a Postgres database, that's it
  • Rust engine under the hood via NAPI-RS — native performance without the complexity leaking through

The goal is simple: durable workflows with the same productivity you'd expect from any good TypeScript library. Define
tasks, compose them, run them. Nothing extra to learn.

Looking for contributors

The codebase is small enough to understand end-to-end, and there are lots of interesting problems to solve. Good first issues are tagged on GitHub.

Docs: https://docs.sayiir.dev/getting-started/nodejs
Repo: github.com/sayiir/sayiir

Top comments (0)