Dineshs91 / django-cqrs

A demo application to show how cqrs can be implemented in Django

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

django-cqrs

A demo application to show how cqrs can be implemented in Django

Bring up the services.

cd into the project root. (After cloning this repo)

Bring up the services up.

docker-compose up -d --build

Visit http://localhost:8000/posts/

Shutdown the containers.

docker-compose down

NOTE: For docker commands refer this

Test events replay

docker exec -it cqrs_web_1 blog/demo/replay_three.sh

docker exec -it cqrs_web_1 blog/demo/replay_all.sh

Architecture

Currently there are only two events PostCreatedEvent and PostUpdatedEvent.

I tried to replicate the concepts from this video I did not implement the command part.

There are 2 types of data,

  1. event data
  2. entity data

Event data captures every change to the system, whereas entity data has only the recent state.

Any state change to the application is captured through an event (PostCreatedEvent, PostUpdatedEvent). For storing event data I've used MongoDB and for storing entity data PostgresDB.

Creation of event data is handled in django forms. Forms save method is overloaded with the code which creates the events and makes a call to event handler. Event handler creates the application state, which in turn gets stored in postgres.

So all the writes go through Events and EventHandler and reads happen on the entity data which is stored in postgres.

If anybody wants to help out or interested about this, please open a PR or start a discussion in the issues section.

About

A demo application to show how cqrs can be implemented in Django

License:GNU General Public License v2.0


Languages

Language:Python 70.6%Language:HTML 16.8%Language:JavaScript 7.5%Language:Shell 2.9%Language:Dockerfile 1.7%Language:CSS 0.6%