Implementing DDD, CQRS and Event Sourcing in Node.js (Book & Code)
$29.99
Minimum price
$34.99
Suggested price

Implementing DDD, CQRS and Event Sourcing in Node.js

About the Book

Note: The book contains all chapters and can be considered complete in terms of content. However, before marking it 100% complete, there will be some refinement done. Nevertheless, the content is ready to be read through in its current state.

Abstract

This book explains and illustrates how to implement Domain-Driven Design, Command Query Responsibility Segregation and Event Sourcing in Node.js. The reader is taught to build software that is problem centered, well designed, event-based, reactive and scalable. Domain-Driven Design (DDD) is a methodology that focuses on the actual problem to solve and its involved knowledge areas. Command Query Responsibility Segregation (CQRS) promotes to separate a software into a write side and a read side. Event Sourcing is an architectural pattern where state is represented as a series of immutable events. All concepts are described in theory and put into practice with standalone examples and a fully functional sample application. This is done without third party technologies or frameworks. The code is written in JavaScript and uses Node.js as runtime. This book includes a source code bundle with all standalone examples and the sample application implementation. The bundle contains more than 5000 lines of JS code.

Target audience

The target reader is experienced with Node.js and wants to implement DDD, CQRS and Event Sourcing without deep-diving into theory. Naturally, this also implies advanced skills in JavaScript. The second potential reader has theoretical knowledge about the mentioned concepts, but struggles with translating them into actual code. For such a person, it might be required to build up the respective JavaScript and Node.js knowledge. Apart from the first four chapters, which cover the more conceptual parts, this book heavily focuses on code and implementation. Also, some of the covered topics are not explained to their full extent, but rather as far as needed. As a consequence, the book is not recommended to be used as a reference.

Chapter order and structure

The chapter order in this book is determined by what makes most sense in terms of building the sample application. As a consequence, the topics are laid out in a way so they can build upon each other. This also reduces the likelihood of referring to terms before they are explained. Every chapter has the same structure. First, the respective concepts are introduced and defined. Then, they are described in detail and illustrated either with drawings or code examples. At the end of each chapter, the discussed concepts are applied to the sample application. This is done by describing the working steps to take and by showing the according drawings or code. An exception is chapter 5, where there is no sample application section.

Programming paradigms

The content and the code examples in this book compromise an overall combination of imperative, declarative, object-oriented and functional programming. However, most parts apply the object-oriented paradigm and therefore partially contradict with a functional approach. There are different motivations for this. For one, the primary goal is to use the most prevalent style with regards to the target reader. Furthermore, at the time of writing, I am no expert in the functional paradigm and cannot apply and explain it adequately. Still, over the course of the book the domain-related implementations transition towards a more functional style. Also, individual infrastructural functionalities apply selected principles of it wherever useful. As these changes come automatically together with introducing specific concepts, there is no need for specialized upfront knowledge.

Code examples

This book includes a bundle that contains the implementations for all standalone examples and the sample application. Also, it provides the possibility to run the code when reading on a computer. For this purpose, the bundle includes a playground server that can execute Node.js code and display its output. Almost every implementation shown in the book is accompanied with a hyperlink labeled as "run code" or "run code usage". Clicking such a link opens a web page with an editable text area, an output window and control buttons.

  • Share this book

  • Feedback

    You must own a copy of this Book to access the forums

    Email the Author(s)

About the Author

Alex Lawrence
Alex Lawrence

I am a software developer with knowledge and experience in architecture, automation, backend, frontend, lecturing, operations, technical leadership and testing. Since 2014, my focus lies on full stack web application development with JavaScript as language and Node.js as backend runtime. As part of a software architecture, I apply and implement CQRS and/or Event Sourcing wherever it makes sense. For the frontend, I work with many different libraries and tools, including the obligatory use of HTML and (S)CSS. Most recently, I started to work with React and redux. In parallel, I am learning more about the theory and concepts of Functional Programming. Since a few years, I am a strong supporter for Free/Libre Open Source Software.

Packages

Book & Code

Includes:

  • extras
    Code bundle (Release 2020-10-09)
  • English

  • PDF

  • EPUB

  • MOBI

  • WEB

$29.99
Minimum price
$34.99
Suggested price
Book & Code - 5 copies (20% discount)

This package is meant for 5 individual readers, such as a team.

Includes:

  • extras
    Code bundle (Release 2020-10-09)
  • English

  • PDF

  • EPUB

  • MOBI

  • WEB

$119.99
Minimum price
$139.99
Suggested price
Book & Code - 10 copies (30% discount)

This book is meant for 10 individual readers.

Includes:

  • extras
    Code bundle (Release 2020-10-09)
  • English

  • PDF

  • EPUB

  • MOBI

  • WEB

$209.99
Minimum price
$244.99
Suggested price

Table of Contents

  • Preface
    • About the author
    • Target audience
    • Content and structure
    • Formatting and highlighting
    • Programming paradigms
    • Code examples
  • Chapter 1: Domain
    • Technological and business domains
    • Domain Experts
    • Subdomains and their types
    • Identification of Subdomains
    • Sample application: Domains
  • Chapter 2: Domain Model
    • Tangibility
    • Difference to expert knowledge
    • Model creation
    • Representation possibilities
    • Ubiquitous Language
    • Sample application: Domain Model
  • Chapter 3: Bounded Context
    • Model and context size
    • Relation to subdomains
    • Contexts and language
    • Technological boundaries
    • Visualization of contexts
    • Sample application: Bounded Contexts
  • Chapter 4: Common architectural patterns
    • Parts of a software
    • Layered Architecture
    • Onion Architecture
    • Approach used in this book
    • Sample application: Software architecture
  • Chapter 5: Useful code qualities
    • Model binding
    • Refactoring
    • Readability
    • Behavior and state
    • Focus and responsibilities
    • Command-Query-Separation
  • Chapter 6: Value Objects, Entities and Services
    • Value Objects
    • Entities
    • Domain Services
    • Invariants
    • Sample application: Model implementation
  • Chapter 7: Domain Events
    • Relation to Event-driven Architecture
    • Naming conventions
    • Structure and content
    • Distribution and processing
    • Sample application: Context integration
  • Chapter 8: Aggregates
    • Transactions
    • Structure and handling
    • Concurrency
    • Design considerations
    • Eventual Consistency
    • Sample application: Aggregates and consistency
  • Chapter 9: Repositories
    • Emphasis on the model
    • Design and implementation
    • Optimistic Concurrency
    • Interaction with Domain Events
    • Sample application: Repositories and event publishing
  • Chapter 10: Application Services
    • Design and implementation
    • Different service scenarios
    • Transactions and Processes
    • Cross-cutting concerns
    • Authentication and Authorization
    • Sample application: Application Services
  • Chapter 11: Command Query Responsibility Segregation
    • Architectural overview
    • Write and Read Model
    • Read Model synchronization
    • Commands and Queries
    • Command and Query Handlers
    • Sample application: CQRS
  • Chapter 12: Event Sourcing
    • Architectural overview
    • Event-sourced Write Model
    • Event Store
    • Read Model projection
    • Domain Event publishing
    • Sample application: Event Sourcing
  • Chapter 13: Separate executable programs
    • Program layouts
    • Context-level communication
    • Remote use case execution
    • Remote event distribution
    • Sample application: Separate executable programs
  • Chapter 14: User Interface
    • HTTP file server
    • Task-based UI
    • Optimistic UI
    • Reactive Read Models
    • Components and composition
    • Sample application: User interface
  • Bibliography

Authors have earned$9,656,384writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub