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.
# Install dependencies npm install # Download data for offline development (optional) npm run download-data # Start development server npm run dev
Visit http://localhost:3000
- Features
- Tech Stack
- Installation
- Development
- Testing
- Social Login Setup (OAuth)
- Deployment
- Project Structure
- Documentation
- Contributing
- License
- 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
- 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
- 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
- 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
- Nitro - Universal server engine
- Node.js 22+ - Server runtime
- SQLite - Local database (better-sqlite3)
- Canvas - Server-side chart rendering
- PapaParse - CSV parsing
- Zod - Data validation
- S3 - Data storage and CDN
- 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
- Node.js 22+ (LTS recommended)
- npm 10+
brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman
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
npm install
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
Mortality Watch supports true offline development - work on planes, trains, or anywhere without internet!
Edit .env:
# Download only these countries NUXT_PUBLIC_DEV_COUNTRIES=USA,SWE,DEU # Enable offline mode NUXT_PUBLIC_USE_LOCAL_CACHE=true
# Download just your dev countries (fast) npm run download-data # Or download all 320+ countries (slow, ~15min) npm run download-data -- --all
npm run dev
Now:
- β Zero internet requests
- β All data served from local cache
- β Fast development iteration
- β Helpful errors if you try unavailable countries
| 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 |
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
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
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)
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
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)
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
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)
Every push triggers automated checks:
- Lint & Format - ESLint with auto-fix
- Type Check - TypeScript strict mode
- Unit Tests - 376 Vitest tests
- Build Verification - Production build check
- E2E Tests - Playwright on Chromium
All checks must pass before merge. View CI status:
Git hooks automatically run on commit:
- ESLint (auto-fix enabled)
- Prettier (auto-format)
- TypeScript type checking
Powered by husky + lint-staged.
Mortality Watch supports social login with X (Twitter) and Google. Social login buttons only appear when the corresponding OAuth credentials are configured.
- Go to Twitter Developer Portal
- Create a new app or use an existing one
- Go to User authentication settings and enable OAuth 2.0
- Set the following:
- Type of App: Web App
- Callback URL:
https://your-domain.com/auth/twitter - Website URL:
https://your-domain.com
- 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
- Go to Google Cloud Console
- Create a new project or select an existing one
- Go to APIs & Services β Credentials
- Click Create Credentials β OAuth client ID
- Select Web application
- Add to Authorized redirect URIs:
https://your-domain.com/auth/google - 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
Social login session encryption automatically reuses your existing JWT_SECRET - no additional configuration needed.
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
- 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)
# 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.
# Add Dokku remote git remote add dokku [email protected]:mortality-watch # Deploy git push dokku master
# Build npm run build # Run NODE_ENV=production node .output/server/index.mjs
# Generate static site npm run generate # Deploy .output/public directory
Note: Server routes (/chart.png, /api/*) won't work with static deployment.
.
βββ 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
- README.md - This file (overview and getting started)
- DEPLOYMENT.md - Deployment options (Docker, Dokku, Node.js)
- ACCESSIBILITY.md - Accessibility guidelines and testing
- 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
- Prerendered:
/,/about,/sources,/donate(static HTML at build time) - Server-Side Rendered:
/ranking(fresh data on each request) - Client-Only:
/explorer(interactive, no SSR)
- Development: Client β
/api/data/*β Local cache or S3 fallback - Production: Client β
/api/data/*β S3 - Server: Direct S3 fetch (no self-requests)
- Client-side: Interactive charts in browser
- Server-side: PNG generation for Open Graph images (
/chart.png) - State: Encoded in URL query parameters
-
Fork and clone
git clone https://github.com/your-username/mortality-watch.git cd mortality-watch -
Install dependencies
npm install
-
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
-
Create a branch
git checkout -b feature/your-feature
-
Make changes
- Write code
- Add tests
- Run
npm run check
-
Commit
git commit -m "feat: add awesome feature"Pre-commit hooks will automatically:
- Lint and fix code
- Format with Prettier
- Run type checks
-
Push and create PR
git push origin feature/your-feature
Follow Conventional Commits:
feat:- New featurefix:- Bug fixdocs:- Documentation changeschore:- Maintenance tasksrefactor:- Code refactoringtest:- Test changesperf:- Performance improvements
- 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
[Add your license here]
- UN World Population Prospects - Historical mortality data
- World Mortality Dataset - Recent mortality statistics
- National Statistics Offices - Country-specific data
- Built with Nuxt
- Charts powered by Chart.js
- UI components from Nuxt UI
- Deployed on [Your hosting platform]
- Website: https://www.mortality.watch
- GitHub: https://github.com/MortalityWatch/mortality-watch
- Issues: https://github.com/MortalityWatch/mortality-watch/issues
- 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
- 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