Skip to content

NHS RAP Cookiecutter Template

Project Status: Active Python: 3.10 | 3.11 | 3.12 | 3.13 Cookiecutter Checks Deploy Docs Code Style: Ruff pre-commit

A Cookiecutter template for creating standardised NHS England Reproducible Analytical Pipeline (RAP) projects.


Overview

This template provides a standardised project structure for developing Reproducible Analytical Pipelines within NHS England. It includes pre-configured tooling for testing, linting, documentation, and dependency management following modern Python development practices.

What you get:

  • Standardised structure following RAP principles
  • Pre-configured tooling for testing, linting, and formatting
  • Multiple environment options (uv, conda, poetry, virtualenv, etc.)
  • NHS-branded documentation ready to customise
  • Security scanning with gitleaks pre-commit hook
  • Flexible configuration for different project needs

What is RAP?

Reproducible Analytical Pipelines (RAP) is a set of tools, principles, and techniques to help you improve your analytical processes. With RAP, you leverage open-source tools to make your work more efficient, more reusable, and less error-prone.

Learn more at the NHS RAP Community of Practice.

Core RAP Principles:

Principle Description
Automation Minimise manual, error-prone steps. Automate data retrieval, processing, and output generation.
Modular, reusable code Write code in independent, loosely-coupled functions that can be tested and reused.
Transparency Publish code openly under appropriate licences to improve trust and collaboration.
Open-source tools Use Python, R, SQL, and other freely available languages instead of proprietary software.
Version control Use Git to track changes, enable collaboration, and maintain an audit trail.
Good coding practices Follow standards like PEP8, write clear documentation, and use logical project structures.
Testing Implement automated tests to ensure reliability and catch errors early.
Peer review Review code collaboratively to ensure quality, accuracy, and adherence to standards.

Installation

This package is not published to PyPI. Install directly from GitHub:

pipx (recommended for CLI tools):

pipx install git+https://github.com/nhsengland/nhse-rap-cookiecutter.git

See the pipx documentation for installation instructions.

uv:

uv tool install git+https://github.com/nhsengland/nhse-rap-cookiecutter.git

See the uv documentation for installation instructions.

pip:

pip install git+https://github.com/nhsengland/nhse-rap-cookiecutter.git

Quick Start

Using the CLI:

nhs-rap-template

Using cookiecutter directly:

cookiecutter gh:nhsengland/nhse-rap-cookiecutter

Configuration Options

The template prompts for the following:

Category Option Description Choices
Project project_name Human-readable project name Text
repo_name Repository name (default: lowercase project_name with underscores) Text
module_name Python module name (default: repo_name with dashes converted to underscores) Text
description Brief project description Text
author_name Your full name Text
author_email Your email address Text
organization_name Your organisation name (default: NHS England) Text
team_name Your team name Text
team_email Team contact email Text
git_hosting_platform Git hosting platform github, gitlab, azure_devops, other
repository_url Repository URL (can override default) Text
Python python_version_number Minimum Python version 3.10, 3.11, 3.12, 3.13
environment_manager Virtual environment tool uv, virtualenv, conda, pipenv, pixi, poetry, none
Options include_code_scaffold Include example code modules Yes, No
linting_and_formatting Code quality tools ruff, flake8+black+isort
open_source_license Project licence MIT, Apache-2.0, GPL-3.0, No license file
docs Documentation tool mkdocs, none

Generated Project Structure

your-project/
├── data/
│   ├── external/        # Data from third-party sources
│   ├── interim/         # Intermediate transformed data
│   ├── processed/       # Final canonical datasets
│   └── raw/             # Original immutable data
├── docs/                # MkDocs documentation with NHS styling
├── models/              # Trained models and predictions
├── notebooks/           # Jupyter notebooks for exploration
├── references/          # Data dictionaries and documentation
├── reports/
│   └── figures/         # Generated graphics
├── scripts/             # Setup and utility scripts
│   └── setup_repository.py  # Automated repository setup
├── tests/
│   ├── unittests/       # Unit tests (pytest)
│   └── e2e/             # End-to-end integration tests
├── your_module/         # Source code package
│   ├── __init__.py
│   ├── config.py        # Configuration management
│   ├── dataset.py       # Data loading and processing
│   ├── features.py      # Feature engineering
│   ├── plots.py         # Visualisation functions
│   └── modeling/
│       ├── train.py     # Model training
│       └── predict.py   # Model inference
├── .env                 # Environment variables (not tracked in git)
├── .pre-commit-config.yaml  # Pre-commit hooks configuration
├── badges.toml          # Optional project badges
├── CODE_OF_CONDUCT.md   # Community guidelines
├── LICENSE              # Project license
├── LICENSE-OGL          # Open Government License for docs
├── Makefile             # Convenience commands
├── mkdocs.yml           # Documentation configuration
├── OPEN_CODE_CHECKLIST.md  # NHS England standards for publishing code
├── README.md
├── pyproject.toml       # Project configuration and dependencies
└── setup.cfg            # Legacy tool configuration (flake8 only)

Each directory serves a specific purpose in the RAP workflow. The structure follows data science best practices while accommodating NHS-specific requirements.


Next Steps


Licence

Unless stated otherwise, the codebase is released under the MIT Licence. This covers both the codebase and any sample code in the documentation.

HTML and Markdown documentation is © Crown copyright and available under the terms of the Open Government 3.0 licence.

Acknowledgements

This template is based on Cookiecutter Data Science, adapted for NHS England RAP standards and modern Python tooling.