Skip to content

kokospapa8/majestic-monolith-django

Repository files navigation

majestic-monolith-django

Introduction

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.

Why majestic modular monolith?

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.

Sample application

This repo provides sample application illustrating following usecase. sample_application I have broken down the application into four modules(auth, user, shipping, distribution) using techniques I used for application prototyping. modular monolith Please refer to ERD attached. ERD dbdiagram.io API doc can be accessed via (/api/docs/redoc) (you must login as staff) API

Infrastructure

Infra 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

Features

  • cache : REDIS
  • authentication : JWT
  • drf-spectacular: api doc

CI/CD

Github action

  • CI
    • precommit
    • pytest using docker-compose
  • CD
    • ECS deployment support

pytest

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

Libraries

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

How to Setup

Refer to setup Refer to infra setup

Convention

Refer to convention

TODO List

Future updates are listed here.

Projects

Contribution

I always welcome feedback and contribution. Please help me improve the project.

Reference

Cookie-cutter

Use cookie cutter to start new project

cookiecutter https://github.com/kokospapa8/majestic-monolith-django.git --checkout cookie-cutter

Release

version

  • 0.1.0 initial application update with api
  • 0.2.0 cookie cutter
  • 0.2.1 drf-spectacular

release plan

  • 0.3.0 async support

About

Starter Django project strive for majestic monolith

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages