A modern, type-safe monorepo template for building full-stack applications with Next.js, tRPC, Drizzle ORM, and Trigger.dev.
ε
₯ |
δΊ¬ |
θ‘ | Kyoto - Vibe git template
ζΉ |
ε |- Bun (v1.1.42+) - Install Bun
- PostgreSQL Database - Use Neon, Supabase, or any PostgreSQL provider
- Trigger.dev Account - Sign up for background job processing
- Sentry Account - Sign up for error tracking
- PostHog Account - Sign up for analytics (optional)
-
Create a new repository from this template:
# Use GitHub's "Use this template" button, or: gh repo create my-app --template stevepeak/kyoto-template -
Clone your new repository:
git clone <your-repo-url> cd my-app
-
Install dependencies:
bun install
-
Set up environment variables: Create a
.envfile in the root directory:# App Configuration APP_URL="http://localhost:3000" # Database (PostgreSQL) DATABASE_URL="postgresql://user:password@host:5432/database" # Better Auth BETTER_AUTH_SECRET="your-secret-here" # Generate with: openssl rand -base64 32 # Trigger.dev TRIGGER_PROJECT_ID="proj_xxxxx" # Get from Trigger.dev dashboard TRIGGER_SECRET_KEY="tr_dev_xxxxx" # Get from Trigger.dev dashboard # AI Services (choose one) OPENAI_API_KEY="sk-xxxxx" # OpenAI # OR OPENROUTER_API_KEY="sk-or-v1-xxxxx" # OpenRouter OPENROUTER_PROVISION_KEY="sk-or-v1-xxxxx" # OpenRouter # OR AI_GATEWAY_API_KEY="vck_xxxxx" # AI Gateway # Sentry (Error Tracking) SENTRY_DSN="https://xxxxx@sentry.io/xxxxx" # PostHog (Analytics - optional) POSTHOG_API_KEY="ph_xxxxx" POSTHOG_HOST="https://us.i.posthog.com"
-
Set up the database:
# Generate migration files from schema bun --cwd packages/db db:generate # Apply migrations to database bun --cwd packages/db db:migrate # Or push schema directly (for development) bun --cwd packages/db db:push
-
Start development servers:
# Start all apps (web + trigger) bun run dev # Or start just the web app bun run dev:web
- Web app: http://localhost:3000
- Trigger.dev dev server will start automatically
kyoto-template/
βββ apps/
β βββ web/ # Next.js 16 web application
β β βββ app/ # App Router pages and routes
β β βββ ...
β βββ trigger/ # Trigger.dev background jobs
β βββ src/tasks/ # Background task definitions
β βββ ...
β
βββ packages/
β βββ api/ # tRPC API definitions
β β βββ src/
β β βββ index.ts # Main router export
β β βββ trpc.ts # tRPC setup
β β
β βββ db/ # Drizzle ORM database package
β β βββ src/
β β β βββ schema.ts # Database schema definitions
β β β βββ migrate.ts # Migration runner
β β βββ migrations/ # Generated migration files
β β
β βββ config/ # Environment variable validation
β β βββ src/index.ts # Zod-validated config
β β
β βββ agents/ # AI agent tooling and MCP integration
β βββ utils/ # Shared utilities
β βββ posthog/ # PostHog analytics helpers
β
βββ config/ # Shared configuration
βββ eslint/ # ESLint config
βββ tsconfig/ # TypeScript configs
bun run dev- Start all development serversbun run dev:web- Start only the web appbun run build- Build all packages and appsbun run typecheck- Type check all packagesbun run lint- Lint all packagesbun run fix- Auto-fix linting issuesbun run ci- Run CI checks (typecheck + lint + knip + build)bun run clean- Clean all build artifacts
bun --cwd packages/db db:generate- Generate migration filesbun --cwd packages/db db:migrate- Run migrationsbun --cwd packages/db db:push- Push schema directly (dev only)bun --cwd packages/db db:studio- Open Drizzle Studio
bun --cwd apps/trigger dev- Start Trigger.dev dev serverbun --cwd apps/trigger deploy- Deploy tasks to Trigger.dev
- Bun - Fast JavaScript runtime and package manager
- Turborepo - High-performance monorepo build system
- TypeScript - Type-safe JavaScript
- Next.js 16 - React framework with App Router
- React 19 - UI library
- Tailwind CSS v4 - Utility-first CSS
- tRPC - End-to-end typesafe APIs
- Drizzle ORM - Type-safe SQL ORM
- PostgreSQL - Database
- Trigger.dev - Background job processing
- Zod - Schema validation
- Sentry - Error tracking and monitoring
- PostHog - Product analytics
- Vercel - Deployment (configured in
vercel.json)
Centralized environment variable parsing and validation with Zod. Provides type-safe access to all environment variables across the monorepo.
import { getConfig } from '@app/config'
const { APP_URL, DATABASE_URL } = getConfig()Server-side tRPC API definitions. Contains all API routers and procedures with end-to-end type safety.
Drizzle ORM database package. Contains schema definitions, migrations, and database connection logic.
import { db } from '@app/db'
import { schema } from '@app/db/schema'AI agent tooling and MCP (Model Context Protocol) integration for orchestrating specialized agents.
Shared JavaScript utilities and helper functions.
Adjust types and schemas first before implementing logic. Run typecheck after changes:
bun run typecheckUse named arguments instead of inline arguments:
// β
Good
function greet(args: { name: string }) {}
// β Avoid
function greet(name: string) {}- NEVER edit files in
packages/db/migrations - ONLY edit
packages/db/src/schema.tsto make schema changes - Use
db:generateto create migrations anddb:migrateto apply them
- Uses ESLint and Prettier for code formatting
- Uses Knip for detecting unused code
- Pre-commit hooks with Husky and lint-staged
The project is configured for Vercel deployment. Set all environment variables in the Vercel dashboard.
Deploy background jobs:
bun --cwd apps/trigger deploy- Next.js Documentation
- tRPC Documentation
- Drizzle ORM Documentation
- Trigger.dev Documentation
- Turborepo Documentation
See LICENSE file for details.