A production-ready monorepo showcasing modern web development with Next.js 15, React 19, and a thoughtfully-architected feature module system.
Clear separation between presentation, business logic, and data. Feature modules follow a strict no-barrel-files convention to prevent bundle bloat and maintain clear server/client boundaries in React Server Components.
End-to-end type safety with tRPCβfrom database queries to API responses to client components. If it compiles, it works.
Includes authentication (Clerk), background jobs (Inngest), database (PostgreSQL + Prisma on NeonDB), AI integration (OpenAI + E2B sandboxes), and comprehensive error handling.
- Next.js 15 β App Router, React Server Components, Turbopack
- React 19 β Latest concurrent features and optimizations
- TypeScript β Strict mode, zero compromises
- Turborepo β Monorepo with intelligent caching
- tRPC β End-to-end typesafe APIs with
superjsontransformer - PostgreSQL + Prisma β Relational database with type-safe ORM, hosted on NeonDB (serverless Postgres)
- TanStack Query β Server state management, caching, & synchronization
- Clerk β Complete auth with GitHub OAuth, middleware-protected routes
- Inngest β Durable async workflows and background processing
- Tailwind CSS 4 β Modern CSS with native cascade layers
- Shadcn/UI + Radix UI β 60+ accessible components
- next-themes β Seamless dark mode
- Lucide Icons β Beautiful, consistent iconography
- Biome β Blazing fast linting & formatting (replaces ESLint + Prettier)
- Sherif β Validates monorepo dependencies
- Storybook β Component documentation & visual testing
- OpenAI β GPT integration for intelligent features
- E2B Code Interpreter β Sandboxed code execution
- Cloudinary β Media management & optimization
turborepo-nextjs/
βββ apps/
β βββ web/ # Main Next.js application
β β βββ app/ # App Router (route groups & pages)
β β β βββ (home)/ # Public routes: /, /pricing, /auth
β β β βββ api/ # API routes: tRPC, webhooks, Inngest
β β β βββ projects/ # Protected routes: /projects/*
β β β
β β βββ modules/ # π― Feature modules (domain-driven)
β β β βββ home/ # Home page features
β β β βββ projects/ # Project management
β β β βββ messages/ # Message handling
β β β βββ usage/ # Usage tracking
β β β βββ layout/ # Shared layout components
β β β
β β βββ trpc/ # tRPC setup & routers
β β βββ inngest/ # Background job definitions
β β βββ prisma/ # Database schema & migrations (PostgreSQL)
β β βββ middleware.ts # Auth protection (Clerk)
β β βββ env.mjs # Type-safe environment variables
β β
β βββ storybook/ # Component playground (60+ stories)
β βββ stories/ # Visual documentation for all UI components
β
βββ packages/
βββ design-system/ # Shared UI library
β βββ src/
β βββ components/ # Shadcn UI components (ui/ & magicui/)
β βββ hooks/ # Reusable React hooks
β βββ lib/ # Utilities (cn, etc.)
β
βββ typescript-config/ # Shared TypeScript configurations
βββ base.json # Base strict config
βββ nextjs.json # Next.js specific
βββ react-library.json # For packages
- Node.js 24.6.0+ (LTS recommended)
- pnpm 10.14.0+
- PostgreSQL database (NeonDB recommended, or local/Docker)
# 1. Clone the repository
git clone https://github.com/nass59/turborepo-nextjs.git
cd turborepo-nextjs
# 2. Install dependencies
pnpm install
# 3. Set up environment variables
cp apps/web/.env.example apps/web/.env.local
# Then edit apps/web/.env.local with your keys
# 4. Set up database & generate Prisma client
cd apps/web && pnpm prisma generate && pnpm prisma db push && cd ../..
# 5. Start all development servers
pnpm devThat's it! Your apps will be running:
- π Web app: localhost:3000
- π Storybook: localhost:6006
# Development
pnpm dev # Start all apps (web + storybook)
pnpm build # Build all packages & apps for production
pnpm typecheck # Run TypeScript checks across workspace
pnpm lint # Lint all code with Biome
pnpm format # Auto-format code with Biome
# Dependencies
pnpm check-dependencies # Validate with Sherif
pnpm bump-deps # Update all dependencies (except geist)
pnpm bump-ui # Sync Shadcn UI components to design-system
# Cleanup
pnpm clean # Remove build artifacts & caches# Web App (apps/web)
cd apps/web
pnpm dev # Start with Turbopack (fast refresh)
pnpm build # Production build
pnpm start # Start production server
pnpm typecheck # Type check this app
# Storybook (apps/storybook)
cd apps/storybook
pnpm dev # Start Storybook dev server
pnpm build # Build static Storybook site
pnpm chromatic # Deploy to Chromatic (visual testing)-
Add a new module in
apps/web/modules/your-feature/modules/your-feature/ βββ ui/ # Components βββ server/ # Server functions βββ types.ts # Types βββ constants.ts # Config -
Create tRPC procedures in
apps/web/trpc/routers/your-feature.tsimport { protectedProcedure } from '../trpc'; export const yourFeatureRouter = { list: protectedProcedure.query(async ({ ctx }) => { // Server-side logic with ctx.clerkUserId }), };
-
Use in components via tRPC hooks
'use client'; import { useTRPC } from '@/trpc/client'; export function YourComponent() { const { data } = useQuery(trpc.yourFeature.yourAction.queryOptions()); // ... }
-
Add to design system via Shadcn CLI
pnpm bump-ui # Syncs latest Shadcn components -
Create Storybook story in
apps/storybook/stories/import type { Meta, StoryObj } from '@storybook/react'; import { YourComponent } from '@workspace/design-system/components/ui/your-component'; const meta: Meta<typeof YourComponent> = { title: 'UI/YourComponent', component: YourComponent, };
-
Use in your app
import { YourComponent } from '@workspace/design-system/components/ui/your-component';
Define Inngest functions in apps/web/inngest/functions.ts:
import { inngest } from './client';
export const processTask = inngest.createFunction(
{ id: 'process-task' },
{ event: 'app/task.process' },
async ({ event, step }) => {
// Durable async workflow
}
);This project includes comprehensive documentation for AI assistants:
docs/AI-DEVELOPMENT-GUIDE.mdβ Guidelines for AI pair programming.github/copilot-instructions.mdβ GitHub Copilot specific instructions- ADRs β Architectural Decision Records in
docs/adr/ - JSDoc β All public APIs documented
Helpful Scripts:
./scripts/ai-analysis.sh # Generate project analysis
./scripts/adr-helper.sh new # Create new ADR
./scripts/debug-helper.sh # Debug assistance- Architecture Decision Records β Why we made key technical choices
- AI Development Guide β Guidelines for AI-assisted development
- Copilot Instructions β Project conventions for GitHub Copilot
- 0002: Turborepo for Monorepo Management
- 0005: PostgreSQL with Prisma for User Data
- 0006: Clerk Authentication
- 0010: API Design Standards (tRPC)
The @workspace/design-system package exports 60+ accessible components built on:
- Radix UI primitives
- Tailwind CSS 4 styling
- CVA (class-variance-authority) for variants
- Lucide Icons for iconography
Usage:
// Direct imports (no barrel files)
import { Button } from '@workspace/design-system/components/ui/button';
import { cn } from '@workspace/design-system/lib/utils';Explore components:
cd apps/storybook && pnpm dev
# Visit http://localhost:6006# Connect your repo to Vercel
vercel
# Add environment variables in Vercel dashboard
# Deploy!
vercel --prod# Build
docker build -t turborepo-nextjs .
# Run
docker run -p 3000:3000 turborepo-nextjsEnsure all required env vars are set in your deployment platform. Turborepo will automatically pass them through during build (configured in turbo.json).
This project is licensed under the MIT License β see LICENSE.md for details.
Built with amazing open source tools:
- Vercel β Hosting & deployment platform
- Shadcn β UI component design
- Turborepo Team β Monorepo tooling
- Next.js Team β The React framework
- Biome β Fast, unified toolchain
- tRPC β End-to-end type safety
- Clerk β Beautiful authentication
- Add comprehensive test coverage
- Implement E2E testing with Playwright
- Add performance monitoring (Sentry)
- Add CI/CD workflows
- Internationalization (i18n)
Built with β€οΈ by nass190