Built by the creator of tx|Primitives for memory, tasks & orchestrationVisit tx docs
tx-agent-kit
Architecture

Architecture Overview

High-level architecture of the tx-agent-kit monorepo

tx-agent-kit is a pnpm monorepo organized into two top-level directories: apps/ for deployable applications and packages/ for shared libraries.

Applications

Four applications target different runtime environments:

AppTechnologyPortPurpose
apps/apiEffect HttpApi4000REST API server for auth, workspaces, tasks, invitations
apps/webNext.js3000Client-only SPA dashboard
apps/workerTemporal-Background workflow execution
apps/mobileExpo React Native-Cross-platform mobile client

Each app has a strict responsibility boundary. The API serves HTTP endpoints and orchestrates domain logic; it is the only app that touches the database. The web app is a pure client-side SPA that never queries the database, never runs server-side code, and never imports Effect. The worker runs Temporal workflows for background processing, and all workflows must be deterministic. The mobile app is an Expo project sharing the same API client patterns as the web app.

Packages

Shared packages provide domain logic, infrastructure, and tooling:

PackagePurpose
packages/coreDDD domain slices (entities, ports, application logic)
packages/dbDrizzle schema, migrations, repositories, effect-schemas, factories
packages/contractsShared API schemas using effect/Schema
packages/authPassword hashing and JWT token primitives
packages/loggingStructured JSON logger (replaces console.*)
packages/observabilityOpenTelemetry bootstrap and instrumentation
packages/testkitShared test utilities and harness code
packages/toolingESLint configs, scaffold CLI, build tooling

Key architectural decisions

  1. Effect for the backend, vanilla for the frontend. The API and worker use Effect for dependency injection, error handling, and service composition. The web app is deliberately Effect-free to keep the frontend simple.

  2. Schema as the contract layer. effect/Schema is the single validation library across the entire stack. No zod, no joi, no yup. Contracts in packages/contracts are shared between the API and its consumers.

  3. DDD in packages/core. Domain logic lives in packages/core/src/domains/<domain>/ following the domain-driven design pattern. Persistence implementations live in packages/db/src/repositories/.

  4. Inward-only dependencies. Domain code never depends on infrastructure. The dependency arrow always points inward, from concrete to abstract.

  5. Mechanical enforcement. Every architectural constraint is enforced by ESLint rules, structural invariant checks, or shell scripts. pnpm lint verifies all constraints.

Explore further

PageWhat it covers
Monorepo StructureDetailed breakdown of every app and package
DDD PatternHow domain-driven design is implemented
Dependency FlowThe rules governing what can import what
Data FlowEnd-to-end request lifecycle from client to database and back

On this page