Skip to content

Repository files navigation

⚡ OmniAdapter — The Universal Backend Glue Generator

License Node TypeScript Open in StackBlitz Stars

One YAML file. PostgreSQL + SQLite + Redis + Stripe. Zero boilerplate.

┌───────────────────┐    omni generate     ┌───────────────────────────────────┐
│ omni.config.yaml  │ ───────────────────> │  src/generated/                   │
│ (Single Source)   │                      │  ├── omni-bridge.ts               │
└───────────────────┘                      │  ├── services/ (Postgres/Redis)   │
          │                                │  ├── routes/ (Express/Hono/Next)  │
          │ omni db push                   │  └── types/models.ts              │
          ▼                                └───────────────────────────────────┘
┌───────────────────┐
│ Database Schema   │ (Auto DDL Migrations: CREATE TABLE, INDEXES, CONSTRAINTS)
└───────────────────┘

OmniAdapter solves the universal "glue code" problem that every backend developer faces: writing the same connection pools, cache layers, webhook handlers, router boilerplate, and CRUD services over and over. Define your schema in omni.config.yaml, run the CLI, and get a fully type-safe, production-ready TypeScript backend bridge in seconds.


🚀 Why It's Disruptive

Problem Traditional Approach OmniAdapter
PostgreSQL / SQLite connection pooling 40 lines of manual pool setup Auto-generated with optimized defaults
Redis caching layer Manual get/set logic Automatic cache-aside / write-through strategies
Express / Hono / Next.js Routers Hand-rolled HTTP handlers `--target express
Database Schema Migrations Manual CREATE TABLE scripts omni db push auto DDL schema sync
Stripe webhook handling Hand-rolled event parsing Fully typed webhook event constructor
Type-safe service layer Manual interfaces + validation AST-generated interfaces from YAML
Mock testing infrastructure Write your own mocks Built-in mock environment with 100% test coverage

📦 Quick Start (Copy-Paste Ready)

1. Install

npm install -g omniadapter
# or clone and build locally
npm install && npm run build

2. Create omni.config.yaml

project: "my-saas"
version: "1.0.0"

database:
  provider: postgresql
  host: localhost
  port: 5432
  database: my_saas
  user: postgres
  password: secret
  ssl: false
  pool:
    min: 2
    max: 10

redis:
  host: localhost
  port: 6379

stripe:
  secretKey: sk_test_...
  webhookSecret: whsec_...

collections:
  users:
    name: "users"
    table: "users"
    fields:
      id: { type: uuid, required: true, unique: true }
      email: { type: string, required: true, unique: true, index: true }
      name: { type: string, required: false }
      age: { type: number, required: false }
    cache:
      ttlSeconds: 300
      strategy: write-through
    stripe:
      webhookEndpoint: /webhooks/stripe/users
      webhookEvents:
        - invoice.payment_succeeded

outputs:
  directory: "src/generated"

3. Generate

omni generate --config omni.config.yaml --out src/generated

4. Use It in Your App

import { OmniBridge, UsersService } from './generated';

const app = new OmniBridge({
  database: { host: 'localhost', port: 5432, database: 'my_saas', user: 'postgres', password: 'secret' },
  redis: { host: 'localhost', port: 6379 },
  stripe: { secretKey: 'sk_test_...' }
});

await app.connect();

const user = await (app.collections.users as UsersService).findById('user-123');
console.log(user?.email);

await app.disconnect();

🏗 Project Architecture

OmniAdapter/
├── cli/              # CLI entry point (omni generate, omni serve)
├── generator/        # AST parser, config validator, code emitter
├── templates/        # Code template fragments
├── types/            # Shared TypeScript interfaces
├── tests/            # Vitest suite with mock PostgreSQL, Redis, Stripe
├── src/generated/    # Your auto-generated backend (DO NOT EDIT MANUALLY)
└── omni.config.yaml  # The single source of truth

Generated Services Include:

  • database.service.ts — Connection-pooled PostgreSQL queries
  • redis.service.ts — Auto-connect with TTL support
  • stripe.service.ts — Product/price creation + webhook event construction
  • users.service.ts / orders.service.ts — Type-safe CRUD with caching
  • omni-bridge.ts — Unified bridge that wires everything together
  • types/models.ts — Fully typed interfaces derived from YAML

🧪 Testing & Mock Environments

Every generated service is covered by a mock environment that simulates real database, Redis, and Stripe behavior without external dependencies:

npm test        # Run full suite
npm run test:watch  # Watch mode for TDD

Mock infrastructure (tests/mock-env/):

  • MockPool — Returns predictable rows for SQL queries
  • MockRedis — In-memory key-value store with TTL simulation
  • MockStripe — Returns mock products, prices, and webhook events

🔧 CLI Commands

Command Description
omni generate --config omni.config.yaml Generate backend services
omni generate --target express Auto-generate Express router (src/generated/routes/express.router.ts)
omni generate --target hono Auto-generate Hono router (src/generated/routes/hono.router.ts)
omni generate --target nextjs Auto-generate Next.js Route Handlers
omni db push Auto DDL migration (CREATE TABLE, indexes, constraints)
omni migrate Output timestamped SQL migration script to migrations/
omni serve Start development REST API preview server

📊 Performance Benchmarks

Metric Traditional OmniAdapter
Setup time for new service ~4 hours < 30 seconds
Lines of boilerplate removed 0 500+
Type errors caught at build Some 100%
Mock test infrastructure Manual Built-in

🌍 Why Open Source?

We believe every backend developer deserves a universal adapter. No vendor lock-in. No hidden configuration. Just one YAML file that describes your data, and a generator that produces production-grade TypeScript code you actually want to maintain.


📖 Quick Reference Commands

Generate from scratch:

npm install
npm run generate
npm test
npm run build

Watch and rebuild:

npm run dev

Built with ❤️ by shashank — July 2026

Releases

Packages

Contributors

Languages