Skip to content

Repository files navigation

CSA Validation Automation Framework

Bridging Pharmaceutical Quality & Software Test Automation

Validation Pipeline Python License: MIT FDA CSA


๐ŸŽฏ What Is This?

An open-source Python/Playwright framework that implements the FDA's Computer Software Assurance (CSA) methodology as an automated validation lifecycle.

It takes a pharmaceutical software system, classifies its features by risk, generates and executes the appropriate level of testing (scripted or unscripted), captures digital evidence, and produces a complete CSA Validation Summary Report โ€” all aligned to the FDA's final CSA guidance (September 2025).


๐Ÿ”ฌ Why Does This Matter?

The pharmaceutical industry is in the middle of a historic shift. The FDA's final CSA guidance (September 2025) formally moves the industry away from documentation-heavy Computer System Validation (CSV) toward a risk-based, critical-thinking approach.

The core idea:

Spend 80% of your effort testing, not documenting โ€” the inverse of traditional CSV.

The problem? Most pharma companies don't have the technical expertise to automate this new approach, and most QA automation engineers don't understand the pharma regulatory context.

This framework bridges that gap.


๐Ÿ—๏ธ Architecture โ€” The CSA Four-Step Framework in Code

Every module in this repository maps directly to the FDA's CSA process:

graph LR
    A["๐Ÿ“‹ Step 1<br/>Identify Intended Use<br/><code>system_inventory/</code>"] --> B["โš–๏ธ Step 2<br/>Risk Assessment<br/><code>risk_engine/</code>"]
    B --> C["๐Ÿงช Step 3<br/>Assurance Activities<br/><code>test_suites/</code>"]
    C --> D["๐Ÿ“„ Step 4<br/>Establish Record<br/><code>evidence_capture/</code><br/><code>report_generator/</code>"]
Loading
CSA Step Module What It Does
Step 1 โ€” Identify Intended Use system_inventory/ Catalogs software features, classifies direct vs. supporting use
Step 2 โ€” Risk Assessment risk_engine/ FMEA-based risk calculation โ†’ HIGH / NOT HIGH classification
Step 3a โ€” Scripted Testing test_suites/scripted/ Automated Playwright tests for HIGH-risk features
Step 3b โ€” Unscripted Testing test_suites/unscripted/ Exploratory test session logger for NOT HIGH-risk features
Step 4a โ€” Evidence Capture evidence_capture/ Digital evidence collection + ALCOA+ validation
Step 4b โ€” Report Generation report_generator/ Auto-generated Validation Summary Report (HTML/PDF)

๐ŸŽฎ Demo App โ€” The System Under Validation

The framework validates a simplified pharmaceutical Quality Management System (QMS) built with FastAPI + PostgreSQL. It simulates the kind of regulated software pharma companies actually need to validate:

Feature Risk Level Regulatory Driver
๐Ÿ” User Authentication + Roles HIGH 21 CFR Part 11 ยง11.10(d)
โœ๏ธ Electronic Signatures HIGH 21 CFR Part 11 ยง11.50, ยง11.70
๐Ÿ“ Audit Trail HIGH 21 CFR Part 11 ยง11.10(e)
โš ๏ธ Deviation Management HIGH GMP workflow integrity
๐Ÿ”ง CAPA Management NOT HIGH Supporting quality function
๐Ÿ“„ Document Control NOT HIGH Supporting quality function
๐Ÿ“Š Dashboard / Reporting NOT HIGH Informational function

๐Ÿ›ก๏ธ Recent Compliance Upgrades

  • Evidence Integrity: SHA-256 cryptographic hashing and OS metadata for all exported artifacts, ensuring strict chain of custody and preventing tampering (PIC/S PI 041).
  • Strict ALCOA+: Expanded programmatic validation to all 9 data integrity principles, with chronologically consistent timestamp checks and fail-fast CI/CD pipeline enforcement.
  • 21 CFR Part 11: Strict 15-minute JWT session timeouts, industry-standard password complexity rules, and foolproof business action attribution in the SQL ORM audit trail.
  • ICH Q9 Risk Assessment: Visible Risk Matrix terminal outputs and interactive Defect Severity classification during unscripted exploratory testing.
  • Validation Summary Report: Integrated scripted Pytest outputs alongside unscripted exploratory sessions into the final auto-generated PDF.

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.11+
  • Docker & Docker Compose
  • Git

Setup

# Clone the repository
git clone https://github.com/miltonklun/pharma-csa-framework.git
cd pharma-csa-framework

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -e ".[dev]"

