- Goal
- Repo Features
- Before Setup
- Development usage
- Production usage
- License
- Reources
- Special Thanks To
- Bugs
This project main goal is to provide an enreach starting point for mid-level to large scale projects.
-
Latest LTS Django4.2
Latest LTS included 4.2.x and needed requirements
-
Git
python gitignore and README with license
-
Docker File
Latest Python image dockerfile prod/dev and dockerignore
-
Docker Compose
Docker compose prod/dev and minimum setup for django and db included,with volumes and network
-
Nginx + Gunicorn
included nginx setup with gunicorn as serving service and file configs for production
-
Django env
enviroment sample file and setup
-
Github Actions
Pre Configurations for CI/CD in github actions. plus two step jobs for testing and deploying on vps with docker
-
Black and Flake8
Included Pep8 and Flake8 configuration file for test purposes.Reformating the codes and bring the best out of it.
-
Django Rest Framework
Included DRF package and all its dependencies along side of cors headers. plus simplejwt and jwt authentication for identity.
-
Swagger and Redoc
Allowing the urls to include rest api documentations
-
Locust
locust for api load testing
-
Seq
Seq logging for log monitoring
-
Attrs
Attrs for Dto
-
Poetry
Poetry for better dependency management
-
Tests
django-pytest and pytest-cov and factoryboy for test and test coverage
-
Redis
Redis and beat for schedules and cache
-
Integrated Response & Exceptions
integrated response and exceptions for REST
-
Djoser
Preconfigured Djoser for authentication
-
Honeypot
Honeypot admin panel to ban anyone tries to brute force into /admin
-
Preconfigured
Preconfigured settings and etc...
-
README
README.md files in all layers for more information
Note: I Highly recommend checking Resources section.
-
Read layers README.md
Every layer has it's own README.md for furture explanation
-
Change env variables in /envs to suite your project needs
/envs directory contains environment variables for database and django
- Review settings in /src/infrastructure/settings
You'll need to have Docker and Docker Compose installed. It's available on Windows, macOS and most distros of Linux.
If you're using Windows, it will be expected that you're following along inside of WSL or WSL 2.
That's because we're going to be running shell commands. You can always modify these commands for PowerShell if you want.
git clone https://github.com/alireza0sfr/Django-DRF-Clean-Architecture-Base.git
The first time you run this it's going to take 5-10 minutes depending on your internet connection speed and computer's hardware specs. That's because it's going to download a few Docker images and build the Python + requirements dependencies.
docker-compose -f docker/docker-compose.yml up --build
Now that everything is built and running we can treat it like any other Django app.
If you receive an error about a port being in use? Chances are it's because something on your machine is already running on the same port as one of the services in docker-compose. then you have to change the docker-compose.yml file according to your needs.
Visit http://localhost:port in your favorite browser.
In this phase of the project you can launch the service either in your pc/laptop to use as local host or you can setup on a vps to access through ip or even the domain which is dedicated to it.
docker-compose -f docker-compose-stage.yml up --build
In this phase of the project you can launch the project only on the vps with the domain name connect to it other than that you have to change the settings accordingly.(you can use the stage config as base for the nginx) But before that don't forget to check nginx config located at /nginx/default.conf the db. then all you need to do to build the project is to run the command bellow:
docker-compose -f docker-compose-prod.yml up --build
With special thanks to Mr.Ali Bigdeli this repo uses his security configs for more info read this.
MIT.
Clean Architecture: https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
This repository is heavily inspired by Django Clean Architecture and Ultimate Django4.2 Template repositories.
Feel free to let me know if something needs to be fixed. or even any features seems to be needed in this repo.