How riley-brown/turbo-repo-express-next-example works
Project type and purpose
• This is a full-stack monorepo built with Turborepo and pnpm workspaces.
• It contains a Next.js front-end (“apps/front-end”), an Express back-end (“apps/server”), and several locally shared TypeScript packages under “packages/*”.
• Its main goal is to demonstrate how to bundle and transpile shared packages at build time—using Next.js’s transpilePackages for the front-end and tsup with noExternal for the server.
File structure
• Top-level orchestrator files:
• turbo.json / pnpm-workspace.yaml: defines the workspace and build pipelines
• package.json, pnpm-lock.yaml: root dependency management
• apps/:
• front-end: Next.js app (pages/, public/, next.config.js with transpilePackages)
• server: Express app (index.ts, tsup.config.ts for bundling)
• packages/: shared libs:
• eslint: custom ESLint rules
• logger: logging utility
• utils: general utilities
• tsconfig: base and node TypeScript configs
• Tooling configs: .eslintrc.js, tsconfig.json, .vscode/, etc.
README for additional insights
• The front-end uses Next.js 13’s built-in transpilePackages to include local packages
• The server uses tsup with noExternal to bundle @example/* packages into dist/
• Turborepo runs install, dev, build, start across all apps and packages in parallel or in pipelines
a. Main components (nodes):
• Monorepo root (Turborepo orchestrator + pnpm workspace)
• Front-end app (Next.js)
• Back-end app (Express)
• Shared packages (logger, utils, eslint, tsconfig)
• Build tools (Next.js build, tsup, pnpm)
• External dependencies (npm registry modules, client browsers)
b. Relationships & interactions (edges):
• Front-end ↔ Shared packages: imports at build time via transpilePackages
• Server ↔ Shared packages: bundles via tsup noExternal
• Client browser → Front-end: HTTP(S) requests for UI pages and API calls
• Front-end → Server API: fetch /api endpoints
• Turborepo → apps & packages: orchestrates dev, build, start scripts
• pnpm → all workspace nodes: resolves dependencies
c. Architectural patterns & principles:
• Monorepo for code sharing and unified versioning
• Build-time code-sharing vs. individual package builds
• BFF pattern: Next.js front-end acting as a frontend that also proxies or calls the Express API
• Bundle-everything approach: zero separate publish/build steps for shared packages
d. Key technologies:
• Next.js 13, React, TypeScript
• Express.js, tsup
• Turborepo, pnpm workspaces
• ESLint (custom rules), shared tsconfig