No description
  • TypeScript 84.6%
  • JavaScript 11.9%
  • Shell 3.2%
  • Makefile 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Riccardo Agnoletto 5cc69bc22a
Some checks failed
CI / Core Gates (build · typecheck · test · lint · tasks) (push) Has been cancelled
CI / Scaffold Smoke (template · scaffold · install · build · test) (push) Has been cancelled
Scaffold Integration Matrix / Scaffold Leg a (template · scaffold · install · build) (push) Has been cancelled
Scaffold Integration Matrix / Scaffold Leg b (template · scaffold · install · build) (push) Has been cancelled
Scaffold Integration Matrix / Scaffold Leg c (template · scaffold · install · build) (push) Has been cancelled
Scaffold Integration Matrix / Scaffold Leg d (template · scaffold · install · build) (push) Has been cancelled
docs(root): checkpoint 0.1.0 publish and forgejo move
create-node-ddd-app@0.1.0 is live on npm (manual publish, 2FA). Mark
scaffolding-publish-config done, add the scaffolding-ci-publish follow-up
(tag-triggered publish once Forgejo Actions is confirmed), re-rank the
roadmap "Now" to station 0.2.0, tick the 0.1.0 release checkbox, and
record the checkpoint in the Decisions Log with the review verdict.
Retire .build.yml: the repo moved from sourcehut to
git.marric.quest/riccardo/create-node-ddd-app.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CEfCdS1MkqWTG8ANAs8UMg
2026-09-14 21:50:55 +02:00
.claude feat(root): add ddd-model skill and agent, ship in template 2026-09-10 18:46:07 +02:00
.github/workflows fix(root): vendor root tsconfig.json into the scaffold template 2026-09-14 19:23:30 +02:00
.husky docs(runner): add hook documentation and TDD phase logs 2026-02-03 17:09:30 +01:00
.omp docs(root): pin red evidence requirement in epic-loop v2 2026-09-10 17:49:32 +02:00
.playwright-mcp initial commit 2026-01-20 12:31:07 +01:00
.serena feat(root): ts-morph integration 2026-02-11 13:22:04 +01:00
.tasks docs(root): checkpoint 0.1.0 publish and forgejo move 2026-09-14 21:50:55 +02:00
.vscode initial commit 2026-01-20 12:31:07 +01:00
apps fix(root): address adversarial sweep findings on scaffold slice 2026-09-09 17:10:47 +02:00
docker initial commit 2026-01-20 12:31:07 +01:00
docs docs(root): checkpoint 0.1.0 publish and forgejo move 2026-09-14 21:50:55 +02:00
packages build(root): add npm publish metadata and package readme for 0.1.0 2026-09-14 19:23:31 +02:00
scripts feat(root): add strategic direction staleness check to tasks cli 2026-06-09 20:21:49 +02:00
todo chore(root): removed old doc 2026-01-23 12:08:25 +01:00
tools feat(root): add ast-grep guard against projection-typed tags 2026-06-15 18:04:33 +02:00
.dockerignore initial commit 2026-01-20 12:31:07 +01:00
.env.example feat(runner): fence adapter wiring, auth none|casbin|casdoor 2026-09-09 01:02:57 +02:00
.gitignore feat(runner): fence adapter wiring, auth none|casbin|casdoor 2026-09-09 01:02:57 +02:00
.mcp.json chore(deps): pin ts-morph-readonly-mcp as pnpm git dependency 2026-04-20 13:17:30 +02:00
.prettierignore initial commit 2026-01-20 12:31:07 +01:00
.prettierrc initial commit 2026-01-20 12:31:07 +01:00
AGENTS.md docs(root): add effect-ts typecheck-first working rule for all agents 2026-08-12 15:30:36 +02:00
CLAUDE.md docs(root): document tsserver blind spot and omp harness audit 2026-09-08 10:33:37 +02:00
commitlint.config.js feat(root): add git conventions with commitlint and husky 2026-01-20 16:06:50 +01:00
CONTRIBUTING.md refactor(root): migrate from vitest to node:test across codebase 2026-01-25 22:58:54 +01:00
docker-compose.override.yml.dist initial commit 2026-01-20 12:31:07 +01:00
docker-compose.yml feat(runner): wire kurrentdb event-store adapter (phase 6) 2026-06-23 10:08:12 +02:00
docker.sh initial commit 2026-01-20 12:31:07 +01:00
Dockerfile initial commit 2026-01-20 12:31:07 +01:00
eslint.config.mjs feat(root): vendor monorepo into create-node-ddd-app template (lite) 2026-09-08 21:25:51 +02:00
LICENSE docs(root): apply mit license and fix doc drift 2026-07-06 11:24:53 +02:00
Makefile initial commit 2026-01-20 12:31:07 +01:00
nx.json feat(root): vendor monorepo into create-node-ddd-app template (lite) 2026-09-08 21:25:51 +02:00
opencode.json docs(root): make ts-morph semantic tooling model-agnostic in opencode 2026-08-12 15:27:34 +02:00
package.json ci(root): add blocking core-gates workflow and harden ci toolchain 2026-07-06 18:20:47 +02:00
pnpm-lock.yaml feat(root): add create-node-ddd-app package skeleton + bin arg parsing 2026-09-08 12:58:26 +02:00
pnpm-workspace.yaml feat(root): add create-node-ddd-app package skeleton + bin arg parsing 2026-09-08 12:58:26 +02:00
README.md docs(root): apply mit license and fix doc drift 2026-07-06 11:24:53 +02:00
sgconfig.yml chore(root): harvest ast-grep, ts-morph daemon, infra-shared-kernel 2026-06-05 11:57:18 +02:00
test-authorization.mjs initial commit 2026-01-20 12:31:07 +01:00
test-debug.mjs initial commit 2026-01-20 12:31:07 +01:00
test-endpoints.mjs initial commit 2026-01-20 12:31:07 +01:00
test-health.sh initial commit 2026-01-20 12:31:07 +01:00
test-update-only.mjs initial commit 2026-01-20 12:31:07 +01:00
tsconfig.base.json initial commit 2026-01-20 12:31:07 +01:00
tsconfig.json initial commit 2026-01-20 12:31:07 +01:00
tsconfig.tsmorph.json feat(runner): fence adapter wiring, auth none|casbin|casdoor 2026-09-09 01:02:57 +02:00
tsconfig.tsmorph.with-tests.json feat(root): ts-morph integration 2026-02-11 13:22:04 +01:00

