Skip to content

Repository files navigation

🌿 LeafForm

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 Design System & Vision

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.

πŸ“ Complete Repository & File Structure

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

Detailed Breakdown of Root & Config Files

  • 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 under apps/* and packages/* 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 .env variables.
    • docker-compose.yml: Spins up local containerized PostgreSQL database (5432) and Redis instance (6379).
    • .env & .env.example: Store environment secrets such as DATABASE_URL, JWT_SECRET, PORT, and NEXT_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.

⚑ Tech Stack

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

πŸ› οΈ Prerequisites

Ensure you have the following installed on your machine:

  • Node.js: v18.0.0 or higher
  • PNPM: v8.0.0 or higher (npm install -g pnpm)
  • Docker (Optional): For running local PostgreSQL database services via docker-compose.yml

πŸš€ Getting Started

1. Environment & Setup

Run the provided setup script to make setup executables active and initialize environment configs:

chmod +x ./setup.sh
./setup.sh

2. Install Dependencies

Install workspace dependencies across all applications and shared packages:

pnpm install

3. Environment Configuration

Check 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"

πŸ’» Running Development Servers

Start Everything (Recommended)

Run all applications (web, api) and watched packages concurrently:

pnpm dev

Run Specific Applications

  • Start API Server (apps/api) only:

    pnpm --filter @repo/api dev
  • Start Web Application (apps/web) only:

    pnpm --filter web dev

πŸ—οΈ Building & Verification

  • 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

πŸ“– Key Documentation & Entry Points

  • 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

πŸ“ License

Distributed under the MIT License. See LICENSE for more information.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages