This project is a starter django repo aiming to achieve majestic monolith architecture. Main purpose is to provide scaffolding skeleton and sample architecture for rapid prototype structure that can scale to mid-range size application. I have complied useful techniques and libraries to help build backend API server.
Inspired by Majestic monolith and Two Scoops of Django, this starter code will help you build scalable application for a small team of developers.
MicroService is everywhere and no doubt that they are the next big thing, for a company with many developers and in need for concurrent feature releases.
However, MSA needs a lot of coordination and preparation to make is work. If you are the only developer in the team or developing ina a relatively small to medium scale architecture, MSA can be overwhelming.
You can reduce cognitive load by following DDD practice. With code isolation, data isolation and some cloud architecture help, majestic monolith django(MMD) can prepare for the scale and bigger team coordination.
This repo provides sample application illustrating following usecase.
I have broken down the application into four modules(auth
, user
, shipping
, distribution
) using techniques I used for application prototyping.
Please refer to ERD attached.
dbdiagram.io
API doc can be accessed via (/api/docs/redoc) (you must login as staff)
I will provide base CDK template for deployment.(TBD) I recommend to use seperate repository for CDK. CDK incldues following modules
- ECS cluster with django and nginx image
- EventBridge
- Aurora for Mysql
- ALB
Refer to infra setup
I will update rest of diagram in the future to support for scalable infrastructure SAM
- API gateway
- Lambda
- dynamodb
- cache : REDIS
- authentication : JWT
- drf-spectacular: api doc
Github action
- CI
- precommit
- pytest using docker-compose
- CD
- ECS deployment support
You can run pytest on CLI:
(project_root)/majestic-monolit-django/$ python -m pytest --ds=settings.test
You can also run docker-compose to run pytest
(project_root)/$ docker-compose -f docker-compose-test.yml up --build
Project uses poetry for dependency management Here are some of django packages used
- Django 3.2
- djangorestframework
- django-storages
- django-request-logging
- djangorestframework-simplejwt
- drf-spectacular
- django-guid
- easy-thumbnails
- django-daterangefilter
- boto3 refer to pyproject.toml
Refer to setup Refer to infra setup
Refer to convention
Future updates are listed here.
I always welcome feedback and contribution. Please help me improve the project.
Use cookie cutter to start new project
cookiecutter https://github.com/kokospapa8/majestic-monolith-django.git --checkout cookie-cutter
- 0.1.0 initial application update with api
- 0.2.0 cookie cutter
- 0.2.1 drf-spectacular
- 0.3.0 async support