# EvidenzWerk — Comprehensive Methodological & Technical Handbook (Compendium 2026)

> **Note (IMPORTANT):**
> **Purpose of This Handbook:** This compendium unites two essential references in a single end-to-end volume:
> 1. **Part I — Methodological Reference Guide & Guided Student Mode (with Retina Screenshots & Video):** Explains every evidence synthesis methodology implemented in **EvidenzWerk** — from classical two-group comparisons to clinical survival analysis (**Hazard Ratios per Tierney et al. 2007**), **Three-Level Meta-Analysis with Cluster-Robust Variance Estimation (`clubSandwich` CR2)**, **Frequentist Network Meta-Analysis (NMA per Rücker 2012)**, **Diagnostic Test Accuracy (DTA / Reitsma-HSROC & QUADAS-2)**, **RoB 2**, **ROBINS-I**, **GRADE**, **RAISE-2025**, and the new **🎓 Student Mode (`Studi-Modus`)** with AI Voice Co-Pilot and 3-Tier Paywall Navigator. Every method is explained so clearly that researchers, PhD candidates, students, and curious laypeople immediately understand *when* to use it, *which raw numbers* to enter, and *how to interpret the resulting plots and estimates*.
> 2. **Part II — Technical System, Calculation Engine & OpenAPI 3.1 Documentation:** Documents the complete software architecture (`Next.js 16`, `SQLite` in WAL mode, the isolated `R` bridge to `metafor` & `clubSandwich`, the glass-box calculation trace, the 100%-parity `v1` Agent REST API with transactional dry-run and idempotency, server-enforced multi-user blinding, native zero-dependency PDF/DOCX/SVG/Poster renderers, and Podman Quadlet deployment).

---

## 0. Complete Video Walkthrough & Interactive Visual Gallery

### 0.1 End-to-End Video Walkthrough (MP4)

The following video walks live through our reference showcase projects — from the bilingual Project Dashboard through Protocol & Multi-User Blinding, PRISMA-S Literature Search, Dual Screening with Cohen's $\kappa$, Quote-Anchored PDF Extraction, Clinical Kaplan-Meier Reconstruction (Tierney et al. 2007), RoB 2 & ROBINS-I, Three-Level REML + CR2, the 5-Part Publication Bias Suite, Network Meta-Analysis (NMA), Diagnostic Test Accuracy (SROC & QUADAS-2), GRADE, the Glass-Box Calculation Trace, RAISE-2025 Ratification, the 29-file Journal Submission Package, and the guided **🎓 Student Mode**:

![EvidenzWerk Complete Walkthrough Video (2026)](/Users/franzhuetter/.gemini/antigravity-cli/brain/ddf3e4eb-130f-4bd1-a05b-29ff57ae1d90/evidenzwerk-gesamtschau-2026.mp4)

*(In the repository, the video files are stored under public/handbuch/videos/, and all Retina screenshots under public/handbuch/screenshots/.)*

---


## Part I — Methodological Reference Guide & Guided Student Mode

### 1. The Complete Lifecycle of a Systematic Review and Meta-Analysis

EvidenzWerk maps the entire lifecycle of a systematic review and quantitative evidence synthesis in strict accordance with the **Cochrane Handbook (Version 6.5)**, **PRISMA 2020**, **PRISMA-S**, **PRISMA-P**, **GRADE**, and **RAISE 2025** without a single copy-paste break between tools.

```mermaid
flowchart LR
  P["1. Protocol & PICOS<br/>(PRISMA-P, Team Blinding)"] --> R["2. Search & Import<br/>(OpenAlex, PubMed, CT.gov, RIS/BibTeX)"]
  R --> S["3. Dual Screening<br/>(Reviewer A/B, Cohen's κ, Conflicts)"]
  S --> E["4. Full-Text Extraction<br/>(PDF Anchor, Verbatim Quotes)"]
  E --> C["5. Coding & Bias<br/>(10 Metrics, RoB 2, ROBINS-I, QUADAS-2)"]
  C --> A["6. Statistical Synthesis<br/>(3-Level CR2, NMA, DTA, PubBias)"]
  A --> G["7. GRADE & Ratification<br/>(Certainty of Evidence, RAISE)"]
  G --> M["8. Submission Package<br/>(DOCX, PDF, SVG, Poster, ZIP)"]
```

#### 1.1 Dashboard, Protocol (PRISMA-P), and Server-Enforced Multi-User Blinding

![Bilingual Dashboard (EN)](/handbuch/screenshots/01-dashboard-en.png)

Every project begins in the **Protocol** tab (`PicosEditor.tsx`, `buildPrismaP`) by defining the structured research question using the **PICOS framework**:
- **P (Population):** Which patients, learners, or participants are studied? (e.g., *Adult learners $\ge 18$ years* or *Patients with metastatic stage IV NSCLC, ECOG 0–1*)
- **I (Intervention / Index Test):** Which treatment, educational intervention, exposure, or diagnostic test is evaluated?
- **C (Comparator / Control):** What is the benchmark comparison (placebo, standard of care, active control, clinical reference standard)?
- **O (Outcomes):** Which primary and secondary endpoints are synthesized?
- **S (Study Design):** Which study designs are eligible (randomized controlled trials only, quasi-experimental designs, or adjusted cohort studies)?

![Protocol & Server-Enforced Multi-User Blinding](/handbuch/screenshots/02-protokoll-team-verblindung.png)

> **Note (TIP):**
> **True Server-Enforced Multi-User Blinding (`TeamPanel.tsx`, `lib/tenancy.ts`):**
> Cochrane standards require two independent reviewers (**Reviewer A** and **Reviewer B**) to screen and code studies without seeing each other's decisions beforehand. In EvidenzWerk, project owners assign real user accounts to the roles **Reviewer / Coder A**, **Reviewer / Coder B**, or **Co-Author**. While a study remains in the `queued` state, the server strips the other reviewer's votes at the database and API layer before data ever reaches the browser, and locks the reviewer role selector.

