Recognize drug classifications and their mechanisms of action

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Finding Sources
Finding Sources
Finding Sources
I've reached my database query limit. I have enough from the library and my own knowledge to give you a thorough, authoritative answer. Let me compile a comprehensive guide to drug classifications and their mechanisms of action.

Drug Classifications and Their Mechanisms of Action

Drug classifications organize medications by their chemical structure, therapeutic use, or - most usefully for clinical practice - their mechanism of action (how they interact with biological targets to produce effects). Below is a systematic overview of the major drug classes across body systems.

1. How Drugs Work: Core Mechanisms

Before classifying drugs, understanding the four fundamental mechanisms helps frame everything else:
MechanismDescriptionExamples
Receptor agonismBinds receptor and activates it (mimics endogenous ligand)Morphine at opioid receptors, albuterol at β2
Receptor antagonismBinds receptor and blocks it without activatingPropranolol at β-adrenoceptors, naloxone at opioid receptors
Enzyme inhibitionBlocks an enzyme's catalytic activityACE inhibitors, statins, MAO inhibitors
Ion channel modulationOpens or blocks ion channelsLocal anesthetics, calcium channel blockers, benzodiazepines
Transporter inhibitionBlocks reuptake or active transportSSRIs (serotonin reuptake), thiazides (Na/Cl cotransporter)
DNA/RNA interferenceIntercalates DNA or inhibits nucleic acid synthesisAntibiotics (fluoroquinolones), anticancer agents
  • Katzung's Basic and Clinical Pharmacology, 16e

2. Cardiovascular Drugs

Antihypertensives

ClassMechanismExamples
ACE InhibitorsBlock angiotensin-converting enzyme → less angiotensin II → vasodilation, less aldosteroneLisinopril, enalapril, ramipril
ARBsBlock AT1 receptor for angiotensin II directlyLosartan, valsartan, irbesartan
Beta-blockers (β-blockers)Competitively block β1 (and β2) adrenergic receptors → reduced HR, CO, renin releaseMetoprolol, atenolol, carvedilol
Calcium channel blockers (CCBs)Block L-type voltage-gated Ca²⁺ channels in cardiac/vascular smooth muscle → vasodilationAmlodipine (dihydropyridine), verapamil, diltiazem
Thiazide diureticsInhibit Na⁺/Cl⁻ cotransporter in distal convoluted tubuleHydrochlorothiazide, chlorthalidone
Aldosterone antagonistsBlock mineralocorticoid receptorSpironolactone, eplerenone
Alpha-1 blockersBlock α1-adrenoceptors in arterioles → vasodilationPrazosin, doxazosin
Direct vasodilatorsOpen K⁺ channels (minoxidil) or release NO (hydralazine)Hydralazine, minoxidil

Antiarrhythmics (Vaughan Williams Classification)

ClassMechanismExamples
Class INa⁺ channel blockers (slow conduction)Ia: quinidine, procainamide; Ib: lidocaine, mexiletine; Ic: flecainide, propafenone
Class IIβ-blockers (reduce automaticity, slow AV conduction)Metoprolol, esmolol, propranolol
Class IIIK⁺ channel blockers (prolong repolarization/QT)Amiodarone, sotalol, dofetilide
Class IVCa²⁺ channel blockers (slow SA/AV node)Verapamil, diltiazem
Misc.Adenosine - activates IKAdo → hyperpolarization; Digoxin - inhibits Na⁺/K⁺-ATPaseAdenosine, digoxin

Antilipid Agents

ClassMechanismExamples
Statins (HMG-CoA reductase inhibitors)Inhibit the rate-limiting step of cholesterol synthesis → upregulate LDL receptorsAtorvastatin, rosuvastatin, simvastatin
PCSK9 inhibitorsMonoclonal antibodies that block PCSK9 protein → prevent LDL receptor degradationEvolocumab, alirocumab
EzetimibeBlocks Niemann-Pick C1L1 transporter in intestinal brush border → less cholesterol absorptionEzetimibe
FibratesActivate PPARα → increased lipoprotein lipase, reduced TG synthesisFenofibrate, gemfibrozil
Bile acid sequestrantsBind bile acids in gut → interrupt enterohepatic circulation, upregulate LDL receptorsCholestyramine, colesevelam

3. Drugs Acting on the Nervous System

Analgesics

ClassMechanismExamples
OpioidsAgonists at μ, κ, δ opioid receptors (Gi-coupled) → ↓ adenylyl cyclase, ↓ Ca²⁺ influx, ↑ K⁺ efflux → analgesiaMorphine, fentanyl, codeine, tramadol
NSAIDsInhibit COX-1 and/or COX-2 enzymes → ↓ prostaglandin synthesisIbuprofen, naproxen, diclofenac
Selective COX-2 inhibitorsSelectively inhibit COX-2 (induced isoform) → fewer GI side effectsCelecoxib
Paracetamol (acetaminophen)Central COX inhibition + activation of descending serotonergic pathways (exact mechanism debated)Paracetamol
Triptans5-HT1B/1D receptor agonists → vasoconstriction of cranial vessels, inhibition of trigeminal nociceptionSumatriptan, rizatriptan

Antidepressants

ClassMechanismExamples
SSRIsSelectively inhibit serotonin reuptake transporter (SERT)Fluoxetine, sertraline, escitalopram
SNRIsInhibit both SERT and norepinephrine transporter (NET)Venlafaxine, duloxetine
TCAsInhibit NET and SERT; also block H1, muscarinic, α1 receptorsAmitriptyline, imipramine, nortriptyline
MAO inhibitorsIrreversibly inhibit MAO-A/B → increased monoamine availabilityPhenelzine, tranylcypromine
NaSSAsBlock α2 autoreceptors (↑ NE/5-HT release) + 5-HT2A/5-HT3 antagonismMirtazapine
BupropionInhibits dopamine and norepinephrine reuptake (NDRI)Bupropion

Antipsychotics

ClassMechanismExamples
Typical (First-generation)Primarily D2 receptor antagonistsHaloperidol, chlorpromazine, fluphenazine
Atypical (Second-generation)D2 antagonism + 5-HT2A antagonism (broader receptor profile)Olanzapine, quetiapine, risperidone
Partial agonistsPartial agonist at D2 and 5-HT1A; antagonist at 5-HT2AAripiprazole, brexpiprazole, cariprazine
  • Kaplan & Sadock's Comprehensive Textbook of Psychiatry

Anxiolytics/Sedatives

ClassMechanismExamples
BenzodiazepinesPositive allosteric modulators of GABAA receptor → ↑ Cl⁻ influx frequencyDiazepam, lorazepam, alprazolam
BarbituratesAlso potentiate GABAA but increase Cl⁻ channel open duration (more dangerous)Phenobarbital, thiopental
BuspironePartial 5-HT1A agonist; no GABA activityBuspirone
Z-drugsBind GABAA BZ site but are non-benzodiazepine in structureZolpidem, zaleplon, zopiclone

Antiepileptics

ClassMechanismExamples
Na⁺ channel blockersStabilize inactivated state of voltage-gated Na⁺ channelsPhenytoin, carbamazepine, valproate, lamotrigine
GABA potentiationEnhance GABAergic inhibitionValproate (↑ GABA synthesis), vigabatrin (GABA-T inhibitor), tiagabine (blocks GABA reuptake)
Ca²⁺ channel blockersBlock T-type Ca²⁺ channels in thalamusEthosuximide (absence seizures)
SV2A modulatorsBind synaptic vesicle glycoprotein 2A → inhibit neurotransmitter releaseLevetiracetam, brivaracetam
AMPA antagonistsBlock AMPA glutamate receptorsPerampanel

