# Full Stack Project Examples
> Real-world Node.js/TypeScript project structures for production-ready applications
** Purpose:** Reference architectures for AI agents using octocode-mcp to generate Node.js/TypeScript applications
**π€ For:** AI agents and developers building production applications
**π Focus:** Modern TypeScript/JavaScript stacks - Web + Mobile (Node.js)
**π± Mobile:** React Native monorepo examples with shared codebase
**βοΈ Runtime:** All projects run on Node.js - builds, tests, development, deployment
**Last Updated:** October 13, 2025
---
## Best for Application Generation
This file provides **complete project structures** to help AI agents:
1. **Scaffold full-stack applications** - Ready-to-use templates and boilerplates
2. **Choose architecture patterns** - Monorepo vs multi-repo, feature-based vs layer-based
3. **Reference real production apps** - Learn from battle-tested projects (Cal.com, Supabase)
4. **Understand modern stacks** - T3 Stack, Bulletproof React, Enterprise TypeScript
**Generation Priorities:**
- β‘ **T3 Stack (Next.js)** - Fastest MVP with SSR/SEO + end-to-end type safety
- β‘ **Bulletproof React (Vite)** - Fastest SPA development with scalable architecture
- β‘ **Enterprise Stack** - Large-scale applications with microservices
**Build Tool Decision (2025 Standard):**
- π **Use Vite:** Pure client-side SPAs, internal tools, dashboards, rapid prototyping
- π **Use Next.js:** SSR/SEO required, marketing sites, blogs, e-commerce, content platforms
**Testing Framework (2025 Standard):**
- β
**Primary:** Vitest (faster, better DX, Vite-compatible)
- π **Alternative:** Jest (for legacy NestJS patterns only)
- π **E2E:** Playwright (modern, fast, reliable)
---
## Quick Reference
### Build Tool Selection Guide (2025)
| Your Project Type | Build Tool | Stack | Example |
|------------------|-----------|-------|---------|
| Marketing site, blog, e-commerce | **Next.js** | T3 Stack | Example 1 |
| Internal dashboard, admin panel | **Vite** | Bulletproof React | Example 2 |
| SPA with no SEO needs | **Vite** | Bulletproof React | Example 2 |
| Content-heavy site (CMS) | **Next.js** | T3 Stack | Example 1 |
| Rapid prototype (SPA) | **Vite** | Bulletproof + Vite | Example 2 |
| Enterprise with SSR | **Next.js** | NestJS + Next.js | Example 3 |
| Enterprise SPA | **Vite** | NestJS + Vite | Example 3 |
**Simple Rule:** Need SSR/SEO? β Next.js | Building SPA? β Vite
### Top 3 Project Templates for 2025
1. **β‘ ESSENTIAL - T3 Stack (create-t3-app)** - 35k+ GitHub stars
- Best for: Rapid MVP development with SSR/SEO, type-safe full-stack apps
- Stack: Next.js 15 + tRPC + Prisma + NextAuth + Tailwind
- Build Tool: Next.js (use when SEO/SSR needed)
- Testing: Vitest + Playwright
- Why: Zero boilerplate, end-to-end type safety, massive community
- Get started: `npx create-t3-app@latest`
2. **β‘ PRODUCTION-READY - Bulletproof React Architecture** - 28k+ GitHub stars
- Best for: Scalable React SPAs with clear boundaries (no SSR needed)
- Stack: Vite + React + Feature-based architecture + TypeScript
- Build Tool: Vite (fastest dev experience for SPAs)
- Testing: Vitest + Testing Library + MSW
- Why: Battle-tested structure, lightning-fast HMR, enterprise-grade organization
- Repository: github.com/alan2207/bulletproof-react
3. **β‘ PRODUCTION-READY - Next.js Enterprise Boilerplate** - 10k+ GitHub stars
- Best for: High-performance enterprise apps with SSR/SEO
- Stack: Next.js 15 + TypeScript + Tailwind + Drizzle ORM + Testing Suite
- Build Tool: Next.js (SSR/SEO optimized)
- Testing: Vitest + Playwright
- Why: Production-ready with monitoring, testing, CI/CD configured
- Repository: github.com/ixartz/Next-js-Boilerplate
### Project Structure Decision Guide
#### Monorepo vs Multi-Repo
**Choose Monorepo when:**
- Building multiple related apps (web + mobile + admin)
- Sharing significant code between frontend/backend
- Team needs atomic changes across multiple projects
- Want unified tooling, testing, and deployment
- **Tools:** Turborepo (preferred for Next.js), Nx (enterprise-grade), pnpm workspaces
**Choose Multi-Repo when:**
- Projects are independent with different lifecycles
- Teams are completely separate
- Different tech stacks per project
- Simpler deployment requirements
#### Feature-Based vs Layer-Based Structure
**Feature-Based (Recommended for 2025):**
```
src/
βββ features/
β βββ auth/ # Everything auth-related
β βββ dashboard/ # Everything dashboard-related
β βββ profile/ # Everything profile-related
βββ shared/ # Shared utilities
```
**Benefits:** Better scalability, clearer boundaries, easier to navigate, team ownership
**Layer-Based (Traditional):**
```
src/
βββ components/ # All components
βββ services/ # All services
βββ utils/ # All utilities
```
**Benefits:** Simpler for small projects, familiar pattern
**2025 Best Practice:** Start feature-based. Use layers within features.
### Modern Stack Recommendations
#### Choosing Your Build Tool: Vite vs Next.js
**Use Vite when:**
- Building pure client-side SPAs
- Rapid prototyping and experimentation
- Micro-frontend architectures
- SSR/SEO is not a critical concern
- Want fastest dev server and hot module replacement
- Building internal tools or dashboards
**Use Next.js when:**
- Server-side rendering (SSR) required
- SEO is essential (marketing sites, blogs, e-commerce)
- Need static site generation (SSG) or incremental static regeneration (ISR)
- Building full-stack React applications
- Want zero-config deployment on Vercel
- Team projects with structured conventions
#### For Startups/MVPs (Speed Priority)
**Option A: With SSR/SEO (Marketing, Blog, E-commerce)**
- **Frontend:** Next.js 15 + React 19 + Tailwind CSS
- **Backend:** tRPC (type-safe APIs without overhead)
- **Database:** Prisma + PostgreSQL (Vercel Postgres or Supabase)
- **Auth:** NextAuth.js or Clerk
- **Testing:** Vitest + Testing Library + Playwright
- **Deployment:** Vercel (zero-config)
- **Example:** T3 Stack (Example 1)
**Option B: Client-Side SPA (Internal Tools, Dashboards)**
- **Frontend:** Vite + React 19 + Tailwind CSS
- **Backend:** tRPC or REST APIs
- **Database:** Prisma + PostgreSQL
- **Auth:** Clerk or custom JWT
- **Testing:** Vitest + Testing Library
- **Deployment:** Netlify, Vercel, or Cloudflare Pages
- **Example:** Bulletproof React with Vite (Example 2)
#### For Enterprise/Scale (Robustness Priority)
- **Frontend:** Next.js 15 or Vite + React 19 + TypeScript strict mode
- **Backend:** NestJS (modular, microservices-ready)
- **Database:** Prisma + PostgreSQL + Redis caching
- **Auth:** Passport.js with JWT + OAuth 2.0
- **Testing:** Vitest (unit/integration) + Playwright (E2E)
- **Deployment:** Kubernetes or AWS ECS
- **Example:** Enterprise TypeScript Stack (Example 3)
#### For Traditional Teams (Familiarity Priority)
- **Frontend:** Vite + React 19 + TypeScript
- **Backend:** Express.js + REST APIs
- **Database:** MongoDB + Mongoose or PostgreSQL + TypeORM
- **Auth:** Passport.js or JWT
- **Testing:** Vitest + Testing Library
- **Deployment:** Traditional cloud providers
- **Example:** Classic Full Stack (Example 4)
---
## π Quick Navigation
- [Example 1: T3 Stack - Modern TypeScript Monorepo](#example-1-t3-stack---modern-typescript-monorepo)
- [Example 2: Bulletproof React - Feature-Based Architecture](#example-2-bulletproof-react---feature-based-architecture)
- [Example 3: Enterprise TypeScript Stack](#example-3-enterprise-typescript-stack)
- [Example 4: Classic Full Stack](#example-4-classic-full-stack)
- [Real-World Production Examples](#real-world-production-examples)
- [Choosing Your Stack](#choosing-your-stack)
- [Best Practices](#best-practices)
---
## Example 1: T3 Stack - Modern TypeScript Monorepo
### Stack: Next.js 15 + tRPC + Prisma + NextAuth + Tailwind + Turborepo
**β‘ ESSENTIAL - PRODUCTION-READY** - The most popular TypeScript full-stack starter for 2025
**GitHub:** create-t3-app (35,000+ stars) | **Created by:** Theo Browne & T3 OSS Community
**Live Example:** Cal.com (scheduling platform handling millions of users)
### Why This Example
- **Zero Boilerplate:** No REST/GraphQL layer needed - direct type-safe functions
- **End-to-End Type Safety:** Database to frontend with full IntelliSense
- **Fastest Time to Market:** Ships with auth, database, styling ready to go
- **Battle-Tested:** Powers production apps like Cal.com with real traffic
- **Modular:** Choose only what you need (tRPC, Prisma, auth, Tailwind)
- **Active Community:** Huge ecosystem, constant updates, extensive docs
### Project Structure
```
my-t3-app/
βββ src/
β βββ app/ # Next.js 15 App Router
β β βββ (auth)/ # Route groups
β β β βββ login/
β β β β βββ page.tsx
β β β βββ register/
β β β βββ page.tsx
β β βββ dashboard/
β β β βββ page.tsx
β β β βββ layout.tsx
β β βββ api/ # API Routes
β β β βββ trpc/[trpc]/
β β β βββ route.ts
β β βββ layout.tsx # Root layout
β β βββ page.tsx # Home page
β β
β βββ server/ # tRPC Backend
β β βββ api/
β β β βββ routers/ # tRPC routers
β β β β βββ user.ts # User operations
β β β β βββ post.ts # Post operations
β β β β βββ auth.ts # Auth operations
β β β βββ root.ts # Root router
β β β βββ trpc.ts # tRPC setup
β β βββ auth.ts # NextAuth config
β β βββ db.ts # Prisma client
β β
β βββ components/ # React components
β β βββ ui/ # UI components (shadcn/ui)
β β β βββ button.tsx
β β β βββ card.tsx
β β β βββ modal.tsx
β β βββ features/ # Feature components
β β βββ auth/
β β βββ dashboard/
β β
β βββ hooks/ # Custom React hooks
β β βββ use-session.ts
β β βββ use-media-query.ts
β β
β βββ lib/ # Utilities
β β βββ utils.ts # Helper functions
β β βββ validators.ts # Zod schemas
β β
β βββ styles/ # Global styles
β βββ globals.css
β
βββ prisma/
β βββ schema.prisma # Database schema
β βββ migrations/ # Migration history
β
βββ public/ # Static assets
β
βββ .env # Environment variables
βββ .env.example
βββ next.config.js
βββ tailwind.config.ts
βββ tsconfig.json
βββ package.json
```
### For Monorepo (Turborepo Structure)
```
my-t3-monorepo/
βββ apps/
β βββ web/ # Next.js web app (structure above)
β βββ mobile/ # React Native/Expo app
β βββ admin/ # Admin dashboard
β
βββ packages/
β βββ ui/ # Shared UI components
β β βββ src/
β β β βββ button.tsx
β β β βββ card.tsx
β β βββ package.json
β β
β βββ api/ # Shared tRPC routers
β β βββ src/
β β β βββ routers/
β β βββ package.json
β β
β βββ db/ # Shared database
β β βββ prisma/
β β β βββ schema.prisma
β β βββ src/
β β β βββ client.ts
β β βββ package.json
β β
β βββ auth/ # Shared auth config
β β βββ src/
β β βββ index.ts
β β
β βββ config/ # Shared configs
β βββ eslint-config/
β βββ typescript-config/
β βββ tailwind-config/
β
βββ turbo.json # Turborepo config
βββ package.json # Root package.json
βββ pnpm-workspace.yaml # PNPM workspaces
```
### Key Features
- **End-to-end Type Safety:** Type inference from database to frontend without code generation
- **Zero API Layer Overhead:** Call backend functions directly like regular functions
- **Optimized Builds:** Turborepo caches builds, only rebuilds what changed
- **Authentication Ready:** NextAuth.js pre-configured with multiple providers
- **Database Migrations:** Prisma handles schema changes safely
- **Modern React:** Server Components, Streaming, Suspense out of the box
### Technology Details
- **Frontend:** Next.js 15 with App Router, React 19, TypeScript strict mode
- **Styling:** Tailwind CSS 4 with shadcn/ui components
- **State Management:** React Server Components (minimal client state), TanStack Query (via tRPC)
- **API:** tRPC v11 for type-safe APIs without REST/GraphQL overhead
- **Database:** Prisma 6 with PostgreSQL/MySQL/SQLite
- **Auth:** NextAuth.js v5 (Auth.js) or Clerk
- **Testing:** Vitest + Testing Library + Playwright
- **Validation:** Zod for runtime type validation
- **Build Tool:** Turborepo for monorepos, standard Next.js otherwise
- **Dev Server:** Next.js dev server (optimized for App Router)
### Getting Started
```bash
# Create new T3 app with CLI
npx create-t3-app@latest
# Choose your stack interactively:
# β tRPC
# β Prisma
# β NextAuth.js
# β Tailwind CSS
```
### Deployment
- **All-in-one:** Vercel (recommended - zero config, optimal performance)
- **Database:** Vercel Postgres, Supabase, PlanetScale, Railway
- **Alternative:** Railway, Render, Fly.io for full-stack deployment
### Real-World Usage
- **Cal.com:** Open-source scheduling platform (10k+ stars)
- **Taxonomy:** App directory example by Vercel
- **Countless SaaS products:** MVPs and production apps worldwide
### Related Resources
- [Frontend Libraries](./frontend-libs.md) - Next.js 15, React 19, Tailwind
- [Backend Development](./backend.md) - tRPC, API design
- [Database & ORM](./database.md) - Prisma best practices
- [Tooling & Productivity](./tooling.md) - Turborepo, monorepos
- **Official Docs:** https://create.t3.gg/
---
## Example 2: Bulletproof React - Feature-Based Architecture
### Stack: React 19 + Feature-Based Structure + TypeScript + Modern Tooling
**β‘ PRODUCTION-READY** - Industry-standard architecture for scalable React applications
**GitHub:** bulletproof-react (28,000+ stars) | **Created by:** Alan Alickovic
**Philosophy:** Simple, scalable, powerful architecture for production-ready apps
### Why This Example
- **Feature-Based Organization:** Scales from small to massive applications
- **Clear Boundaries:** Unidirectional code flow (shared β features β app)
- **Proven Pattern:** Used by thousands of production applications
- **Framework Agnostic:** Works with Next.js, Vite, CRA, Remix
- **Best Practices Built-in:** Performance, testing, security patterns included
- **Maintainability Focus:** Easy to onboard developers, debug, and extend
### Project Structure
```
bulletproof-app/
βββ src/
β βββ app/ # Application layer
β β βββ routes/ # Route definitions
β β β βββ index.tsx # Public routes
β β β βββ app.tsx # Protected routes
β β β βββ auth.tsx # Auth routes
β β βββ provider.tsx # App providers (React Query, etc.)
β β βββ router.tsx # Router setup
β β
β βββ features/ # Feature modules (core pattern)
β β βββ auth/ # Authentication feature
β β β βββ api/ # API calls
β β β β βββ login.ts
β β β β βββ register.ts
β β β βββ components/ # Feature components
β β β β βββ LoginForm.tsx
β β β β βββ RegisterForm.tsx
β β β βββ hooks/ # Feature hooks
β β β β βββ use-auth.ts
β β β βββ stores/ # Feature state
β β β β βββ auth-store.ts
β β β βββ types/ # Feature types
β β β β βββ index.ts
β β β βββ utils/ # Feature utils
β β β βββ validators.ts
β β β
β β βββ dashboard/ # Dashboard feature
β β β βββ api/
β β β β βββ get-stats.ts
β β β βββ components/
β β β β βββ StatsCard.tsx
β β β β βββ RecentActivity.tsx
β β β βββ hooks/
β β β β βββ use-stats.ts
β β β βββ types/
β β β βββ index.ts
β β β
β β βββ users/ # Users feature
β β β βββ api/
β β β β βββ get-users.ts
β β β β βββ create-user.ts
β β β β βββ update-user.ts
β β β β βββ delete-user.ts
β β β βββ components/
β β β β βββ UsersList.tsx
β β β β βββ UserForm.tsx
β β β β βββ UserCard.tsx
β β β βββ hooks/
β β β β βββ use-users.ts
β β β β βββ use-user.ts
β β β βββ types/
β β β βββ index.ts
β β β
β β βββ comments/ # Comments feature
β β βββ api/
β β βββ components/
β β βββ hooks/
β β βββ types/
β β
β βββ components/ # Shared components
β β βββ ui/ # UI primitives
β β β βββ button/
β β β β βββ button.tsx
β β β β βββ button.test.tsx
β β β βββ input/
β β β βββ modal/
β β β βββ card/
β β βββ form/ # Form components
β β β βββ FormField.tsx
β β β βββ FormError.tsx
β β βββ layout/ # Layout components
β β βββ Header.tsx
β β βββ Footer.tsx
β β βββ Sidebar.tsx
β β
β βββ hooks/ # Shared hooks
β β βββ use-disclosure.ts
β β βββ use-media-query.ts
β β βββ use-debounce.ts
β β
β βββ lib/ # Shared libraries
β β βββ api-client.ts # API client (axios/fetch)
β β βββ query-client.ts # React Query client
β β βββ auth.ts # Auth utilities
β β
β βββ stores/ # Global state
β β βββ theme-store.ts
β β βββ notifications-store.ts
β β
β βββ types/ # Shared types
β β βββ api.ts
β β βββ common.ts
β β
β βββ utils/ # Shared utilities
β β βββ format.ts
β β βββ validators.ts
β β βββ helpers.ts
β β
β βββ config/ # App configuration
β β βββ env.ts
β β βββ constants.ts
β β
β βββ test/ # Test utilities
β βββ setup.ts
β βββ utils.tsx # Test helpers
β βββ mocks/ # Mock data
β
βββ public/ # Static assets
β
βββ .env # Environment variables
βββ .env.example
βββ vite.config.ts # or next.config.js
βββ tsconfig.json
βββ tailwind.config.ts
βββ package.json
```
### Architecture Principles
**1. Unidirectional Flow:**
```
shared/ β features/ β app/
```
- Features can use shared code
- App can use features and shared code
- Features CANNOT import from other features directly
- Shared code CANNOT import from features or app
**2. Feature Isolation:**
Each feature is self-contained with its own:
- API calls
- Components
- Hooks
- Types
- State
- Utils
**3. Vertical Slicing:**
Features represent complete vertical slices of functionality, not technical layers.
### Key Features
- **Scalability:** Add features without touching existing code
- **Maintainability:** Clear boundaries make debugging easier
- **Team Collaboration:** Teams can own entire features
- **Testing:** Features can be tested in isolation
- **Performance:** Easy to lazy-load entire features
- **Code Reuse:** Shared layer for common functionality
### Technology Details
- **Build Tool:** Vite (recommended for SPAs) or Next.js (if SSR/SEO needed)
- **Framework:** React 19 with TypeScript strict mode
- **Styling:** Tailwind CSS or CSS Modules
- **State Management:**
- React Query (server state)
- Zustand or Context (client state)
- **Form Handling:** React Hook Form + Zod
- **Testing:** Vitest (preferred) + Testing Library + MSW (mock service worker)
- **Routing:** React Router v6+ (Vite) or Next.js App Router (Next.js)
- **API Client:** Axios or native fetch with wrapper
- **Dev Server:** Vite (lightning-fast HMR)
### Getting Started
```bash
# Clone the repository
git clone https://github.com/alan2207/bulletproof-react.git
# Or start with the structure manually
# Follow the documentation at:
# https://github.com/alan2207/bulletproof-react/blob/master/docs/project-structure.md
```
### Best Practices Included
- **API Layer Abstraction:** All API calls in feature/api folders
- **Component Colocation:** Components close to where they're used
- **Custom Hooks:** Reusable logic extracted to hooks
- **Type Safety:** Full TypeScript with strict mode
- **Error Handling:** Consistent error boundaries
- **Loading States:** Suspense and loading patterns
- **Optimistic Updates:** React Query optimistic updates
- **Security:** Authentication, authorization patterns built-in
### When to Use Bulletproof React
**Perfect for:**
- Medium to large React applications
- Teams with multiple developers
- Long-term projects requiring maintainability
- When you need clear feature boundaries
- Applications expected to scale significantly
**Consider alternatives if:**
- Building a simple landing page or small app
- Prototyping an MVP very quickly (consider T3 Stack instead)
- Team is very small (2-3 developers) and familiar with simpler structures
### Related Resources
- [Frontend Libraries](./frontend-libs.md) - React patterns, component design
- [Testing](./testing.md) - Testing strategies for features
- **Official Docs:** https://github.com/alan2207/bulletproof-react
---
## Example 3: Enterprise TypeScript Stack
### Stack: NestJS + Next.js + Prisma + GraphQL + Redis + Microservices
**β‘ PRODUCTION-READY** - Best for large enterprise applications requiring ultimate scalability
**Use Case:** Multi-team organizations, microservices architecture, complex business logic
### Why This Example
- **Modular Architecture:** NestJS modules enforce clear separation of concerns
- **Microservices Ready:** Built-in support for splitting into microservices
- **Enterprise Patterns:** Dependency injection, guards, interceptors, pipes, filters
- **Scalability:** Handles high traffic with caching, queues, and horizontal scaling
- **Team Collaboration:** Multiple teams can work on different modules independently
- **Testing:** Dependency injection makes unit testing straightforward
- **Documentation:** Auto-generated OpenAPI/GraphQL schemas
### Project Structure
```
enterprise-stack/
βββ apps/
β βββ web/ # Next.js Frontend
β β βββ src/
β β β βββ app/ # Next.js 15 App Router
β β β β βββ (auth)/ # Auth routes group
β β β β β βββ login/
β β β β β βββ register/
β β β β βββ (dashboard)/ # Dashboard routes
β β β β β βββ layout.tsx
β β β β β βββ page.tsx
β β β β β βββ users/
β β β β β βββ settings/
β β β β βββ layout.tsx
β β β β βββ page.tsx
β β β βββ components/
β β β β βββ ui/ # UI components
β β β β βββ features/ # Feature components
β β β βββ lib/
β β β β βββ apollo.ts # Apollo Client
β β β β βββ graphql/ # GraphQL operations
β β β β βββ queries/
β β β β βββ mutations/
β β β β βββ fragments/
β β β βββ utils/
β β βββ public/
β β βββ next.config.js
β β βββ package.json
β β
β βββ api/ # NestJS Backend
β β βββ src/
β β β βββ modules/ # Feature modules
β β β β βββ auth/
β β β β β βββ auth.module.ts
β β β β β βββ auth.service.ts
β β β β β βββ auth.resolver.ts # GraphQL
β β β β β βββ auth.controller.ts # REST
β β β β β βββ dto/
β β β β β β βββ login.dto.ts
β β β β β β βββ register.dto.ts
β β β β β βββ strategies/
β β β β β β βββ jwt.strategy.ts
β β β β β β βββ local.strategy.ts
β β β β β βββ guards/
β β β β β βββ jwt-auth.guard.ts
β β β β β βββ roles.guard.ts
β β β β β
β β β β βββ users/
β β β β β βββ users.module.ts
β β β β β βββ users.service.ts
β β β β β βββ users.resolver.ts
β β β β β βββ users.controller.ts
β β β β β βββ dto/
β β β β β βββ entities/
β β β β β β βββ user.entity.ts
β β β β β βββ tests/
β β β β β βββ users.service.spec.ts
β β β β β βββ users.resolver.spec.ts
β β β β β
β β β β βββ posts/
β β β β β βββ posts.module.ts
β β β β β βββ posts.service.ts
β β β β β βββ posts.resolver.ts
β β β β β βββ dto/
β β β β β
β β β β βββ notifications/
β β β β β βββ notifications.module.ts
β β β β β βββ notifications.service.ts
β β β β β βββ notifications.gateway.ts # WebSocket
β β β β β βββ dto/
β β β β β
β β β β βββ payments/ # Payment module
β β β β βββ payments.module.ts
β β β β βββ payments.service.ts
β β β β βββ payments.controller.ts
β β β β βββ dto/
β β β β
β β β βββ common/ # Shared code
β β β β βββ decorators/ # Custom decorators
β β β β β βββ current-user.decorator.ts
β β β β β βββ roles.decorator.ts
β β β β βββ filters/ # Exception filters
β β β β β βββ http-exception.filter.ts
β β β β β βββ graphql-exception.filter.ts
β β β β βββ guards/ # Global guards
β β β β β βββ throttler.guard.ts
β β β β βββ interceptors/ # Interceptors
β β β β β βββ logging.interceptor.ts
β β β β β βββ transform.interceptor.ts
β β β β βββ pipes/ # Validation pipes
β β β β β βββ validation.pipe.ts
β β β β βββ middleware/
β β β β βββ logger.middleware.ts
β β β β
β β β βββ database/ # Database module
β β β β βββ database.module.ts
β β β β βββ prisma.service.ts
β β β β
β β β βββ cache/ # Cache module
β β β β βββ cache.module.ts
β β β β βββ redis.service.ts
β β β β
β β β βββ queue/ # Queue module (Bull/BullMQ)
β β β β βββ queue.module.ts
β β β β βββ processors/
β β β β βββ email.processor.ts
β β β β βββ notifications.processor.ts
β β β β
β β β βββ config/ # Configuration
β β β β βββ app.config.ts
β β β β βββ database.config.ts
β β β β βββ redis.config.ts
β β β β βββ validation.ts
β β β β
β β β βββ graphql/ # GraphQL setup
β β β β βββ schema.gql # Generated schema
β β β β βββ scalars/ # Custom scalars
β β β β βββ date.scalar.ts
β β β β
β β β βββ app.module.ts # Root module
β β β βββ main.ts # Bootstrap
β β β
β β βββ prisma/
β β β βββ schema.prisma
β β β βββ seed.ts # Database seeding
β β β βββ migrations/
β β β
β β βββ test/ # E2E tests
β β β βββ app.e2e-spec.ts
β β β βββ auth.e2e-spec.ts
β β β βββ jest-e2e.json
β β β
β β βββ .env
β β βββ .env.example
β β βββ nest-cli.json
β β βββ tsconfig.json
β β βββ package.json
β β
β βββ admin/ # Admin Dashboard (optional)
β βββ ... # Similar Next.js structure
β
βββ packages/
β βββ ui/ # Shared UI components
β β βββ src/
β β β βββ button/
β β β βββ card/
β β β βββ modal/
β β β βββ index.ts
β β βββ package.json
β β
β βββ types/ # Shared TypeScript types
β β βββ src/
β β β βββ user.ts
β β β βββ post.ts
β β β βββ index.ts
β β βββ package.json
β β
β βββ utils/ # Shared utilities
β β βββ src/
β β β βββ validators.ts
β β β βββ formatters.ts
β β β βββ index.ts
β β βββ package.json
β β
β βββ config/ # Shared configs
β β βββ eslint-config/
β β βββ typescript-config/
β β βββ tailwind-config/
β β
β βββ database/ # Shared database package
β βββ prisma/
β β βββ schema.prisma
β βββ src/
β β βββ client.ts
β βββ package.json
β
βββ libs/ # NestJS shared libraries
β βββ shared/ # Shared code between NestJS services
β β βββ src/
β β β βββ interfaces/
β β β βββ dto/
β β β βββ utils/
β β βββ package.json
β β
β βββ logger/ # Custom logger library
β βββ src/
β βββ package.json
β
βββ docker/
β βββ Dockerfile.web
β βββ Dockerfile.api
β βββ docker-compose.yml
β
βββ k8s/ # Kubernetes configs
β βββ web/
β βββ api/
β βββ database/
β
βββ .github/
β βββ workflows/
β βββ ci.yml
β βββ deploy-web.yml
β βββ deploy-api.yml
β
βββ nx.json # Nx configuration
βββ turbo.json # or Turborepo
βββ package.json
βββ README.md
```
### Key Features
- **Modular Architecture:** Each module is self-contained with clear boundaries
- **Dependency Injection:** Built-in IoC container for better testability
- **Dual API Support:** GraphQL and REST in the same application
- **WebSocket Support:** Real-time features with WebSocket gateways
- **Caching Layer:** Redis integration for high-performance caching
- **Queue System:** Background jobs with Bull/BullMQ
- **Microservices Ready:** Easy transition to microservices architecture
- **Enterprise Patterns:** Guards, interceptors, pipes, filters, decorators
- **API Documentation:** Auto-generated Swagger/OpenAPI docs
- **Monitoring:** Built-in health checks, metrics, logging
### Technology Details
- **Frontend:** Next.js 15, React 19, Apollo Client, Tailwind CSS
- **Backend:** NestJS 10+, TypeScript strict mode
- **API:** GraphQL (Code-first with @nestjs/graphql) + REST
- **Database:** Prisma 6 + PostgreSQL
- **Caching:** Redis with @nestjs/cache-manager
- **Queue:** Bull/BullMQ for background jobs
- **WebSocket:** Socket.io via @nestjs/websockets
- **Auth:** Passport.js with JWT strategy, OAuth 2.0
- **Validation:** class-validator + class-transformer + Zod
- **Testing:**
- Frontend: Vitest (preferred) + Testing Library
- Backend: Vitest (preferred) or Jest + Supertest (E2E)
- E2E: Playwright
- **Monitoring:** Prometheus metrics, Sentry error tracking
- **Monorepo:** Nx (recommended for NestJS) or Turborepo
### Deployment
- **Frontend:** Vercel, AWS Amplify, CloudFront + S3
- **Backend:** Kubernetes (GKE, EKS, AKS), AWS ECS, Google Cloud Run
- **Database:** AWS RDS, Google Cloud SQL, Azure Database
- **Caching:** AWS ElastiCache, Google Memorystore, Redis Cloud
- **Queue:** AWS SQS, Google Cloud Tasks, self-hosted Redis
- **Container Registry:** Docker Hub, AWS ECR, Google Container Registry
### Real-World Use Cases
- **Multi-tenant SaaS platforms**
- **E-commerce platforms with complex business logic**
- **Financial applications requiring high reliability**
- **Healthcare systems with strict compliance requirements**
- **Enterprise dashboards with real-time data**
### When to Use This Stack
**Perfect for:**
- Large enterprises with multiple teams
- Applications requiring microservices architecture
- Complex business logic and workflows
- High scalability requirements (millions of users)
- Projects with long-term maintenance (5+ years)
- When you need advanced patterns (CQRS, Event Sourcing, etc.)
**Overkill for:**
- Small projects or MVPs
- Teams smaller than 5 developers
- Simple CRUD applications
- Rapid prototyping
- Projects with unclear requirements
### Related Resources
- [Frontend Libraries](./frontend-libs.md) - Next.js, React, Apollo
- [Backend Development](./backend.md) - NestJS, GraphQL, microservices
- [Database & ORM](./database.md) - Prisma advanced patterns
- [Architecture](./architecture.md) - Clean Architecture with NestJS
- [Infrastructure](./infrastructure.md) - Kubernetes, Docker, CI/CD
---
## Example 4: Classic Full Stack
### Stack: React + Express + MongoDB + JWT/OAuth
**Good for:** Traditional REST API architecture, teams familiar with MERN stack, existing MERN projects
### Why This Example
- **Familiar Patterns:** Industry-standard MERN stack
- **Large Ecosystem:** Massive community, extensive packages
- **Flexible:** Works with any frontend/backend combination
- **Well-Documented:** Years of tutorials, courses, blog posts
- **Simple to Understand:** Traditional request/response model
- **Works Anywhere:** Deploy on any cloud provider or VPS
### Project Structure
```
classic-fullstack/
βββ client/ # React Frontend
β βββ public/
β β βββ index.html
β β βββ assets/
β βββ src/
β β βββ components/ # React components
β β β βββ common/ # Shared components
β β β β βββ Button.tsx
β β β β βββ Modal.tsx
β β β β βββ Card.tsx
β β β βββ layout/ # Layout components
β β β β βββ Header.tsx
β β β β βββ Footer.tsx
β β β β βββ Sidebar.tsx
β β β βββ features/ # Feature components
β β β βββ auth/
β β β β βββ LoginForm.tsx
β β β β βββ RegisterForm.tsx
β β β βββ dashboard/
β β β βββ profile/
β β β
β β βββ pages/ # Page components
β β β βββ Home.tsx
β β β βββ Login.tsx
β β β βββ Dashboard.tsx
β β β βββ Profile.tsx
β β β
β β βββ hooks/ # Custom hooks
β β β βββ useAuth.ts
β β β βββ useUser.ts
β β β βββ useDebounce.ts
β β β
β β βββ store/ # State management
β β β βββ slices/ # Redux Toolkit slices
β β β β βββ authSlice.ts
β β β β βββ userSlice.ts
β β β β βββ uiSlice.ts
β β β βββ store.ts # Store configuration
β β β
β β βββ services/ # API services
β β β βββ api.ts # Axios instance
β β β βββ authService.ts
β β β βββ userService.ts
β β β βββ postService.ts
β β β
β β βββ utils/ # Utilities
β β β βββ validators.ts
β β β βββ formatters.ts
β β β βββ helpers.ts
β β β
β β βββ types/ # TypeScript types
β β β βββ user.ts
β β β βββ post.ts
β β β βββ api.ts
β β β
β β βββ styles/ # Global styles
β β β βββ globals.css
β β β
β β βββ App.tsx # Root component
β β βββ main.tsx # Entry point
β β βββ router.tsx # Route configuration
β β
β βββ package.json
β βββ tsconfig.json
β βββ vite.config.ts # Vite config
β βββ tailwind.config.ts
β
βββ server/ # Express Backend
β βββ src/
β β βββ controllers/ # Route controllers
β β β βββ authController.ts
β β β βββ userController.ts
β β β βββ postController.ts
β β β
β β βββ middleware/ # Express middleware
β β β βββ auth.ts # JWT verification
β β β βββ errorHandler.ts
β β β βββ validation.ts
β β β βββ rateLimiter.ts
β β β
β β βββ models/ # Database models
β β β βββ User.ts # Mongoose model
β β β βββ Post.ts
β β β βββ Comment.ts
β β β
β β βββ routes/ # API routes
β β β βββ auth.ts # /api/auth/*
β β β βββ users.ts # /api/users/*
β β β βββ posts.ts # /api/posts/*
β β β βββ index.ts # Route aggregator
β β β
β β βββ services/ # Business logic
β β β βββ authService.ts
β β β βββ userService.ts
β β β βββ postService.ts
β β β βββ emailService.ts
β β β
β β βββ utils/ # Server utilities
β β β βββ jwt.ts
β β β βββ validators.ts
β β β βββ logger.ts
β β β βββ errors.ts
β β β
β β βββ config/ # Configuration
β β β βββ database.ts
β β β βββ env.ts
β β β βββ constants.ts
β β β
β β βββ types/ # TypeScript types
β β β βββ index.ts
β β β
β β βββ app.ts # Express app setup
β β βββ server.ts # Server entry point
β β
β βββ package.json
β βββ tsconfig.json
β
βββ shared/ # Shared code
β βββ types/ # Shared TypeScript types
β β βββ user.ts
β β βββ post.ts
β β βββ api.ts
β βββ constants/ # Shared constants
β βββ index.ts
β
βββ tests/ # Tests
β βββ client/ # Frontend tests
β β βββ unit/
β β β βββ components/
β β βββ integration/
β β βββ features/
β βββ server/ # Backend tests
β βββ unit/
β β βββ services/
β β βββ utils/
β βββ integration/
β βββ api/
β
βββ .github/
β βββ workflows/
β βββ ci.yml
β
βββ docker-compose.yml # Local development
βββ .env.example
βββ package.json # Root package
βββ README.md
```
### Key Features
- **Separation of Concerns:** Clear frontend/backend separation
- **REST API:** Traditional REST endpoints with standard HTTP methods
- **Redux State Management:** Centralized state for complex client-side logic
- **MongoDB:** Flexible NoSQL database with Mongoose ODM
- **Authentication:** JWT or Passport.js with multiple strategies
- **Familiar Patterns:** MVC-inspired architecture
### Technology Details
- **Frontend:** React 19, TypeScript, Vite (fast dev server + HMR), Redux Toolkit
- **Styling:** Tailwind CSS or Material-UI
- **API Client:** Axios with interceptors for auth, error handling
- **Routing:** React Router v6+
- **Backend:** Express.js, Node.js 20+
- **Database:** MongoDB with Mongoose
- **Auth:** JWT or Passport.js (Local, Google, GitHub strategies)
- **Validation:** express-validator or Joi + Zod
- **Testing:**
- Frontend: Vitest (preferred) + Testing Library
- Backend: Vitest (preferred) or Jest + Supertest
- E2E: Playwright
- **API Documentation:** Swagger/OpenAPI
### Deployment
- **Frontend:** Netlify, Vercel, S3 + CloudFront, Surge
- **Backend:** Heroku, Render, DigitalOcean, AWS Elastic Beanstalk
- **Database:** MongoDB Atlas (recommended), self-hosted
- **Full-Stack:** Railway, Render (monorepo support)
### When to Use This Stack
**Perfect for:**
- Traditional web applications
- Teams with MERN stack experience
- Projects requiring flexible schema (MongoDB)
- When you want REST APIs with standard tooling
- Migrating from older MERN applications
**Consider alternatives if:**
- You want end-to-end type safety (use T3 Stack)
- Building complex enterprise apps (use NestJS)
- Need rapid MVP development (use T3 Stack or Bulletproof)
### Related Resources
- [Frontend Libraries](./frontend-libs.md) - React, Redux
- [Backend Development](./backend.md) - Express.js, REST APIs
- [Database & ORM](./database.md) - MongoDB, Mongoose
---
## Real-World Production Examples
### Open Source Applications to Study (2025)
**β‘ ESSENTIAL - Cal.com** - 35k+ GitHub stars
- **Stack:** T3 Stack (Next.js + tRPC + Prisma)
- **What:** Open-source scheduling platform (Calendly alternative)
- **Why Study:** Perfect example of T3 Stack at scale with real users
- **Learn:** Authentication flows, database design, real-time features
- **Repository:** github.com/calcom/cal.com
**Supabase Dashboard** - 75k+ GitHub stars (main repo)
- **Stack:** Next.js + TypeScript + PostgreSQL + Supabase
- **What:** Firebase alternative with PostgreSQL backend
- **Why Study:** Complex dashboard with real-time data, authentication patterns
- **Learn:** Database management UI, real-time subscriptions, auth flows
- **Repository:** github.com/supabase/supabase
**Documenso** - 8k+ GitHub stars
- **Stack:** Next.js 14 + TypeScript + Prisma + tRPC + Tailwind
- **What:** Open-source DocuSign alternative for document signing
- **Why Study:** Production SaaS built with modern stack
- **Learn:** Document handling, e-signatures, payment integration
- **Repository:** github.com/documenso/documenso
**Plane** - 30k+ GitHub stars
- **Stack:** Next.js + Django + PostgreSQL
- **What:** Open-source Jira alternative for project management
- **Why Study:** Complex state management, real-time collaboration
- **Learn:** Multi-user collaboration, permission systems, real-time updates
- **Repository:** github.com/makeplane/plane
**Formbricks** - 8k+ GitHub stars
- **Stack:** Next.js + tRPC + Prisma + TypeScript + Turborepo
- **What:** Open-source Typeform alternative for surveys
- **Why Study:** Monorepo structure, widget integration, analytics
- **Learn:** Embeddable widgets, survey logic, data visualization
- **Repository:** github.com/formbricks/formbricks
**Twenty CRM** - 20k+ GitHub stars
- **Stack:** NestJS + React + GraphQL + TypeScript + PostgreSQL
- **What:** Open-source Salesforce alternative
- **Why Study:** Enterprise architecture, NestJS at scale
- **Learn:** CRM features, GraphQL best practices, modular architecture
- **Repository:** github.com/twentyhq/twenty
**Novu** - 35k+ GitHub stars
- **Stack:** NestJS + React + MongoDB + TypeScript + Microservices
- **What:** Open-source notification infrastructure
- **Why Study:** Microservices architecture, multi-channel notifications
- **Learn:** Event-driven architecture, notification routing, provider integrations
- **Repository:** github.com/novuhq/novu
**Rallly** - 4k+ GitHub stars
- **Stack:** Next.js + tRPC + Prisma + TypeScript + Tailwind
- **What:** Open-source Doodle alternative for scheduling polls
- **Why Study:** Clean code, simple but complete feature set
- **Learn:** Polling logic, real-time updates, clean UI/UX
- **Repository:** github.com/lukevella/rallly
---
## Choosing Your Stack
### Decision Matrix
| Project Type | Build Tool | Recommended Stack | Why |
|-------------|-----------|------------------|-----|
| **Startup MVP (with SEO)** | Next.js | Example 1 (T3 Stack) | Fastest time to market, SSR/SEO, type safety |
| **Startup MVP (SPA)** | Vite | Example 2 (Bulletproof + Vite) | Fastest dev experience, client-side only |
| **Scalable React App** | Vite or Next.js | Example 2 (Bulletproof) | Feature-based architecture scales perfectly |
| **Enterprise/Microservices** | Next.js or Vite | Example 3 (NestJS + GraphQL) | Modular architecture, microservices-ready |
| **Traditional Web App** | Vite | Example 4 (MERN + Vite) | Familiar patterns, fast dev server |
| **E-commerce** | Next.js | Example 1 or 3 | SSR/SEO critical, type safety for payments |
| **SaaS Platform** | Vite or Next.js | Example 1 or 3 | Multi-tenancy, subscriptions, scalability |
| **Content Site/Blog** | Next.js | Example 1 (T3/Next.js) | SSR/SSG essential, SEO optimization |
| **Real-time Apps** | Vite or Next.js | Example 1 or 3 | WebSocket support with type safety |
| **Internal Tools/Dashboards** | Vite | Example 2 (Bulletproof + Vite) | Fast dev, no SSR needed, rapid iteration |
| **API-First Product** | Vite (frontend) | Example 3 (NestJS) | OpenAPI docs, multiple API types |
### Technology Comparison
#### Build Tool: Vite vs Next.js
**Vite Advantages:**
- β‘ Lightning-fast dev server with instant HMR
- π Faster cold starts and hot reloads
- Pure SPA focus - no SSR complexity
- π§ Simple configuration
- π¦ Better for micro-frontends
**Next.js Advantages:**
- π Built-in SSR/SSG/ISR for SEO
- π± Image optimization out of the box
- π£οΈ File-based routing (App Router)
- βοΈ Zero-config deployment on Vercel
- Full-stack capabilities (API routes)
**When to Choose:**
- **Vite:** Internal tools, dashboards, admin panels, SPAs, prototypes
- **Next.js:** Marketing sites, blogs, e-commerce, any public-facing content requiring SEO
#### Type Safety (Most Important in 2025)
1. **Excellent:** Example 1 (tRPC end-to-end), Example 3 (GraphQL + Prisma)
2. **Good:** Example 2 (TypeScript + patterns), Example 4 (TypeScript + REST)
#### Developer Experience
1. **Best DX (SPA):** Vite + Example 2 (Bulletproof) - Fastest HMR, clean architecture
2. **Best DX (Full-Stack):** Example 1 (T3) - Zero API overhead, instant feedback
3. **Great:** Example 2 (Bulletproof) - Clear patterns, easy navigation
4. **Good:** Example 3 (NestJS) - Strong patterns but steeper learning curve
5. **Familiar:** Example 4 (MERN) - Traditional but well-known
#### Scalability
1. **Enterprise-grade:** Example 3 (NestJS microservices)
2. **Highly Scalable:** Example 1 (T3 monorepo), Example 2 (Bulletproof)
3. **Scalable:** Example 4 (traditional scaling patterns)
#### Learning Curve
1. **Gentle:** Example 1 (T3) - Intuitive patterns, great docs
2. **Low:** Example 4 (MERN) - Traditional and familiar
3. **Moderate:** Example 2 (Bulletproof) - New patterns but clear benefits
4. **Steep:** Example 3 (NestJS) - Enterprise patterns, decorators, DI
#### Community & Ecosystem (2025)
1. **Massive:** Example 1 (Next.js/React), Example 4 (MERN)
2. **Large:** Example 3 (NestJS), Example 2 (React)
3. **All have excellent documentation and active communities**
#### Time to Production
1. **Fastest:** Example 1 (T3) - 1-2 weeks for MVP
2. **Fast:** Example 2 (Bulletproof) - 2-3 weeks for MVP
3. **Moderate:** Example 4 (MERN) - 2-4 weeks for MVP
4. **Slower:** Example 3 (NestJS) - 3-6 weeks for MVP (but better long-term)
### Stack Selection Flowchart
```
START
|
ββ Do you need SEO / Server-Side Rendering?
β ββ YES β Use Next.js
β β ββ Need rapid MVP? β Example 1: T3 Stack β‘
β β ββ Enterprise/Microservices? β Example 3: NestJS + Next.js β‘
β β
β ββ NO β Use Vite (faster dev experience)
β ββ Feature-based architecture? β Example 2: Bulletproof + Vite β‘
β ββ Traditional MERN? β Example 4: MERN + Vite
β ββ Enterprise? β Example 3: NestJS + Vite
|
ββ Alternative Decision Path (by project type):
β ββ Marketing site, blog, e-commerce?
β β ββ YES β Next.js (Example 1 or 3) β‘
β β
β ββ Internal tool, dashboard, admin panel?
β β ββ YES β Vite (Example 2) β‘
β β
β ββ Large enterprise with microservices?
β β ββ YES β Example 3: NestJS + (Vite or Next.js) β‘
β β
β ββ Rapid prototype/MVP?
β ββ Need SEO? β Example 1: T3 Stack (Next.js) β‘
β ββ SPA only? β Example 2: Bulletproof + Vite β‘
```
---
## Best Practices
### Monorepo Management (2025 Standards)
**Top Tools:**
- **Turborepo** (Recommended for Next.js, Vite): Fast builds, simple config
- **Nx** (Recommended for NestJS, enterprise): Most powerful, steepest learning curve
- **pnpm workspaces** (Lightweight): Good for simple monorepos
**Best Practices:**
- **Shared packages:** Extract common code (ui, utils, types, config)
- **Consistent tooling:** Unified ESLint, Prettier, TypeScript configs
- **Versioning:** Use changesets for coordinated releases
- **Caching:** Leverage build caches (Turborepo/Nx automatically)
- **Task dependencies:** Define clear build order (db β api β web)
- **Selective testing:** Only test affected packages
### Project Structure Principles
**Feature-Based Organization (2025 Standard):**
- Group by feature, not file type
- Each feature is self-contained vertical slice
- Clear boundaries between features
- Shared code in dedicated `/shared` or `/common` folder
**Layered Architecture:**
- **Presentation Layer:** UI components, pages
- **Application Layer:** Business logic, use cases
- **Data Layer:** API calls, database access
- **Infrastructure Layer:** External services, utilities
**Folder Naming:**
- Use lowercase with hyphens: `user-profile/`
- Or camelCase for components: `userProfile/`
- Be consistent across the entire project
### Type Safety (Critical for 2025)
**End-to-End Types:**
- **Option 1:** tRPC (no code generation needed)
- **Option 2:** GraphQL Code Generator
- **Option 3:** OpenAPI TypeScript Generator
- Share types between frontend/backend via packages
**Runtime Validation:**
- **Zod** (TypeScript-first): Recommended for 2025
- **Yup:** Alternative with good DX
- Validate at API boundaries (input + output)
**Strict TypeScript:**
```json
{
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true
}
}
```
### Testing Strategy
**Testing Framework Preference:**
- **Primary:** Vitest (faster, better TypeScript support, compatible with Vite)
- **Alternative:** Jest (if needed for specific NestJS patterns or legacy codebases)
- **E2E:** Playwright (recommended for 2025) or Cypress
**Unit Tests (60-70% of tests):**
- Test business logic in isolation
- Mock external dependencies with Vitest or MSW
- Fast execution (< 5 seconds for entire suite)
- Use Vitest's built-in mocking and snapshot testing
**Integration Tests (20-30% of tests):**
- Test API endpoints with real database (test DB)
- Test multiple units working together
- Use factories for test data
- Vitest for API integration tests with Supertest
**E2E Tests (10-20% of tests):**
- Test critical user flows only
- Use Playwright (recommended) for modern browser automation
- Run on CI for every PR
- Parallel execution for faster test runs
**Coverage Goals:**
- Critical paths: 90%+ coverage
- Overall: 70-80% coverage
- Focus on business logic, not boilerplate
- Use Vitest's built-in coverage with v8 or istanbul
### Security (Non-Negotiable for 2025)
**Authentication:**
- Use battle-tested libraries (NextAuth.js, Passport.js, Clerk)
- JWT with refresh tokens (short-lived access tokens)
- OAuth 2.0 for social login
- Multi-factor authentication for sensitive apps
**Authorization:**
- RBAC (Role-Based) or ABAC (Attribute-Based)
- Check permissions at API level, not just UI
- Principle of least privilege
**Input Validation:**
- Validate ALL inputs with schemas (Zod)
- Sanitize user input
- Use parameterized queries (ORMs handle this)
- Rate limiting on all endpoints
**Environment Variables:**
- Never commit secrets (use .env.local, not .env)
- Different secrets per environment
- Use secret managers in production (AWS Secrets Manager, etc.)
**Headers:**
- CORS: Configure properly for production
- CSP (Content Security Policy): Prevent XSS
- HTTPS only in production
- Security headers with Helmet.js
### Performance (Essential for Production)
**Database:**
- Index frequently queried fields
- Use database query analyzers (EXPLAIN)
- Implement pagination (cursor-based preferred)
- Database connection pooling
**Caching:**
- Redis for session storage
- API response caching (Redis or HTTP cache)
- CDN for static assets
- Browser caching with proper headers
**Frontend:**
- Code splitting (React lazy, Next.js dynamic imports)
- Image optimization (next/image, Cloudinary)
- Lazy load components below the fold
- Web Vitals monitoring
**API:**
- Compression (gzip/brotli)
- Response pagination
- Field selection (GraphQL or sparse fieldsets)
- Database query optimization (N+1 problem)
### DevOps (Production-Ready Checklist)
**CI/CD:**
- Automated tests on every PR
- Automated deployment on merge to main
- Environment-specific deployments (dev/staging/prod)
- Rollback capability
**Monitoring:**
- **Error Tracking:** Sentry (recommended), Rollbar
- **Performance:** Vercel Analytics, DataDog
- **Logs:** Better Stack (formerly Logtail), CloudWatch
- **Uptime:** UptimeRobot, Better Stack
**Infrastructure as Code:**
- Docker for containerization
- Docker Compose for local development
- Kubernetes for production (if needed)
- Terraform or Pulumi for cloud resources
**Database Migrations:**
- Version-controlled schema changes (Prisma, Drizzle)
- Run migrations before deployment
- Backup before migrations
- Rollback plan for failed migrations
### Code Quality
**Linting & Formatting:**
- **ESLint:** Catch bugs and enforce patterns
- **Prettier:** Automatic code formatting
- **TypeScript:** Strict mode enabled
- Consistent configs across monorepo
**Pre-commit Hooks:**
- Husky + lint-staged
- Run linter on staged files
- Run type checking
- Prevent commits with errors
**Code Reviews:**
- Required for all production code
- Use PR templates
- Automated checks (CI) must pass
- Focus on logic, security, performance
**Documentation:**
- README with setup instructions
- API documentation (auto-generated preferred)
- Architecture diagrams (C4 model, ERD)
- Code comments for complex logic only
---
## Related Resources
### Core Development
- [Frontend Libraries](./frontend-libs.md) - React 19, Next.js 15, UI libraries
- [Backend Development](./backend.md) - Node.js, NestJS, tRPC, REST, GraphQL
- [Database & ORM](./database.md) - Prisma, TypeORM, MongoDB
- [Architecture](./architecture.md) - System design, patterns, best practices
### Quality & Infrastructure
- [Testing](./testing.md) - Testing strategies, tools, best practices
- [Security](./security.md) - Authentication, authorization, common vulnerabilities
- [Infrastructure](./infrastructure.md) - Deployment, Docker, Kubernetes, CI/CD
- [Tooling](./tooling.md) - Monorepo tools, dev productivity, VSCode setup
### Learning & Community
- [Learning Resources](./learning.md) - Courses, tutorials, books
- [AI Agents](./ai-agents.md) - Using AI in development workflow
---
## Additional Resources
### Official Documentation
- **T3 Stack:** https://create.t3.gg/
- **Bulletproof React:** https://github.com/alan2207/bulletproof-react
- **Next.js:** https://nextjs.org/docs
- **NestJS:** https://docs.nestjs.com/
- **Prisma:** https://www.prisma.io/docs
- **tRPC:** https://trpc.io/docs
### Community & Learning
- **Next.js Discord:** https://nextjs.org/discord
- **T3 Community:** https://discord.gg/t3-turbo
- **NestJS Discord:** https://discord.gg/nestjs
- **Reddit:** r/reactjs, r/nextjs, r/node
### Tools & Services
- **Deployment:** Vercel, Railway, Render, Fly.io
- **Database:** Vercel Postgres, Supabase, PlanetScale, Railway
- **Auth:** Clerk, Auth0, Supabase Auth
- **Monitoring:** Sentry, Vercel Analytics, Better Stack
---
*Part of octocode-mcp resources collection*