Food Safety, Quality Assurance & HACCP

Making sure every pack is safe and consistent. Learn food hazards (biological, chemical, physical, allergens), prerequisite programmes (GMP, GHP, pest control, sanitation), HACCP's 7 principles with hazard analysis, CCPs, critical limits and monitoring, food safety management systems (ISO 22000, FSSC 22000, BRCGS), FSSAI regulations and labelling, sampling plans and operating characteristic curves, microbiological criteria, traceability and recalls, and food fraud — with Python for acceptance probability and CCP monitoring.

Food safety is non-negotiable: contaminated food causes hundreds of millions of illnesses a year worldwide. Quality assurance adds consistency — the same taste, texture and composition every time.

Modern systems prevent problems through controlled processes (HACCP) rather than relying on end-product testing, which can never catch every defect.

An analogy

HACCP is like airport security: instead of checking every passenger after the plane lands (end testing), you set specific checkpoints (CCPs) where threats are reliably stopped, with clear limits and actions when something goes wrong.

Food hazards

Four types:

HACCP — 7 principles

After assembling a team, describing the product and verifying the flow diagram:

Prerequisites and management systems

HACCP rests on prerequisite programmes: hygienic premises and equipment design, cleaning and sanitation, pest control, personal hygiene, water quality, supplier approval, allergen management, training. Management systems: ISO 22000/FSSC 22000, BRCGS, SQF; in India, FSSAI licensing, Schedule 4 hygiene requirements, and product standards and labelling regulations (including front-of-pack and allergen declarations).

Sampling, traceability and food safety culture

Sampling plans (ICMSF two- and three-class) have OC curves showing acceptance probability vs defect level; detecting rare contamination requires very large samples. Environmental monitoring (Listeria swabs), rapid methods (PCR, ATP bioluminescence), metal detectors and X-ray inspection, lot coding and one-step-forward/one-step-back traceability, mock recalls, and blockchain traceability. Food safety culture — leadership and employee behaviour — is now an explicit requirement in GFSI standards.

Formulas

Worked example: Acceptance probability

Given: n = 5, c = 0, p = 10%

Find: P_a.

Answer: 0.59

Worked example: Samples to detect

Given: Detect 1% contamination with 95% confidence

Find: n.

Answer: 299 samples

Worked example: Risk score

Given: Likelihood 3/5, severity 5/5

Find: Risk.

Answer: 15 — high, control as CCP

Sampling plan OC values and CCP monitoring

from math import comb
# Two-class sampling plan (n = 10, c = 0): probability of accepting a lot vs defect rate
n, c = 10, 0
for p in (0.01, 0.05, 0.10, 0.20):
    Pa = sum(comb(n, i) * p**i * (1 - p)**(n - i) for i in range(c + 1))
    print(f"defect rate {p:.0%}: probability of acceptance {Pa:.3f}")
# HACCP critical limit monitoring for a cooking CCP (core temp >= 75 C)
readings = [78.2, 76.5, 74.1, 79.0, 75.3]
for i, t in enumerate(readings, 1):
    status = "OK" if t >= 75.0 else "DEVIATION -> corrective action (re-cook, hold)"
    print(f"batch {i}: {t:.1f} C {status}")
# defect rate 1%: probability of acceptance 0.904
# defect rate 5%: probability of acceptance 0.599
# defect rate 10%: probability of acceptance 0.349
# defect rate 20%: probability of acceptance 0.107
# batch 1: 78.2 C OK
# batch 2: 76.5 C OK
# batch 3: 74.1 C DEVIATION -> corrective action (re-cook, hold)
# batch 4: 79.0 C OK
# batch 5: 75.3 C OK

Testing 10 samples accepts a lot with 5% contaminated units 60% of the time — end-product testing is weak at detecting low defect rates. That is why HACCP controls the process: every batch's core temperature is checked against the critical limit, and deviations trigger defined corrective actions and records.

Common mistakes

Applications

Key takeaways

Going further