Skip to content

Tech Stack

TheTerms is a Turborepo monorepo with a Next.js 14 web application at its core. The backend uses tRPC for type-safe API communication, Prisma for database access, and NextAuth for authentication.

Browser → Next.js App Router → tRPC Router → Prisma ORM → PostgreSQL
NextAuth (JWT)
Redis (cache)
LayerTechnologyWhy
MonorepoTurborepo + pnpm workspacesShared code between packages without publish cycles
FrameworkNext.js 14 (App Router)Server components, streaming, output: "standalone" for Docker
APItRPC v10 + React QueryEnd-to-end type safety from database to UI, no code generation
AuthNextAuth v5 (beta)JWT sessions, Google/Microsoft OAuth, credential provider
ORMPrisma 6Type-safe queries, automatic migrations, PostgreSQL support
DatabasePostgreSQL 14+ACID transactions, JSON support, mature ecosystem
CacheRedis 6+Session caching, job queues (future)
EmailResendDeveloper-friendly API, React Email templates
UITailwind CSS + shadcn/uiUtility-first styling, accessible component primitives
Rich TextTipTap v3Extensible ProseMirror-based editor, SSR-compatible
Drag & Dropdnd-kitAccessible drag-and-drop for clause reordering
TestingVitest + Testing LibraryFast unit/integration tests with live database

TheTerms uses tRPC instead of REST for the internal API. This provides compile-time type safety between the server and client — when a router procedure changes its input or output type, TypeScript catches mismatches immediately.

The public REST API (planned) will be built on top of tRPC using a separate layer, generating an OpenAPI spec for external consumers.

NextAuth is configured with JWT strategy. Sessions are stored in signed cookies rather than a database table. This avoids a database lookup on every request and simplifies horizontal scaling. The trade-off is that session revocation requires token expiry rather than immediate invalidation.

The Next.js output: "standalone" setting produces a self-contained Node.js server with only the required dependencies. This dramatically reduces the Docker image size compared to copying the full node_modules.

The Prisma schema includes binaryTargets: ["native", "linux-musl-openssl-3.0.x"] to support both local development (macOS/Linux) and Alpine-based Docker containers.