Effect CQRS + Event Sourcing Template

A production-ready TypeScript template implementing CQRS (Command Query Responsibility Segregation) and Event Sourcing patterns using Domain-Driven Design (DDD) and Hexagonal Architecture. Built with Effect and Nx.

🎯 What is This?

This is a template project demonstrating:

  • DDD - Domain-Driven Design with bounded contexts
  • CQRS - Separate write (commands) and read (queries) models
  • Event Sourcing - Complete audit trail of state changes
  • Hexagonal Architecture - Pluggable adapters for infrastructure
  • Clean Architecture - Testable, maintainable, technology-agnostic
  • Type Safety - Full TypeScript with Effect for typed error handling

Perfect for building scalable, maintainable event-driven applications.

🚀 Quick Start

# Clone the repository
git clone <repo-url>
cd create-node-ddd-app

# Start with in-memory adapters (fastest)
./docker.sh dev

# Or start with PostgreSQL (event store + projections)
./docker.sh postgres

# View all available commands
./docker.sh

The API will be available at:

Visit /docs for interactive Swagger API documentation.

Local Development

# Install dependencies
pnpm install

# Build the application
pnpm nx run runner:build

# Run the application
node apps/runner/dist/index.js

Expected output (abridged):

🔧 Application Configuration:
  ├─ Environment: development
  ├─ Event Store: memory
  ├─ Event Bus: memory
  ├─ Auth Provider: memory
  ├─ Telemetry: noop
  ├─ Projections:
  │   └─ PostListView: memory
  └─ Servers:
      ├─ HTTP REST: enabled (port 3000)
      ├─ Web SSR: enabled (port 3001)
      ├─ gRPC: disabled
      └─ WebSocket: disabled