4. Antimicrobials

Antibiotics

ClassMechanismExamples
Beta-lactamsInhibit transpeptidases (PBPs) → prevent peptidoglycan cross-linking → cell wall synthesis disruptionPenicillins, cephalosporins, carbapenems, monobactams
GlycopeptidesBind D-Ala-D-Ala terminus of peptidoglycan precursors → block transglycosylationVancomycin, teicoplanin
AminoglycosidesIrreversibly bind 30S ribosomal subunit (16S rRNA) → misreading/premature terminationGentamicin, amikacin, tobramycin
TetracyclinesReversibly bind 30S ribosome → block aminoacyl-tRNA attachmentDoxycycline, minocycline, tetracycline
MacrolidesBind 50S ribosome (23S rRNA) → block translocationAzithromycin, erythromycin, clarithromycin
FluoroquinolonesInhibit DNA gyrase (topoisomerase II) and topoisomerase IV → prevent DNA replication/repairCiprofloxacin, levofloxacin, moxifloxacin
SulfonamidesCompetitive inhibitor of dihydropteroate synthase → block folate synthesisSulfamethoxazole (used with trimethoprim)
TrimethoprimInhibits dihydrofolate reductase (DHFR) → block folate synthesis (different step)TMP-SMX (co-trimoxazole)
MetronidazoleReduced to cytotoxic nitroso intermediates that damage DNAMetronidazole
LinezolidBinds 50S + 30S junction → inhibits 70S initiation complex formationLinezolid, tedizolid

Antivirals

