Skip to content
Chinonso.Ani
All case studies

Research: NHS Benchmarking backend transformation

The transformation is best described as a shift from a callback-driven Express backend on the Node 12-era stack to a typed FastAPI backend built around explicit request/response models, dependency injection, and database migrations.

Completed
Jul 2026

Project summary

The transformation is best described as a shift from a callback-driven Express backend on the Node 12-era stack to a typed FastAPI backend built around explicit request/response models, dependency injection, and database migrations.

The main architectural changes are:

  • request routing moved from hand-wired Express middleware chains to FastAPI routers that are discovered and included as typed modules;
  • input/output validation moved from ad hoc JavaScript objects and custom error handling to Pydantic models and response_model contracts;
  • persistence moved from raw SQL / stored-procedure orchestration through seriate to SQLAlchemy sessions plus Alembic-managed schema changes;
  • authentication and authorization moved from custom header parsing and callback logic to dependency-based JWT enforcement;
  • background work and email side effects became explicit background tasks instead of being embedded in route callbacks;
  • observability improved through audit middleware and SQLAlchemy listeners, rather than relying on error-prone request-scoped callback chains.

Official Docs Evidence

  • NHS Benchmarking Network - About Us - public organizational context for a benchmarking-focused health and care network. Use this as the organization-level framing, not as a source of private project details.
  • Node.js Previous Releases - Node.js 12 reached end of life in April 2022, so Node 12-era code should be described as legacy and unsupported.
  • FastAPI Dependencies - FastAPI uses dependency injection to share database sessions, authentication, and other request-scoped behavior.
  • FastAPI Background Tasks - FastAPI supports background tasks for deferred side effects such as email.
  • FastAPI First Steps / Automatic Docs - FastAPI is built around typed path operations and automatic interactive OpenAPI documentation.
  • SQLAlchemy ORM Session Basics - SQLAlchemy’s ORM is session-oriented; this supports the current app’s explicit SessionLocal pattern.
  • Alembic Tutorial / Migrations - Alembic is the standard SQLAlchemy migration layer and fits the current repo’s versioned schema workflow.

Version Note

  • Node.js 12 is past end of life as of April 2022, so the old implementation should be described as a legacy runtime era rather than a current support target.
  • The current backend repo pins Python 3.12, FastAPI 0.112.2, Pydantic 2.8.2, SQLAlchemy-related persistence tooling, and Alembic in pyproject.toml.
  • The legacy Node repo declares engines.node as ^10.0.0 in package.json, so the repository itself reflects an older Node-generation contract even though the user-facing comparison frame is Node 12.

The narrative

  1. The legacy service optimized for direct routing and operational patchwork: Express middleware, direct SQL execution, custom auth files, manually mounted routes, and mixed server/static responsibilities.
  2. The FastAPI service optimized for explicit boundaries: typed request and response models, dependency-injected DB/auth context, router discovery, schema migrations, and background task handling.
  3. The main thought shift was from “wire the next endpoint quickly” to “make every endpoint self-describing, testable, and enforceable at the boundary.”

Reusable Takeaway

The backend transformation is a boundary change: from route-driven SQL plumbing to typed FastAPI services with explicit validation, migration discipline, and dependency-managed cross-cutting concerns.

Facing a similar constraint?

Start with the operational reality - not a sales pitch. Three minutes, ten questions, a tailored read on where to begin.

Email copied to clipboard