✅ Runner: Application started successfully
🚀 CQRS + Event Sourcing architecture active
   🌐 REST API: http://localhost:3000
   📚 Swagger Docs: http://localhost:3000/docs

With zero configuration, the runner seeds a canonical in-memory PostListView projection (set PROJECTION_DEFAULT=none to opt out).

📋 Table of Contents

Core Documentation

Product & Planning

Architecture Decisions

For LLM Agents

  • CLAUDE.md - LLM-specific navigation and rules

🔄 CQRS + Event Sourcing Flow

┌─────────────┐
│   Client    │
└──────┬──────┘
       │
       ▼
┌─────────────────────────────────────┐
│    REST API (port 3000)              │
│  Commands       │       Queries      │
└────────┬────────┴────────┬───────────┘
         │                 │
         ▼                 ▼
┌──────────────────┐  ┌──────────────┐
│  Write Model     │  │  Read Model  │
│ (PostService)    │  │(QueryDB)     │
│      ↓           │  │      ↑       │
│  EventStore ─────┼──┼─→ Projector  │
└──────────────────┘  └──────────────┘
         │                 ▲
         └───────────────┬─┘
               EventBus
          (Effect Queue)

💾 API Examples

Create a Post (Command)

curl -X POST http://localhost:3000/posts \
  -H "Content-Type: application/json" \
  -d '{
    "aggregateId": "post-001",
    "userId": "user-123",
    "title": "My First Post",
    "content": "Testing CQRS and Event Sourcing!"
  }'

Get a Post (Query)

curl http://localhost:3000/posts/post-001

List All Posts (Query)

curl http://localhost:3000/posts

Publish a Post (Command)

curl -X POST http://localhost:3000/posts/post-001/publish

🏗️ Architecture at a Glance

packages/
├── domain/
│   ├── shared-kernel/          # Core domain primitives (zero dependencies)
│   ├── debate-domain/          # Post aggregate, events, commands, queries
│   └── auth-domain/            # Authentication models
├── application/
│   ├── app/                    # Cross-cutting ports, API definitions, error mapping
│   ├── debate-application/     # PostService, PostProjector, contract tests
│   └── auth-application/       # AuthService, AuthorizationService
└── infrastructure/
    ├── eventstore-inmemory-adapter/   # Event persistence (dev/test)
    ├── eventstore-postgres-adapter/   # Event persistence (production)
    ├── database-inmemory-adapter/     # CQRS read model (dev/test)
    ├── database-postgres-adapter/     # CQRS read model (production)
    ├── event-queue-adapter/           # Event bus (Effect Queue)
    ├── http-rest-adapter/             # REST API + Swagger
    └── ...                            # auth, telemetry, grpc, websocket, web-ssr

apps/
└── runner/                     # Composition root (wires everything)

Key Principle: Domain is stable. Infrastructure is replaceable. Runner is sacrificial.

🔧 Configuration

The application is configured via environment variables:

# Event persistence (write model)
EVENT_STORE=memory              # memory, postgres (eventstoredb: planned)

# Async event distribution
EVENT_BUS=memory                # memory (rabbitmq, kafka: planned)

# Read model projections (one block per projection)
# Zero-config boots a canonical in-memory PostListView projection.
PROJECTION_DEFAULT=memory                # memory, postgres, none (opt out of seeding)
PROJECTION_POST_LIST_VIEW_TYPE=memory    # memory, postgres (mongodb: planned)
# For postgres: PROJECTION_POST_LIST_VIEW_HOST / _PORT / _DATABASE / _USER / _PASSWORD