ClassMechanismExamples
Nucleoside reverse transcriptase inhibitors (NRTIs)Incorporated into viral DNA → chain termination (lack 3'-OH group)Zidovudine, tenofovir, emtricitabine
Non-NRTIs (NNRTIs)Bind allosteric site on reverse transcriptase (non-competitive)Efavirenz, nevirapine, rilpivirine
Protease inhibitorsBlock HIV protease → prevent polyprotein cleavage → non-infectious virionsRitonavir, darunavir, lopinavir
Integrase inhibitorsBlock HIV integrase → prevent integration into host genomeRaltegravir, dolutegravir, bictegravir
Neuraminidase inhibitorsBlock influenza neuraminidase → prevent new virion release from cellsOseltamivir (Tamiflu), zanamivir
Acyclovir classNucleoside analogues (phosphorylated by viral thymidine kinase) → inhibit viral DNA polymeraseAcyclovir, valacyclovir, ganciclovir

Antifungals

ClassMechanismExamples
AzolesInhibit CYP51 (lanosterol 14α-demethylase) → block ergosterol synthesisFluconazole, itraconazole, voriconazole
PolyenesBind directly to ergosterol → form pores in fungal membraneAmphotericin B, nystatin
EchinocandinsInhibit β-1,3-glucan synthase → disrupt fungal cell wallCaspofungin, micafungin, anidulafungin
AllylaminesInhibit squalene epoxidase → block ergosterol synthesis (earlier step than azoles)Terbinafine

5. Endocrine/Metabolic Drugs

Antidiabetics

ClassMechanismExamples
InsulinBinds insulin receptor (tyrosine kinase) → GLUT4 translocation, anabolic effectsRegular, NPH, glargine, lispro
Metformin (biguanide)Activates AMPK, inhibits mitochondrial Complex I → reduces hepatic glucose outputMetformin
SulfonylureasBlock ATP-sensitive K⁺ channels on β cells → depolarization → insulin releaseGlibenclamide, glipizide, gliclazide
GLP-1 receptor agonistsBind GLP-1R → ↑ insulin secretion (glucose-dependent), ↓ glucagon, slow gastric emptyingSemaglutide, liraglutide, exenatide
DPP-4 inhibitorsBlock dipeptidyl peptidase-4 → prevent degradation of endogenous GLP-1 and GIPSitagliptin, saxagliptin, linagliptin
SGLT2 inhibitorsBlock Na⁺-glucose cotransporter 2 in proximal tubule → glucosuriaEmpagliflozin, dapagliflozin, canagliflozin
ThiazolidinedionesActivate PPARγ nuclear receptor → improve insulin sensitivityPioglitazone, rosiglitazone

Thyroid Drugs

ClassMechanismExamples
ThionamidesInhibit thyroid peroxidase → block T3/T4 synthesis; propylthiouracil also blocks T4→T3 conversionMethimazole, propylthiouracil (PTU)
Thyroid hormoneReplace or supplement T3/T4; bind nuclear thyroid hormone receptorsLevothyroxine (T4), liothyronine (T3)

6. Respiratory Drugs

ClassMechanismExamples
Short-acting β2-agonists (SABAs)Activate β2-adrenoceptors → Gs → cAMP → bronchial smooth muscle relaxationAlbuterol (salbutamol), terbutaline
Long-acting β2-agonists (LABAs)Same mechanism, longer durationSalmeterol, formoterol
Inhaled corticosteroids (ICS)Bind glucocorticoid receptor → suppress inflammatory gene transcriptionBudesonide, fluticasone, beclomethasone
Muscarinic antagonists (SAMA/LAMA)Block M3 receptors in bronchial muscle → bronchodilationIpratropium (SAMA), tiotropium, umeclidinium (LAMA)
Leukotriene receptor antagonistsBlock CysLT1 receptors → reduce bronchoconstriction, mucus, inflammationMontelukast, zafirlukast
PDE4 inhibitorsInhibit phosphodiesterase-4 → ↑ cAMP → anti-inflammatoryRoflumilast (for COPD)
Anti-IgEBinds free IgE → prevents IgE-mediated mast cell activationOmalizumab

7. Anticancer Drugs

ClassMechanismExamples
Alkylating agentsCross-link DNA strands → prevent replicationCyclophosphamide, cisplatin, carboplatin
AntimetabolitesStructural analogues that interfere with DNA/RNA synthesisMethotrexate (DHFR inhibitor), 5-FU (thymidylate synthase), cytarabine (DNA chain termination)
Topoisomerase inhibitorsInhibit topoisomerase I (camptothecins) or II (anthracyclines)Irinotecan, doxorubicin, etoposide
Vinca alkaloidsBind tubulin → prevent microtubule polymerization → mitotic arrestVincristine, vinblastine
TaxanesStabilize microtubules → prevent depolymerization → mitotic arrestPaclitaxel, docetaxel
Tyrosine kinase inhibitors (TKIs)Block aberrant kinase signaling (e.g. BCR-ABL, EGFR)Imatinib (BCR-ABL), erlotinib (EGFR), lapatinib (HER2)
mTOR inhibitorsBlock mTOR kinase → inhibit cell growth/proliferationEverolimus, temsirolimus
VEGF pathwayAnti-VEGF antibody → block tumor angiogenesisBevacizumab
Immune checkpoint inhibitorsBlock PD-1/PD-L1 or CTLA-4 → restore T-cell anti-tumor immunityPembrolizumab, nivolumab (anti-PD-1); atezolizumab (anti-PD-L1); ipilimumab (anti-CTLA-4)
Hormone therapyBlock androgen/estrogen receptor or synthesisTamoxifen (SERM), aromatase inhibitors, enzalutamide (AR antagonist)

8. Gastrointestinal Drugs

ClassMechanismExamples
Proton pump inhibitors (PPIs)Irreversibly inhibit H⁺/K⁺-ATPase on parietal cells → suppress gastric acidOmeprazole, pantoprazole, lansoprazole
H2 receptor antagonistsBlock H2 receptors on parietal cells → reduce acid secretionRanitidine, famotidine, cimetidine
AntacidsChemically neutralize HCl in stomach (not enzyme/receptor based)Al(OH)3, Mg(OH)2
5-HT3 antagonistsBlock 5-HT3 receptors on vagal afferents → antiemeticOndansetron, granisetron
NK1 antagonistsBlock substance P at NK1 receptors in brainstem → antiemeticAprepitant
ProkineticsDopamine D2 antagonism ± 5-HT4 agonism → increase GI motilityMetoclopramide, domperidone

9. Anticoagulants and Antiplatelets

ClassMechanismExamples
HeparinsActivate antithrombin III → rapidly inhibits thrombin (IIa) and Factor XaUFH, LMWH (enoxaparin, dalteparin)
Vitamin K antagonistsBlock VKORC1 → deplete Factors II, VII, IX, X, Protein C/SWarfarin, acenocoumarol
Direct thrombin inhibitorsDirectly inhibit thrombin (Factor IIa) without antithrombinDabigatran (oral), bivalirudin (parenteral)
Direct Factor Xa inhibitorsDirectly block Factor XaRivaroxaban, apixaban, edoxaban
AspirinIrreversibly acetylates COX-1 → ↓ TXA2 → reduced platelet aggregationAspirin
ADP receptor blockers (P2Y12)Block P2Y12 purinergic receptor → ↓ ADP-mediated platelet activationClopidogrel, ticagrelor, prasugrel
GP IIb/IIIa inhibitorsBlock fibrinogen binding to activated plateletsAbciximab, eptifibatide, tirofiban

10. Immunosuppressants

ClassMechanismExamples
Calcineurin inhibitorsInhibit calcineurin → block IL-2 transcription → suppress T-cell activationCyclosporine, tacrolimus
mTOR inhibitorsInhibit mTOR signaling → block T-cell proliferation response to IL-2Sirolimus (rapamycin), everolimus
AntimetabolitesInhibit de novo purine synthesis → block lymphocyte proliferationAzathioprine, mycophenolate mofetil
GlucocorticoidsBind GR → suppress NF-κB and AP-1 → broad anti-inflammatory/immunosuppressive effectPrednisolone, methylprednisolone
Biologics (anti-TNF)Block TNF-α → reduce inflammationInfliximab, adalimumab, etanercept

Summary: Drug Target Categories

Drug Targets
├── Receptors (GPCRs, ion channel-linked, enzyme-linked, nuclear)
│   ├── Agonists → activate the receptor
│   ├── Antagonists → block the receptor
│   └── Partial agonists → submaximal activation
├── Enzymes
│   ├── Competitive inhibitors (reversible)
│   └── Irreversible inhibitors (e.g., aspirin, PPIs)
├── Ion Channels
│   ├── Blockers (Na⁺, Ca²⁺, K⁺ channels)
│   └── Modulators (GABA-A positive allosteric modulators)
├── Transporters
│   └── Inhibitors (SSRIs, SGLT2i, loop diuretics)
└── Nucleic Acids / Cell wall synthesis
    └── Direct DNA damage, enzyme inhibition of synthesis

Key sources: Katzung's Basic and Clinical Pharmacology 16e, Goodman & Gilman's Pharmacological Basis of Therapeutics, Lippincott Illustrated Reviews: Pharmacology, Goldman-Cecil Medicine, Harrison's Principles of Internal Medicine 22e.

Create a quick reference PDF of major drug classes by system

Reading File
Running Command

ls /home/daytona/workspace/ 2>/dev/null && echo "---" && python3 -c "import repo…

Running Command

mkdir -p /home/daytona/workspace/drug-reference

Writing File

~/drug-reference/build_pdf.py

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT
from reportlab.platypus import BaseDocTemplate, Frame, PageTemplate

OUTPUT = "/home/daytona/workspace/drug-reference/Drug_Classes_Quick_Reference.pdf"

# ─── Colour palette ───────────────────────────────────────────────────────────
NAVY    = colors.HexColor("#1B3A5C")
TEAL    = colors.HexColor("#1A7A8A")
LBLUE   = colors.HexColor("#D6EAF8")
MINT    = colors.HexColor("#D1F2EB")
LEMON   = colors.HexColor("#FEF9E7")
LAVEN   = colors.HexColor("#EBE6F5")
SALMON  = colors.HexColor("#FDECEA")
PEACH   = colors.HexColor("#FEF3E7")
WHITE   = colors.white
LGRAY   = colors.HexColor("#F2F3F4")
DGRAY   = colors.HexColor("#5D6D7E")
BLACK   = colors.black

# ─── System colour map ────────────────────────────────────────────────────────
SYS_COLORS = {
    "Cardiovascular":    (colors.HexColor("#154360"), colors.HexColor("#D6EAF8")),
    "Nervous System":    (colors.HexColor("#1B5E20"), colors.HexColor("#D5F5E3")),
    "Antimicrobials":    (colors.HexColor("#6E2F0A"), colors.HexColor("#FDEBD0")),
    "Endocrine":         (colors.HexColor("#4A235A"), colors.HexColor("#F5EEF8")),
    "Respiratory":       (colors.HexColor("#1A5276"), colors.HexColor("#D6EAF8")),
    "Anticancer":        (colors.HexColor("#7B241C"), colors.HexColor("#FDEDEC")),
    "GI":                (colors.HexColor("#0E6655"), colors.HexColor("#D0ECE7")),
    "Anticoag/Platelet": (colors.HexColor("#784212"), colors.HexColor("#FDEBD0")),
    "Immunosuppressants":(colors.HexColor("#283747"), colors.HexColor("#D6DBDF")),
}

# ─── Styles ───────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()

def make_style(name, parent="Normal", **kwargs):
    return ParagraphStyle(name, parent=styles[parent], **kwargs)

cover_title = make_style("CoverTitle", fontSize=32, textColor=WHITE,
                         alignment=TA_CENTER, fontName="Helvetica-Bold", leading=38)
cover_sub   = make_style("CoverSub",   fontSize=14, textColor=colors.HexColor("#A9CCE3"),
                         alignment=TA_CENTER, fontName="Helvetica", leading=20)
cover_date  = make_style("CoverDate",  fontSize=10, textColor=colors.HexColor("#85C1E9"),
                         alignment=TA_CENTER, fontName="Helvetica")

sys_heading = make_style("SysHeading", fontSize=13, textColor=WHITE,
                         fontName="Helvetica-Bold", leading=16, spaceAfter=0, spaceBefore=0)
cls_name    = make_style("ClsName",    fontSize=9,  textColor=NAVY,
                         fontName="Helvetica-Bold", leading=12)
moa_text    = make_style("MoaText",    fontSize=8,  textColor=colors.HexColor("#2C3E50"),
                         fontName="Helvetica", leading=11)
eg_text     = make_style("EgText",     fontSize=7.5,textColor=DGRAY,
                         fontName="Helvetica-Oblique", leading=10)
note_text   = make_style("NoteText",   fontSize=7,  textColor=colors.HexColor("#7F8C8D"),
                         fontName="Helvetica", leading=9)
toc_style   = make_style("TocStyle",   fontSize=10, textColor=NAVY,
                         fontName="Helvetica", leading=16)
toc_heading = make_style("TocHeading", fontSize=14, textColor=NAVY,
                         fontName="Helvetica-Bold", leading=20, spaceAfter=6)
footer_sty  = make_style("Footer",     fontSize=7,  textColor=DGRAY,
                         fontName="Helvetica", alignment=TA_CENTER)

# ─── Drug data ────────────────────────────────────────────────────────────────
DRUG_DATA = {
    "Cardiovascular": [
        ("ACE Inhibitors",
         "Inhibit angiotensin-converting enzyme → ↓ angiotensin II → vasodilation + ↓ aldosterone",
         "Lisinopril, Enalapril, Ramipril, Perindopril"),
        ("ARBs (Angiotensin Receptor Blockers)",
         "Block AT1 receptor → vasodilation (angiotensin II still formed but cannot act)",
         "Losartan, Valsartan, Irbesartan, Candesartan"),
        ("Beta-Blockers (β-blockers)",
         "Competitive antagonism at β1 (± β2) adrenoceptors → ↓ HR, ↓ CO, ↓ renin release",
         "Metoprolol, Atenolol, Bisoprolol, Carvedilol, Propranolol"),
        ("Calcium Channel Blockers (CCBs)",
         "Block L-type voltage-gated Ca²⁺ channels → vasodilation (dihydropyridines) / ↓ nodal conduction (non-DHP)",
         "Amlodipine, Nifedipine (DHP); Verapamil, Diltiazem (non-DHP)"),
        ("Thiazide Diuretics",
         "Inhibit Na⁺/Cl⁻ cotransporter (NCC) in distal convoluted tubule → ↑ NaCl excretion",
         "Hydrochlorothiazide, Chlorthalidone, Indapamide"),
        ("Loop Diuretics",
         "Inhibit Na⁺/K⁺/2Cl⁻ cotransporter (NKCC2) in thick ascending loop of Henle",
         "Furosemide, Bumetanide, Torsemide"),
        ("Aldosterone Antagonists",
         "Block mineralocorticoid receptor → ↓ Na⁺ reabsorption, K⁺-sparing",
         "Spironolactone, Eplerenone, Finerenone"),
        ("Statins (HMG-CoA Reductase Inhibitors)",
         "Inhibit HMG-CoA reductase → ↓ cholesterol synthesis → upregulate hepatic LDL receptors",
         "Atorvastatin, Rosuvastatin, Simvastatin, Pravastatin"),
        ("PCSK9 Inhibitors",
         "Monoclonal antibodies blocking PCSK9 → prevent LDL receptor degradation → ↓↓ LDL",
         "Evolocumab, Alirocumab"),
        ("Antiarrhythmics – Class I (Na⁺ blockers)",
         "Ia: ↓ conduction + prolong APD (quinidine). Ib: shorten APD (lidocaine). Ic: ↓↓ conduction (flecainide)",
         "Ia: Quinidine, Procainamide; Ib: Lidocaine, Mexiletine; Ic: Flecainide, Propafenone"),
        ("Antiarrhythmics – Class III (K⁺ blockers)",
         "Block K⁺ channels → prolong repolarisation and QT interval",
         "Amiodarone, Sotalol, Dofetilide, Ibutilide"),
        ("Digoxin",
         "Inhibits Na⁺/K⁺-ATPase → ↑ intracellular Ca²⁺ → ↑ contractility; vagal tone ↑ → ↓ AV conduction",
         "Digoxin"),
        ("Nitrates",
         "Metabolised to NO → activate guanylyl cyclase → ↑ cGMP → vascular smooth muscle relaxation",
         "GTN (nitroglycerin), Isosorbide mononitrate/dinitrate"),
        ("SGLT2 Inhibitors (cardiac/renal)",
         "Block SGLT2 in proximal tubule → glucosuria; reduce preload/afterload, cardioprotective",
         "Empagliflozin, Dapagliflozin, Canagliflozin"),
    ],
    "Nervous System": [
        ("Opioid Analgesics",
         "Agonists at μ (mu), κ (kappa), δ (delta) opioid receptors (Gi-coupled) → ↓ cAMP, ↓ Ca²⁺ influx, ↑ K⁺ efflux → analgesia",
         "Morphine, Fentanyl, Oxycodone, Codeine, Tramadol, Buprenorphine"),
        ("NSAIDs",
         "Non-selective inhibition of COX-1 and COX-2 → ↓ prostaglandin synthesis → analgesia, antipyresis, anti-inflammation",
         "Ibuprofen, Naproxen, Diclofenac, Ketorolac"),
        ("Selective COX-2 Inhibitors",
         "Selectively inhibit inducible COX-2 → ↓ prostaglandins with fewer GI effects (COX-1 spared)",
         "Celecoxib, Etoricoxib"),
        ("SSRIs (Antidepressants)",
         "Selectively inhibit serotonin reuptake transporter (SERT) → ↑ synaptic serotonin",
         "Fluoxetine, Sertraline, Escitalopram, Paroxetine, Citalopram"),
        ("SNRIs (Antidepressants)",
         "Inhibit both SERT and norepinephrine transporter (NET) → ↑ synaptic 5-HT and NE",
         "Venlafaxine, Duloxetine, Desvenlafaxine"),
        ("TCAs (Tricyclic Antidepressants)",
         "Inhibit NET and SERT; also block H1, muscarinic M1, α1 receptors → multiple side effects",
         "Amitriptyline, Imipramine, Nortriptyline, Clomipramine"),
        ("MAO Inhibitors",
         "Irreversibly inhibit monoamine oxidase A/B → ↑ NE, 5-HT, dopamine at synapse",
         "Phenelzine, Tranylcypromine; Moclobemide (reversible MAO-A)"),
        ("Typical Antipsychotics",
         "Primarily D2 dopamine receptor antagonists → block mesolimbic pathway (antipsychotic) + nigrostriatal (EPS)",
         "Haloperidol, Chlorpromazine, Fluphenazine, Trifluoperazine"),
        ("Atypical Antipsychotics",
         "D2 antagonism + 5-HT2A antagonism (and other receptors) → antipsychotic with lower EPS risk",
         "Olanzapine, Quetiapine, Risperidone, Aripiprazole, Clozapine"),
        ("Benzodiazepines",
         "Positive allosteric modulators of GABAA receptors → ↑ frequency of Cl⁻ channel opening → CNS depression",
         "Diazepam, Lorazepam, Clonazepam, Alprazolam, Midazolam"),
        ("Antiepileptics – Na⁺ Channel Blockers",
         "Stabilise inactivated state of voltage-gated Na⁺ channels → prevent repetitive firing",
         "Phenytoin, Carbamazepine, Lamotrigine, Oxcarbazepine, Valproate"),
        ("Antiepileptics – SV2A Modulators",
         "Bind synaptic vesicle glycoprotein 2A → modulate neurotransmitter release",
         "Levetiracetam, Brivaracetam"),
        ("Levodopa / Dopamine Agonists",
         "Levodopa: precursor converted to dopamine in CNS. DA agonists: directly stimulate D2/D3 receptors",
         "Levodopa + Carbidopa; Pramipexole, Ropinirole, Rotigotine"),
        ("Acetylcholinesterase Inhibitors",
         "Inhibit AChE → ↑ acetylcholine at cholinergic synapses (central and peripheral)",
         "Donepezil, Rivastigmine, Galantamine (dementia); Neostigmine (NMJ)"),
    ],
    "Antimicrobials": [
        ("Beta-Lactams (Penicillins / Cephalosporins / Carbapenems)",
         "Inhibit transpeptidases (PBPs) → prevent peptidoglycan cross-linking → cell wall synthesis failure → bactericidal",
         "Amoxicillin, Flucloxacillin; Cefazolin, Ceftriaxone; Meropenem, Ertapenem"),
        ("Glycopeptides",
         "Bind D-Ala-D-Ala terminus of peptidoglycan precursors → block transglycosylation and transpeptidation",
         "Vancomycin, Teicoplanin"),
        ("Aminoglycosides",
         "Irreversibly bind 30S ribosomal subunit (16S rRNA) → misreading of mRNA → premature termination → bactericidal",
         "Gentamicin, Amikacin, Tobramycin, Streptomycin"),
        ("Tetracyclines",
         "Reversibly bind 30S ribosome → block aminoacyl-tRNA entry at A site → bacteriostatic",
         "Doxycycline, Minocycline, Tetracycline, Tigecycline"),
        ("Macrolides",
         "Bind 50S ribosome (23S rRNA) at peptidyl transferase site → block translocation → bacteriostatic",
         "Azithromycin, Clarithromycin, Erythromycin"),
        ("Fluoroquinolones",
         "Inhibit DNA gyrase (topoisomerase II) and topoisomerase IV → prevent DNA replication and repair → bactericidal",
         "Ciprofloxacin, Levofloxacin, Moxifloxacin, Norfloxacin"),
        ("Sulfonamides + Trimethoprim",
         "Sulfonamides: inhibit dihydropteroate synthase. TMP: inhibits DHFR. Both block folate synthesis at sequential steps",
         "Sulfamethoxazole-Trimethoprim (Co-trimoxazole / TMP-SMX)"),
        ("Metronidazole",
         "Reduced to cytotoxic nitroso free-radical intermediates inside anaerobic/microaerophilic organisms → DNA strand breaks",
         "Metronidazole, Tinidazole"),
        ("Oxazolidinones",
         "Bind 50S+30S junction → prevent 70S initiation complex formation → inhibit protein synthesis",
         "Linezolid, Tedizolid"),
        ("NRTIs (Antiretrovirals)",
         "Nucleoside/nucleotide analogues incorporated into viral DNA → chain termination (lack 3'-OH group)",
         "Zidovudine (AZT), Tenofovir (TDF/TAF), Emtricitabine, Lamivudine, Abacavir"),
        ("NNRTIs (Antiretrovirals)",
         "Bind allosteric pocket on HIV reverse transcriptase (non-competitive) → conformational change → enzyme inactivation",
         "Efavirenz, Nevirapine, Rilpivirine, Doravirine"),
        ("HIV Protease Inhibitors",
         "Block HIV aspartyl protease → prevent polyprotein cleavage → immature, non-infectious virions",
         "Ritonavir, Darunavir, Lopinavir, Atazanavir"),
        ("HIV Integrase Inhibitors",
         "Block HIV integrase strand transfer → prevent integration of viral DNA into host genome",
         "Raltegravir, Dolutegravir, Bictegravir, Cabotegravir"),
        ("Antifungals – Azoles",
         "Inhibit fungal CYP51 (lanosterol 14α-demethylase) → ↓ ergosterol synthesis → membrane disruption",
         "Fluconazole, Itraconazole, Voriconazole, Posaconazole"),
        ("Antifungals – Polyenes",
         "Bind directly to ergosterol in fungal membrane → pore formation → ion leakage → fungicidal",
         "Amphotericin B, Nystatin"),
        ("Antifungals – Echinocandins",
         "Inhibit β-1,3-glucan synthase → disrupt fungal cell wall synthesis → fungicidal for Candida",
         "Caspofungin, Micafungin, Anidulafungin"),
        ("Neuraminidase Inhibitors (Influenza)",
         "Block influenza neuraminidase → prevent cleavage of sialic acid → inhibit viral release from cells",
         "Oseltamivir (Tamiflu), Zanamivir, Baloxavir (different MOA: cap-dependent endonuclease inhibitor)"),
    ],
    "Endocrine": [
        ("Insulin",
         "Binds insulin receptor (receptor tyrosine kinase) → GLUT4 translocation → glucose uptake; anabolic effects on fat, protein",
         "Rapid: Lispro, Aspart, Glulisine; Short: Regular; Inter: NPH; Long: Glargine, Detemir, Degludec"),
        ("Metformin (Biguanide)",
         "Activates AMPK; inhibits mitochondrial Complex I → ↓ hepatic gluconeogenesis; does not cause hypoglycaemia",
         "Metformin"),
        ("Sulfonylureas",
         "Block ATP-sensitive K⁺ channels (KATP) on β-cells → membrane depolarisation → Ca²⁺ influx → insulin secretion",
         "Glibenclamide, Glipizide, Gliclazide, Glimepiride"),
        ("GLP-1 Receptor Agonists",
         "Bind GLP-1R (Gs-coupled) → ↑ glucose-dependent insulin secretion, ↓ glucagon, slow gastric emptying, ↓ appetite",
         "Semaglutide, Liraglutide, Dulaglutide, Exenatide, Tirzepatide (dual GLP-1/GIP)"),
        ("DPP-4 Inhibitors (Gliptins)",
         "Block dipeptidyl peptidase-4 enzyme → prevent degradation of endogenous GLP-1 and GIP → modest incretin enhancement",
         "Sitagliptin, Saxagliptin, Linagliptin, Alogliptin"),
        ("SGLT2 Inhibitors (metabolic)",
         "Block Na⁺-glucose cotransporter 2 in proximal tubule → glucosuria → ↓ plasma glucose; weight loss, BP reduction",
         "Empagliflozin, Dapagliflozin, Canagliflozin, Ertugliflozin"),
        ("Thiazolidinediones (TZDs)",
         "Activate PPARγ nuclear receptor → regulate adipokine and glucose transporter gene expression → ↑ insulin sensitivity",
         "Pioglitazone, Rosiglitazone"),
        ("Levothyroxine",
         "Replaces/supplements T4 → converted peripherally to T3 → binds nuclear thyroid hormone receptors → regulate metabolism",
         "Levothyroxine (T4); Liothyronine (T3)"),
        ("Thionamides (Antithyroid)",
         "Inhibit thyroid peroxidase → block T3/T4 synthesis. PTU also blocks T4→T3 peripheral conversion",
         "Methimazole, Carbimazole, Propylthiouracil (PTU)"),
        ("Glucocorticoids",
         "Bind intracellular GR → translocate to nucleus → suppress NF-κB, AP-1 → broad anti-inflammatory and immunosuppressive",
         "Prednisolone, Dexamethasone, Hydrocortisone, Methylprednisolone, Budesonide"),
    ],
    "Respiratory": [
        ("Short-Acting β2-Agonists (SABA)",
         "Activate β2-adrenoceptors → Gs → ↑ cAMP → PKA activation → smooth muscle relaxation → bronchodilation (rapid onset)",
         "Albuterol (Salbutamol), Terbutaline, Levalbuterol"),
        ("Long-Acting β2-Agonists (LABA)",
         "Same mechanism as SABA; lipophilic tail anchors in membrane → prolonged receptor engagement (12–24 h duration)",
         "Salmeterol, Formoterol, Indacaterol, Vilanterol"),
        ("Short-Acting Muscarinic Antagonists (SAMA)",
         "Block M3 muscarinic receptors on bronchial smooth muscle → prevent ACh-induced bronchoconstriction",
         "Ipratropium bromide"),
        ("Long-Acting Muscarinic Antagonists (LAMA)",
         "Same mechanism as SAMA; selectively dissociate from M3 slowly (kinetically selective) → 24 h bronchodilation",
         "Tiotropium, Umeclidinium, Glycopyrronium, Aclidinium"),
        ("Inhaled Corticosteroids (ICS)",
         "Bind GR → suppress inflammatory gene transcription → ↓ cytokines, ↓ eosinophil infiltration → reduce airway inflammation",
         "Budesonide, Fluticasone, Beclomethasone, Ciclesonide, Mometasone"),
        ("Leukotriene Receptor Antagonists (LTRA)",
         "Block CysLT1 receptors → prevent leukotriene-mediated bronchoconstriction, mucus secretion, eosinophil recruitment",
         "Montelukast, Zafirlukast"),
        ("PDE4 Inhibitors",
         "Inhibit phosphodiesterase-4 → ↑ cAMP in inflammatory cells → anti-inflammatory; used in COPD",
         "Roflumilast"),
        ("Anti-IgE Biologic",
         "Binds free IgE → prevents IgE binding to mast cell FcεRI receptors → inhibit mast cell degranulation",
         "Omalizumab"),
        ("Anti-IL-5 / IL-4/13 Biologics",
         "IL-5 blockade: ↓ eosinophil survival/recruitment. IL-4/13 blockade: ↓ Th2 inflammation, ↓ IgE, ↓ mucus",
         "Mepolizumab, Benralizumab (anti-IL-5); Dupilumab (anti-IL-4Rα/IL-13)"),
    ],
    "Anticancer": [
        ("Alkylating Agents",
         "Form covalent bonds with DNA → intra/inter-strand cross-links → prevent replication and transcription → apoptosis",
         "Cyclophosphamide, Ifosfamide, Cisplatin, Carboplatin, Oxaliplatin, Dacarbazine"),
        ("Antimetabolites – Folate Antagonists",
         "Inhibit dihydrofolate reductase (DHFR) → ↓ THF → impair thymidylate and purine synthesis",
         "Methotrexate, Pemetrexed"),
        ("Antimetabolites – Pyrimidine Analogues",
         "5-FU: inhibit thymidylate synthase + incorporated into RNA. Cytarabine: incorporated into DNA → chain termination",
         "5-Fluorouracil (5-FU), Capecitabine (prodrug of 5-FU), Cytarabine, Gemcitabine"),
        ("Topoisomerase Inhibitors",
         "Topo I inhibitors (camptothecins): stabilise Topo I-DNA complex → single-strand breaks. Topo II inhibitors: stabilise cleavable complex → double-strand breaks",
         "Irinotecan, Topotecan (Topo I); Doxorubicin, Etoposide, Epirubicin (Topo II)"),
        ("Vinca Alkaloids",
         "Bind β-tubulin → inhibit tubulin polymerisation → prevent spindle formation → metaphase arrest → apoptosis",
         "Vincristine, Vinblastine, Vinorelbine"),
        ("Taxanes",
         "Bind and stabilise polymerised microtubules → prevent depolymerisation → disrupt spindle dynamics → cell death",
         "Paclitaxel, Docetaxel, Nab-paclitaxel, Cabazitaxel"),
        ("Tyrosine Kinase Inhibitors (TKIs)",
         "Competitively inhibit ATP binding site of tyrosine kinases → block downstream proliferation/survival signalling",
         "Imatinib (BCR-ABL), Erlotinib/Gefitinib (EGFR), Trastuzumab+Lapatinib (HER2), Ibrutinib (BTK)"),
        ("VEGF Pathway Inhibitors",
         "Bevacizumab: anti-VEGF antibody → prevents VEGF binding to receptor → inhibit tumour angiogenesis",
         "Bevacizumab, Ramucirumab; Sunitinib, Sorafenib (multi-target TKIs incl. VEGFR)"),
        ("Immune Checkpoint Inhibitors",
         "Block PD-1/PD-L1 or CTLA-4 co-inhibitory pathways → restore T-cell anti-tumour immune response",
         "Pembrolizumab, Nivolumab (anti-PD-1); Atezolizumab (anti-PD-L1); Ipilimumab (anti-CTLA-4)"),
        ("Hormone Therapy",
         "SERMs/aromatase inhibitors: block estrogen signalling in ER+ breast cancer. Anti-androgens: block AR in prostate cancer",
         "Tamoxifen (SERM), Letrozole/Anastrozole (aromatase inhibitors); Enzalutamide, Abiraterone (prostate)"),
    ],
    "GI": [
        ("Proton Pump Inhibitors (PPIs)",
         "Irreversibly inhibit H⁺/K⁺-ATPase (proton pump) on gastric parietal cells → profound ↓ acid secretion",
         "Omeprazole, Pantoprazole, Lansoprazole, Esomeprazole, Rabeprazole"),
        ("H2 Receptor Antagonists",
         "Competitively block H2 receptors on parietal cells → reduce histamine-stimulated acid secretion",
         "Ranitidine, Famotidine, Cimetidine"),
        ("5-HT3 Antagonists (Antiemetics)",
         "Block 5-HT3 receptors on vagal afferents and in chemoreceptor trigger zone → suppress nausea/vomiting",
         "Ondansetron, Granisetron, Palonosetron"),
        ("NK1 Receptor Antagonists (Antiemetics)",
         "Block substance P at NK1 receptors in nucleus tractus solitarius → prevent chemotherapy-induced delayed emesis",
         "Aprepitant, Fosaprepitant, Netupitant"),
        ("Prokinetics",
         "Metoclopramide/Domperidone: D2 antagonism → ↑ GI motility + antiemetic. Metoclopramide also 5-HT4 agonist",
         "Metoclopramide, Domperidone, Prucalopride (5-HT4 agonist)"),
        ("Laxatives",
         "Osmotic: draw water into lumen (lactulose, macrogol). Stimulant: activate myenteric plexus (senna, bisacodyl). Bulk: increase stool bulk (psyllium)",
         "Lactulose, Macrogol; Senna, Bisacodyl; Psyllium, Methylcellulose"),
        ("Antidiarrhoeals",
         "Loperamide: agonist at enteric μ-opioid receptors → ↓ peristalsis, ↑ anal sphincter tone, ↓ secretion (does not cross BBB)",
         "Loperamide; Codeine phosphate; Bismuth subsalicylate"),
        ("IBD Biologics",
         "Anti-TNF: block TNF-α-mediated inflammation. Anti-integrins: block gut-homing lymphocyte trafficking",
         "Infliximab, Adalimumab (anti-TNF); Vedolizumab (anti-α4β7 integrin); Ustekinumab (anti-IL-12/23)"),
    ],
    "Anticoag/Platelet": [
        ("Unfractionated Heparin (UFH)",
         "Activates antithrombin III → accelerates inhibition of thrombin (IIa), Factor Xa and others; effect monitored by aPTT",
         "Unfractionated Heparin (IV/SC)"),
        ("Low Molecular Weight Heparins (LMWH)",
         "Activate antithrombin III with preference for Factor Xa inhibition over thrombin; more predictable PK, no routine monitoring",
         "Enoxaparin, Dalteparin, Tinzaparin"),
        ("Vitamin K Antagonists",
         "Inhibit VKORC1 (Vitamin K epoxide reductase) → deplete Factors II, VII, IX, X + Protein C/S; effect monitored by INR/PT",
         "Warfarin, Acenocoumarol, Phenprocoumon"),
        ("Direct Thrombin Inhibitors (DTIs)",
         "Directly inhibit thrombin (Factor IIa) independent of antithrombin; dabigatran is oral, bivalirudin is parenteral",
         "Dabigatran (oral DOAC); Bivalirudin, Argatroban (parenteral)"),
        ("Direct Factor Xa Inhibitors",
         "Directly inhibit Factor Xa at active site → block prothrombinase complex; predictable PK, no routine monitoring",
         "Rivaroxaban, Apixaban, Edoxaban, Betrixaban"),
        ("Aspirin (Antiplatelet)",
         "Irreversibly acetylates serine residue on COX-1 → prevents TXA2 synthesis → ↓ platelet aggregation for platelet lifespan",
         "Aspirin 75–100 mg (antiplatelet dose)"),
        ("P2Y12 Receptor Antagonists",
         "Block ADP-activated P2Y12 purinergic receptor on platelets → prevent Gi-mediated ↓ cAMP → ↓ platelet activation",
         "Clopidogrel, Prasugrel (irreversible); Ticagrelor, Cangrelor (reversible)"),
        ("GP IIb/IIIa Inhibitors",
         "Block fibrinogen/vWF binding site on glycoprotein IIb/IIIa (αIIbβ3 integrin) → prevent platelet cross-linking/aggregation",
         "Abciximab (mAb), Eptifibatide, Tirofiban (small molecules)"),
    ],
    "Immunosuppressants": [
        ("Calcineurin Inhibitors",
         "Inhibit calcineurin phosphatase → prevent NFAT dephosphorylation → block IL-2 gene transcription → ↓ T-cell activation",
         "Cyclosporine (CsA), Tacrolimus (FK506)"),
        ("mTOR Inhibitors",
         "Inhibit mTOR kinase (FKBP12 complex) → block IL-2 receptor signalling → prevent T- and B-cell proliferation",
         "Sirolimus (Rapamycin), Everolimus"),
        ("Antimetabolites (Immunosuppressant)",
         "Azathioprine: prodrug → 6-MP → inhibit de novo purine synthesis → ↓ lymphocyte proliferation. MMF: inhibit IMPDH",
         "Azathioprine, Mycophenolate mofetil (MMF)"),
        ("Anti-TNF Biologics",
         "Block TNF-α (soluble or membrane-bound) → ↓ downstream NF-κB activation → reduce systemic inflammation",
         "Infliximab, Adalimumab, Etanercept, Certolizumab, Golimumab"),
        ("JAK Inhibitors",
         "Inhibit Janus kinases (JAK1, JAK2, JAK3, TYK2) → block cytokine receptor signalling (JAK-STAT pathway)",
         "Tofacitinib (JAK1/3), Baricitinib (JAK1/2), Upadacitinib (JAK1), Ruxolitinib (JAK1/2)"),
        ("IL-6 Receptor Antagonists",
         "Block IL-6 receptor → prevent IL-6-mediated pro-inflammatory signalling (STAT3 activation)",
         "Tocilizumab, Sarilumab"),
        ("Anti-CD20 (B-cell depletion)",
         "Bind CD20 on B-cell surface → antibody-dependent cellular cytotoxicity (ADCC), CDC, and apoptosis → B-cell depletion",
         "Rituximab, Obinutuzumab, Ocrelizumab"),
    ],
}

# ─── Page decorators ──────────────────────────────────────────────────────────
def cover_bg(canvas, doc):
    canvas.saveState()
    # Dark gradient background simulation
    canvas.setFillColor(NAVY)
    canvas.rect(0, 0, A4[0], A4[1], fill=1, stroke=0)
    # Decorative accent stripe
    canvas.setFillColor(TEAL)
    canvas.rect(0, A4[1]*0.38, A4[0], 4, fill=1, stroke=0)
    canvas.setFillColor(colors.HexColor("#2E86C1"))
    canvas.rect(0, A4[1]*0.38-6, A4[0], 3, fill=1, stroke=0)
    canvas.restoreState()

def inner_page(canvas, doc):
    canvas.saveState()
    # Subtle top bar
    canvas.setFillColor(NAVY)
    canvas.rect(0, A4[1]-18*mm, A4[0], 18*mm, fill=1, stroke=0)
    # Footer
    canvas.setFillColor(LGRAY)
    canvas.rect(0, 0, A4[0], 12*mm, fill=1, stroke=0)
    canvas.setFont("Helvetica", 7)
    canvas.setFillColor(DGRAY)
    canvas.drawCentredString(A4[0]/2, 4*mm,
        f"Drug Classes Quick Reference  |  Page {doc.page}  |  For educational use only")
    # Header text
    canvas.setFillColor(WHITE)
    canvas.setFont("Helvetica-Bold", 9)
    canvas.drawString(1.5*cm, A4[1]-12*mm, "DRUG CLASSES QUICK REFERENCE")
    canvas.setFont("Helvetica", 9)
    canvas.drawRightString(A4[0]-1.5*cm, A4[1]-12*mm, "Pharmacology by Body System")
    canvas.restoreState()

# ─── Build flowables ──────────────────────────────────────────────────────────
def build_system_table(system, entries, hdr_color, bg_color):
    """Return a KeepTogether block for one drug system section."""
    flowables = []

    # Section header bar
    hdr_data = [[Paragraph(f"  {system.upper()}", sys_heading)]]
    hdr_tbl = Table(hdr_data, colWidths=[17.5*cm])
    hdr_tbl.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), hdr_color),
        ("TOPPADDING",    (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
        ("ROUNDEDCORNERS", [4]),
    ]))
    flowables.append(hdr_tbl)
    flowables.append(Spacer(1, 3))

    # Build table rows
    rows = []
    rows.append([
        Paragraph("<b>Drug Class</b>", make_style("TH", fontSize=8, textColor=WHITE, fontName="Helvetica-Bold")),
        Paragraph("<b>Mechanism of Action</b>", make_style("TH2", fontSize=8, textColor=WHITE, fontName="Helvetica-Bold")),
        Paragraph("<b>Key Examples</b>", make_style("TH3", fontSize=8, textColor=WHITE, fontName="Helvetica-Bold")),
    ])
    for cls, moa, examples in entries:
        rows.append([
            Paragraph(cls, cls_name),
            Paragraph(moa, moa_text),
            Paragraph(examples, eg_text),
        ])

    col_w = [4.2*cm, 8.8*cm, 4.5*cm]
    tbl = Table(rows, colWidths=col_w, repeatRows=1)

    row_bg = []
    for i in range(1, len(rows)):
        c = bg_color if i % 2 == 1 else WHITE
        row_bg.append(("BACKGROUND", (0, i), (-1, i), c))

    tbl.setStyle(TableStyle([
        # Header row
        ("BACKGROUND",    (0,0), (-1,0), hdr_color),
        ("TEXTCOLOR",     (0,0), (-1,0), WHITE),
        ("FONTNAME",      (0,0), (-1,0), "Helvetica-Bold"),
        ("FONTSIZE",      (0,0), (-1,0), 8),
        ("TOPPADDING",    (0,0), (-1,0), 5),
        ("BOTTOMPADDING", (0,0), (-1,0), 5),
        # Body
        ("FONTSIZE",      (0,1), (-1,-1), 8),
        ("TOPPADDING",    (0,1), (-1,-1), 4),
        ("BOTTOMPADDING", (0,1), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 5),
        ("RIGHTPADDING",  (0,0), (-1,-1), 5),
        ("VALIGN",        (0,0), (-1,-1), "TOP"),
        # Borders
        ("GRID",          (0,0), (-1,-1), 0.3, colors.HexColor("#BDC3C7")),
        ("LINEBELOW",     (0,0), (-1,0), 1, hdr_color),
        *row_bg,
    ]))

    flowables.append(tbl)
    flowables.append(Spacer(1, 8))
    return flowables

