GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com β€” GitHub - MortalityWatch/mortality.watch: Track Global Mortality, Life Expectancy & Excess Deaths

BranchesTags
Open more actions menu

Latest commit

 

History

657 Commits
657 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.husky
.husky
 
 
.vscode
.vscode
 
 
app
app
 
 
db
db
 
 
docs
docs
 
 
public
public
 
 
scripts
scripts
 
 
server
server
 
 
tests
tests
 
 
.dockerignore
.dockerignore
 
 
.editorconfig
.editorconfig
 
 
.env.example
.env.example
 
 
.gitignore
.gitignore
 
 
.npmrc
.npmrc
 
 
.nvmrc
.nvmrc
 
 
CLAUDE.md
CLAUDE.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
Procfile
Procfile
 
 
README.md
README.md
 
 
REVIEW.md
REVIEW.md
 
 
SECURITY.md
SECURITY.md
 
 
bugs.md
bugs.md
 
 
bun.lock
bun.lock
 
 
drizzle.config.ts
drizzle.config.ts
 
 
eslint.config.mjs
eslint.config.mjs
 
 
nuxt.config.ts
nuxt.config.ts
 
 
package.json
package.json
 
 
playwright.config.ts
playwright.config.ts
 
 
pre-deploy.sh
pre-deploy.sh
 
 
renovate.json
renovate.json
 
 
tsconfig.json
tsconfig.json
 
 
tsconfig.test.json
tsconfig.test.json
 
 
vitest.config.ts
vitest.config.ts
 
 

Repository files navigation

Mortality Watch

CI

Global mortality data visualization and analysis platform

A Nuxt 4 web application for exploring and analyzing mortality data across 320+ countries and territories. Features interactive charts, real-time data visualization, and comprehensive mortality statistics from multiple international sources.


πŸš€ Quick Start

# Install dependencies
npm install

# Download data for offline development (optional)
npm run download-data

# Start development server
npm run dev

Visit http://localhost:3000


πŸ“‹ Table of Contents

  • Features
  • Tech Stack
  • Installation
  • Development
    • Environment Variables
    • Offline Development
    • Available Scripts
  • Testing
  • Social Login Setup (OAuth)
  • Deployment
  • Project Structure
  • Documentation
  • Contributing
  • License

✨ Features

Data Visualization

  • Interactive Charts: Line, bar, and matrix charts with Chart.js
  • Multiple Chart Types: Weekly, monthly, quarterly, yearly data
  • Age Group Analysis: All ages, 0-14, 15-64, 65-74, 75-84, 85+
  • Excess Mortality: Calculate and visualize excess deaths
  • Baseline Methods: Linear regression, mean, auto-detection
  • Moving Averages: 13w, 26w, 52w, 104w smoothing

Data Sources

  • 320+ Countries: Comprehensive global coverage
  • Multiple Sources: UN, World Mortality Dataset, national statistics
  • Real-time Updates: Data fetched from S3 CDN
  • Age-Standardized Rates: ASMR calculations with standard populations

Technical Features

  • Hybrid SSR: Prerendered pages + SSR + client-only routes
  • Offline Development: Work without internet after initial download
  • Server-side Chart Rendering: Dynamic OG images for social sharing
  • Security: OWASP-compliant headers, CSP, XSS protection
  • Accessibility: WCAG 2.1 compliant, screen reader friendly
  • Performance: Optimized builds, CDN-ready, caching strategies

πŸ›  Tech Stack

Frontend

  • Nuxt 4 - Vue 3 meta-framework with hybrid rendering
  • Vue 3 - Composition API with script setup
  • TypeScript - Strict mode enabled
  • Tailwind CSS - Utility-first styling via Nuxt UI
  • Chart.js - Interactive data visualization
  • PrimeVue - Additional UI components

Backend

  • Nitro - Universal server engine
  • Node.js 22+ - Server runtime
  • SQLite - Local database (better-sqlite3)
  • Canvas - Server-side chart rendering

