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:
- Biological — bacteria, viruses, parasites, toxins
- Chemical — pesticide residues, mycotoxins (aflatoxin), heavy metals, cleaning chemicals, adulterants
- Physical — glass, metal, stones, plastic, bone
- Allergens — milk, egg, peanut, tree nuts, wheat/gluten, soy, fish, shellfish, sesame
- Plus food fraud — adulteration and mislabelling for economic gain
HACCP — 7 principles
After assembling a team, describing the product and verifying the flow diagram:
- 1. Conduct hazard analysis
- 2. Determine critical control points (decision tree)
- 3. Establish critical limits (e.g. ≥ 75 °C core, metal ≤ 2 mm Fe)
- 4. Establish monitoring procedures
- 5. Establish corrective actions
- 6. Establish verification procedures
- 7. Establish documentation and records
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
- Acceptance probability (binomial):
P_a = Σ_{i≤c} C(n,i)·pⁱ(1−p)^(n−i) - Zero-acceptance plan:
P_a = (1 − p)ⁿ - Risk:
Risk = likelihood × severity - Sample size to detect:
n = ln(1 − confidence)/ln(1 − p)
Worked example: Acceptance probability
Given: n = 5, c = 0, p = 10%
Find: P_a.
- 0.9⁵
Answer: 0.59
Worked example: Samples to detect
Given: Detect 1% contamination with 95% confidence
Find: n.
- ln(0.05)/ln(0.99)
Answer: 299 samples
Worked example: Risk score
Given: Likelihood 3/5, severity 5/5
Find: Risk.
- 3 × 5
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 OKTesting 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
- Wrong: Relying on end-product testing. — Right: Control the process with HACCP and prerequisites.
- Wrong: Too many CCPs. — Right: CCPs only where control is essential and measurable.
- Wrong: Undeclared allergens from cross-contact. — Right: Allergen matrix, segregation, cleaning validation, labelling.
Applications
- Food factories: HACCP plans and FSSC 22000 certification.
- Restaurants & catering: FSSAI hygiene rating, cooking and holding controls.
- Exports: Meeting EU/US import requirements (aflatoxin, residues).
- Recalls: Traceability to limit scope and harm.
Key takeaways
- Biological, chemical, physical hazards + allergens.
- HACCP's 7 principles on top of prerequisites.
- Sampling plans have limited power.
- Traceability, verification and culture matter.
Going further
- Quantitative risk assessment: Dose–response and exposure modelling.
- Whole-genome sequencing: Outbreak source tracking.
- Food fraud vulnerability: VACCP and TACCP assessments.