Sidewinder Django Starter Kit

repository·master·Indexed 42 days ago

https://github.com/stribny/sidewinder

An opinionated Django starter kit (v0.2.0) designed to accelerate development and simplify VPS deployment. It features a pre-configured stack including GeoDjango, Django REST Framework, django-allauth, Huey for task queuing, and uv for dependency management. Includes Ansible-based deployment, a testing stack with pytest and Playwright, and Docker Compose orchestration for Redis and MailHog.

Tokens
6.7K
Snippets
27
Records
40
Agent score
53%

What's inside Sidewinder

  1. Overview of Sidewinder Django Starter Kit

    master

    Sidewinder is an opinionated Django starter kit designed for rapid development and deployment, specifically optimized for single Virtual Private Server (VPS) environments. It provides a pre-configured project structure, development tools, and deployment automation to help developers (such as indie hackers and students) move from project start to production quickly.

    Key focus areas:

    • Developer Experience: Includes linting, formatting, auto-reloading, and debugging tools.
    • Deployment: Ready for VPS deployment using Ansible, Caddy, and Gunicorn on Fedora.
    • Modern Tooling: Uses uv for dependency management and django-environ for configuration.
  2. Core features and included technologies in Sidewinder

    master

    Sidewinder comes pre-configured with a robust set of technologies to handle common web application requirements:

    • Core Framework: Django (including GeoDjango support) with a custom User model for flexibility.
    • Dependency Management: Uses uv for modern Python dependency management.
    • Configuration: Uses environment variables instead of multiple configuration files.
    • Authentication: django-allauth for email-based and 3rd party authentication.
    • API Development: Django REST Framework (DRF) with modern API docs, standardized error responses, and CORS configuration.
    • Task Queue: Huey for background and periodic tasks.
    • Testing Stack: pytest for unit testing, factoryboy and Faker for test fixtures, and Playwright for end-to-end frontend testing.
    • Logging: Structured logging support.
    • Deployment: Ansible-based deployment to a VPS, including built-in commands for backups and restores.
  3. Database migration considerations during deployment

    master

    The deployment process automatically runs database migrations. To avoid breaking the application, ensure that new application versions are always compatible with the existing database schema.

    Best Practice: Always move migrations forward. Do not attempt to roll back to previous versions if they are incompatible with the current database schema state.

  4. Sidewinder Core Features and Tech Stack

    master

    Sidewinder comes pre-configured with several industry-standard libraries across different layers of the application:

    Configuration & Auth

    • Dependency Management: uv
    • Environment Variables: django-environ
    • GeoDjango: Pre-configured support
    • Authentication: Custom User model, django-allauth (email/3rd party), and argon2-cffi for password hashing.

    API & Frontend

    • REST APIs: Django REST Framework with token authentication.
    • API Documentation: drf-spectacular (OpenAPI) and drf-standardized-errors.
    • CORS: django-cors-headers (restricted to API endpoints).
    • Frontend: Bring your own CSS; basic styling for auth/example pages is included.

    Background Tasks

    • Task Queue: huey for background and periodic tasks.
    • Monitoring: django-huey-monitor integrated into Django admin.

    Development & Testing

    • Linting/Formatting: ruff, pre-commit, and bandit (security).
    • Debugging: django-debug-toolbar, django-silk (profiling), snoop, and django-extensions (shell_plus).
    • Testing: pytest (with pytest-django, pytest-xdist, etc.), factoryboy (fixtures), Faker (data), and Playwright (E2E).
  5. Deploy a specific application version

    master

    To deploy a version other than the default master branch, set the APP_VERSION environment variable to a valid Git identifier (such as a branch name, tag, or commit hash) when running the make deploy command.

    # inside deployment/ansible 
    APP_VERSION="v1.0" make deploy
  6. Install developer tooling and dependencies

    master

    While uv run automatically handles standard dependencies, certain development tools require manual installation steps in the project's root directory.

    Install pre-commit hooks

    To enable automated git hooks via pre-commit:

    uv run -- pre-commit install

    Install Playwright

    To install the necessary browser binaries for Playwright:

    uv run -- playwright install
    # Install pre-commit hooks
    uv run -- pre-commit install
    
    # Install Playwright
    uv run -- playwright install
  7. Provision a server for Sidewinder

    master

    To deploy Sidewinder, you must first obtain a Virtual Private Server (VPS).

    Requirements:

    • Operating System: You must choose Fedora Linux as the OS distribution.
    • Access: Ensure you have a working SSH connection to the server.
    • Network: The server should have a static IP address. If using a custom domain with HTTPS, ensure the domain points to your VPS IP.

    It is recommended to use a provider like Digital Ocean that allows pre-configuring the VPS with your public SSH key.

  8. Deploy Sidewinder to a VPS

    master

    Sidewinder is designed for one-click-style deployment to a single Virtual Private Server (VPS) using an Ansible playbook.

    Deployment Specifications:

    • Operating System: Fedora
    • Database: PostgreSQL
    • Reverse Proxy: Caddy
    • WSGI Server: Gunicorn
    • Process Management: systemd services
    • Capabilities: Includes provided backup and restore commands.
  9. Create a new project from the Sidewinder template

    master
    Sidewinder is designed to be used as a GitHub template. To start a new project without previous commit history or links to the original repository, go to the Sidewinder repository homepage on GitHub and click the "Use this template" button. This creates a clean repository for your own use.