Skip to main content

Meet @strutvane/framework: The Backend Core That Turns Your Tables Into a Secured API

Migrations, an ORM, an automatic CRUD API with OpenAPI docs, tenant isolation and safe file storage, in one strictly typed TypeScript package.

Updated 7 min readMarkdown

Think about the last time you added a table to a business app.

You wrote the migration. Then the model. Then five endpoints. Then validation, filtering, sorting and pagination. Then the permission check on every single endpoint. Then the "customer A must never see customer B's rows" check. Then you updated the API docs (or meant to).

Next week, a new table. Same dance. 💃

@strutvane/framework exists so you only do the first step by hand.


What it is

@strutvane/framework is the backend and database core of Strutvane, an open-source (MIT) TypeScript framework for business (B2B) apps. You describe a table once in a migration. The framework turns that into the database schema, generated types, a secured CRUD API (create, read, update, delete) with OpenAPI docs, and the metadata the admin UI reads. It also carries the kernel, the shared contracts, the command-line tool behind node strut, and the toolkit other packages use to install themselves.

One package, one version, one source of truth.

Why it exists

The TypeScript world has great libraries for each piece: routing, database access, validation, docs. What it doesn't give you is the glue. Every team wires those pieces together by hand, and every team re-learns the same lessons about security the hard way.

I wanted the glue to be the product:

  • Your migrations are the source of truth. Types, API and screens follow from them.
  • Safe is the default. If you write nothing, nothing leaks.
  • Everything generated is plain code you own. No black box.

The framework also used to be five separate packages (core, contracts, CLI, devkit and the backend). In the 0.2 line they became one package with subpaths (@strutvane/framework/core, /contracts, /console, /devkit). Fewer moving parts, and an app always has exactly one copy of the kernel.

What you get

Data

  • Migrations as the source of truth. A schema builder (schema.create('posts', (t) => …)) with ids, strings, slugs, foreign keys, timestamps, soft deletes and more.
  • Four databases. MySQL 8.4+ (the default), MariaDB, PostgreSQL and SQLite, picked with DB_CONNECTION and the usual DB_* keys in .env.
  • node strut migrate replays your migration files in a sandboxed child process (no secrets, no network, a timeout), applies the pending ones, regenerates the types in .strutvane/, and checks for drift. There's also migrate:status, migrate:rollback, migrate:fresh, db:seed and friends.
  • Its own ORM. Models with relations, eager loading and pagination, plus seeders and factories for realistic test data.
  • Model events such as post.created and post.updated, emitted only after the transaction commits, so a rolled-back write never triggers anything.

API

  • An automatic CRUD API per resource: list, show, create, update, delete, restore and a POST /query endpoint.
  • Filtering, sorting, search and pagination (cursor and page-number) through one documented URL format. Only fields you marked as filterable, sortable or searchable are accepted. Anything else gets a 422 that lists every problem at once, not just the first.
  • OpenAPI 3.1 at /openapi.json, a readable docs page at /docs, and a manifest at /.well-known/strutvane.json that tells clients (like the admin UI) what the current user may do.
  • One error format. Every failure is an RFC 9457 "problem" response with a stable, lowercase code and messages from a catalog. No stack traces, no raw SQL.

The application around it

  • A bootstrap/app.ts built with Application.configure(), route files, middleware (CSRF, auth, permission checks, throttling, signed URLs, idempotency), form requests and an exception handler.
  • A security kit: key ring with key rotation, encryption, URL signing and an HTTP client that refuses private and cloud-metadata addresses.
  • Storage and safe uploads: local disks, size limits enforced while the upload streams in, file types detected from the file's actual bytes (not the browser's claim), signed temporary links.
  • Cache (memory and file stores), sessions, maintenance mode and facades such as Log, Cache, DB and Storage.
  • Testing helpers in @strutvane/framework/testing: a test app, factories, "acting as" a user, and database refresh, on real SQLite or PGlite (an in-process PostgreSQL).

Secure by default

