Skip to content

A Node.js CQRS and Event Sourcing Microservice Example Using Nest.js, Event Store, and Swagger

License

Notifications You must be signed in to change notification settings

sanogotech/ViSpeech

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Thesis K16 - Build system recognize Vietnamese voice

Trần Thanh Tịnh - 1612704

Trần Thị Khánh Linh - 1612339

Logo

A Node.js CQRS/ES Swagger API Microservice Boilerplate

Description

This is an application boilerplate that demonstrates how to use Nest.js and Event Store to create a RESTful Users API microservice.

Please note that commands have been implemented and they do write into the Event Store, however, queries for denormalized views have some boilerplate but it is up to you to implement them using your favorite database technology of choice. (use MongoDB in my position, suggest use NoSql or PostgreSql)

In case you don't feel like downloading dependencies locally, I've added support for Docker so follow those instructions in "Running the app" and you'll have everything up and running in less than 2 minutes.

The system has 6 main folder (can run as a stand-alone) as located in ./src

  • server - main web api build with NestJS
  • client - web proxy for navigate request and security network
  • client/ui - web ui for main application
  • core - web api build with Python Flask for transcript audio file to text
  • release - release plan and steps build system
  • services - stack for deploy application with Event Store, GCloud, Jenkins, Nginx, Kafka, Redis

Dependency Table

Name Version
EventStore latest
Node.js Dubnium
TypeScript 3
Docker Compose 3

Installation

With Docker
  1. Install Docker (from the Docker website)
  2. Fork and clone the ViSpeech repo (see Contributing page)
  3. From the src folder run: docker-compose up
  4. Open a browser and navigate to http://localhost to see the application running
  5. To shutdown the application run: docker-compose down
Without Docker (for development/debugging)
  1. Fork and clone the ReactiveTraderCloud repo (see Contributing page)

  2. Install dependencies & add them to your path:

  1. Enable Kafka

     tar -xzf kafka_2.12-2.5.0.tgz
     cd kafka_2.12-2.5.0
     bin/zookeeper-server-start.sh config/zookeeper.properties
     bin/kafka-server-start.sh config/server.properties
  2. Populate Event Store:

    EventStore.ClusterNode.exe --db ./db --log ./logs
  3. Start the ViSpeech server:

    cd src/server
    npm install
    npm run start
  4. (Optional) Start Node services by running npm run start:dev from their respective folders, e.g.:

    cd src/server/node/priceHistory
    npm install
    npm run start:dev
  5. Start the client against the local server components:

    cd src/client
    npm install
    npm run start:dev
    cd src/client/ui
    npm install
    npm run start

CI/CD

We practice continuous integration and deployment. Every merge to master causes a build and deployment to our development environment to occur as follows:

cicd

Running the app

# development
$ yarn start

# watch mode
$ yarn start:dev

# production mode
$ yarn start:prod

# analyze production mode
$ yarn start:analyze

# using with Docker
$ ./scripts/up.sh # to start
$ ./scripts/down.sh # to stop

Relateds Links

Medium Article (Part 1): https://medium.com/@qasimsoomro/building-microservices-using-node-js-with-ddd-cqrs-and-event-sourcing-part-1-of-2-52e0dc3d81df

Medium Article (Part 2): https://medium.com/@qasimsoomro/building-microservices-using-node-js-with-ddd-cqrs-and-event-sourcing-part-2-of-2-9a5f6708e0f

Swagger Explorer URL: http://localhost:7070/api

Event Store URL: http://localhost:2113

Test

# unit tests
$ yarn test

# e2e tests
$ yarn test:e2e

# test coverage
$ yarn test:cov

Supported Node.js Versions

Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js.

Client libraries targetting some end-of-life versions of Node.js are available, and can be installed via npm dist-tags. The dist-tags follow the naming convention legacy-(version).

Legacy Node.js versions are supported as a best effort:

  • Legacy versions will not be tested in continuous integration.
  • Some security patches may not be able to be backported.
  • Dependencies will not be kept up-to-date, and features will not be backported.

Versioning

This library follows Semantic Versioning.

This library is considered to be General Availability (GA). This means it is stable; the code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against GA libraries are addressed with the highest priority.

About

A Node.js CQRS and Event Sourcing Microservice Example Using Nest.js, Event Store, and Swagger

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 38.6%
  • TypeScript 29.9%
  • CSS 29.9%
  • Handlebars 0.6%
  • SCSS 0.5%
  • HTML 0.3%
  • Other 0.2%