---

### 2. Literature Search (PRISMA-S), Deduplication & Dual Screening

#### 2.1 Four-Pillar Literature Search and PRISMA-S Logging

![Literature Search & PRISMA-S Protocol](/handbuch/screenshots/03-recherche-prisma-s.png)

In the **Search (`Recherche`)** tab, EvidenzWerk combines four complementary retrieval channels so no relevant trial is missed:
1. **AI-Assisted Multi-Query Search via OpenAlex (`AiSearchPanel.tsx`, `lib/scholarly.ts`):** Decomposes the research question into multiple synonymous Boolean search paths and logs exact query URLs, timestamps, and hit counts.
2. **PubMed / MEDLINE via NCBI E-Utilities (`PubmedPanel.tsx`, `lib/pubmed.ts`):** Supports full Boolean syntax including `MeSH Terms` (`[mh]`), `[tiab]` field tags, and publication type filters.
3. **ClinicalTrials.gov API v2 Registry Search (`TrialsPanel.tsx`, `lib/clinicaltrials.ts`):** Essential for detecting **publication bias (the file-drawer problem)**: identifies completed trials (`COMPLETED`) with or without a published journal article. Unpublished registry trials are flagged with `registry_unpublished = 1` and highlighted in the Analysis tab.
4. **External Databases & File Import (`ExternalSearchPanel.tsx`, `ImportForm.tsx`):** Direct import of `.ris`, `.bib` (BibTeX), `.nbib` (PubMed/Medline), and `.csv` exports from subscription databases such as **Embase (Ovid)**, **Scopus**, **Web of Science**, **PsycINFO**, or **ERIC**, including PRISMA-S-compliant documentation of search interface and exact multi-line query syntax.

#### 2.2 Dual Screening, Cohen's Kappa ($\kappa$), and Third-Party Conflict Resolution

