This repository implements a Django application following the principles of Clean Architecture and Domain-Driven Design (DDD). It serves as a practical example of how to structure a robust and maintainable application.
- 🧭 Product
- ⚙️ Functional
- 🏗️ Architecture/
- 📘 Architecture Decision Records (ADR)
- 🚀 Operations
- 🧪 Testing
- 🤝 Contributing
Clone the repository.
git clone [email protected]:tyronejosee/project_marketly.git
cd project_marketly💡 We recommend using uv for this project. It is a fast, modern Python package manager that handles dependency resolution, virtual environments, and installs with superior performance and safety.
Install the project dependencies.
uv syncCreate a copy of the .env.example file and rename it to .env.
cp .env.example .envUpdate the values of the environment variables (Important).
💡 Make sure to correctly configure your variables before building the container.
Build your container; it will take time the first time, as Docker needs to download all dependencies and build the image.
Use the -d (detached mode) flag to start your containers in the background.
Use the --build flag if you have changes and need to rebuild.
docker compose up
docker compose up -d
docker compose up --buildStop the running containers (does not remove them).
docker compose stopStart previously created and stopped containers.
docker compose startShow container logs in real-time.
docker compose logs -fRestart a service with issues (Replace <service_name>).
docker compose restart <service_name>Remove your container.
docker compose downAccess the web service console that runs Django.
docker compose exec web bashInside the Django console, create the migrations.
python manage.py makemigrationsRun the migrations.
python manage.py migrateIf you need to be more specific, use:
python manage.py migrate <app_label> <migration_name>List all available migrations and their status.
python manage.py showmigrations💡 Manually create the migration if Django skips an app; this happens because Django did not find the
/migrationsfolder.
Create a superuser to access the entire site without restrictions.
python manage.py createsuperuserLog in to admin:
http://127.0.0.1:8000/admin/Access Swagger or Redoc.
http://127.0.0.1:8000/api/schema/swagger/
http://127.0.0.1:8000/api/schema/redoc/Check the creation of migrations before creating them.
docker compose exec web python manage.py makemigrations users💡 Checking migrations before their creation is necessary to avoid inconsistencies in user models.
Access the PostgreSQL console.
docker compose exec db psql -U postgres -d fandomhub_dbList all the tables in the database.
\dtShow the detailed structure of a specific table.
\d <table_name>Create a backup of your database (Optional).
docker compose exec web python manage.py dumpdata > backup.jsonLoad the created backup if needed (Optional).
docker compose exec web python manage.py loaddataRun all tests.
pytestRun tests for a specific domain.
pytest tests/<domain>Run unit tests for a specific domain (with coverage).
pytest tests/<domain> -o addopts="--cov=src/modules/<domain> --cov-report=term-missing"This project is under the MIT License.
Enjoy! 🎉