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)
│ │ │ ├── api/ # API routes (NextAuth, tRPC)
│ │ │ ├── invite/ # Team invitation acceptance page
│ │ │ └── s/ # Signer-facing signing page
│ │ ├── components/ # React components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── lib/ # Shared utilities (auth config, tRPC client)
│ │ └── server/ # Server-side code
│ │ ├── routers/ # tRPC routers (one per domain)
│ │ ├── services/ # Email, webhooks
│ │ └── 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/ # Email service (Resend integration)
│ ├── jobs/ # Background job definitions
│ └── ui/ # Shared UI components
├── docker-compose.yml # Production deployment
├── docker-compose.dev.yml # Local dev dependencies
├── Dockerfile # Multi-stage production 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.

Email sending service using Resend. Defines React Email templates for signing invitations, team invitations, and admin notifications.

Background job definitions (future — currently placeholder). Will handle email queuing, webhook delivery, and scheduled tasks.

Shared UI components used across packages. Based on shadcn/ui primitives with Tailwind CSS.

The API surface is defined by tRPC routers in apps/web/src/server/routers/:

RouterPurpose
accountProfile management, password change, account deletion
apikeyAPI key CRUD (for future public API)
batchBulk CSV import for signing invitations
containerContainer CRUD, listing, search
dashboardDashboard statistics, recent activity
documentDocument and version CRUD, clause management
invitationTeam member invitations
password-resetPassword reset token generation and redemption
signingSigning request creation, signer view/submit, audit trail
teamTeam member listing, role changes, removal
webhookWebhook endpoint management (future)