These are not settings you have to remember. They're what you get when you write nothing:

  • Deny by default. Without a permission provider (that's @strutvane/auth's job), the HTTP app refuses to start unless you're in local development or you explicitly mark the API as public.
  • Tenancy, twice. For multi-tenant apps (one app, many customer companies), every query is filtered by tenant in the application and, on PostgreSQL, by row-level security in the database itself. Two locks on the same door.
  • No guessing what exists. A row outside your tenant or your permissions answers 404, exactly like a row that doesn't exist.
  • Writes are re-checked. A created or updated row must still match the user's permissions, inside the same transaction, or the write is rolled back with a 403.
  • Hidden fields stay on the server. They're never sent, never writable, and absent from the docs.
  • Mass assignment comes from the model. A field is writable through the API only if the model lists it as fillable. Privilege-like names such as role or is_* need an extra, explicit opt-in.
  • Query cost is bounded. At most 100 rows per page, offset pages stop at 10,000 rows deep, and PostgreSQL connections get a 5-second statement timeout by default.

How it fits into Strutvane

The framework is the hub every other package plugs into:

  • @strutvane/auth provides sign-in and permissions through a small contract (a "permission provider"). The two never import each other.
  • @strutvane/ui builds the admin screens from the manifest, over plain HTTP.
  • Add-ons like Redis, health checks and social login depend on the published framework as a peer dependency, so your app has exactly one copy. They connect only through documented extension points: container tokens, hooks, domain events and installers.
  • node strut add <package> installs an add-on and runs its installer, which writes config, .env keys and provider registrations for you. Running it twice changes nothing.

A quick look

npm install @strutvane/framework

A migration (the node strut make:migration create_posts_table command scaffolds one like it):

import { migration } from '@strutvane/framework/schema'

export default migration({
  up(schema) {
    schema.create('posts', (t) => {
      t.id()
      t.string('title', 200)
      t.slug('slug').from('title')
      t.foreignId('author_id').constrained('users').cascadeOnDelete()
      t.timestamps()
      t.softDeletes()
    })
  },
  down(schema) {
    schema.dropIfExists('posts')
  },
})

A model holds behaviour only. Its columns come from the types generated by migrate:

import { Model } from '@strutvane/framework/database'

export class Post extends Model('posts', { fillable: ['title'] }) {
  author() {
    return this.belongsTo(User, 'author_id')
  }
}

const page = await Post.query().with('author').orderBy('created_at', 'desc').paginate(25)

Then:

node strut migrate

⚠️ This is a 0.2 preview. The APIs may still change before 1.0, planned for January 2027.

Built to be trusted

  • More than 3,200 automated tests, run against real database engines, not mocks. Coverage must stay above 90% for lines, functions and statements and 85% for branches.
  • CI on Linux, Windows and macOS, on Node 24 and Node 26.
  • Extra suites outside the main gate: a soak test that runs a real server under mixed load and then a burst of concurrent requests, and a "tripwire" run that fails any test file that leaves timers, sockets or child processes behind.
  • Security-reviewed, with attack-style tests for uploads and tenant isolation.
  • Every release is staged by CI and approved by a human with two-factor authentication, and published with npm provenance, so you can check that what's on npm was built from this repository.

What's next

The README lists what isn't there yet, honestly:

  • Queues and mail, plus database and Redis cache stores in the framework itself, are coming in 0.3. (Redis caching is available today through the @strutvane/redis add-on.)
  • Custom routes are served but don't appear in /openapi.json yet.
  • Then 1.0, planned for January 2027.

Try it, and tell me what you think

This is the first package-by-package post in the Strutvane series. Next up: @strutvane/auth.

Follow the series to catch the next post. 🚀

— Vishwajit VM


Part of the Strutvane series. Strutvane™ is open source under the MIT licence.

About the author

  • Hi, I'm Vishwajit VM, a backend & AI engineer from New Delhi. For 5+ years I've built the parts of apps you don't see: APIs, databases, queues and AI agents, for teams in hiring, real estate, finance, retail and civic tech. My rule is simple: a system should keep working when something goes wrong. Right now I'm a backend developer at SPNX, building an EU VAT-registration platform that runs in production. After hours I'm building Strutvane, an open-source TypeScript framework for business apps (I'm writing about it as a series on my blog, vishwajitvm.hashnode.dev), plus my own products such as DevFlow-AI (self-hosted AI code review) and Hopline (encrypted peer-to-peer file transfer). Day to day I work with Python, FastAPI, Node.js, TypeScript, NestJS, PostgreSQL, Redis, Docker, LangGraph and RAG, and I've shipped plenty of Laravel/PHP and React along the way. Outside work, I'm a part-time photographer. See my work at https://vishwajit-labs-web.vercel.app/

No comments yet. Be the first to comment.

More from this blog