# Install Playwright browsers
playwright install chromium

# Start the demo app
cd demo_app && docker-compose up -d && cd ..

# Run the full CSA validation pipeline
make validate

View Reports

# Open the generated Validation Summary Report
open report_generator/outputs/Validation_Summary_Report.pdf

# View Allure test report
allure serve allure-results/

๐Ÿ“š Pharma-to-Code Glossary

Pharma Quality Concept Software QA Equivalent Framework Module
CSA Intended Use Assessment Requirements analysis system_inventory/
Risk Assessment (FMEA / ICH Q9) Test prioritization matrix risk_engine/
GAMP Software Categories System classification risk_engine/config/
Scripted Testing (IQ/OQ/PQ) Automated Playwright tests test_suites/scripted/
Unscripted Testing (Exploratory) Exploratory test sessions test_suites/unscripted/
ALCOA+ Data Integrity Data quality assertions evidence_capture/validators/
Validation Summary Report Test execution report report_generator/
Audit Trail DB change tracking evidence_capture/
Electronic Signature Authenticated user action Demo app feature
Continuous Validation CI/CD pipeline .github/workflows/

๐Ÿ“– Full glossary: docs/glossary.md


๐Ÿ“– Regulatory References

This framework implements concepts from:

  1. FDA CSA Guidance (Sept 2025) โ€” fda.gov/media/188844/download
  2. 21 CFR Part 11 โ€” Electronic Records & Electronic Signatures
  3. EU GMP Annex 11 โ€” Computerised Systems
  4. GAMP 5 Second Edition (2022) โ€” Software Categories & Risk-Based Lifecycle
  5. PIC/S PI 041 โ€” Data Integrity Guidance (ALCOA+ Principles)
  6. ICH Q9 (R1) โ€” Quality Risk Management (FMEA Methodology)

๐Ÿ“– Detailed regulatory analysis: CSA_INFO.md


๐Ÿ—‚๏ธ Project Structure

pharma-csa-framework/
โ”œโ”€โ”€ README.md                           # This file
โ”œโ”€โ”€ CSA_INFO.md                         # Regulatory theory & reference guide
โ”œโ”€โ”€ docs/                               # Documentation
โ”‚   โ”œโ”€โ”€ glossary.md                     # Pharma โ†” Software QA mapping
โ”‚   โ”œโ”€โ”€ csa_methodology.md              # How the framework implements CSA
โ”‚   โ””โ”€โ”€ templates/                      # Validation document templates
โ”œโ”€โ”€ demo_app/                           # Target system under validation
โ”‚   โ”œโ”€โ”€ app/                            # FastAPI application
โ”‚   โ”œโ”€โ”€ Dockerfile
โ”‚   โ””โ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ system_inventory/                   # CSA Step 1: Intended Use
โ”œโ”€โ”€ risk_engine/                        # CSA Step 2: Risk Assessment
โ”œโ”€โ”€ test_suites/
โ”‚   โ”œโ”€โ”€ scripted/                       # CSA Step 3a: Automated tests
โ”‚   โ””โ”€โ”€ unscripted/                     # CSA Step 3b: Exploratory logger
โ”œโ”€โ”€ evidence_capture/                   # CSA Step 4a: Digital evidence
โ”œโ”€โ”€ report_generator/                   # CSA Step 4b: Report generation
โ”œโ”€โ”€ .github/workflows/                  # CI/CD validation pipeline
โ””โ”€โ”€ tests/                              # Unit tests for framework modules

๐Ÿ› ๏ธ Technology Stack

Component Technology
Demo App Python + FastAPI + PostgreSQL
Test Automation Playwright + pytest
Risk Engine Python + YAML configs
Evidence Capture Python + psycopg2
Report Generation Jinja2 + HTML/PDF (WeasyPrint)
CI/CD GitHub Actions
Containerization Docker + Docker Compose

โš ๏ธ Disclaimer

This framework is a learning and demonstration project. It is not intended to serve as regulatory advice or to replace professional CSV/CSA validation services. The regulatory interpretations within this project reflect the author's understanding of publicly available FDA guidance documents and industry best practices. Always consult with qualified regulatory professionals for actual validation activities.


๐Ÿ“ License

This project is licensed under the MIT License.


Author

Milton Klun
QA Automation Engineer | AI Quality Testing

LinkedInEmailLive Site

About

FDA CSA-compliant test automation framework. Built with Python and Playwright to automate pharmaceutical risk assessments, ALCOA+ evidence capture, and 21 CFR Part 11 validation workflows.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages