Skip to content

Latest commit

Β 

History

History
89 lines (71 loc) Β· 3.27 KB

File metadata and controls

89 lines (71 loc) Β· 3.27 KB

oRPC Multiservice Monorepo Playground

A full-stack TypeScript monorepo demonstrating microservices architecture with oRPC, TanStack Query, and end-to-end type safety.

πŸš€ Quick Start

Prerequisites

  • Node.js: 24+ recommended
  • pnpm: 10.21.0+ (project uses pnpm workspaces)

Installation

# Install dependencies
pnpm install

# Start development (runs API + Web in parallel)
pnpm dev

The API server starts at http://localhost:3000 and the web app at http://localhost:5173.

Available Scripts

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 issues

πŸ“ Architecture

Monorepo Structure

orpc-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

Service Architecture

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)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Sponsors