Skip to content

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

License

Notifications You must be signed in to change notification settings

Dineshs91/django-cqrs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published