S42-Core is a Bun-first backend framework for building professional APIs, services, and modular cells. It is built around dynamic modules, high-performance HTTP primitives, and event-driven communication.
Developed by Cesar Casas (CEO & Head of Engineering at Stock42 LLC) with AI-assisted engineering workflows (Codex).
- Fast HTTP backends on Bun (
Bun.serve, WebRequest/Response). - Modular architecture with convention-based loading.
- Event-driven communication for distributed cells/services.
- Built-in utilities for Redis, MongoDB, SQL, SQLite, SSE, and dependency container patterns.
- Cluster orchestration and IPC for multi-worker runtimes.
Core runtime choices follow Bun APIs first:
- HTTP server:
Bun.serve - Route registration:
Bun.serve({ routes })+ fallback matcher for wildcard patterns - Process/workers:
Bun.spawn+ IPC - File/module discovery:
Bun.Glob - SQL/SQLite:
Bun.SQLandbun:sqlite - Redis:
Bun.RedisClient
S42-Core supports three module types:
fullDomain modules withcontrollers/and optionalevents/.mwsMiddleware modules withmws/index.tscontract (default,beforeRequest,afterRequest).shareShared modules for reusable code (services,types,utils, etc.) with no route/event registration.
Load order:
mwssharefull
Middleware execution is on-demand at controller level (requireBefore, requireAfter, beforeRequest, afterRequest).
Install:
bun add s42-coreMinimal bootstrap:
import { Modules, RouteControllers, Server } from 's42-core'
const modules = new Modules('./modules')
await modules.load()
const server = new Server()
await server.start({
port: 5678,
RouteControllers: new RouteControllers(modules.getControllers()),
hooks: modules.getHooks(),
})Run local module demo in this repo:
bun run modules/server.tsmodules/
auth/
__module__.ts # type: "mws"
mws/index.ts
share/
__module__.ts # type: "share"
services/
types/
operators/
__module__.ts # type: "full"
controllers/
events/
English:
- SERVER
- ROUTECONTROLLERS
- CONTROLLER
- MODULES
- CLUSTER
- EVENTSDOMAIN
- REDISDB
- MONGODB
- SQL
- SQLITE
- SSE
- CORESTATS
- DEPENDENCIES
- MAILGUN
- VIEWTEMPLATE
- TEST
Spanish:
- SERVER.es
- ROUTECONTROLLERS.es
- CONTROLLER.es
- MODULES.es
- CLUSTER.es
- EVENTSDOMAIN.es
- REDISDB.es
- MONGODB.es
- SQL.es
- SQLITE.es
- SSE.es
- CORESTATS.es
- DEPENDENCIES.es
- MAILGUN.es
- VIEWTEMPLATE.es
- TEST.es
See TODO.md for prioritized engineering backlog (P0-P3) based on full src/ analysis and Bun docs alignment.
MIT
S42-Core is developed by Cesar Casas and the engineering team at Stock42 LLC, a company focused on AI solutions, AI agents, and production-grade backend systems.
