Node.js Monorepo Template - Project Structure
This is a Node.js monorepo built with Turborepo, pnpm workspaces, and modern tooling, designed for building scalable server-side applications and shared libraries.
Repository Layout
Core Directories
apps/
- Individual Node.js applications or services (deployable units).- Each subdirectory is typically a separate application (e.g., an API server, a background job processor).
- Example:
apps/api-service/
- could be an Express.js or NestJS application. - Example:
apps/data-processor/
- could be a standalone Node.js script or service.
packages/
- Shared libraries, utilities, and configurations used by applications in theapps/
directory or other packages.- packages/eslint-config/ - Shared ESLint configuration
- packages/typescript-config/ - Shared TypeScript configuration
- packages/hono-helpers/ - Hono framework utilities and middleware
- packages/tools/ - CLI tools and development scripts
- packages/workspace-dependencies/ - Shared dependencies management
Configuration Files
- package.json - Root package with workspace scripts and dev dependencies
- pnpm-workspace.yaml - Defines pnpm workspace structure
- turbo.json - Turborepo configuration for builds, tasks, and caching
- Justfile - Convenient command aliases for development
- tsconfig.json - Root TypeScript configuration
- .syncpackrc.cjs - Dependency version synchronization
Code Generation
turbo/generators/
- Turbogen
templates for scaffolding new applications and packages.templates/node-service/
- Example: Template for a basic Node.js service (e.g., using Express or Fastify).templates/library-package/
- Template for a shared library package.templates/package/
- Generic shared package template (as before, likely still useful). (Update these paths and descriptions to match your actual Node.js application/service templates.)
Build & Development
.turbo/
- Turborepo cache and daemon filesnode_modules/
- Workspace dependencies (managed by pnpm).github/workflows/
- CI/CD pipelines for testing and deployment
Key Concepts
- Monorepo Benefits: Shared dependencies, atomic commits, consistent tooling, easier refactoring across multiple Node.js applications and libraries.
- pnpm Workspaces: Efficient dependency management and linking for local development across packages.
- Turborepo: Build orchestration, intelligent caching, and parallelization of tasks like building, testing, and linting.
- Code Generation: Use
just new-app
(or your project's specific command) to scaffold new Node.js applications or services from predefined templates.