Skip to content

Tech Stack

TheTerms is a Turborepo monorepo with a Next.js 14 web application at its core. The internal backend uses tRPC for type-safe API communication, Prisma for database access, and NextAuth for authentication. The public REST API is a separate, already-shipped surface built on Hono with a hand-written OpenAPI 3.1 spec — it doesn’t sit on top of tRPC.

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
Internal APItRPC v10 + React QueryEnd-to-end type safety from database to UI, no code generation
Public REST APIHono + @hono/zod-openapi + ScalarHand-written OpenAPI 3.1 spec, interactive reference UI, independent of the tRPC layer
AuthNextAuth v5 (beta)JWT sessions, credential provider
ORMPrisma 6Type-safe queries, automatic migrations, PostgreSQL support
DatabasePostgreSQL 14+ACID transactions, JSON support, mature ecosystem
BillingStripeSubscription tiers and usage-based billing
RedisRedis 7Provisioned via Docker Compose; not currently used by application code — rate limiting today is in-memory per instance, not Redis-backed
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

tRPC internally, a separate hand-written REST API for external consumers

Section titled “tRPC internally, a separate hand-written REST API for external consumers”

TheTerms uses tRPC instead of REST for the internal API that powers the web app. 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 is a distinct, already-shipped layer built directly on Hono with its own hand-written OpenAPI 3.1 spec (@hono/zod-openapi) — it does not sit on top of tRPC or generate its spec from it. See API Reference for the live endpoint list.

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.