Skip to content

Project Structure

TheTerms uses Turborepo with pnpm workspaces. The root turbo.json defines the build pipeline, and each package or app has its own package.json.

theterms/
├── apps/
│ └── web/ # Next.js 14 application
│ ├── src/
│ │ ├── app/ # App Router pages and layouts
│ │ │ ├── (auth)/ # Auth pages: login, signup, password reset
│ │ │ ├── (dashboard)/ # Dashboard pages (protected)
│ │ │ ├── pricing/ # Public pricing page
│ │ │ ├── invite/ # Team invitation acceptance page
│ │ │ ├── s/ # Signer-facing signing page
│ │ │ └── api/
│ │ │ ├── auth/[...nextauth]/ # NextAuth handler
│ │ │ ├── trpc/[trpc]/ # tRPC handler
│ │ │ ├── v1/[...path]/ # Public REST API (Hono)
│ │ │ └── webhooks/stripe/ # Stripe billing webhook receiver
│ │ ├── components/ # React components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── lib/ # Shared utilities (auth config, tRPC client, URL safety)
│ │ ├── types/ # Ambient type declarations
│ │ ├── middleware.ts # Next.js middleware
│ │ └── server/ # Server-side code
│ │ ├── routers/ # tRPC routers (one per domain)
│ │ ├── services/ # Domain logic — one service per resource
│ │ ├── actions/ # Server actions (e.g. auth)
│ │ ├── api/v1/ # Public REST API — routes, schemas, middleware
│ │ ├── config/ # Tier limits and plan configuration
│ │ ├── errors.ts # Shared error types
│ │ └── trpc.ts # tRPC context, middleware chain
│ └── __tests__/ # Test files
├── packages/
│ ├── db/ # Prisma schema, client, migrations
│ │ └── prisma/
│ │ ├── schema.prisma # Data model
│ │ └── migrations/ # SQL migration files
│ ├── email/ # Stub — `export {}`, not yet implemented
│ ├── jobs/ # Stub — `export {}`, not yet implemented
│ └── ui/ # Stub — `export {}`, not yet implemented
├── docker-compose.yml # Internal deployment stack (not a customer-facing self-hosting option)
├── docker-compose.dev.yml # Local dev dependencies (Postgres, Redis)
├── Dockerfile # Multi-stage build
├── docker-entrypoint.sh # Auto-migration on startup
├── turbo.json # Turborepo pipeline config
└── pnpm-workspace.yaml # Workspace package definitions

The main Next.js application. Contains all pages, components, API routes, and tRPC routers.

The Prisma schema and generated client. All other packages import the database client from here via @theterms/db.

packages/email, packages/jobs, packages/ui

Section titled “packages/email, packages/jobs, packages/ui”

All three are placeholder stubs today — each is just export {}; behind a package.json. Nothing in the app imports from them yet. Email sending currently lives directly in apps/web/src/server/services/email.ts (Resend integration) and email-templates.ts, not in packages/email.

The internal API surface is defined by tRPC routers in apps/web/src/server/routers/. This powers the web app only — it’s separate from the public REST API (apps/web/src/server/api/v1/), which is a hand-written Hono layer, not generated from these routers.

RouterPurpose
accountProfile management, password change, account deletion
apikeyAPI key CRUD
batchBulk CSV import for signing invitations
billingStripe subscription and tier management
containerContainer CRUD, listing, search
dashboardDashboard statistics, recent activity
documentDocument and version CRUD, clause management
email-verificationSignup email verification token issuance and redemption
invitationTeam member invitations
password-resetPassword reset token generation and redemption
signingSigning request creation, signer view/submit, audit trail
teamTeam member listing, role changes, removal
templateMark/unmark containers as templates, cloning
webhookWebhook endpoint management — shipped, not future