Data

  • PapaParse - CSV parsing
  • Zod - Data validation
  • S3 - Data storage and CDN

Development & Testing

  • Vitest - Unit testing (376 tests)
  • Playwright - E2E testing (32+ tests)
  • GitHub Actions - CI/CD pipeline
  • ESLint - Code linting with accessibility rules
  • Prettier - Code formatting
  • Husky - Git hooks
  • Lint-staged - Pre-commit checks

πŸ“¦ Installation

Prerequisites

  • Node.js 22+ (LTS recommended)
  • npm 10+

Canvas Dependencies (for server-side chart rendering)

macOS

brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

Ubuntu/Debian

sudo apt-get update
sudo apt-get install -y \
  build-essential \
  libcairo2-dev \
  libpango1.0-dev \
  libjpeg-dev \
  libgif-dev \
  librsvg2-dev \
  libpixman-1-dev

Windows

See node-canvas documentation

Install Project Dependencies

npm install

πŸ’» Development

Environment Variables

Create a .env file based on .env.example:

# Public site URL (for OG images)
NUXT_PUBLIC_SITE_URL=https://www.mortality.watch

# Incognito mode (inverts colors)
NUXT_PUBLIC_INCOGNITO_MODE=0

# Use local cache only (offline mode)
NUXT_PUBLIC_USE_LOCAL_CACHE=true

# Development countries (subset for offline work)
NUXT_PUBLIC_DEV_COUNTRIES=USA,SWE,DEU

# Email (Resend)
EMAIL_HOST_PASSWORD=your_resend_api_key
EMAIL_FROM=Mortality Watch <[email protected]>

# Error tracking (optional)
SENTRY_DSN=your_sentry_dsn

# Umami Analytics (optional)
NUXT_UMAMI_ID=your_website_id          # Get from Umami dashboard
NUXT_UMAMI_HOST=https://ua.e7ad.cc  # Your Umami instance URL

Offline Development

Mortality Watch supports true offline development - work on planes, trains, or anywhere without internet!

Step 1: Choose Your Countries

Edit .env:

# Download only these countries
NUXT_PUBLIC_DEV_COUNTRIES=USA,SWE,DEU

# Enable offline mode
NUXT_PUBLIC_USE_LOCAL_CACHE=true

Step 2: Download Data

# Download just your dev countries (fast)
npm run download-data

# Or download all 320+ countries (slow, ~15min)
npm run download-data -- --all

Step 3: Work Offline

npm run dev

Now:

  • βœ… Zero internet requests
  • βœ… All data served from local cache
  • βœ… Fast development iteration
  • βœ… Helpful errors if you try unavailable countries

Development Modes

Mode Command Countries Internet
Offline Dev (recommended) npm run dev From .env ❌ Not needed
Default Remove env var 18 defaults βœ… Fallback to S3
Custom Subset Set NUXT_PUBLIC_DEV_COUNTRIES Your choice βœ… Fallback to S3
All Countries npm run download-data -- --all 320+ βœ… Required once

Available Scripts

Development

npm run dev              # Start dev server (http://localhost:3000)
npm run build            # Production build
npm run generate         # Static site generation
npm run preview          # Preview production build

Data Management

npm run download-data              # Download dev countries from .env
npm run download-data -- --all     # Download all 320+ countries
NUXT_PUBLIC_DEV_COUNTRIES=USA,GBR npm run download-data  # Custom subset

Code Quality

npm run lint             # Check linting
npm run lint:fix         # Auto-fix linting issues
npm run format           # Format code with Prettier
npm run typecheck        # TypeScript type checking
npm run check            # Run all checks (lint + typecheck + test)

Testing

