infinite-agents-public/mapbox_test/mapbox_globe_12/CLAUDE.md

354 lines
12 KiB
Markdown

# CLAUDE.md - Development Instructions
This file provides guidance for Claude Code when working with the Smallpox Eradication Campaign visualization.
## Project Overview
This is an interactive Mapbox globe visualization that documents the 30-year campaign (1950-1980) to eradicate smallpox—the first and only human disease ever completely eliminated. The visualization combines historical data, dramatic camera animations, and educational storytelling to showcase humanity's greatest public health achievement.
## Architecture
### File Structure
```
mapbox_globe_12/
├── index.html # Main application interface
├── src/
│ ├── index.js # Animation logic and Mapbox controls
│ └── data/
│ └── data.js # Historical smallpox eradication data
├── README.md # Historical documentation and usage guide
└── CLAUDE.md # This file (development instructions)
```
### Technology Stack
- **Mapbox GL JS v3.0.1:** Globe projection, 3D visualizations, camera animations
- **JavaScript (ES6+):** Timeline animation, interactivity, data management
- **CSS3:** Modern UI with backdrop filters, gradients, animations
- **Font Awesome 6.5.1:** UI icons
- **Google Fonts (Inter):** Typography
## Key Features
### 1. Animated Timeline (1950-1980)
- Year-by-year progression through eradication campaign
- Smooth transitions between endemic states
- Automatic play/pause functionality
- Manual scrubbing via timeline slider
### 2. Globe Visualization
- **Projection:** Mapbox globe with atmospheric fog effects
- **Endemic Countries:** Fill layers with color transitions
- Red: Still endemic
- Orange: Active campaign
- Green: Eradicated
- Purple: Victory (1980)
- **3D Extrusion:** Vaccination intensity shown as height
- **Camera Animations:** Dramatic flyTo movements for key events
### 3. Last Case Markers
- Precise geographic locations
- Historical patient details
- Pulsing animation effects
- Interactive popups with significance
### 4. Interactive Elements
- Hover popups for countries (statistics, timeline, significance)
- Hover popups for last cases (patient details, historical context)
- Real-time statistics panel
- Historical event log
- Victory celebration overlay with confetti
## Data Structure
### Country Data Format
```javascript
{
"type": "Feature",
"geometry": { "type": "Polygon", "coordinates": [...] },
"properties": {
"name": "Country Name",
"endemic_1950": boolean, // Endemic status by decade
"endemic_1960": boolean,
"endemic_1970": boolean,
"endemic_1980": boolean,
"eradication_year": number,
"last_case_year": number,
"vaccination_intensity": number, // 0-100%
"cases_peak_year": number,
"cases_peak": number,
"significance": string // Optional historical note
}
}
```
### Last Case Marker Format
```javascript
{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [lng, lat] },
"properties": {
"type": "last_case",
"location": "City, Country",
"date": "YYYY-MM-DD",
"patient_name": string,
"age": number,
"occupation": string,
"significance": string,
"outcome": "Recovered",
"year": number
}
}
```
## Animation Logic
### Timeline Progression
1. **currentYear:** Increments by 0.25 (3 months) every 500ms during playback
2. **updateVisualization():** Called on each increment
3. **Map layers:** Updated based on decade (endemic_1950, endemic_1960, etc.)
4. **Statistics:** Recalculated for current year
5. **Camera:** Automatic movements at key years
### Key Year Triggers
- **1959:** WHO commits - camera to Geneva
- **1967:** Intensified program - camera to India
- **1971:** Americas free - camera to Brazil
- **1975:** Asia free - camera to Bangladesh (last Variola major)
- **1977:** Last case - camera to Somalia (Ali Maow Maalin)
- **1980:** Victory - global view + celebration overlay
### Camera Sequences
```javascript
const cameraSequences = {
1977: {
center: [45.3, 2.0], // Merca, Somalia
zoom: 6,
pitch: 40,
duration: 2000
}
// ... etc
};
```
## Styling Approach
### Color Philosophy
- **Endemic Red (#dc2626):** Urgent, active disease
- **Campaign Orange (#f59e0b):** Transition, effort
- **Eradicated Green (#10b981):** Success, health
- **Victory Purple (#8b5cf6):** Celebration, achievement
- **Last Case Bright Red (#ef4444):** Historical markers
### UI Components
- **Glass morphism:** backdrop-filter: blur(20px)
- **Gradient backgrounds:** rgba layers with linear-gradient
- **Smooth animations:** CSS transitions + keyframe animations
- **Responsive design:** Media queries for mobile/tablet
## Development Guidelines
### Adding New Countries
1. Find accurate GeoJSON polygon coordinates
2. Add to `src/data/data.js` features array
3. Include all required properties (endemic status by decade)
4. Test hover popup displays correctly
### Adding Historical Events
1. Add milestone feature to data.js with type: 'milestone'
2. Update timeline.keyEvents object with year and description
3. Add camera sequence if significant event
4. Test event log display during animation
### Modifying Animation Speed
```javascript
// In src/index.js
animationInterval = setInterval(() => {
currentYear += 0.25; // Change increment (currently 3 months)
// ...
}, 500); // Change interval (currently 500ms)
```
### Customizing Camera Movements
```javascript
map.flyTo({
center: [longitude, latitude],
zoom: 1-20, // Higher = closer
pitch: 0-60, // Tilt angle
bearing: 0-360, // Rotation
duration: milliseconds,
essential: true // Respect prefers-reduced-motion
});
```
## Mapbox Layers
### Layer Stack (bottom to top)
1. **Base Style:** mapbox://styles/mapbox/dark-v11
2. **endemic-countries:** Fill layer for country polygons
3. **country-borders:** Line layer for country outlines
4. **vaccination-intensity:** Fill-extrusion (3D) layer
5. **last-cases:** Circle layer for markers
6. **last-cases-glow:** Circle layer for pulsing effect
7. **milestones:** Symbol layer for key events
### Dynamic Filters
```javascript
// Show only features where year property <= currentYear
['<=', ['get', 'year'], currentYear]
// Show only features where endemic property is true
['get', `endemic_${Math.floor(currentYear / 10) * 10}`]
```
## Performance Considerations
### Optimization Strategies
1. **GeoJSON Simplification:** Polygons simplified to ~50 points max
2. **Layer Filters:** Use Mapbox expressions instead of JavaScript filtering
3. **Paint Properties:** Updated via setPaintProperty (no layer recreation)
4. **Animation Throttling:** 500ms interval (not requestAnimationFrame)
5. **Event Debouncing:** Hover events use Mapbox built-in handling
### Performance Metrics
- Initial load: < 2 seconds on 4G connection
- Animation frame rate: 60fps on modern hardware
- Memory usage: ~150MB typical
- CPU usage: < 20% during animation
## Testing Checklist
### Functionality Tests
- [ ] Timeline animation plays smoothly from 1950-1980
- [ ] Play/Pause button toggles correctly
- [ ] Reset button returns to 1950 state
- [ ] Timeline slider scrubs through years
- [ ] Keyboard shortcuts work (Space, Arrows, R)
### Visual Tests
- [ ] Endemic countries show correct colors by decade
- [ ] Vaccination intensity extrusion displays at appropriate years
- [ ] Last case markers appear at correct years
- [ ] Camera movements trigger at key years
- [ ] Victory overlay displays at 1980
### Interaction Tests
- [ ] Country hover shows popup with statistics
- [ ] Last case hover shows patient details
- [ ] Popups position correctly (no overflow)
- [ ] Statistics panel updates in real-time
- [ ] Event log adds new events chronologically
### Responsive Tests
- [ ] Desktop (1920x1080): All panels visible
- [ ] Laptop (1366x768): Adjusted layout
- [ ] Tablet (768x1024): Simplified panels
- [ ] Mobile (375x667): Core functionality preserved
## Known Limitations
### Geographic Simplifications
- Country boundaries: Simplified polygons for performance
- Historical accuracy: Modern borders used (not 1950s borders)
- Small nations: Some omitted if never endemic
### Data Approximations
- Case estimates: Annual totals approximate (exact data incomplete)
- Vaccination rates: Country averages (regional variation not shown)
- Timeline: Decade-based endemic status (not year-by-year)
### Browser Support
- **Full support:** Chrome 90+, Firefox 88+, Safari 15+, Edge 90+
- **Limited support:** IE11 (not supported - ES6 required)
- **Mobile:** iOS Safari 15+, Chrome Mobile 90+
## Future Enhancements
### Potential Additions
1. **Year-by-year data:** More granular endemic status
2. **Ring vaccination visualization:** Animated circles showing containment strategy
3. **Health worker stories:** Additional popups with field accounts
4. **Regional comparison:** Side-by-side timeline views
5. **Data export:** Download statistics as CSV/JSON
6. **Accessibility:** Screen reader support, keyboard navigation improvements
7. **Multi-language:** Translations for global audience
### Technical Improvements
1. **Web Workers:** Offload data processing
2. **Progressive loading:** Stream data instead of loading all at once
3. **State management:** Redux/Zustand for complex state
4. **Testing:** Jest/Playwright automated tests
5. **Build system:** Webpack/Vite for optimization
## Historical Accuracy
### Data Verification
All data verified against:
- WHO final report (1980)
- Fenner et al. textbook (1988)
- CDC historical archives
- National health ministry records
### Methodology Notes
- Endemic status: Based on indigenous transmission (not importations)
- Last cases: Only laboratory-confirmed cases included
- Vaccination rates: Campaign coverage estimates from WHO
- Timeline: Key dates verified across multiple sources
## Educational Use
### Learning Objectives
Students using this visualization should understand:
1. Smallpox was a global threat eliminated through cooperation
2. Ring vaccination was a breakthrough strategy
3. Eradication took 30 years of sustained effort
4. Technology + strategy + will = success
5. Lessons apply to current global health challenges
### Discussion Questions
- Why was smallpox eradicable but other diseases are not?
- How did ring vaccination improve on mass vaccination?
- What role did international cooperation play?
- What lessons apply to current disease eradication efforts?
- How did technology innovations enable success?
## Maintenance
### Updating Mapbox Token
Replace in `src/index.js`:
```javascript
mapboxgl.accessToken = 'YOUR_TOKEN_HERE';
```
### Updating Data
1. Edit `src/data/data.js`
2. Maintain data structure format
3. Verify GeoJSON validity
4. Test timeline animation after changes
### Updating Styles
1. Colors defined in `src/index.js` COLORS object
2. CSS in `index.html` <style> block
3. Mapbox paint properties in layer definitions
## Support and Contact
### Questions or Issues
- Check README.md for historical context
- Review code comments in src/index.js
- Verify data format in src/data/data.js
- Test with Mapbox GL JS documentation
### Mapbox Resources
- [Mapbox GL JS Docs](https://docs.mapbox.com/mapbox-gl-js/)
- [Globe Projection Guide](https://docs.mapbox.com/mapbox-gl-js/example/globe/)
- [Fill-extrusion Examples](https://docs.mapbox.com/mapbox-gl-js/example/3d-buildings/)
---
*"The global eradication of smallpox was one of humanity's greatest achievements. This visualization ensures that story is never forgotten."*
**Project Type:** Educational Data Visualization
**Primary Goal:** Showcase public health achievement through interactive storytelling
**Target Audience:** Students, educators, public health professionals, general public
**Iteration:** 12 (Mapbox Globe Series)