The boring infrastructure layer your business logic deserves.
Most production applications stand on the same nine infrastructure pillars. Yet, most teams reinvent them—usually poorly, under time pressure, and without realizing they are solving already-solved problems.
Forge exists to eliminate the "infrastructure tax." It is an opinionated, composable toolkit that handles the heavy lifting of distributed systems so your team can spend time on what the app does (business value), rather than how it survives (infrastructure).
Forge makes the right way the easy way.
Forge is unapologetically built for modern, high-performance backend development.
- TypeScript (Strict Mode): Every module is heavily typed. Configurations are inferred, database queries are type-checked, and resilience policies are strictly validated at compile time.
- Bun Runtime: Forge is Bun-first. We leverage Bun's native TypeScript execution, blazing-fast startup times, built-in test runner, and native APIs (like
bun:sqlitefor lightweight outbox/job queues) to keep overhead near zero.
Node.js served us well, but modern backends need faster feedback loops and lower memory footprints. Bun provides native TS execution without transpilation overhead, a Jest-compatible test runner that runs in milliseconds, and a bundler that makes deploying single-binary serverless functions trivial.
Forge is modular. Import only what you need; tree-shaking ensures zero bloat.
| Module | Purpose |
|---|---|
forge/telemetry |
Structured logging, distributed tracing, and metrics (Prometheus/OTLP) with automatic context propagation. |
forge/resilience |
Composable decorators for retry, timeout, circuitBreaker, bulkhead, and rateLimit. |
forge/config |
Schema-validated, fail-fast configuration and secrets management. Typed access, redacted logging. |
forge/preference |
User-owned runtime preferences with fail-safe reads, validated writes, durable stores, scopes, and migrations. |
forge/data |
Connection pooling, Unit of Work (transactions), type-safe query building, and migration tooling. |
forge/messaging |
Transactional Outbox pattern, idempotent consumers, Dead Letter Queues (DLQ), and background jobs. |
forge/http |
Resilient HTTP client, server middleware stack, OpenAPI generation, and RFC 7807 Problem Details. |
forge/security |
JWT/JWKS validation, declarative AuthZ middleware, and automated audit logging. |
forge/lifecycle |
Graceful shutdown orchestration, dependency health probes (liveness/readiness), and signal handling. |
- Bun First: Leverage Bun's native APIs instead of reinventing them. Use
Bun.serve()for HTTP servers, Bun's built-infetchfor HTTP requests,bun:sqlitefor lightweight persistence, andbun:testfor testing. If Bun already provides a capability—don't wrap it, don't polyfill it, don't replace it with a third-party library. Forge extends Bun; it doesn't abstract it away. - Composable, Not Monolithic: Use
forge/resiliencewithoutforge/data. There are no forced peer dependencies. - Interfaces First: Every module exposes an interface (
Logger,Cache,MessageBus) with real and in-memory implementations. Testability is a first-class feature. - Observable by Default: Every operation emits metrics and traces unless explicitly silenced. You cannot fix what you cannot see.
- Fail-Fast at Boot: Misconfigurations and missing secrets crash the app in milliseconds during startup, not 3 hours later in production.
- Zero Magic: No hidden control flow, no global state, no decorator-based dependency injection containers. Explicit wiring only.
A good library knows its boundaries. To keep Forge lean and focused, we explicitly do not build:
- ❌ A UI/Frontend Framework: Forge is strictly for backend/server-side infrastructure.
- ❌ A Domain Modeler: We do not enforce DDD, CQRS, or Event Sourcing. Your business entities are your own.
- ❌ A Heavy ORM: No identity maps, no lazy-loading proxies, no hidden N+1 queries. We provide a type-safe query builder and raw SQL execution.
- ❌ A Workflow/BPMN Engine: For complex, long-running state machines, use dedicated tools like Temporal or Inngest.
- ❌ A Service Mesh: We handle application-level resilience. Network-level mTLS and routing should be handled by your infrastructure (e.g., Kubernetes, Istio).
bun add @infinityi/forgeimport { forge, asComponent } from '@infinityi/forge/lifecycle';
import { serve, type HttpServer } from '@infinityi/forge/http';
import { config } from './config';
import { db } from './data';
import { router } from './http';
let server: HttpServer | undefined;
const app = await forge.boot({
config,
logger: console,
components: [
asComponent('db', {
start: () => db.ping(),
stop: () => db.shutdown(),
}),
asComponent('http', {
start: () => {
server = serve(router, { port: config.http.port });
},
stop: () => server?.stop(true),
}),
],
shutdownTimeout: 30_000, // Graceful shutdown window
});
app.logger.info('Forge application started', {
port: config.http.port,
});Forge ships with in-memory doubles for all core interfaces, making unit testing with Bun's native test runner effortless:
import { describe, it, expect } from 'bun:test';
import { InMemoryMessageBus } from '@infinityi/forge/messaging/testing';
describe('Order Service', () => {
it('publishes an event when an order is placed', async () => {
const bus = new InMemoryMessageBus();
await bus.publish({
type: 'OrderPlaced',
payload: { orderId: '123' },
});
expect(bus.publishedEvents).toContainEqual({
type: 'OrderPlaced',
payload: { orderId: '123' },
});
});
});Run tests at lightning speed:
bun testWe welcome contributions! Please read our Contributing Guide to get started.
Development Setup:
git clone https://github.com/your-org/forge.git
cd forge
bun install
bun run build
bun testForge is open-source software licensed under the MIT License.