Skip to content

This is a Node.js server that implements Domain-Driven Design (DDD) in a minimalistic way. The main purpose of this server is to focus on business logic and be agnostic to any transport or protocol.

Notifications You must be signed in to change notification settings

fermersky/node-ddd-monorepo

Repository files navigation

Node.js server with minimalistic implementation of DDD

This is a Node.js server that implements Domain-Driven Design (DDD) in a minimalistic way. The main purpose of this server is to focus on business logic and be agnostic to any transport or protocol.

The server has two entities, namely Driver and WorkShift. A driver can have multiple shifts. Instead of using an ORM, the server uses manual mapping from SQL queries to domain entities. The server implements dependency injection using tsyringe library.

The server supports two different transports: HTTP (fastify) and WebSocket (uWebSocket.js).

The documentation is generated using Docusaurus, and can be found in the ./apps/docs folder.

Some libs from the app stack

  • pnpm: package manager
  • tsx: local TS development & file watching
  • tsc: TS linting
  • tsc-alias: replacing paths aliases (such as @api, @domain and @infrastrcuture) with relative paths
  • esbuild: TS -> JS compilation
  • node:test: node.js native test runner
  • knex: query builder & migrations
  • chance: generating random data
  • zod: validation & schema defs
  • docusaurus: API docs
  • tsyringe: DI library
  • uWebSockets.js: C++ implementation of WebSockets
  • fastify: HTTP framework
  • Turborepo: build system for monorepo - https://turbo.build/repo

Turborepo

Run the following command:

npx create-turbo@latest

What's inside?

This Turborepo includes the following packages/apps:

Apps and Packages

  • docs: docusaurus app
  • server: backend
  • eslint-config-custom: eslint configurations (includes eslint-config-next and eslint-config-prettier)
  • tsconfig: tsconfig.jsons used throughout the monorepo

Utilities

This Turborepo has some additional tools already setup for you:

Build

To build all apps and packages, run the following command:

cd node-ddd-monorepo
pnpm build

Develop

To develop all apps and packages, run the following command:

cd node-ddd-monorepo
pnpm dev

Remote Caching

Turborepo can use a technique known as Remote Caching to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.

By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can create one, then enter the following commands:

cd node-ddd-monorepo
npx turbo login

This will authenticate the Turborepo CLI with your Vercel account.

Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo:

npx turbo link

Useful Links

Learn more about the power of Turborepo:

About

This is a Node.js server that implements Domain-Driven Design (DDD) in a minimalistic way. The main purpose of this server is to focus on business logic and be agnostic to any transport or protocol.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published