typescript-ddd-example

repository·master·Indexed 23 days ago

https://github.com/codelytv/typescript-ddd-example

A reference implementation of a TypeScript application demonstrating Hexagonal Architecture, Domain-Driven Design (DDD), Command Query Responsibility Segregation (CQRS), and Event-Driven Architecture (EDA) principles. The project includes a backoffice frontend and backend, a MOOC backend, and infrastructure configurations for MongoDB, PostgreSQL, RabbitMQ, Elasticsearch, and Kibana.

Tokens
3K
Snippets
13
Records
29
Agent score
81%

What's inside typescript-ddd-example

  1. Overview of Hexagonal Architecture, DDD & CQRS in TypeScript

    master
    This repository serves as a complete project example demonstrating the application of Domain-Driven Design (DDD), Command Query Responsibility Segregation (CQRS), and Event-Driven Architecture (EDA) principles using TypeScript. It is designed to show how to implement Hexagonal Architecture while keeping the code as simple as possible.
  2. Eject from Create React App configuration

    master

    If you need full control over the underlying build tools (Webpack, Babel, ESLint, etc.), you can run npm run eject.

    Warning: This is a one-way operation. Once you eject, you cannot undo it.

    Ejecting removes the single build dependency and copies all configuration files and transitive dependencies directly into your project. After ejecting, you are responsible for maintaining these configurations.

    npm run eject
  3. Configure Elasticsearch service

    master

    The elasticsearch service uses image docker.elastic.co/elasticsearch/elasticsearch:7.9.3. It is configured as a single-node cluster.

    Key configurations:

    • Ports: Exposed on 9200.
    • Memory: ES_JAVA_OPTS is set to -Xms2048m -Xmx2048m. bootstrap.memory_lock is enabled.
    • Ulimits: memlock is set to -1 (unlimited) to allow Elasticsearch to lock memory.
    • Persistence: Uses the esdata volume.
      elasticsearch:
        image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
        container_name: codely-elasticsearch
        environment:
          - node.name=codely-elasticsearch
          - discovery.type=single-node
          - bootstrap.memory_lock=true
          - 'ES_JAVA_OPTS=-Xms2048m -Xmx2048m'
        ulimits:
          memlock:
            soft: -1
            hard: -1
        volumes:
          - esdata:/usr/share/elasticsearch/data
        ports:
          - '9200:9200'
  4. Configure Kibana service

    master

    The kibana service uses image docker.elastic.co/kibana/kibana:7.8.1. It connects to the Elasticsearch service via the following environment variables:

    • ELASTICSEARCH_URL: The URL of the Elasticsearch instance (default: http://codely-elasticsearch:9200)
    • ELASTICSEARCH_HOSTS: The hosts for Elasticsearch (default: http://codely-elasticsearch:9200)

    It exposes the Kibana UI on port 5601.

      kibana:
        image: docker.elastic.co/kibana/kibana:7.8.1
        container_name: codely-kibana
        environment:
          ELASTICSEARCH_URL: http://codely-elasticsearch:9200
          ELASTICSEARCH_HOSTS: http://codely-elasticsearch:9200
        ports:
          - 5601:5601
  5. Configure MongoDB service

    master

    The mongo service uses the mongo:5.0.0 image. It exposes port 27017 and provides a connection string via the MONGO_URL environment variable. Data is persisted in the local ./data/mongo directory.

      mongo:
        image: mongo:5.0.0
        environment:
          - MONGO_URL=mongodb://mongo:27017/dev
        volumes:
          - ./data/mongo:/data/db:delegated
        ports:
          - 27017:27017
  6. Configure PostgreSQL service

    master

    The postgres service uses the default postgres image. It exposes port 5432. You can configure the database credentials and name using the following environment variables:

    • POSTGRES_PASSWORD: The database password (default: codely)
    • POSTGRES_USER: The database user (default: codely)
    • POSTGRES_DB: The database name (default: mooc-backend-dev)
      postgres:
        image: postgres
        environment:
          - POSTGRES_PASSWORD=codely
          - POSTGRES_USER=codely
          - POSTGRES_DB=mooc-backend-dev
        ports:
          - '5432:5432'
        restart: always