Skip to content

Architecture

Luke C Hartman edited this page Nov 2, 2026 · 1 revision

Architecture

This repo is a Next.js (Pages Router) app with Firebase (Auth, Firestore, Storage, Cloud Functions, App Check). One codebase powers four sites — see Sites.

High-level layers

Browser (Next pages + components)
    ↔ AuthContext / Firebase client SDK
    ↔ Firestore + Storage
    ↔ Callable / triggered Cloud Functions
Layer Responsibility
pages/ Routes (login, dashboard, report, settings pages)
components/ UI (admin/, dashboard/, reports/, modals, etc.)
context/ Auth state and custom claims
hooks/, lib/, utils/ Shared helpers and data access
config/ Brand + Firebase client config (config/brand.js, config/brands/*, config/firebase.js)
functions/ Cloud Functions (Auth claims, experiment/archive, help requests, pipeline runs, temp passwords)
public/ Static assets and i18n locales (per-brand overrides under public/brands/, public/locales/_brands/)

Brands

NEXT_PUBLIC_BRAND selects misinfo (Truth Sleuth) or caffeine. Brand files hold app name, icons, feature flags (pipelineAdmin, experimentSettings), and optional fixed report agency. Study copies use env overrides — see Sites and Environment.

Local vs production

Mode Command Backend
Emulators (recommended for day-to-day) npm run dev Local Auth/Firestore/Functions/Storage
Live Firebase npm run dev:live [target] Real project (App Check / prod Auth apply)
Production App Hosting (Truth Sleuth live) or Netlify (other three sites) Real project

Data and pipeline

  • User and agency reports live in Firestore (reports, agency, …) — Firestore schema.
  • Nightly untrustworthy-site pipeline imports curated articles into live Truth Sleuth only (misinfo-5d004), not study or Caffeine.
  • Callable functions and triggers: Cloud Functions.

Where docs live

Clone this wiki locally