A full-stack TypeScript monorepo demonstrating microservices architecture with oRPC, TanStack Query, and end-to-end type safety.
- Node.js: 24+ recommended
- pnpm: 10.21.0+ (project uses
pnpmworkspaces)
# Install dependencies
pnpm install
# Start development (runs API + Web in parallel)
pnpm devThe API server starts at http://localhost:3000 and the web app at http://localhost:5173.
pnpm dev # Start all services in development mode
pnpm build # Build all packages and apps
pnpm preview # Preview production builds
pnpm type:check # TypeScript type checking
pnpm test # Run tests
pnpm test:watch # Run tests in watch mode
pnpm test:coverage # Run tests with coverage
pnpm lint # Lint code
pnpm lint:fix # Fix linting issuesorpc-multiservice-monorepo-playground/
├── apps/
│ ├── api/ → HTTP server aggregating all services
│ └── web/ → React frontend with TanStack Query
├── packages/
│ ├── auth-contract/ → Auth API contract
│ ├── auth-service/ → Auth implementation
│ ├── chat-contract/ → Chat API contract
│ ├── chat-service/ → Chat implementation (real-time)
│ ├── planet-contract/ → Planet CRUD contract
│ └── planet-service/ → Planet CRUD implementation
└── package.json → Monorepo root
Each microservice follows the contract-first pattern:
┌──────────────────────────────────────────┐
│ API Aggregator (apps/api) │
│ - Routes requests to services │
│ - Provides shared context (auth, etc.) │
└──────────────────────────────────────────┘
↓
┌──────────────────────────────────────────┐
│ Service Layer │
│ - Implements business logic │
│ - Uses middleware (auth, retry, etc.) │
│ - Handles errors with type safety │
└──────────────────────────────────────────┘
↓
┌──────────────────────────────────────────┐
│ Contract Layer │
│ - Defines API shape with Zod schemas │
│ - OpenAPI metadata (routes, tags) │
│ - Shared types (TypeScript inference) │
└──────────────────────────────────────────┘