A Node.js application that fetches, processes, and generates JSON data files for the IFRC Preparedness for Effective Response (PER) Dashboard.
This data fetcher was developed in January 2025 to support the PER Dashboard components in the IFRC GO Platform:
- GO Web App: IFRCGo/go-web-app
- The main IFRC GO Platform web application
- Contains two complementary PER Dashboard views in
app/src/views/PERDashboard/:- Summary Dashboard: Overview of global PER implementation, showing:
- Assessment completion rates by region
- Global statistics and trends
- Special considerations coverage (Urban, Epidemic, Climate)
- Geographic distribution of assessments
- Performance Dashboard: Detailed analysis of assessment results, including:
- Component-level ratings and trends
- Area-wise performance breakdown
- Cycle-to-cycle comparisons
- Detailed country-level insights
- Summary Dashboard: Overview of global PER implementation, showing:
- Has a storybook implementation in
packages/go-ui-storybook/src/stories/ - Uses the processed data from this fetcher for visualizations and analysis
The PER Dashboards provide interactive visualizations and analysis tools for National Societies' preparedness assessments. This data fetcher optimizes and pre-processes the raw API data to enable efficient dashboard performance and reduce client-side computation.
The PER Data Fetcher serves as a data pipeline that:
- Fetches raw assessment data from the IFRC API
- Processes and transforms the data into optimized formats
- Generates JSON files used by the PER Dashboard for visualization and analysis
- Fetches data from multiple IFRC API endpoints using pagination:
/api/v2/per-status/: Assessment status information/api/v2/countries/: Country data with geographical information/api/v2/per-prioritization/: Component prioritization data/api/v2/per-assessments/: Detailed assessment data
The raw data is processed and transformed into several specialized JSON files:
Raw data fetched from API endpoints:
per-assessments.json(~26MB): Raw assessment data and responsescountries.json(~397KB): Country and geographical informationprioritization.json(~708KB): Component prioritization dataper-status.json(~116KB): Assessment status information
Processed and optimized data for dashboard consumption:
per-dashboard-data.json(~2.9MB): Main dashboard data- Grouped assessment data
- Pre-calculated ratings
- Optimized component structure
map-data.json(~1.4MB): Geospatial visualization data- Simplified geographical data
- Pre-processed regional statistics
component-descriptions.json(~16KB): Component metadata- Component descriptions
- Relationship mappings
per-assessments-processed.json(~7.8MB): Processed assessment data- Filtered and normalized responses
- Optimized for quick queries
last-update.json(~46B): Timestamp of last data update
- Total raw data size: ~27.2MB
- Total processed data size: ~12.1MB
- Overall size reduction: ~55%
- Update frequency: Every 30 minutes via GitHub Actions
The data fetcher includes specialized text analysis for PER consideration fields:
-
Input Fields:
urban_considerations: Text field for urban-specific considerationsepi_considerations: Text field for epidemic-related considerationsclimate_environmental_considerations: Text field for climate/environmental factors
-
Text Analysis Process:
- Supports multilingual input (English and Spanish)
- Searches for affirmative words: ['yes', 'sí', 'si']
- Text normalization:
- Converts to lowercase
- Removes diacritical marks
- Standardizes variations
-
Output Fields: Each text field is processed into a corresponding boolean field:
urban_considerations_simplifiedepi_considerations_simplifiedclimate_environmental_considerations_simplified
This processing enables:
- Efficient filtering and aggregation
- Simplified visualization logic
- Reduced client-side processing
- Consistent data representation
Components are organized into 5 main areas:
- Policy Strategy and Standards
- Analysis and planning
- Operational capacity
- Coordination
- Operations support
Each assessment contains:
- Metadata (ID, country, date, phase)
- Component ratings and responses
- Special considerations (Urban, Epidemic, Climate)
- Notes and additional information
Components are evaluated using a numerical rating system:
- Ratings are stored in
rating_value - Text descriptions in
rating_title - Changes between assessments are tracked
- Zero-rated duplicates are filtered out
The dashboard uses the processed data for various visualizations:
-
Component Performance Analysis
- Rating trends over time
- Area-wise performance breakdown
- Regional comparisons
-
Assessment Cycle Tracking
- Progress through assessment phases
- Completion status monitoring
- Cycle-to-cycle comparisons
-
Geographical Analysis
- Regional distribution of assessments
- Country-level performance tracking
- Spatial patterns visualization
-
Special Considerations
- Urban considerations tracking
- Epidemic preparedness monitoring
- Climate and environmental aspects
This tool exclusively uses publicly accessible IFRC GO Platform API endpoints, requiring no authentication:
-
PER Status
- Endpoint:
https://goadmin.ifrc.org/api/v2/per-process-status/ - Documentation: GO Platform API - PER Process Status
- Contains: Assessment status, phases, and metadata
- Endpoint:
-
Countries
- Endpoint:
https://goadmin.ifrc.org/api/v2/country/ - Documentation: GO Platform API - Countries
- Contains: Country information, regions, and geographical data
- Endpoint:
-
PER Prioritization
- Endpoint:
https://goadmin.ifrc.org/api/v2/per-prioritization/ - Documentation: GO Platform API - PER Prioritization
- Contains: Component prioritization and relationships
- Endpoint:
-
PER Assessments
- Endpoint:
https://goadmin.ifrc.org/api/v2/per-assessment/ - Documentation: GO Platform API - PER Assessment
- Contains: Detailed assessment responses and ratings
- Endpoint:
- Full API documentation: IFRC GO Platform API Docs
- API versioning: All endpoints use v2 of the API
- Rate limiting: Public endpoints have standard rate limits
- Response format: All endpoints return JSON data with pagination
- Common query parameters:
limit: Number of records per pageoffset: Pagination offsetordering: Field to sort byformat: Response format (json/api)
Example of raw API response structure:
{
"count": 100,
"next": "https://goadmin.ifrc.org/api/v2/per-assessment/?offset=30",
"previous": null,
"results": [
{
"id": 123,
"country_details": {
"iso3": "USA",
"name": "United States of America",
"region": 1
},
"assessment_number": 2,
"date_of_assessment": "2024-01-15",
// ... additional fields
}
]
}Note: While these endpoints are public, please follow IFRC's API usage guidelines and implement appropriate caching to avoid unnecessary load on their servers.
-
per-dashboard-data.json
interface DashboardData { assessments: { component_id: number; // Unique identifier for the component component_num: number; // Sequential number of the component component_name: string; // Name of the component area_id: number; // Identifier for the area area_name: string; // Name of the area assessments: Array<{ assessment_id: number; // Unique identifier for the assessment assessment_number: number; // Sequential number for the assessment country_id: number; // Country identifier country_name: string; // Country name region_id: number; // Region identifier region_name: string; // Region name date_of_assessment: string; // ISO date format rating_value: number; // Numerical rating rating_title: string; // Text description of rating }>; }[]; countryAssessments: { [countryName: string]: Array<{ assessment_number: number; date: string; // ISO date format area_ratings: any[]; // Area-specific ratings components: any[]; // Component-specific data phase: number; // Assessment phase number phase_display: string; // Human-readable phase name }>; }; }
-
last-update.json
interface LastUpdate { lastUpdate: string; // ISO date format of last successful update }
The processed data files are hosted in this repository and accessed via GitHub's raw content URLs. The dashboard components fetch these files directly from GitHub.
In the GO Web App, the data URLs are configured in the dashboard components:
// PER Performance Dashboard
// app/src/views/PERDashboard/PERPerformanceDashboard/index.tsx
const PER_DASHBOARD_DATA_URL = 'https://api.github.com/repos/[org]/ifrc-per-data-fetcher/contents/data/per-dashboard-data.json';
const LAST_UPDATE_DATA_URL = 'https://api.github.com/repos/[org]/ifrc-per-data-fetcher/contents/data/last-update.json';To modify the data source:
- Fork the data fetcher repository
- Update the URLs in the dashboard components to point to your fork
- Ensure your repository is public or provide appropriate authentication
The dashboard components use specialized data handlers to process and transform the data for visualization:
-
Performance Dashboard Handler (
PERPerformanceDashboard/dataHandler.ts)- Processes component ratings and trends
- Calculates assessment cycles
- Groups data by region
- Generates summary statistics
-
Summary Dashboard Handler (
PERSummaryDashboard/dataHandler.ts)- Processes global statistics
- Handles geographic data for map visualization
- Calculates completion rates
- Processes special considerations
-
Data Fetching
// Example from PERPerformanceDashboard const fetchData = async () => { const response = await fetch(PER_DASHBOARD_DATA_URL); const data = await response.json(); initializeData(data); // Initialize data handlers };
-
Data Processing
// Example usage in components const componentRatings = getComponentRatings(filters); const cycles = getCycles(filters); const summaryData = summarizeData(filters);
-
Data Updates
- Files are automatically updated daily via GitHub Actions
- Components check
last-update.jsonfor the latest data timestamp - Data is cached in the browser to improve performance
The data handlers include robust error handling for:
- Missing or malformed data
- Invalid ratings or dates
- Missing relationships between components and areas
- Network failures during data fetching
The PER Data Fetcher exists to solve several challenges with the raw API data:
-
Data Size Optimization
- Raw API response sizes:
- Per Assessments: ~26MB
- Countries: ~397KB
- Prioritization: ~708KB
- PER Status: ~116KB
- Processed output sizes:
- Dashboard Data: ~2.9MB (89% reduction)
- Map Data: ~1.4MB
- Component Descriptions: ~16KB
- The significant size reduction is achieved through:
- Removing redundant nested data
- Optimizing data structures for frontend consumption
- Filtering out unused fields
- Compressing repeated information
- Raw API response sizes:
-
Data Normalization
- Text Processing: The API returns free-text fields for considerations (Urban, Epidemic, Climate) that need parsing
// Examples of variations in API responses: "urban_considerations": "Yes, this is considered" "urban_considerations": "si" "urban_considerations": "Sí, parcialmente"
- The fetcher normalizes these into boolean flags by:
- Handling multilingual responses (English/Spanish)
- Accounting for accent variations
- Standardizing affirmative/negative responses
- Text Processing: The API returns free-text fields for considerations (Urban, Epidemic, Climate) that need parsing
-
Relationship Management
- Raw API data requires multiple requests to establish relationships between:
- Components and their areas
- Countries and their regions
- Assessments and their cycles
- The fetcher pre-computes these relationships to avoid:
- Multiple API calls from the frontend
- Complex data joining in the browser
- Redundant data processing
- Raw API data requires multiple requests to establish relationships between:
-
Performance Optimization
- Pre-calculated aggregations for:
- Regional statistics
- Assessment cycle analysis
- Component ratings
- Reduces frontend computation needs
- Improves dashboard rendering speed
- Pre-calculated aggregations for:
-
Dedicated Dashboard API Endpoint
- Current challenges could be better addressed with a dedicated API endpoint that:
- Returns pre-processed data in dashboard-ready format
- Handles data aggregation server-side
- Provides optimized response structures
- Manages caching effectively
- Current challenges could be better addressed with a dedicated API endpoint that:
-
API Improvements
- Standardize consideration responses (boolean instead of text)
- Include pre-calculated relationships
- Provide built-in aggregation options
- Support partial data updates
- Add response compression
-
Migration Strategy
- Keep this data fetcher as a reference implementation
- Gradually move processing logic to API
- Maintain backward compatibility
- Support transition period
The data fetcher serves as a crucial bridge between the current API structure and dashboard requirements. While it effectively solves immediate challenges, a more sustainable long-term solution would be API-level optimizations.
- Install dependencies:
npm install- Run the data fetcher:
npm startThis will:
- Fetch fresh data from the IFRC API
- Process and transform the data
- Generate updated JSON files in the
data/directory
The data is automatically updated daily using GitHub Actions. The workflow:
- Runs at 00:00 UTC every day
- Fetches fresh data from the IFRC API
- Processes and transforms the data
- Commits and pushes any changes to the repository
The last-update.json file tracks the timestamp of the most recent successful update. You can also:
- View the update history in the repository's commit log
- Manually trigger an update from the Actions tab
- Check the Actions tab for any update failures
The application includes robust error handling:
- API request retries and pagination handling
- Data validation and cleaning
- Missing data management
- Duplicate assessment filtering
- Node.js
- Axios for API requests
- File system operations for JSON storage
- Data processing utilities
When contributing to this repository, please:
- Ensure data processing maintains backward compatibility
- Add appropriate error handling
- Update tests if modifying data structures
- Document any new data transformations
This project is licensed under the terms specified by IFRC.