# ─── Main ─────────────────────────────────────────────────────────────────────
def main():
    doc = SimpleDocTemplate(
        OUTPUT,
        pagesize=A4,
        leftMargin=1.5*cm,
        rightMargin=1.5*cm,
        topMargin=2.2*cm,
        bottomMargin=1.8*cm,
    )

    story = []

    # ── COVER PAGE ─────────────────────────────────────────────────────────────
    story.append(Spacer(1, 5*cm))
    story.append(Paragraph("DRUG CLASSES", cover_title))
    story.append(Spacer(1, 0.4*cm))
    story.append(Paragraph("Quick Reference Guide", cover_sub))
    story.append(Spacer(1, 0.3*cm))
    story.append(Paragraph("Mechanisms of Action · Key Examples · Body System Organisation",
                            cover_sub))
    story.append(Spacer(1, 2*cm))

    # Decorative divider on cover
    cover_div_data = [[""]]
    cover_div = Table(cover_div_data, colWidths=[12*cm])
    cover_div.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), TEAL),
        ("TOPPADDING",    (0,0), (-1,-1), 2),
        ("BOTTOMPADDING", (0,0), (-1,-1), 2),
    ]))
    story.append(cover_div)
    story.append(Spacer(1, 2*cm))

    story.append(Paragraph("Based on Goodman &amp; Gilman's, Katzung's, and Lippincott's Pharmacology",
                            cover_date))
    story.append(Spacer(1, 0.3*cm))
    story.append(Paragraph("For educational use only  |  2026", cover_date))
    story.append(PageBreak())

    # ── TABLE OF CONTENTS ──────────────────────────────────────────────────────
    story.append(Spacer(1, 0.5*cm))
    story.append(Paragraph("Contents", toc_heading))
    story.append(HRFlowable(width="100%", thickness=2, color=TEAL, spaceAfter=10))

    systems_list = list(DRUG_DATA.keys())
    for i, sys_name in enumerate(systems_list, 1):
        n_drugs = len(DRUG_DATA[sys_name])
        story.append(Paragraph(
            f"<b>{i}.</b>  {sys_name}  <font color='#7F8C8D' size='9'>({n_drugs} drug classes)</font>",
            toc_style))

    story.append(Spacer(1, 1*cm))
    story.append(Paragraph(
        "<font color='#7F8C8D'>Each section covers: Drug Class Name · Mechanism of Action · Prototypical Examples</font>",
        note_text))
    story.append(PageBreak())

    # ── DRUG SECTIONS ──────────────────────────────────────────────────────────
    for sys_name, entries in DRUG_DATA.items():
        hdr_color, bg_color = SYS_COLORS[sys_name]
        section_flowables = build_system_table(sys_name, entries, hdr_color, bg_color)
        story.extend(section_flowables)

    # ── LEGEND PAGE ────────────────────────────────────────────────────────────
    story.append(PageBreak())
    story.append(Spacer(1, 0.5*cm))
    story.append(Paragraph("Abbreviations & Legend", toc_heading))
    story.append(HRFlowable(width="100%", thickness=2, color=TEAL, spaceAfter=10))

    abbrevs = [
        ["↑ / ↓", "Increase / Decrease"],
        ["MOA", "Mechanism of Action"],
        ["GPCR", "G-protein coupled receptor"],
        ["cAMP", "Cyclic adenosine monophosphate"],
        ["cGMP", "Cyclic guanosine monophosphate"],
        ["PKA / PKC", "Protein kinase A / C"],
        ["NF-κB", "Nuclear factor kappa B"],
        ["STAT", "Signal transducer and activator of transcription"],
        ["PBP", "Penicillin-binding protein"],
        ["DHFR", "Dihydrofolate reductase"],
        ["SERT / NET / DAT", "Serotonin / Norepinephrine / Dopamine transporter"],
        ["DOAC", "Direct oral anticoagulant"],
        ["APD", "Action potential duration"],
        ["EPS", "Extrapyramidal symptoms"],
        ["AUC", "Area under the curve"],
        ["PK", "Pharmacokinetics"],
        ["aPTT / INR / PT", "Activated partial thromboplastin time / International normalised ratio / Prothrombin time"],
        ["BBB", "Blood-brain barrier"],
        ["VEGF", "Vascular endothelial growth factor"],
        ["TNF-α", "Tumour necrosis factor alpha"],
    ]

    abbrev_rows = [[Paragraph("<b>Term</b>", cls_name), Paragraph("<b>Meaning</b>", cls_name)]]
    for term, meaning in abbrevs:
        abbrev_rows.append([Paragraph(term, moa_text), Paragraph(meaning, moa_text)])

    abbrev_tbl = Table(abbrev_rows, colWidths=[5*cm, 12*cm])
    abbrev_tbl.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,0), NAVY),
        ("TEXTCOLOR",     (0,0), (-1,0), WHITE),
        ("FONTNAME",      (0,0), (-1,0), "Helvetica-Bold"),
        ("GRID",          (0,0), (-1,-1), 0.3, colors.HexColor("#BDC3C7")),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [LGRAY, WHITE]),
        ("TOPPADDING",    (0,0), (-1,-1), 4),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 6),
    ]))
    story.append(abbrev_tbl)

    # ── BUILD ──────────────────────────────────────────────────────────────────
    def page_template(canvas, doc):
        if doc.page == 1:
            cover_bg(canvas, doc)
        else:
            inner_page(canvas, doc)

    doc.build(story, onFirstPage=page_template, onLaterPages=page_template)
    print(f"PDF saved: {OUTPUT}")

