A repository showcasing a clean and modular project architecture for scalable and maintainable Django backend applications. This structure is designed to promote best practices, enhance readability, and ensure maintainability for long-term projects.
.
βββ apps
β βββ common # Shared components such as utilities and common models
β βββ users # User-related modules
β βββ __init__.py
βββ bin # Scripts for project setup and management
βββ compose
β βββ django # Docker configuration for Django
βββ core # Core settings and configurations
β βββ settings # Environment-specific settings
β βββ asgi.py, wsgi.py, urls.py
βββ docker-compose-* # Docker Compose configurations for development and production
βββ gunicorn_conf.py # Gunicorn server configuration
βββ requirements # Dependency management
βββ services # Service layer for encapsulating business logic
βββ utils # Utility functions and helpers
βββ manage.py # Django management script
- Modular Design: Clearly separates application modules into
apps
,services
, andutils
. - Environment-Based Configuration: Supports
base
,develop
, andproduction
settings for flexible deployment. - Dockerized Development: Includes Docker and Docker Compose for containerized development and production environments.
- Pre-Commit Hooks: Ensures code quality with pre-configured pre-commit checks.
- Scalability: Architecture designed for large and scalable Django projects.
- Gunicorn Integration: Optimized production server configuration with Gunicorn.
- Python 3.8+
- Docker and Docker Compose
- Git
-
Clone the repository:
git clone https://github.com/Shavkatjon-O/Django-Architecture.git cd Django-Architecture
-
Set up the virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements/develop.txt
-
Run migrations:
python manage.py migrate
-
Start the development server:
python manage.py runserver
-
Build and start the containers:
docker-compose -f docker-compose-develop.yml up --build
-
Access the application:
Visit
http://localhost:8000
in your browser.
Contains project-wide settings, configurations, and URLs. The settings
directory allows for environment-specific configurations (base.py
, develop.py
, production.py
).
Each app encapsulates a specific functionality or feature of the project. Example apps:
common
: Shared utilities and base models.users
: User management, authentication, and profile handling.
A service layer for business logic, keeping your models and views clean and focused.
Shared utilities, reusable helpers, and custom scripts.
-
Production Build:
docker-compose -f docker-compose-production.yml up --build
-
Gunicorn Server: The
gunicorn_conf.py
provides optimized configurations for production.
Run all tests with:
python manage.py test
Ensure proper code quality with pre-commit:
pre-commit run --all-files
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please fork the repository and submit a pull request for any bug fixes or enhancements.
Thanks to all contributors and the Django community for making this possible!