![Dual Screening & Cohen's Kappa](/handbuch/screenshots/04-doppelscreening-kappa.png)

In the **Screening** tab (`ScreeningQueue.tsx`), every imported record undergoes two-stage evaluation (**Title/Abstract Screening** $\rightarrow$ **Full-Text Eligibility**):
- **Inter-Rater Reliability via Cohen's $\kappa$ (`screeningAgreement`):** Continuously computes chance-corrected agreement between Reviewer A and Reviewer B:
  $$\kappa = \frac{p_o - p_e}{1 - p_e}$$
  where $p_o$ is the observed proportion of agreement and $p_e$ is the agreement expected by chance alone.
  - **Landis & Koch (1977) Benchmarks:** $\kappa < 0.40$ fair/poor, $0.41\text{–}0.60$ moderate, $0.61\text{–}0.80$ substantial, $> 0.80$ almost perfect.
- **Conflict Queue & Adjudication:** Whenever Reviewer A votes *Include* and Reviewer B votes *Exclude*, the study automatically transitions to `conflict` and appears in the **Conflict Resolution (Adjudication)** panel for documented consensus decision-making.
- **PRISMA 2020 Exclusion Reasons:** Every full-text exclusion requires a structured exclusion reason (e.g., *Population not PICOS-compliant*, *No control group*, *Retracted / data integrity concern*), fulfilling PRISMA 2020 Item 16b automatically.

---

### 3. Full-Text Extraction with Page Anchor and Verbatim Evidence Quote

![AI Full-Text Extraction with Verbatim Quote](/handbuch/screenshots/05-ki-extraktion-belegzitat.png)

In the **Extraction (`Extraktion`)** tab (`ExtractionPanel.tsx`, `lib/extract.ts`), EvidenzWerk automatically retrieves Open-Access full-text PDFs via **Unpaywall** and **Europe PMC** (`lib/pdf-fetch.ts`), verifies PDF identity via DOI and title-token matching (`lib/pdf-identity.ts`), and extracts structured study findings:
- **No Number Without a Verbatim Quote and Page Number:** Every extracted sample size, mean, standard deviation, $t$/$F$/$p$-value, or hazard ratio is stored alongside the **exact verbatim quote from the PDF (`quote`)** and its **page number (`page`)**.
- **1-Click Transfer to Coding:** Clicking *"Apply → Coding"* transfers the verified numbers directly into the effect-size coding form, marks the extraction as human-verified (`confirmed = 1`), and logs the actor in the audit trail.

---

### 4. Methodological Compendium: All 10 Effect Size Metrics & Study Designs

> **Note (NOTE):**
> **Your Cross-Disciplinary Cheat Sheet:** Different scientific fields rely on different effect size metrics. Psychology and education predominantly use **Hedges' $g$** and **correlations $r$**; internal medicine, cardiology, and epidemiology use **Odds Ratios (OR)**, **Risk Ratios (RR)**, **Risk Differences (RD / NNT)**, and **Incidence Rate Ratios (IRR)**; oncology and cardiology rely on **Hazard Ratios (HR)** from time-to-event survival curves; and public health / radiology synthesize **prevalence proportions** or **sensitivity/specificity**. EvidenzWerk implements all ten metrics natively in `lib/stats.ts` and `lib/metrics.ts`.

| Code | Metric Name | Typical Field | When to Use? | Internal Pooling Scale | Reported Scale (Plot/Text) | Null Value (No Effect) |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| **`smd`** | **Hedges' $g$** (standardized mean difference) | Psychology, Medicine, Education, Social Sciences | Continuous outcome (e.g., pain, depression, test performance) measured across studies using **different scales or instruments**. | Linear ($g$) | Linear ($g$) | $0$ |
| **`md`** | **Mean Difference (MD)** | Cardiology, Critical Care, Laboratory Medicine | Continuous outcome measured on **the exact same natural unit** across all studies (e.g., systolic blood pressure in mmHg, HbA1c in %). | Linear ($\text{MD}$) | Linear ($\text{MD}$) | $0$ |
| **`r`** | **Correlation $r$** (via Fisher's $z$) | Personality, I/O Psychology, Behavioral Sciences | Association between two continuous variables without group assignment. | Fisher's $z = \text{artanh}(r)$ | $r = \tanh(z) \in (-1, +1)$ | $0$ |
| **`or`** | **Odds Ratio (OR)** | Epidemiology, Case-Control Studies, Logistic Regression | Binary event (Yes/No, death/survival, remission), especially in case-control designs or adjusted logistic models. | $\ln(\text{OR})$ | $\text{OR} = \exp(y)$ | $1.0$ |
| **`rr`** | **Risk Ratio / Relative Risk (RR)** | Clinical RCTs, Prospective Cohort Studies | Binary event in prospective trials: ratio of event probabilities $p_1 / p_2$. More intuitive than OR when events are common ($> 10\%$). | $\ln(\text{RR})$ | $\text{RR} = \exp(y)$ | $1.0$ |
| **`rd`** | **Risk Difference (RD) & NNT** | Clinical Guidelines, Health Services Research | Absolute risk difference $p_1 - p_2$ and the derived **Number Needed to Treat ($\text{NNT} = 1 / |\text{RD}|$)** per Altman (1998). | Linear ($\text{RD}$) | Linear ($\text{RD}$) + $\text{NNTB}/\text{NNTH}$ | $0$ |
| **`irr`** | **Incidence Rate Ratio (IRR)** | Infectious Diseases, Pulmonology, Pharmacoepidemiology | Count events per **person-time** (e.g., asthma exacerbations or falls per 1,000 patient-years). | $\ln(\text{IRR})$ | $\text{IRR} = \exp(y)$ | $1.0$ |
| **`prop_logit`** | **Single Proportion / Prevalence (Logit)** | Epidemiology, Single-Arm Phase II Oncology | Pooling a single event rate $p = e / n$ (e.g., complication rate, disease prevalence) without a control group for moderate rates ($5\text{–}95\%$). | $\text{logit}(p) = \ln\frac{p}{1-p}$ | Proportion $p = \frac{1}{1+e^{-y}} \in (0, 1)$ | — |
| **`prop_ft`** | **Single Proportion (Freeman-Tukey Double Arcsine)** | Rare Complications, Surgery, Registry Studies | Single-arm rates/prevalences when studies report **0% or 100% events** — stabilizes variance without artificial $+0.5$ continuity distortion. | Freeman-Tukey $t$ | Proportion $p \in [0, 1]$ (Miller 1978) | — |
| **`hr`** | **Hazard Ratio (HR, Time-to-Event)** | Oncology, Cardiology, Nephrology, Critical Care | **Survival / Time-to-Event Analysis**: time to death, progression, or relapse accounting for **censored patients**. | $\ln(\text{HR})$ | $\text{HR} = \exp(y)$ | $1.0$ |

---

#### 4.1 Continuous Group Comparisons (`smd` / Hedges' $g$ and `md`) and All 6 Input Pathways

Primary studies frequently omit raw means ($M$), standard deviations ($SD$), and group sizes ($n$), reporting instead a $t$-statistic, a one-way $F$-ratio, a mean difference with a $p$-value, or Cohen's $d$. EvidenzWerk converts all six reporting formats into exact small-sample-corrected Hedges' $g$ in `computeEffect`:

1. **Raw Group Statistics ($M_1, SD_1, n_1$ and $M_2, SD_2, n_2$):**
   $$s_{\text{pooled}} = \sqrt{\frac{(n_1 - 1)SD_1^2 + (n_2 - 1)SD_2^2}{n_1 + n_2 - 2}}, \qquad d = \frac{M_1 - M_2}{s_{\text{pooled}}}$$
2. **From $t$-Statistic ($t, n_1, n_2$):** $d = t \cdot \sqrt{\frac{1}{n_1} + \frac{1}{n_2}}$
3. **From One-Way $F$-Statistic ($F$ with $\text{df}_1 = 1$, $n_1, n_2$, sign $\pm 1$):** $t = \pm\sqrt{F}$, then as above.
4. **From Mean Difference $\Delta M$ and Two-Sided $p$-Value ($p, n_1, n_2$):** Computes the quantile $t = F_{t,\text{df}}^{-1}(1 - p/2)$ via the inverse Student-$t$ distribution ($\text{df} = n_1 + n_2 - 2$), then $\text{SE} = |\Delta M| / t$ and $s_{\text{pooled}}$.
5. **From Reported Cohen's $d$ ($d, n_1, n_2$):** Applies the exact Hedges (1981) gamma correction factor $J(\text{df})$.
6. **Direct Input ($g$ and $\text{SE}$):** When Hedges' $g$ and its standard error are directly reported.

**Why Always Hedges' $g$ Instead of Cohen's $d$?** Cohen's $d$ systematically overestimates the population effect in small samples ($n < 30$). EvidenzWerk multiplies $d$ and its standard error by the exact gamma correction factor per Hedges (1981):
$$J(\text{df}) = \frac{\Gamma(\text{df}/2)}{\sqrt{\text{df}/2}\,\Gamma((\text{df}-1)/2)} \approx 1 - \frac{3}{4\cdot\text{df} - 1}, \qquad g = J(\text{df})\cdot d, \qquad v_g = J(\text{df})^2 \cdot \left(\frac{n_1+n_2}{n_1 n_2} + \frac{d^2}{2(n_1+n_2)}\right)$$

---

#### 4.2 Study Designs: Pre-Post (Within-Group) and Cluster-Randomized Trials (ICC)

Two of the most common methodological errors in published meta-analyses occur in **pre-post / crossover designs** and **cluster-randomized trials** (Cochrane Handbook Ch. 23):

1. **Within-Group / Pre-Post / Crossover (`design = 'within'`):**
   When the same individuals are measured before and after an intervention, both measurements are correlated by $r_{\text{pre,post}}$. Per Borenstein et al. (2009, Eq. 4.28), the sampling variance is:
   $$v_d = \left(\frac{1}{n} + \frac{d^2}{2n}\right) \cdot 2(1 - r_{\text{pre,post}})$$
2. **Cluster-Randomized Trials (`design = 'cluster'`, e.g., classrooms, hospital wards, clinics):**
   When entire classrooms or clinics are randomized rather than individuals, observations within a cluster are correlated via the **Intraclass Correlation Coefficient ($\text{ICC}$)**. Plugging total student count $N$ into standard formulas commits a **unit-of-analysis error** and severely overweights the study. EvidenzWerk automatically multiplies the variance by the **Design Effect ($\text{DE}$)** per Higgins et al. (2023):
   $$\text{DE} = 1 + (\bar{m} - 1)\cdot\text{ICC}, \qquad v_{\text{cluster}} = v_{\text{individual}} \cdot \text{DE}$$
   where $\bar{m}$ is the average cluster size.

---

#### 4.3 Clinical Survival Analysis: Hazard Ratios (`hr`) & All 5 Tierney (2007) Pathways

![Clinical Survival Coding & Kaplan-Meier Reconstruction](/handbuch/screenshots/06-codierung-survival-tierney-km.png)

In oncology, cardiology, and transplantation medicine, the gold-standard endpoint is the **Hazard Ratio ($\text{HR}$)** across the entire follow-up curve (e.g., *Progression-Free Survival, PFS* or *Overall Survival, OS*).
- **Interpretation:** An $\text{HR} = 0.52$ $[0.43,\, 0.64]$ (as in *Gandhi et al. / KEYNOTE-189* in our oncology showcase) means that at any given point in time, the instantaneous hazard of death or disease progression under pembrolizumab + platinum chemotherapy is **$48\%$ lower** than under chemotherapy alone.

Because clinical papers frequently omit explicit confidence intervals for $\text{HR}$, `lib/survival.ts` implements **all five canonical reconstruction pathways per Tierney et al. (2007, *Trials* 8:16)** and Parmar et al. (1998, *Stat Med* 17:2815):

| Tierney Pathway | Key (`hrSource`) | What Is Reported in the Clinical Paper? | Mathematical Derivation in `lib/survival.ts` |
| :--- | :--- | :--- | :--- |
| **Pathway 1 (Direct)** | `hr_ci` | Reported Hazard Ratio + 95% confidence interval (e.g., `HR = 0.52; 95% CI 0.43–0.64`) | $y = \ln(\text{HR})$, $\quad \text{SE} = \frac{\ln(\text{HR}_{\text{hi}}) - \ln(\text{HR}_{\text{lo}})}{2 \cdot z_{0.975}}$ (validates log-scale symmetry automatically). |
| **Pathway 2 (Exact Peto)** | `peto` | Observed minus expected events ($O - E$) and log-rank variance $V$ | Per Yusuf et al. (1985): $y = \ln(\text{HR}) = \frac{O - E}{V}, \quad v = \frac{1}{V}, \quad \text{SE} = \frac{1}{\sqrt{V}}$ |
| **Pathway 3 (Log-Rank $p$)** | `logrank_p` | Two-sided log-rank $p$-value, total events $E$, arm sizes $n_1, n_2$, and direction | Computes $z = \pm\Phi^{-1}(1 - p/2)$, allocation ratio $R = n_2 / n_1$, information variance $V = \frac{E \cdot R}{(1 + R)^2}$, and $O - E = z \cdot \sqrt{V}$, yielding $\ln(\text{HR}) = \frac{O - E}{V}$ (Tierney Eq. 7–9). |
| **Pathway 4 (KM Curve Reconstruction)** | `km_kurve` | **Printed Kaplan-Meier survival curve** and the *"Number at risk"* table beneath the time axis | From $\ge 2$ timepoints $t_0 < t_1 < \dots < t_m$ with survival probabilities $S_{1}(t_j), S_{2}(t_j) \in (0, 1]$ and numbers at risk, reconstructs censoring, effective numbers at risk, conditional events $O_{k,j}$, and interval log-rank quantities $(O_j - E_j)$ and $V_j$ per **Tierney et al. (2007, Eq. 10–13)** to obtain $\ln(\text{HR}) = \frac{\sum (O_j - E_j)}{\sum V_j}$. |
| **Pathway 5 (Median Survival)** | `medians` | **Median survival times** in both arms ($m_{\text{Interv.}}, m_{\text{Ctrl.}}$) and total events $E$ | Under exponential hazard assumptions, $\text{HR} \approx \frac{m_{\text{Ctrl.}}}{m_{\text{Interv.}}}$ with $\text{SE}(\ln\text{HR}) \approx \sqrt{\frac{(n_1+n_2)^2}{E \cdot n_1 n_2}}$. Automatically flagged as an approximation in the statistical appendix. |

---

### 5. Risk of Bias Assessment: RoB 2 vs. ROBINS-I vs. QUADAS-2

![RoB 2 & ROBINS-I Assessment](/handbuch/screenshots/07-bias-rob2-robins-i.png)

> **Note (WARNING):**
> **Why Automatic Design Routing Between RoB 2 and ROBINS-I Is Essential (`instrumentFuerDesign`):**
> Evaluating observational cohort or registry studies with **RoB 2** is a major cause of desk rejection at medical journals because RoB 2 Domain 1 evaluates randomization. Non-randomized studies of interventions must be assessed using **ROBINS-I (Sterne et al. 2016, *BMJ* 355:i4919)**, and diagnostic accuracy studies using **QUADAS-2 (Whiting et al. 2011)**. EvidenzWerk automatically selects the proper instrument based on the coded study design.

| Feature | **RoB 2** (`lib/rob2-shared.ts`) | **ROBINS-I** (`lib/robins-i-shared.ts`) | **QUADAS-2** (`lib/dta.ts`) |
| :--- | :--- | :--- | :--- |
| **Target Study Design** | Randomized Controlled Trials (RCT, Cluster-RCT, Crossover-RCT) | Non-Randomized Studies of Interventions (Cohorts, Registries, Quasi-Experiments) | Diagnostic Test Accuracy Studies (Index Test vs. Reference Standard) |
| **Domains** | **5 Domains (`d1`–`d5`):**<br/>D1 Randomization process<br/>D2 Deviations from intended interventions<br/>D3 Missing outcome data<br/>D4 Measurement of the outcome<br/>D5 Selection of the reported result | **7 Domains (`d1`–`d7`):**<br/>D1 **Confounding** (checked against pre-specified confounders!)<br/>D2 Selection of participants<br/>D3 Classification of interventions<br/>D4 Deviations from intended interventions<br/>D5 Missing data<br/>D6 Measurement of outcomes<br/>D7 Selection of reported result | **4 Domains (Risk of Bias + Applicability):**<br/>D1 Patient Selection<br/>D2 Index Test<br/>D3 Reference Standard<br/>D4 Flow & Timing |
| **Judgment Levels & Traffic-Light Symbols** | `+` **Low** (`low`)<br/>`!` **Some concerns** (`some_concerns`)<br/>`×` **High** (`high`) | `+` **Low** (`low`)<br/>`!` **Moderate** (`moderate`)<br/>`×` **Serious** (`serious`)<br/>`‼` **Critical** (`critical` — excluded from synthesis!)<br/>`?` **No information** (`no_information`) | `+` **Low** (`low`)<br/>`?` **Unclear** (`unclear`)<br/>`−` **High** (`high`) |

---

### 6. Statistical Synthesis: From 2-Level REML to Three-Level Meta-Analysis with `clubSandwich` CR2

#### 6.1 Classical 2-Level Models, Forest Plot, Funnel Plot & Subgroups

![Classical Meta-Analysis: Forest Plot, Funnel Plot & Moderators](/handbuch/screenshots/08-analyse-forest-funnel-subgruppen.png)

In the upper section of the **Analysis (`Analyse`)** tab (`AnalysisPanel.tsx`), four synthesis tabs are available:
1. **Fixed-Effect (`fe`):** Assumes all studies share a single identical true effect $\theta$ ($w_i = 1/v_i$).
2. **Random-Effects DerSimonian-Laird (`re-dl`):** Classical method-of-moments estimator for between-study variance $\tau^2$.
3. **Random-Effects REML + Knapp-Hartung (`re-reml`, recommended default for independent studies):** Estimates $\tau^2$ via **Restricted Maximum Likelihood (REML)** and computes confidence intervals using the **Knapp-Hartung $t$-distribution adjustment** with $\text{df} = k - 1$ degrees of freedom (Veroniki et al. 2016; Cochrane recommendation).
4. **Three-Level Model in R (`Drei-Ebenen (R)`):** Required whenever primary studies report **multiple effect sizes** from the same participant cohort.

---

#### 6.2 Three-Level Meta-Analysis (`metafor::rma.mv`) with Cluster-Robust Variance Estimation (`clubSandwich` CR2)

![Three-Level RVE Analysis with CR2](/handbuch/screenshots/09-analyse-3level-rve-cr2.png)

Via the **R-Bridge** (`lib/r-service.ts`, `r/analyse.R`), EvidenzWerk estimates a full **hierarchical Three-Level Model per Cheung (2014) and Assink & Wibbelink (2016)** using `metafor::rma.mv(yi, V, random = ~ 1 | study_id / effect_id, method = "REML")` combined with **small-sample corrected Cluster-Robust Variance Estimation (`clubSandwich::vcovCR(..., type = "CR2")` with Satterthwaite degrees of freedom)** per Pustejovsky & Tipton (2018):

$$y_{ij} = \mu + u_j + e_{ij} + \varepsilon_{ij}$$

- **Level 1 ($\varepsilon_{ij} \sim \mathcal{N}(0, v_{ij})$):** Sampling error of effect $i$ within study $j$ (modeled with within-study correlation $\rho = 0.60$ via `impute_covariance_matrix`).
- **Level 2 ($e_{ij} \sim \mathcal{N}(0, \tau^2_{\text{within}})$):** True effect heterogeneity **within the same study** (across subtests or timepoints).
- **Level 3 ($u_j \sim \mathcal{N}(0, \tau^2_{\text{between}})$):** True effect heterogeneity **between different studies**.
- **Exact $I^2$ Decomposition per Cheung (2014):** Partitions total heterogeneity ($I^2_{\text{total}} = 92.0\%$) into between-study variance ($I^2_{\text{between}} = 59.5\%$) and within-study variance ($I^2_{\text{within}} = 32.5\%$).
- **95% Prediction Interval (`[-0.97; 2.39]` at $\text{df} = 30.2$):** Shows the range in which the true effect of a single new future study is expected to fall with 95% probability (Riley et al. 2011; IntHout et al. 2016).

---

#### 6.3 The 5-Part Publication Bias Suite (Small-Study Effects & $p$-Hacking)

![5-Part Publication Bias Suite](/handbuch/screenshots/10-analyse-publikationsbias-suite.png)

Because every individual publication bias test has known limitations under high heterogeneity $\tau^2$, `r/analyse.R` runs five complementary methods simultaneously:
1. **3-Level Egger Regression (`Egger (3-Level)`):** Regresses effect sizes on their standard errors inside the 3-level CR2 model ($y_{ij} = \beta_0 + \beta_1 \cdot \text{SE}_{ij}$).
2. **Trim-and-Fill per Duval & Tweedie (2000):** Estimates the number $k_0$ of missing studies on the underrepresented side of the funnel plot and computes an adjusted pooled estimate.
3. **PET-PEESE per Stanley & Doucouliagos (2014):** Combines the Precision-Effect Test ($\text{SE}$ predictor) and Precision-Effect Estimate with Standard Error ($\text{SE}^2$ variance predictor).
4. **$p$-curve Analysis per Simonsohn, Nelson & Simmons (2014):** Tests the distribution of statistically significant $p$-values ($p < 0.05$) for right-skewness (true evidential value) vs. flatness/left-skewness ($p$-hacking).
5. **`p-uniform*` per van Aert & van Assen (2019):** Conditional maximum-likelihood estimator using both significant and non-significant studies, robust even under substantial between-study heterogeneity $\tau^2$.

---

### 7. Specialized Medical & Methodological Modules: NMA and DTA / QUADAS-2

#### 7.1 Frequentist Network Meta-Analysis (NMA per Rücker 2012)

![Specialized Module: Network Meta-Analysis (NMA)](/handbuch/screenshots/11-spezialmodul-nma.png)

Implemented in `lib/nma.ts` and `SpezialanalysePanel.tsx`, graph-theoretical Network Meta-Analysis per **Rücker (2012, *Res Synth Methods* 3:312 — the mathematical engine of R's `netmeta` package)** compares **three or more competing interventions** simultaneously by combining direct head-to-head trials and indirect evidence via the Moore-Penrose pseudoinverse $L^+$ of the weighted graph Laplacian $L = B^\top W B$:
- **Network Graph (SVG):** Node size reflects sample/comparison volume; edge thickness reflects the number of direct head-to-head trials.
- **P-Scores per Rücker & Schwarzer (2015):** Frequentist ranking probability (equivalent to Bayesian SUCRA) measuring the certainty that treatment $i$ outperforms competing treatments.
- **League Table & Global Inconsistency Decomposition ($Q_{\text{total}} = Q_{\text{het}} + Q_{\text{inc}}$):** Contrasts network-wide estimates (lower triangle) against direct-only estimates (upper triangle) and tests for loop inconsistency.

---

#### 7.2 Diagnostic Test Accuracy Meta-Analysis (DTA per Reitsma et al. 2005 / HSROC & QUADAS-2)

![Specialized Module: Diagnostic Test Accuracy (DTA, SROC & QUADAS-2)](/handbuch/screenshots/12-spezialmodul-dta-sroc-quadas2.png)

Implemented in `lib/dta.ts`, the bivariate random-effects model per **Reitsma et al. (2005, *J Clin Epidemiol* 58:982)** jointly synthesizes $\text{logit}(\text{Sensitivity}_i)$ and $\text{logit}(1 - \text{Specificity}_i)$ from diagnostic $2 \times 2$ tables ($\text{TP}, \text{FP}, \text{FN}, \text{TN}$), accounting for the negative threshold correlation across studies:
- **SROC Curve (Summary Receiver Operating Characteristic) & 95% Confidence Ellipse:** Plots sensitivity against the false-positive rate ($1 - \text{Specificity}$) with summary point, 95% confidence region, and $\text{AUC}$.
- **Clinical Likelihood Ratios ($\text{LR}^+, \text{LR}^-$), Diagnostic Odds Ratio ($\text{DOR}$), and QUADAS-2 Quality Assessment.**

---

### 8. GRADE Certainty of Evidence, Glass-Box Calculation Trace, Ratification & Submission Package

#### 8.1 GRADE — Rating Certainty of Evidence per Outcome

![GRADE Evidence Profile](/handbuch/screenshots/13-grade-evidenzbewertung.png)

In `GradePanel.tsx` and `lib/grade.ts`, EvidenzWerk evaluates the certainty of evidence for each outcome across the five GRADE downgrading domains (*Risk of Bias*, *Inconsistency / Prediction Interval*, *Indirectness*, *Imprecision / Optimal Information Size*, *Publication Bias*) and three upgrading domains, feeding directly into the **Summary of Findings (SoF)** table.

#### 8.2 Glass-Box Calculation Trace ("Berechnungen")

![Glass-Box Calculation Trace](/handbuch/screenshots/14-rechenweg-glaskasten.png)

In `BerechnungenPanel.tsx` (`lib/rechenweg.ts`, `lib/spur.ts`), every formula is displayed side-by-side with the **actual numbers substituted from your project**, intermediate results, and literature citations.

#### 8.3 Human Ratification at the Four Critical AI Checkpoints (RAISE-2025)

![Human Ratification & RAISE-2025 Compliance](/handbuch/screenshots/15-ratifikation-raise.png)

In strict compliance with **RAISE-2025 (Reporting AI in Evidence Synthesis)**, `lib/v1/ratification.ts` tracks every `agent:*` action at four critical checkpoints (`volltext_verdikt`, `integritaets_ausschluss`, `rob2_urteil`/`robins_urteil`, `grade_urteil`) and requires explicit human ratification (`Confirm` or `Change`), documented in the automated **RAISE Disclosure Report** (`lib/raise.ts`).

#### 8.4 PRISMA 2020 Balance & 29-File Journal Submission Package (`.zip`)

![Report & 29-File Journal Submission Package](/handbuch/screenshots/16-report-einreichungspaket.png)

Via `lib/paket.ts`, EvidenzWerk generates a complete **29-file journal submission archive (`einreichungspaket-projekt-<id>.zip`)** containing the full IMRaD manuscript, structured abstract, title page, cover letter, Table 1, GRADE Summary of Findings table, Vancouver & APA 7 bibliographies, PRISMA 2020 & PRISMA-S appendices, statistical appendix, RAISE AI disclosure, vector SVG figures, and a DIN A0 scientific conference poster in `.docx`, `.pdf`, and `.md`.

---

#### 8.5 🎓 Guided Student Mode (`Studi-Modus`) & Bilingual Architecture (`DE` / `EN`) — "Steering the Wheel Safely Without Engine Physics"

![🎓 Student Mode Hub with Starter Topics & AI Voice Co-Pilot](/handbuch/screenshots/17-studi-modus-voice-lotse.png)

Not everyone who wants a rigorous, evidence-based answer to a medical, psychological, or educational question holds a degree in biostatistics. Many university students in psychology, medicine, education, or health sciences — as well as interested parents (e.g., *"Does methylphenidate / Ritalin actually help children with ADHD?"*) or teenagers (e.g., *"Do smartphones reduce our attention span?"*) — want to synthesize real primary studies rather than rely on opinion blogs.

For this audience, EvidenzWerk provides the guided **🎓 Student Mode** (German: **🎓 Studi-Modus**) at `/studi` (`app/studi/page.tsx`) and inside every project at `/p/[id]/studi` ([`app/p/[id]/studi/page.tsx`](file:///Users/franzhuetter/evidenzwerk/app/p/%5Bid%5D/studi/page.tsx)):

1. **AI Voice & Chat Co-Pilot (`WizardVoiceBot.tsx`, `app/api/wizard/assistant/route.ts`):**
   - Supports **microphone voice input (Speech-to-Text)** and **spoken explanations (Text-to-Speech)** in English (`en-US`) and German (`de-DE`).
   - Explains methodological concepts in plain language grounded in the project's actual numbers (e.g., *"What is the difference between Mean, Median, and Hedges' g?"*, *"Why do we need Three-Level CR2 protection?"*, or *"How do I handle paywalled journals without university access?"*).
2. **Station 1 — Everyday Question to Structured PICOS Translator (`StudiQuestionTranslator.tsx`):**
   - Offers 4 one-click curated starter topics (*Methylphenidate/Ritalin for ADHD*, *Smartphones & Attention Span*, *CBT & Mindfulness for Exam Anxiety*, *Aerobic Exercise for Depression*) and translates any everyday question into the five scientific PICOS criteria.

![🎓 Student Mode Station 4: 3-Tier Paywall & Full-Text Navigator Without University Login](/handbuch/screenshots/18-studi-modus-paywall-lenkrad-klartext.png)

3. **Station 4 — The 3-Tier Paywall & Full-Text Navigator for Users Without University Library Access (`StudiPaywallNavigator.tsx`, `analyzePaywallStatusForProject`):**
   - **Tier 1 (Exhaust Free Legal Open Access First):** Automatically queries Unpaywall, PubMed Central (PMC), Europe PMC, and OpenAlex for legal green/gold Open-Access full-text PDFs.
   - **Tier 2 (Navigate Publisher Paywalls Pragmatically Without University Login):** When a journal article is locked behind a publisher paywall, each study card offers three transparent options:
     - **Option A (Publisher Purchase / 24h Rental + Direct Upload):** Direct DOI link to the publisher's article page and a 24-hour rental search link (DeepDyve), paired with an inline **Upload Purchased PDF** button that immediately extracts the study numbers with verbatim page quotes.
     - **Option B (Free Author Manuscript Request):** Generates a polite, ready-to-send email (EN/DE) to request the free *Accepted Author Manuscript* directly from the authors.
     - **Option C (Proceed with Public Abstract Numbers):** Uses sample sizes and effect numbers reported in the free PubMed/OpenAlex abstract and automatically flags the study for sensitivity verification.

![🎓 Student Mode Station 5 (EN): The 5 Methodological Steering Switches](/handbuch/screenshots/19-student-mode-english.png)

4. **Station 5 — The 5 Methodological Steering Switches (`buildSteeringDecisions`):**
   Users steer five intuitive methodological switches while the full R/metafor glass-box engine works under the hood (with expandable *Glass-Box Engine Details* for thesis supervisors and peer reviewers):
   - **Switch 1 (Comparison Fairness):** Randomized experiments (RCTs) vs. observational studies, automatically routed to RoB 2 or ROBINS-I.
   - **Switch 2 (Common Yardstick):** Automatic effect size selection (Hedges' $g$, Risk Ratio / Odds Ratio, Correlation $r$, or Hazard Ratio).
   - **Switch 3 (Protection Against Double-Counting Participants):** Automatic activation of **Three-Level Meta-Analysis (`metafor::rma.mv`) with `clubSandwich` CR2** whenever studies report multiple outcomes on the same participants.
   - **Switch 4 (Real-World Diversity vs. One-Size-Fits-All):** Random-Effects REML + Knapp-Hartung with 95% prediction interval.
   - **Switch 5 (File-Drawer & Publication Bias Check):** Automated check for unpublished registry trials and small-study effects.

![🎓 Student Mode Station 6 (EN): Plain-Language Result Interpreter & Dossier Download](/handbuch/screenshots/20-student-mode-dossier-english.png)

5. **Stations 6 & 7 — Plain-Language Result Interpreter, Plain-Language Evidence Dossier (`PDF`/`DOCX`/`MD`) & Standalone R Script (`reproduce.R`) (`lib/klartext-dossier.ts`):**
   - Translates the pooled effect estimate (e.g., $g = 0.71$) into the intuitive **Common Language Effect Size (CLES per McGraw & Wong 1992)**: *"69.2 out of 100 people in the intervention group achieve a better outcome than a randomly selected person in the control group (50% = coin toss)"*.
   - Generates a downloadable **Plain-Language Evidence Dossier (`.pdf`, `.docx`, `.md`)** in English or German alongside the self-contained, fully commented **R script (`reproduce-project-<id>.R`)** with embedded dataset.

---

## Part II — Technical System, Calculation Engine & OpenAPI 3.1 Documentation

### 9. System Architecture & Layered Design

EvidenzWerk is engineered as a self-contained **Next.js 16 application (App Router, TypeScript, React 19)** backed by synchronous **SQLite (`better-sqlite3` in WAL mode)** and an isolated **R statistical engine (`metafor` + `clubSandwich`)**.

```mermaid
flowchart TB
  subgraph Client["Clients & Consumers"]
    UI["Browser UI (Expert Studio & Student Mode)<br/>/p/[id] & /p/[id]/studi"]
    AG["AI Agents & Scripts<br/>OpenAPI 3.1 (/api/v1/*)"]
  end

  subgraph Guard["Authentication, Multi-Tenancy & Credits"]
    MW["proxy.ts & lib/route-guard.ts<br/>Session Cookie (evw_session) + Bearer Token (evw_...)"]
    TEN["lib/tenancy.ts<br/>Owner / Admin / project_members + Reviewer A/B Blinding"]
    CRED["lib/credits.ts & lib/licensing.ts<br/>Atomic Credit Reservation & Brain-HR License Bridge"]
  end

  subgraph Core["Shared Operations & Calculation Core (100% UI/API Parity)"]
    OPS["lib/v1/ops.ts & lib/repo.ts<br/>Transactional Core Operations, Audit Trail, Idempotency, Dry-Run"]
    RAT["lib/v1/ratification.ts<br/>4 Checkpoints for agent:* Decisions"]
    STAT["lib/stats.ts · lib/survival.ts · lib/nma.ts · lib/dta.ts · lib/spur.ts<br/>Deterministic TS Engine & Glass-Box Trace"]
    RBR["lib/r-service.ts -> r/analyse.R<br/>Subprocess Rscript (metafor::rma.mv + clubSandwich CR2)"]
    DOC["lib/docx.ts · lib/pdf.ts · lib/svg.ts · lib/abbildungen.ts · lib/paket.ts · lib/klartext-dossier.ts<br/>Native Binary Renderers for DOCX, PDF (TTF Subsetting), SVG, ZIP"]
  end

  subgraph Storage["Persistence & External Services"]
    DB[("SQLite (WAL)<br/>data/evidenzwerk.db")]
    PDFS[("Local PDF Store<br/>data/pdfs/*.pdf")]
    EXT["OpenAlex · PubMed · ClinicalTrials.gov<br/>Unpaywall · Europe PMC · Crossref · OpenRouter/Anthropic"]
  end

  UI --> MW
  AG --> MW
  MW --> TEN
  TEN --> CRED
  CRED --> OPS
  OPS --> RAT
  OPS --> STAT
  OPS --> RBR
  OPS --> DOC
  OPS --> DB
  OPS --> PDFS
  OPS --> EXT
```

#### Core Architectural Guarantees
1. **100% UI / `v1`-API Parity:** Both the browser UI and the `/api/v1/projects/[id]/*` endpoints invoke the exact same functions in `lib/v1/ops.ts` and `lib/repo.ts`, verified by `test/paritaet.test.ts`.
2. **"Never Two Numbers Under One Name" (`lib/laufwahl.ts`, `lib/analyse.ts`):** Every project has a single canonical primary run (`released = 1` 3-Level R run or latest synthesis run) shared across Manuscript, Abstract, Cover Letter, Summary of Findings, Poster, Statistical Appendix, and Plain-Language Dossier.
3. **Zero External Office/PDF Dependencies:** Word `.docx` (`lib/docx.ts`), `.pdf` with TrueType font subsetting (`lib/pdf.ts`, `lib/ttf.ts`), `.svg` charts (`lib/abbildungen.ts`), and `.zip` archives (`lib/zip.ts`) are generated in pure TypeScript without headless browser dependencies.

---

### 10. Database Schema (`SQLite` with WAL & Foreign Keys)

Initialized in `lib/db.ts` (`pragma journal_mode = WAL`, `pragma foreign_keys = ON`, `busy_timeout = 5000`), the database comprises **24 relational tables** across 6 domains:
- **Users, Auth & Team Blinding:** `users`, `sessions` (SHA-256 cookie hashes), `api_tokens` (SHA-256 token hashes), `project_members` (`role IN ('A', 'B', 'coauthor')`).
- **Credits & Licensing:** `credit_ledger`, `license_activations`.
- **Projects & Search:** `projects`, `search_runs`, `living_runs`, `living_candidates`.
- **Studies, Screening & Extraction:** `studies`, `decisions`, `extractions` (with verbatim `quote` and `page`), `study_codings`, `author_queries`.
- **Effects & Synthesis Runs:** `effects`, `analysis_runs` (with SHA-256 `data_hash` and `released` flag).
- **Quality, Evidence & Governance:** `rob2_assessments`, `robins_assessments`, `quadas2_assessments`, `grade_assessments`, `ratifications`, `idempotency_keys`, `llm_calls`.

---

### 11. R-Bridge (`metafor` + `clubSandwich`), OpenAPI 3.1 & Operations

- **Isolated R Subprocess (`lib/r-service.ts`):** Executes `execFile('Rscript', ['--vanilla', 'r/analyse.R', inputPath, outputPath])` with `shell: false`, 60-second timeout, automatic exclusion of retracted studies (`study_retracted = 1`), and canonical SHA-256 `computeDataHash` snapshot verification.
- **OpenAPI 3.1 (`GET /api/v1/openapi.json`):** Supports transactional dry-runs (`?dry_run=true` via SQLite `SAVEPOINT dry_run`), scoped idempotency (`Idempotency-Key` bound to `(key, actor, method, path)` + payload SHA-256), and automatic `human:*` vs. `agent:*` audit stamping.
- **Quality Assurance & Deployment (`Franz2`):** Verified by 40 automated test suites (`npm test`, $>680$ assertions) and deployed as a rootless Podman Quadlet container (`deploy/evidenzwerk.container`, `deploy/deploy.sh`) behind Caddy TLS at `https://metaanalysis.brain-hr.de`.
