This is ideal, clean and well-structured/architected Django Boilerplate and example using Django, Django Ninja, Postgres, Docker and Makefile
- Docker
- Makefile
- Django Ninja for REST API like FastAPI with Pydantic
- PostgreSQL
- Poetry
- Docker Compose for separated PostgreSQL and Main-App with
.env
file - Implement Makefile commands to iteraction with Docker Compose
- Implement DDD architecture, Clean Architecture with applying Clean Code, SOLID principles and Patterns
- Write docstring for class
- Implement Simple DDD Architecture with layer (Domain, Services, DTO) most like Onion Architecture
- Apply Dependency Injection for api endpoints handlers and services and Composite Pattern
- Setup Linters/Formatter and Pre-commit
- Write Tests using Pytest
- Authentication and Authorization with JWT Token
- Implement Custom Exceptions for Auth Service
- Implement Redis Cache CodeService
- Elasticsearch APM and Kibana (ELK) logging and monitoring system
- Simple DDD Architecture with layers for Business Logic and Process
- Applied SOLID Principles and OOP Patterns
- Dependency Injection container to resolve dependencies and using Base Interface classes
- Linters/Formatter and Pre-commit
- Database and Project in Docker compose and makefile to run commands in one command
- OpenAPI Docs
- Writed Unit Tests
Layers
- API (endpoint handlers)
- Domain (Entity)
- Services
- UseCases
- DTO + Repo in Service layer
- Others
Notes:
- Entity is Domain Business logic Interface and Base Class or Abstract Class
- Both Service and Repository layers implemented in Service layer
- UseCases Business Process using Services (services uses repository to get data)
- DTO (Data Transfer Object) and Repo interacts only with data
Entity is like core, Service must provide atomicity, UseCase uses Services to process something, Repository communicate with services and only interact with data, Task queue broker and Web handler communicate with Use Cases and external world, Client, Providers and Repositories communicate with Service and external world,
- Python
- Poetry(Optional)
- Docker
- GNU Make (install on windows using chocolatey package manager)
- Clone this repository
git clone https://github.com/dotpep/clean-ddd-marketplace-api.git
cd clean-marketplace
- Install all dependencies and required packages
- Change
.env.example
file to.env
with provided your environment variables
make app
- up django server containermake app-logs
- display logs of django servermake app-down
- down django server containermake storages
- up storages in separated container (then you can run django server locally)make storages-logs
- display storages logsmake storages-down
- down storage container
make postgres
- enter to postgres db interactive shell mode (psql) to perform SQL queriesmake postgres-db
- immediately go to project database interactive shell modemake ash
- enter to interactive ash shell of project app for alpine docker imagemake django-shell
- enter to django shell of project app using ipython interactive mode
make migrations
- make migrations on modelsmake migrate
- apply all migrationsmake superuser
- create admin usermake collectstatic
- collect all static files in project to base-dir static folder
make run-tests
- run django integrated database tests (requiresmake app
, run django server)