markdown
Project: My Django E-commerce Platform
Workflow Definition Goal
The goal of this prompt is to establish a clear, end-to-end development and deployment workflow for a Django project using a modern, declarative toolchain. The workflow must cover local development environment setup, code quality checks, testing, and deployment automation to a live server.
Technologies and Tools
- Operating System (Local/Dev): NixOS with Nix flakes (for reproducible environments)
- Environment Management:
direnv(automatic environment loading) - Package Management (Python):
uv(for lightning-fast dependency management and isolation) - Configuration File:
pyproject.toml(central source of truth for dependencies and tool configs) - Python/Django Versions: Python 3.12+, Django 5.0+, Django REST Framework, Django Ninja, Django Oscar, Django Waffle, Django CRM, Django Allauth, Django Haystack with Whoosh.
- Code Quality Tools:
ruff(linter)ruff-format(formatter)djlint(Django template linter/formatter)
- Version Control Integration:
pre-commithooks (enforce quality locally)coderabbit(AI-powered code review assistant for GitHub)
- CI/CD (Deployment):
- GitHub Actions (
.github/workflows/deploy.yml) - Deployment target: Linode VPS (Ubuntu)
- Server stack: Apache2 and uWSGI
- Deployment script:
project_manager.sh project_name deploy
- GitHub Actions (
Workflow Stages
1. Local Environment Setup (Nix + direnv)
- Define the structure for
flake.nixandflake.lockto create a reproducible development shell. - The
nix developshell must provide all necessary system dependencies (e.g., Python interpreter, database libraries) and integrate withdirenv. - When a developer enters the project directory,
direnvshould automatically load the Nix-defined environment. - Use
uvwithin this environment to manage the Python dependencies specified inpyproject.toml.
2. Dependency Management and pyproject.toml
- All project dependencies (production, development, testing) are managed exclusively in
pyproject.toml. - The workflow requires generating a locked
requirements.txtfile specifically for the deployment phase usinguv pip freeze(or similaruvcommand) based on thepyproject.tomldefinition. This file must be fresh for every deployment.
3. Local Code Quality and Testing
- Configure
pre-committo run automatically before every commit. - The hooks must execute:
ruff(linting)ruff-format(code formatting)djlint(template linting)
- Define how Django unit tests are run locally using
manage.py testand specify that tests must pass before a pull request can be merged.
4. Continuous Integration (CI) and Code Review
- Describe the use of
coderabbitto automatically review code quality and adherence to standards in GitHub pull requests. - The CI pipeline should mirror the local quality checks (ruff, djlint, tests).
5. Deployment Process (GitHub Actions to Linode VPS)
- The
deploy.ymlGitHub Actions workflow is triggered on pushes to the main branch. - The workflow steps must include:
- Checkout the repo.
- Set up the Nix environment (if running in self-hosted runner, otherwise just run commands).
- Generate the fresh
requirements.txtusinguv. - SSH into the Linode Ubuntu VPS.
- Execute the remote deployment script:
./project_manager.sh project_name deploy.
- The deployment script handles environment synchronization (e.g.,
pip install -r requirements.txt), static file collection, database migrations, and restarting theuwsgiservice viasystemctl.
Prompt to the AI Assistant
"Based on the 'Workflow Definition Goal' and 'Technologies and Tools' provided above, generate a detailed, step-by-step guide and accompanying configuration file snippets for a developer to implement this exact workflow. The response should provide:
flake.nixanddirenvconfiguration examples.- A robust
pyproject.tomltemplate including all specified dependencies and tool configurations (ruff,djlint). - A
.pre-commit-config.yamlfile. - The structure for the
.github/workflows/deploy.ymlGitHub Actions file. - A high-level outline of the
project_manager.shdeployment script logic.
The instructions must be clear, actionable, and prioritize the use of uv and nix as the foundational environment tools."