ARCHE
FamiliesDocsExamplesBlogGitHub ↗
Documentation

Start

  • Getting started
  • Philosophy

Guides

  • First hour
  • Agent context
  • Verification
  • Package managers
  • Scaffold lifecycle
  • Showcase & portfolio

Walkthroughs

  • TypeScript fullstack
  • Convex product
  • Rust API & fullstack
  • Solana family
  • Customize & experiments
  • Automation (JSON/MCP)

CLI

  • Overview
  • Flags
  • Subcommands
  • Generated output

Presets

  • Preset catalog

Stack

  • TypeScript architecture
  • Convex
  • Rust
  • Solana
  • Authentication
  • Prisma store
  • tRPC

Operations

  • Deployment
  • Environment variables
  • Workers & queues
  • CI & testing
  • Scaling
  • Security
  • Troubleshooting

Reference

  • Stack links
  • Capabilities
  • This source repo
  • Code examples
← Documentation

Architecture

Package boundaries, type flow, and how the TypeScript fullstack preset is layered.

1 min read

This page describes the TypeScript fullstack shape—the reference template in this repository. For other presets, see Convex, Rust, and Solana.

Layer diagram

Data Flow Diagram
┌─────────────────────────────────────┐
│ apps/web (Next.js) │
│ ↑ tRPC client │
├─────────────────────────────────────┤
│ packages/trpc (client contract) │
│ ↑ types only │
├─────────────────────────────────────┤
│ apps/server (Express) │
│ ├── modules/*/*.trpc.ts │
│ ├── Better Auth (/api/auth/*) │
│ └── tRPC endpoint (/api/trpc) │
│ ↓ │
│ packages/store (Prisma client) │
└─────────────────────────────────────┘

Request flow

Loading diagram…

Package boundaries

AreaLocationResponsibility
Webapps/webNext.js App Router, tRPC client, Better Auth client
APIapps/serverExpress, Better Auth handler, tRPC procedures in src/modules/*
Workerapps/workerBullMQ jobs when --worker is enabled
Contractpackages/trpcClient-only re-export of AppRouter / createCaller
Datapackages/storePrisma schema + client
Authpackages/authBetter Auth server + shared client config
Sharedpackages/backend-commonserverEnv, Redis, logging, env validation

Rule: packages/trpc does not define routers. Procedures live in apps/server/src/modules/<feature>/*.trpc.ts and compose in app.router.ts.

Type flow

terminal
Prisma schema → Prisma client → tRPC procedures → Next.js UI

A schema change propagates through TypeScript types—there is no separate OpenAPI sync step for the default stack.

Module-first API

Features are folders under apps/server/src/modules/<name>/:

  • *.trpc.ts — procedures
  • *.service.ts — business logic (framework-agnostic where possible)
  • *.repository.ts — persistence
  • *.policy.ts — authorization decisions

Keep transport (tRPC), validation (Zod), and persistence separate so Rust or other clients can share boundaries later.

Turborepo

Root turbo.json is rendered at scaffold time with:

  • Transit nodes for dev
  • db:* tasks when a database package exists
  • mdx:generate when the web app includes Fumadocs content

Remote cache is not promised by default—CI may wire credentials, but generated docs do not claim remote cache is on.

Further reading

  • tRPC — client vs server responsibilities
  • Store — Prisma package
  • Auth — Better Auth integration
  • TypeScript walkthrough — scaffold and verify loop