npm run test             # Run unit tests
npm run test:ui          # Test UI with Vitest
npm run test:coverage    # Test coverage report
npm run test:e2e         # Run E2E tests
npm run test:e2e:ui      # E2E test UI (interactive)
npm run test:e2e:debug   # Debug E2E tests
npm run test:e2e:report  # View E2E test report

Development Server

npm run dev

Features:

  • Hot Module Replacement - Instant updates
  • TypeScript - Full type checking
  • Server Routes - /api/data/*, /chart.png, /api/health
  • Local Data Cache - Offline-first development

Pages:

  • / - Homepage (prerendered)
  • /explorer - Interactive data explorer (client-only)
  • /ranking - Country rankings (SSR)
  • /about - About page (prerendered)
  • /sources - Data sources (prerendered)
  • /donate - Donation page (prerendered)

πŸ§ͺ Testing

Unit Tests (Vitest)

npm test                 # Run all unit tests
npm run test:ui          # Interactive test UI
npm run test:coverage    # Coverage report

376 unit tests passing βœ…

Coverage includes:

  • Data loading and processing
  • Chart state management
  • Data validation
  • URL state encoding/decoding
  • Mortality calculations
  • Utility functions
  • Composables

E2E Tests (Playwright)

npm run test:e2e         # Run E2E tests (chromium)
npm run test:e2e:ui      # Interactive E2E test UI
npm run test:e2e:debug   # Debug E2E tests
npm run test:e2e:report  # View test report

32+ E2E tests passing βœ…

Test coverage:

  • Homepage and navigation
  • Explorer page interactions
  • Ranking page functionality
  • Chart rendering and controls
  • Responsive layout
  • URL state persistence

E2E tests run on:

  • Chromium (CI and local)
  • Firefox (local only)
  • WebKit/Safari (local only)
  • Mobile viewports (Chrome & Safari)

CI/CD Pipeline

Every push triggers automated checks:

  1. Lint & Format - ESLint with auto-fix
  2. Type Check - TypeScript strict mode
  3. Unit Tests - 376 Vitest tests
  4. Build Verification - Production build check
  5. E2E Tests - Playwright on Chromium

All checks must pass before merge. View CI status: CI

Pre-commit Checks

Git hooks automatically run on commit:

  • ESLint (auto-fix enabled)
  • Prettier (auto-format)
  • TypeScript type checking

Powered by husky + lint-staged.


πŸ” Social Login Setup (OAuth)

Mortality Watch supports social login with X (Twitter) and Google. Social login buttons only appear when the corresponding OAuth credentials are configured.

X (Twitter) OAuth Setup

  1. Go to Twitter Developer Portal
  2. Create a new app or use an existing one
  3. Go to User authentication settings and enable OAuth 2.0
  4. Set the following:
    • Type of App: Web App
    • Callback URL: https://your-domain.com/auth/twitter
    • Website URL: https://your-domain.com
  5. Copy your Client ID and Client Secret

Add to .env:

NUXT_OAUTH_X_CLIENT_ID=your_client_id
NUXT_OAUTH_X_CLIENT_SECRET=your_client_secret

Google OAuth Setup

  1. Go to Google Cloud Console
  2. Create a new project or select an existing one
  3. Go to APIs & Services β†’ Credentials
  4. Click Create Credentials β†’ OAuth client ID
  5. Select Web application
  6. Add to Authorized redirect URIs: https://your-domain.com/auth/google
  7. Copy your Client ID and Client Secret

Add to .env:

NUXT_OAUTH_GOOGLE_CLIENT_ID=your_client_id
NUXT_OAUTH_GOOGLE_CLIENT_SECRET=your_client_secret

Session Encryption

Social login session encryption automatically reuses your existing JWT_SECRET - no additional configuration needed.

Local Development

For local development, use http://localhost:3000 as your redirect URI:

  • X callback: http://localhost:3000/auth/twitter
  • Google callback: http://localhost:3000/auth/google

Behavior

  • If OAuth credentials are not set, the social login buttons are automatically hidden
  • Users can sign up/login with social providers, which:
    • Creates a new account if the email doesn't exist
    • Links to an existing account if the email matches
    • Automatically marks email as verified (social providers verify emails)

🚒 Deployment

Docker (Recommended)

# Build
docker build -t mortality-watch .

# Run
docker run -p 3000:3000 \
  -e NUXT_PUBLIC_SITE_URL=https://www.mortality.watch \
  mortality-watch

See DEPLOYMENT.md for complete Docker, Dokku, and Node.js deployment guides.

Dokku

# Add Dokku remote
git remote add dokku [email protected]:mortality-watch

# Deploy
git push dokku master

Node.js Server

# Build
npm run build

# Run
NODE_ENV=production node .output/server/index.mjs

Vercel/Netlify (Static)

# Generate static site
npm run generate

# Deploy .output/public directory

Note: Server routes (/chart.png, /api/*) won't work with static deployment.


πŸ“‚ Project Structure

.
β”œβ”€β”€ app/                          # Application code
β”‚   β”œβ”€β”€ components/              # Vue components
β”‚   β”‚   └── charts/              # Chart components
β”‚   β”œβ”€β”€ composables/             # Vue composables
β”‚   β”œβ”€β”€ lib/                     # Utility libraries
β”‚   β”‚   β”œβ”€β”€ chartState.ts        # Chart state encoding/decoding
β”‚   β”‚   β”œβ”€β”€ dataLoader.ts        # Data loading abstraction
β”‚   β”‚   └── mortality/           # Mortality-specific utilities
β”‚   β”œβ”€β”€ pages/                   # Route pages
β”‚   β”œβ”€β”€ data.ts                  # Core data fetching logic
β”‚   β”œβ”€β”€ model.ts                 # TypeScript types
β”‚   └── chart.ts                 # Chart.js configuration
β”‚
β”œβ”€β”€ server/                       # Server-side code
β”‚   β”œβ”€β”€ api/                     # API routes
β”‚   β”‚   β”œβ”€β”€ data/[...path].ts   # Data proxy with local cache
β”‚   β”‚   └── health.ts           # Health check endpoint
β”‚   β”œβ”€β”€ routes/                  # Custom server routes
β”‚   β”‚   └── chart.png.ts        # Server-side chart rendering
β”‚   └── utils/                   # Server utilities
β”‚       └── chartRenderer.ts    # Chart.js server setup
β”‚
β”œβ”€β”€ scripts/                      # Build and utility scripts
β”‚   └── download-data.ts         # Data download script
β”‚
β”œβ”€β”€ .data/                        # Local data cache (git-ignored)
β”‚   └── cache/
β”‚       └── mortality/           # Downloaded CSV files
β”‚
β”œβ”€β”€ public/                       # Static assets
β”œβ”€β”€ tests/                        # Test files (co-located with source)
β”‚
β”œβ”€β”€ nuxt.config.ts               # Nuxt configuration
β”œβ”€β”€ package.json                 # Dependencies and scripts
β”œβ”€β”€ tsconfig.json                # TypeScript configuration
β”œβ”€β”€ eslint.config.mjs            # ESLint configuration
β”‚
β”œβ”€β”€ Dockerfile                   # Docker container
β”œβ”€β”€ .dockerignore                # Docker build optimization
β”‚
β”œβ”€β”€ README.md                    # This file
β”œβ”€β”€ DEPLOYMENT.md                # Deployment guide
└── ACCESSIBILITY.md             # Accessibility documentation

πŸ“š Documentation

Comprehensive Guides

  • README.md - This file (overview and getting started)
  • DEPLOYMENT.md - Deployment options (Docker, Dokku, Node.js)
  • ACCESSIBILITY.md - Accessibility guidelines and testing

Architecture

  • Hybrid SSR: Prerendered pages for SEO, SSR for fresh data, client-only for interactivity
  • Data Layer: Environment-aware data loading (local cache in dev, S3 in production)
  • Server Routes: Chart rendering, data proxy, health checks
  • Security: OWASP headers, CSP, XSS protection
  • Accessibility: WCAG 2.1 compliance, screen reader support

Key Concepts

Rendering Modes

  • Prerendered: /, /about, /sources, /donate (static HTML at build time)
  • Server-Side Rendered: /ranking (fresh data on each request)
  • Client-Only: /explorer (interactive, no SSR)

Data Flow

  1. Development: Client β†’ /api/data/* β†’ Local cache or S3 fallback
  2. Production: Client β†’ /api/data/* β†’ S3
  3. Server: Direct S3 fetch (no self-requests)

Chart Rendering

  • Client-side: Interactive charts in browser
  • Server-side: PNG generation for Open Graph images (/chart.png)
  • State: Encoded in URL query parameters

🀝 Contributing

Development Workflow

  1. Fork and clone

    git clone https://github.com/your-username/mortality-watch.git
    cd mortality-watch
  2. Install dependencies

    npm install
  3. Download test data

    # Quick start with 3 countries
    echo "NUXT_PUBLIC_DEV_COUNTRIES=USA,GBR,DEU" >> .env
    echo "NUXT_PUBLIC_USE_LOCAL_CACHE=true" >> .env
    npm run download-data
  4. Create a branch

    git checkout -b feature/your-feature
  5. Make changes

    • Write code
    • Add tests
    • Run npm run check
  6. Commit

    git commit -m "feat: add awesome feature"

    Pre-commit hooks will automatically:

    • Lint and fix code
    • Format with Prettier
    • Run type checks
  7. Push and create PR

    git push origin feature/your-feature

Commit Message Format

Follow Conventional Commits:

  • feat: - New feature
  • fix: - Bug fix
  • docs: - Documentation changes
  • chore: - Maintenance tasks
  • refactor: - Code refactoring
  • test: - Test changes
  • perf: - Performance improvements

Code Standards

  • TypeScript: Strict mode enabled
  • ESLint: No errors allowed
  • Prettier: Auto-formatted on commit
  • Tests: Add tests for new features
  • Accessibility: Follow WCAG 2.1 AA guidelines

πŸ“„ License

[Add your license here]


πŸ™ Acknowledgments

Data Sources

  • UN World Population Prospects - Historical mortality data
  • World Mortality Dataset - Recent mortality statistics
  • National Statistics Offices - Country-specific data

Technologies

  • Built with Nuxt
  • Charts powered by Chart.js
  • UI components from Nuxt UI
  • Deployed on [Your hosting platform]

πŸ“§ Contact

  • Website: https://www.mortality.watch
  • GitHub: https://github.com/MortalityWatch/mortality-watch
  • Issues: https://github.com/MortalityWatch/mortality-watch/issues

πŸ—ΊοΈ Roadmap

Planned Features

  • Additional chart types (scatter, radar)
  • Export data as CSV/JSON
  • Comparison mode (multiple countries side-by-side)
  • Embed charts on external sites
  • Mobile app (Progressive Web App)
  • API for programmatic access
  • User accounts and saved configurations

Infrastructure

  • Redis caching for chart images
  • CDN integration for global distribution (S3)
  • Automated data updates from sources
  • CI/CD pipeline (GitHub Actions)
  • Error tracking (Sentry)
  • Analytics (Umami - privacy-first)

Built with ❀️ by the Mortality Watch team

Last updated: 2026-01-02

About

Track Global Mortality, Life Expectancy & Excess Deaths

www.mortality.watch

Topics

epidemiologyexcess-deathslife-expectancymortalitynuxtpublic-healthtypescript

Resources

Readme
AGPL-3.0 license

Contributing

Contributing

Security policy

Security policy
Activity

Stars

2 stars

Watchers

0 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 β€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Γ—600. No cookies required.