TYPECHECKED APPLICATION ARCHITECTUREv0.5

RESULTS, SERVICES, LIFETIMES.

Make the shape
of your app obvious.

A small, typed architecture for TypeScript applications built on better-result. Compose dependencies, protect error boundaries and close what you open.

app.tsbetter-effect / live
01import { Effect, Layer, Runtime, Service } from 'better-effect'
02import { Result } from 'better-result'
03
04class Database extends Service<Database>()('Database') {
05  query(id: string) { return ... }
06}
07
08const program = Effect.gen(function* () => {
09  const db = yield* Database
10  return Result.ok(yield* db.query('user-1'))
11})
12
13// requirements flow to the Runtime
14await Runtime.run(AppLive, backend, () => program)

Keep the good parts of Effect. Keep your application yours.

better-effect stays close to TypeScript, Promises and better-result. There is no hidden scheduler to learn and no container vocabulary in your domain code.

Learn the mental model

01 / REQUIREMENTS

Dependencies you can see

Services are tokens, contracts and yieldable handles. TypeScript follows every dependency from the generator to the Runtime.

02 / COMPOSITION

Environments without a cage

Layers describe implementations independently from your container. Merge production wiring and override only what tests need.

03 / LIFETIMES

Ownership with an ending

Scopes make resource ownership explicit: execution-local work closes fast, application resources close gracefully at shutdown.

better-effect

Start with one Service.
Grow with confidence.

Read the guide, wire your first Layer and let the compiler show you what your application needs.

Open the guide