CyberHuginn

Home

/

Notes

/

building-django-healthkit-01-setup

Building a Django Package — Part 1: Setting Up django-healthkit

In this part, we build the initial structure of django-healthkit, configure the package with pyproject.toml, and prepare it for development.

Django

Packages

OpenSource

Python

Aug 14, 2026 · 4 min read

In this series, we are going to build a real Django package called django-healthkit and eventually publish it to PyPI.

In this first part, we will create the project from scratch, set up its structure, configure the package, and prepare it for development.

Prerequisites

To follow this tutorial, you should have a basic understanding of:

  • Python
  • Django
  • pip
  • Python virtual environments
  • Git
  • Basic Python package development concepts

We will use Python 3.10 or newer throughout this tutorial.

Creating the Project

First, create a directory for the project:

mkdir django-healthkit
cd django-healthkit

Then create a virtual environment:

python -m venv .venv

Activate the virtual environment.

On Linux and macOS:

source .venv/bin/activate

On Windows:

.venv\\Scripts\\activate

Installing Django

Install Django as a development dependency:

pip install "Django>=4.2"

Project Structure

Now create the initial project structure:

django-healthkit/
├── src/
│   └── django_healthkit/
│       ├── __init__.py
│       ├── apps.py
│       └── migrations/
│           └── __init__.py
├── tests/
├── .gitignore
├── LICENSE
├── README.md
└── pyproject.toml

We are using the src layout.

The package source code lives inside src/django_healthkit/, while tests are kept in a separate tests/ directory.

Creating the Django App

Create apps.py with the following content:

from django.apps import AppConfig


class DjangoHealthkitConfig(AppConfig):
    default_auto_field = "django.db.models.BigAutoField"
    name = "django_healthkit"

The __init__.py file makes django_healthkit a Python package.

Creating .gitignore

Create a .gitignore file in the project root:

.venv/

__pycache__/
*.py[cod]

*.egg-info/
build/
dist/

.pytest_cache/
.coverage
htmlcov/

.DS_Store

This prevents virtual environments, Python cache files, build artifacts, and other temporary files from being committed to Git.

Creating pyproject.toml

Now we get to one of the most important files in the project.

The pyproject.toml file contains the configuration required to build the package and defines its metadata and dependencies.

For the initial django-healthkit release, create the following file:

[build-system]
requires = ["setuptools>=61"]
build-backend = "setuptools.build_meta"


[project]
name = "django-healthkit"
version = "0.1.0"
description = "Health checks for Django applications"
readme = "README.md"
requires-python = ">=3.10"

dependencies = [
    "Django>=4.2",
]

There are several important fields here.

The name field defines the package name that will eventually be published to PyPI:

name = "django-healthkit"

We are starting with version 0.1.0:

version = "0.1.0"

We also specify that Django is required by the package:

dependencies = [
    "Django>=4.2",
]

We will add more metadata and configuration to this file in the following parts.

Creating README.md

Create a README.md file in the project root:

We will expand the README later with documentation and usage examples.

Installing the Package in Editable Mode

Now that the initial structure is ready, install the package in editable mode:

pip install -e .

The -e option, also known as an Editable Install, allows changes to the package source code to be used immediately during development without reinstalling the package after every change.

We can verify that Python can import the package:

python -c "import django_healthkit; print(django_healthkit)"

If Python prints the package path, the package has been installed successfully.

Creating the First Commit

The project is now ready to be initialized as a Git repository:

git init
git add .
git commit -m "chore: initialize django-healthkit package"

At this point, we have not implemented any health checks yet.

The goal of this first part was to create a standard, installable, and maintainable Django package that is ready for further development.

In the next part, we will design the internal structure of django-healthkit and implement our first health checks.

Related Notes

The API Worked. The Architecture Didn’t.

A practical look at why a working API does not always mean a healthy architecture, covering coupling, synchronous work, database bottlenecks, caching, microservices, failure modes, and the importance of clear boundaries.

When Redis Is Not the Solution

Redis is fast and extremely useful, but that doesn't make it the right solution for every backend problem. A practical look at when Redis helps with caching, rate limiting, OTPs, locks, queues, sessions, and temporary data—and when it simply adds unnecessary infrastructure and complexity.

Django Transactions: What atomic() Actually Protects

Learn how Django transactions work, what transaction.atomic() actually protects, and how to handle race conditions, row locking, database constraints, nested transactions, and post-commit side effects with select_for_update() and on_commit().

The Hidden Cost of Django REST Framework Serializers

Learn how Django REST Framework serializers can cause N+1 queries, slow API responses, and unnecessary database work—and how to optimize them with select_related, prefetch_related, annotations, and better serializer design.

Building a Django Package — Part 4: Publishing django-healthkit to PyPI

In this final part, we prepare django-healthkit for release, build and validate the package, test it on TestPyPI, publish it to PyPI, and create a Git tag and GitHub release.

Building a Django Package — Part 3: Health Check Manager and Endpoint

In Part 3, we connect the database and cache health checks, build the health check manager, expose a Django health endpoint, measure check latency, and return a structured health status.

Building a Django Package — Part 2: Database and Cache Health Checks

In this part, we implement the first health checks for django-healthkit, covering database connectivity and Django cache functionality with simple, independent, and testable checks.

Building a Secure Webhook Receiver for Server-to-Server Communication

How I built a secure FastAPI webhook receiver using RSA signatures to enable authenticated server-to-server communication, proxy requests, and connect applications across different network environments.

Why I Switched to Conventional Git Commit Messages

Why I switched from inconsistent Git commit messages to a Conventional Commits style, with practical examples for cleaner and more maintainable Git history.

Building django-healthkit

How a simple health endpoint for Bidar turned into django-healthkit, a lightweight Django health-check package.

Designing a Gold Jewelry E-Commerce Database with Django

Learn how to design a scalable Django database for a gold jewelry e-commerce platform by modeling products, attributes, and purchasable product variants using real-world domain-driven design principles.

How to Fix Common Next.js 16 Build Errors (Proxy, Dynamic Rendering & Revalidation)

Learn how to fix common Next.js 16 build errors, understand Proxy, Dynamic Rendering, and Revalidation, and improve your application's SEO and performance.

Why I Built cyber-ui: A Minimal Design System for Developers

How my projects, from backend systems to monitoring tools, led me to create a minimal and personal UI foundation.

End of note.