Skip to content

This is an example project to to offer you a very simple example of a CQRS architecture.

License

Notifications You must be signed in to change notification settings

jesperancinha/video-series-app

Repository files navigation

Video Series App


Twitter URL Generic badge

video-series-app e2e-video-series-app

Codacy Badge

Codacy Badge codecov Coverage Status

GitHub language count GitHub top language GitHub top language


Technologies used

Please check the TechStack.md file for details.

Introduction

This is an example project to to offer you a very simple example of a CQRS architecture.

This project is also the official support project of my article on medium:

Please have a look at my Issues file to find out about improvements being made. This file contains a list of ongoing issues that on one hand do not block the development, but on the other hand they are a great nice to haves.

Stable releases

Requests

  1. List all
curl localhost:8090/video-series
  1. Create new records
curl -d '{ "name":"True Blood", "volumes":30, "cashValue": 1323.2, "genre": "DRAMA"}' -H "Content-Type: application/json" -X POST http://localhost:8080/video-series

Swagger

You can also test this application using swagger.

Just run:

make build-docker dcup

And then finally access the API you wish to test:

  1. Command API
  2. Query API

Example payload for Command API:

{
  "name": "True Blood",
  "volumes": 30,
  "cashValue": 1323.2,
  "genre": "DRAMA"
}

Installation notes

Quickstart

The best way to start this application is using the provided docker-composer configuration:

make build-docker

or

docker-composer up

or

docker composer up

There are many further options in the Makefile. Please explore them to find the one that suits you best.

In some cases you'll find that there will be a bin folder in the root. Namely, this will happen when running make build-databases or make local. This is where the jars of each application will go to. You can run them accordingly like this:

java -jar -Dspring.profiles.active=local video-series-command.jar
java -jar -Dspring.profiles.active=local video-series-query.jar

Should there be any resource consumption issues running the containers you can try to run:

make stop

This will attempt to stop all running mongodb and postgres containers, all video-series-app containers and all containers in the docker-compose file.

Makefile options in detail

  1. build - Builds all java bytecode
  2. test - Runs the local tests (they take long in this project)
  3. local - Makes a build without tests and places all jars in a /bin folder
  4. no-test - Makes a build without tests
  5. docker - Starts docker compose
  6. docker-databases - Starts the database containers (Postgres + MongoDB) - You then need to start the SpringBoot/jars manually
  7. docker-mongo - Only starts the mongodb container - This is meant to be tested with the default profile ONLY. It uses an embedded H2 database instead of Postgres.
  8. build-images - Builds the images to run the spring boot processes: video-series-command and video-series-query
  9. build-docker - Makes a clean build, stops containers and relaunches docker-compose.
  10. stop - Makes a full stop of known containers. It is reused in many of the other commands.

Profiles

  1. Default - No need to mention the profile in the command line, and it needs MongoDB only. Data is stored in an embedded H2
  2. local - Specified with -Dspring.profiles.active=local. Needs Postgres and MongoDb. localhost is the common host locally
  3. prod - Named after Production and runs with -Dspring.profiles.active=prod. Only used in docker-compose networks

Docker helper commands

docker system prune --all

Analysis commands

sudo lsof -i :5432

Review Logs

Follow the updates on the ReviewLogs file.

Working versions

1.0.0
git checkout 1.0.0
2.0.0
git checkout 2.0.0

References

About me

GitHub followers