@lawhive / framework

The Framework

Shared TypeScript packages that define standard patterns, libraries, and APIs for how we build services at Lawhive.

events.ts
// Define type-safe events with effects
const { event, router } = ev()

const taskEvents = router({
  created: event({
    schema: z.object({ name: z.string() }),
    effect: async (input) =>
      prisma.task.create({ data: input }),
    selectId: ({ output }) => output.id,
  }),
})

// Publish with composable adapters
const client = createEventClient(events, {
  adapters: [createEventStoreAdapter({ storage })],
  createContext: (fn) => prisma.$transaction((tx) => fn({ tx })),
})

Standard Patterns & APIs

Everything you need to build reliable, event-driven services with consistent patterns across the organisation.

Packages

Install what you need. Each package is independently versioned and published.

Run the Example

The monorepo ships with a full reference app — a task manager with event sourcing, audit trails, and a Next.js frontend. Get it running in under a minute.

1

Start the database

Spins up a PostgreSQL container via Docker Compose.

$bun run db:start
2

Push the schema

Creates the event store, outbox, audit, and task tables.

$bun run db:push
3

Run the example

Starts the Hono server on :9001 and the Next.js app on :9000.

$bun run example
Server — http://localhost:9001Web app — http://localhost:9000API docs — http://localhost:9001/api-reference

Requires Docker and Bun. See examples/server and examples/web for the full source.

Documentation

Jump straight to the section you need.