TsdkArc LogoTsdkArc

Type-safe module composable.

Compose modules like building blocks, nest them, and share them across projects. Clean, simple, scalable.

Read Documentation

Quick Start

import start, { defineModule } from "tsdkarc";

interface ConfigSlice {
  config: { port: number };
}
const configModule = defineModule()({
  name: "config",
  modules: [],
  boot: (ctx) => ctx.set("config", { port: 3000 }),
});

interface ServerSlice {
  server: { listen: () => void };
}
const serverModule = defineModule()({
  name: "server",
  modules: [configModule], // ๐Ÿ‘ˆ Declares dependency
  boot(ctx) {
    ctx.set("server", {
      listen: () => {
        console.log(`Running on ${ctx.config.port}`); // ๐Ÿ‘ˆ Fully typed
      },
    });
  },
});

// Launch ๐Ÿš€
const app = await start([serverModule], {
  afterBoot() {
    console.log("The app is running");
  },
  onError(error, ctx, mod) {
    console.log(`${mod.name} error`, error.message);
    // throw error;
  },
});
app.ctx.server.listen(); // Running on 3000

Why TsdkArc?

Fully Type-Safe Context

The merged union of all slices is fully typed at each module's boundary. Autocomplete works exactly as you'd expect, everywhere.

Auto Resolution

Declare your dependencies. start() resolves the graph.

Composable

Build small modules. Complex wiring becomes just a simple chain.

Robust Lifecycle

Granular control over setup and teardown. From beforeBoot to afterShutdown.

Ideal Use Cases

๐Ÿš€

Bun / Node.js Custom Frameworks

Wire up config, databases, caches, HTTP servers and Business modules in the exact right order without brittle, manual setup.

๐Ÿ“ฆ

Shared Library Modules

Publish reusable infrastructure (like logging or auth or others business modules) that other projects can drop in effortlessly.

โš™๏ธ

Background Workers

Safely orchestrate queue consumers and cron jobs, ensuring automatic resource cleanup via shutdown hooks.

๐Ÿงช

Isolated Testing

Swap out a real database module for an in-memory mock simply by replacing a single dependency.

What it is NOT

A Web Framework

No routing, no HTTP handling, no middleware pipeline (though you can register those as context values).

A Runtime DI Container

No decorators, no reflection. Dependencies are declared statically at definition time.

A State Management Library

The context is boot-time wiring, not reactive application state (not Redux, Zustand, etc.).

A Task Runner / Build Tool

Not a replacement for task runners or build tools like Grunt, Gulp, or Make.

A Process Manager

Not a replacement for process managers like PM2, Docker, or systemd.

An ORM or Data Layer

It can hold a DB pool, but it knows absolutely nothing about databases itself.

A Config Loader

You bring your own config reading logic; it just helps you share it safely across modules.

Other Awesome Projects