Skip to content

brunodantas/cosmic-django

Repository files navigation

cosmic-django

CI Test Matrix Code Quality Python 3.13+ Django 5.2+ uv

Example project applying the patterns from Cosmic Python by Harry Percival and Bob Gregory. This project demonstrates how to build maintainable, testable Django applications using Domain-Driven Design principles while leveraging Django's strengths.

📖 Read the full post: Cosmic Django

✨ Features

  • Domain modeling plus helper functions
  • No Repository Pattern
  • Service Layer Pattern
  • Atomic transactions
  • Design by contract
  • Event-driven architecture with signals
  • Command-query responsibility segregation

🚀 Quick Start

Prerequisites

  • Python 3.11+
  • uv package manager

Installation

# Clone the repository
git clone https://github.com/brunodantas/cosmic-django.git
cd cosmic-django

# Install dependencies
make install dev-install

# Set up the database (sqlite)
make migrate

# Run tests to verify installation
make test

# Start development server
make runserver

🛠️ Development

Commands

The project includes a Makefile for development tasks.

📊 Dependency Visualization

Generate and view the project's dependency graph.

Needs to uncomment the imports from this init file beforehand.

# Generate dependency graph
pydeps cosmic/__init__.py

Dependency Graph

📚 Learning Resources

📄 License

This project is licensed under the GPL License - see the LICENSE file for details.