if __name__ == "__main__":
    main()
Running Command

cd /home/daytona/workspace/drug-reference && python3 build_pdf.py 2>&1

Running Command

ls -lh /home/daytona/workspace/drug-reference/Drug_Classes_Quick_Reference.pdf

Your PDF is ready - built and verified at 31 KB.

Drug Classes Quick Reference

PDF Document · PDF


What's inside the PDF:
SectionContent
Cover pageDark navy design with title and source attribution
Table of ContentsAll 9 systems listed with drug class counts
9 Body System SectionsEach with a colour-coded header and 3-column table
Abbreviations page20 key pharmacology terms defined
The 9 systems covered:
  1. Cardiovascular (14 classes) - antihypertensives, antiarrhythmics, antilipid agents
  2. Nervous System (14 classes) - opioids, antidepressants, antipsychotics, antiepileptics
  3. Antimicrobials (17 classes) - antibiotics, antivirals, antifungals
  4. Endocrine (10 classes) - antidiabetics, thyroid, glucocorticoids
  5. Respiratory (9 classes) - SABAs/LABAs, ICS, LAMAs, biologics
  6. Anticancer (10 classes) - cytotoxics, targeted therapy, immunotherapy
  7. GI (8 classes) - PPIs, antiemetics, prokinetics, IBD biologics
  8. Anticoag/Platelet (8 classes) - heparins, DOACs, antiplatelets
  9. Immunosuppressants (7 classes) - calcineurin inhibitors, biologics, JAK inhibitors
Each row shows: Class name | Mechanism of action | Key drug examples.
This is a shared conversation. Sign in to Orris to start your own chat.