LeafForm is a high-performance, dynamic form builder, survey, quiz, and analytics platform. Built with an end-to-end type-safe TypeScript monorepo architecture, LeafForm combines Next.js 15, Express, tRPC, Drizzle ORM, and Inngest background event processing with an aesthetic Deep Forest Green design system.
LeafForm provides an intuitive and visually stunning user experience designed around a custom Deep Forest Green & Pure White design system (documented in DESIGN.md):
- Primary Deep Forest Gradient:
from-[#092218] via-[#0e2c20] to-[#081a13]with subtle ambient emerald stage glows (emerald-500/10). - Brand Accent Greens: Emerald highlights (
#34d399/text-emerald-400), Shampoo Form Primary (#134e3b), Survey Primary (#0d5c41), and Analytics Primary (#065f46). - Clean Contrast Surfaces: Pure White (
#ffffff) and Slate (#f8fafc,#0f172a,#475569) contrast cards for form elements, builder canvases, and administrative dashboards. - Glassmorphism & Micro-Interactions: Smooth 300msβ500ms transitions, rounded container surfaces (
rounded-3xl/rounded-2xl), interactive carousel controls, and responsive preview stages.
LeafForm is structured as a Turborepo monorepo using PNPM Workspaces. Below is the complete overview of every directory, application, package, configuration file, and git hook in the repository:
monoreop-tRPC/
βββ .agents/ # Customization root containing workspace agent rules & skills
βββ .github/ # GitHub Actions CI/CD workflows and repository settings
β βββ scripts/ # Utility automation and notification scripts
β β βββ notify-telegram.js # Lightweight Telegram notification handler
β βββ workflows/ # CI/CD pipeline automation scripts
βββ .husky/ # Git hooks management (Husky)
β βββ commit-msg # Validates commit messages with Commitlint
β βββ pre-commit # Executes linting and code formatting pre-commit
β βββ pre-push # Executes type checks before pushing code
βββ .vscode/ # Recommended VS Code workspace settings & extensions
βββ .turbo/ # Turborepo local build cache directory
β
βββ apps/ # Executable Applications
β βββ api/ # Express + tRPC Backend API Server
β β βββ src/
β β β βββ index.ts # API server entry point & HTTP listener port setup
β β β βββ server.ts # Express app initialization, CORS, tRPC middleware
β β β βββ env.ts # Backend environment schema validation via Zod
β β βββ eslint.config.js # API-specific linting rules
β β βββ package.json # API app scripts and backend dependencies
β β βββ tsconfig.json # TypeScript compiler configuration for API
β β βββ tsup.config.ts # Bundler configuration for Node backend build
β β
β βββ web/ # Next.js 15 Web Frontend Application
β βββ app/ # Next.js App Router Routes & Pages
β β βββ admin/ # Admin dashboard & response analytics page
β β βββ buildform/ # Visual drag-and-drop dynamic form builder engine
β β βββ getstarted/ # User onboarding and registration flow
β β βββ logout/ # Session destruction and sign-out route
β β βββ submit/ # Form respondent submission view
β β βββ userprofile/ # Account management & profile settings
β β βββ welcome/ # Landing showcase page & hero stage
β β βββ globals.css # LeafForm Deep Forest CSS variables & Tailwind rules
β β βββ layout.tsx # Root layout wrapper, fonts, and React context providers
β β βββ page.tsx # Primary application homepage
β βββ components/ # Reusable UI components & form elements (Shadcn UI)
β βββ hooks/ # Custom React hooks (e.g. useLogin, useSignup)
β βββ lib/ # Client utilities and helpers (utils.ts)
β βββ providers/ # React Query, tRPC & global context providers
β βββ public/ # Web static assets, icons, and favicon
β βββ trpc/ # Client-side tRPC React hooks & client bindings
β βββ components.json # Shadcn component generator configuration
β βββ env.js # Web env validation using @t3-oss/env-nextjs
β βββ eslint.config.js # Next.js ESLint configuration
β βββ next.config.js # Next.js framework configuration options
β βββ package.json # Web application package manifest & dependencies
β βββ postcss.config.mjs # PostCSS plugin setup for Tailwind CSS
β βββ tsconfig.json # Web app TypeScript compiler settings
β
βββ packages/ # Shared Workspace Packages
β βββ database/ # Drizzle ORM Database Access Layer
β β βββ drizzle/ # Drizzle SQL migrations & schema snapshots
β β βββ models/ # Entity schemas (form, formFields, formSubmissions, user, refreshToken)
β β βββ drizzle.config.ts # Drizzle ORM database migration config
β β βββ env.ts # Database environment URL validation
β β βββ index.ts # Database connection instance exporter
β β βββ schema.ts # Central database table & relation definitions
β β βββ package.json # Database package dependencies (drizzle-orm, pg)
β β
β βββ trpc/ # Centralized tRPC API Layer
β β βββ server/ # Root tRPC router, procedures, context, & sub-routers (auth, form, health)
β β βββ client/ # Shared client tRPC type signatures & interfaces
β β βββ package.json # tRPC package dependencies
β β
β βββ services/ # Core Business Logic Domain Services
β β βββ form/ # Form creation, field validation & response processing (core.ts, model.ts)
β β βββ user/ # User authentication, hashing, & profile service logic (core.ts, model.ts)
β β βββ package.json # Domain service dependencies
β β
β βββ innjest/ # Inngest Background Event Processing & Workflows
β β βββ src/client/ # Inngest client UI components & dashboard
β β βββ src/server/ # Inngest analytics handlers & tRPC middleware
β β βββ src/shared/ # Inngest event types & shared interfaces
β β
β βββ logger/ # Shared structured logging package (pino / custom logger)
β βββ utils/ # Shared utility helpers (apiErr, apiRes, hashIT, jwtUtils, initRedis)
β βββ eslint-config/ # Shared ESLint rule presets across applications
β βββ typescript-config/ # Base tsconfig presets (nextjs, node, react)
β
βββ etc/ # Assets & Documentation
β βββ doc/ # Architecture & Design Specifications
β β βββ cicd/ # CI/CD & pipeline documentation
β β β βββ README.md # CodeQL & Telegram notification docs
β β βββ DESIGN.md # LeafForm UI/UX & Deep Forest Design System specification
β β βββ LOGO_DESIGN.md # Logo and brand typography specification
β βββ public/ # Generated logos, media, and design system visual assets
β
βββ .env # Local environment variables configuration file
βββ .env.example # Template for required environment variables
βββ .gitignore # Files, logs, and build output directories ignored by Git
βββ .npmrc # PNPM engine settings and package resolution configs
βββ commitlint.config.js # Conventional commit rules validation configuration
βββ docker-compose.yml # Local Docker configuration for PostgreSQL & Redis
βββ eslint.config.js # Root monorepo linting rules configuration
βββ package.json # Monorepo root manifest, dev dependencies & workspace scripts
βββ pnpm-lock.yaml # Locked dependency tree for PNPM
βββ pnpm-workspace.yaml # Defines active PNPM workspace modules (apps/*, packages/*)
βββ prettier.config.js # Code formatting standards (print width, semicolons, single quotes)
βββ setup.sh # Automated setup & environment injector script
βββ turbo.json # Turborepo task pipeline graph & caching rules
-
Git & CI Hooks (
.husky/,.github/):husky/commit-msg: Validates commit messages against Conventional Commit standards using Commitlint.husky/pre-commit: Automatically runs linting and Prettier formatting on staged files prior to commits.husky/pre-push: Performs full TypeScript type checking across all workspaces before code is pushed..github/workflows/: CI/CD pipelines for automated testing, type checking, and deployment.
-
Workspace & Package Management (
pnpm-workspace.yaml,turbo.json,package.json):pnpm-workspace.yaml: Instructs PNPM to link packages underapps/*andpackages/*as an integrated workspace.turbo.json: Defines build task execution pipelines, task caching rules, and parallel dependency execution graphs.package.json: Contains root-level npm scripts (dev,build,lint,format,check-types) and shared dev tooling dependencies.
-
Environment & Infrastructure (
.env,.env.example,setup.sh,docker-compose.yml):setup.sh: Interactive/automated setup script that verifies toolchain dependencies and injects required.envvariables.docker-compose.yml: Spins up local containerized PostgreSQL database (5432) and Redis instance (6379)..env&.env.example: Store environment secrets such asDATABASE_URL,JWT_SECRET,PORT, andNEXT_PUBLIC_API_URL.
-
Code Quality & Formatting (
commitlint.config.js,eslint.config.js,prettier.config.js):commitlint.config.js: Enforces standardized commit message formats (e.g.feat: ...,fix: ...).eslint.config.js: Unified ESLint configuration enforcing code style, React hooks rules, and TypeScript best practices.prettier.config.js: Shared formatting rule definitions across all file types.
| Layer | Technology |
|---|---|
| Monorepo Manager | Turborepo + PNPM Workspaces |
| Frontend Framework | Next.js 15 (App Router), React 19 |
| Backend API | Express.js + tRPC v10 |
| Database & ORM | PostgreSQL + Drizzle ORM |
| Async Jobs | Inngest (packages/innjest) |
| Styling | Tailwind CSS + Custom CSS Variables (LeafForm Forest System) |
| Type Safety | End-to-End TypeScript + Zod validation |
Ensure you have the following installed on your machine:
- Node.js:
v18.0.0or higher - PNPM:
v8.0.0or higher (npm install -g pnpm) - Docker (Optional): For running local PostgreSQL database services via
docker-compose.yml
Run the provided setup script to make setup executables active and initialize environment configs:
chmod +x ./setup.sh
./setup.shInstall workspace dependencies across all applications and shared packages:
pnpm installCheck the root .env file and adjust database connection credentials or API ports if needed:
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/leaform"
PORT=4000
NEXT_PUBLIC_API_URL="http://localhost:4000"Run all applications (web, api) and watched packages concurrently:
pnpm dev-
Start API Server (
apps/api) only:pnpm --filter @repo/api dev
-
Start Web Application (
apps/web) only:pnpm --filter web dev
-
Build all applications & packages:
pnpm build
-
Run TypeScript type checks across all workspaces:
pnpm check-types
-
Run ESLint checks:
pnpm lint
-
Format codebase with Prettier:
pnpm format
- System Architecture & Topology: etc/doc/SYSTEM_DESIGN.md
- CI/CD & CodeQL Pipelines: etc/doc/cicd/README.md
- Code Design & Safety Specification: etc/doc/CODE_DESIGN.md
- UI/UX & Design System Spec: etc/doc/DESIGN.md
- Logo & Visual Brand Specs: etc/doc/LOGO_DESIGN.md
- Web Frontend Entry: apps/web/app/page.tsx
- Form Builder Interface: apps/web/app/buildform/page.tsx
- API Server Entry: apps/api/src/index.ts
- tRPC Root Router: packages/trpc/server/index.ts
- Database Schema: packages/database/schema.ts
Distributed under the MIT License. See LICENSE for more information.