# Server configuration
HTTP_ENABLED=true
HTTP_PORT=3000
GRPC_ENABLED=false
GRPC_PORT=50051
WEBSOCKET_ENABLED=false
WEBSOCKET_PORT=8080

# Telemetry
TELEMETRY_PROVIDER=noop         # noop, signoz

See SETUP.md for detailed configuration guide.

🧪 Testing

# Run all tests
pnpm nx run-many -t test

# Run tests for a specific package
pnpm nx run debate-domain:test

# Run tests with coverage
pnpm nx run shared-kernel:test:coverage

# End-to-end tests
pnpm test:e2e

See TESTING.md for the testing strategy (contract tests, integration tests, coverage expectations per package).

📦 Build and Deploy

Build

pnpm nx run-many -t build

Docker

# Development
./docker.sh dev

# Production setup with PostgreSQL
./docker.sh postgres

# Infrastructure only (for local Node.js debugging)
./docker.sh infra postgres mongodb

See SETUP.md for complete Docker documentation.

🎓 Learning Resources

For Architects

Start with ARCHITECTURE.md to understand:

  • System design philosophy
  • Design patterns used
  • Dependency management
  • Why each architectural decision was made

For Developers

Start with SETUP.md to:

  • Get your environment running
  • Understand the development workflow
  • Learn Docker setup and commands
  • Configure environment variables

For QA Engineers

See TESTING.md for:

  • How to run tests
  • Testing strategies
  • API endpoint testing examples
  • CQRS flow verification

🛠️ Common Tasks

Run the app locally with debugger

# Terminal 1: Start infrastructure
./docker.sh infra postgres

# Terminal 2: Generate environment config
./docker.sh env:local

# Terminal 3: Build and run with inspector
pnpm nx run runner:build
node --inspect apps/runner/dist/index.js

# Connect debugger in Chrome: chrome://inspect

Test multiple adapters

# In-memory (no infrastructure needed)
pnpm nx run-many -t test

# PostgreSQL setup (integration tests)
./docker.sh infra postgres
pnpm nx run-many -t test

# SigNoz observability
./docker.sh infra postgres signoz
# View traces at http://localhost:3301

Add a new feature

  1. Define domain logic in packages/domain/
  2. Define application services and ports in packages/application/
  3. Implement adapter in packages/infrastructure/ if needed
  4. Wire in apps/runner/src/lib/factories.ts

🐛 Troubleshooting

Port Already in Use

HTTP_PORT=4000 node apps/runner/dist/index.js

"Adapter Not Implemented" Error

Use in-memory adapters:

EVENT_STORE=memory EVENT_BUS=memory PROJECTION_DEFAULT=memory node apps/runner/dist/index.js

Docker Issues

# Clean up everything
./docker.sh clean

# Check service health
./docker.sh health

# View logs
./docker.sh logs

📚 Additional Documentation

All documentation is organized under the docs/ folder:

Category Description
docs/ARCHITECTURE.md System design, patterns, principles
docs/TESTING.md Testing strategy and execution
docs/SETUP.md Development setup and environment
docs/SECURITY.md Security guidelines
docs/TELEMETRY.md Observability with SigNoz
docs/decisions/ Architecture Decision Records
docs/rfcs/ Request for Comments
docs/product/ Vision, roadmap, user stories
docs/templates/ Document templates (RFC, ADR, LOG)
docs/logs/ Operational logs
docs/archive/ Historical documentation
docker/README.md Docker reference

🤝 Contributing

Contributions welcome! Please ensure:

  • Architecture principles are maintained
  • Tests pass and coverage doesn't decrease
  • Documentation is updated
  • Commits follow the project style

📄 License

MIT © Riccardo Agnoletto — see ADR-2026-07-06-repository-license.

Projects generated with create-node-ddd-app are yours: no attribution or license obligation attaches to scaffolded output.


Built with ❤️ using Effect, Nx, and TypeScript