Skip to content

🐍 A repository showcasing clean and modular project architecture for scalable and maintainable Django backend applications.

License

Notifications You must be signed in to change notification settings

Shavkatjon-O/django-architecture

Repository files navigation

Django-Architecture

License Python Version Django

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.


πŸ“ Project Structure

.
β”œβ”€β”€ 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

πŸš€ Features

  • Modular Design: Clearly separates application modules into apps, services, and utils.
  • Environment-Based Configuration: Supports base, develop, and production 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.

πŸ› οΈ Installation and Setup

Prerequisites

  • Python 3.8+
  • Docker and Docker Compose
  • Git

Local Development Setup

  1. Clone the repository:

    git clone https://github.com/Shavkatjon-O/Django-Architecture.git
    cd Django-Architecture
  2. Set up the virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
  3. Install dependencies:

    pip install -r requirements/develop.txt
  4. Run migrations:

    python manage.py migrate
  5. Start the development server:

    python manage.py runserver

Dockerized Setup

  1. Build and start the containers:

    docker-compose -f docker-compose-develop.yml up --build
  2. Access the application:

    Visit http://localhost:8000 in your browser.


🧩 Modules

Core

Contains project-wide settings, configurations, and URLs. The settings directory allows for environment-specific configurations (base.py, develop.py, production.py).

Apps

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.

Services

A service layer for business logic, keeping your models and views clean and focused.

Utils

Shared utilities, reusable helpers, and custom scripts.


πŸ“¦ Deployment

  1. Production Build:

    docker-compose -f docker-compose-production.yml up --build
  2. Gunicorn Server: The gunicorn_conf.py provides optimized configurations for production.


πŸ§ͺ Testing

Run all tests with:

python manage.py test

Ensure proper code quality with pre-commit:

pre-commit run --all-files

πŸ›‘οΈ License

This project is licensed under the MIT License. See the LICENSE file for details.


🀝 Contributing

Contributions are welcome! Please fork the repository and submit a pull request for any bug fixes or enhancements.


πŸ“„ Related Resources


✨ Acknowledgements

Thanks to all contributors and the Django community for making this possible!

Releases

No releases published

Packages

No packages published

Languages