Resilience Atlas

An interactive analytical tool for building understanding of the extent and severity of some of the key stressors and shocks that are affecting rural livelihoods, production systems, and ecosystems in the Sahel, Horn of Africa and South and Southeast Asia.
https://github.com/ConservationInternational/resilienceatlas

Category: Consumption
Sub Category: Agriculture and Nutrition

Keywords

bigdata climate-change conservation resilience sustainability

Keywords from Contributors

forest-monitoring deforestation archiving climate wri-api measur biodiversity transforms prep projection

Last synced: about 13 hours ago
JSON representation

Repository metadata

Resilience Atlas - Evidence-based decision-making around resilience

README.md

Resilience Atlas

Architecture

This repository contains all the code and documentation necessary to set up and deploy the project. It is organised in 4 main subdirectories, with accompanying documentation inside each.

Subdirectory name Description Documentation Tech Stack
frontend Frontend application frontend/README.md React 18.3.1, Next.js 14.2.15, Node.js 22.11.0
backend The Ruby on Rails backend application (API + backoffice) backend/README.md Ruby 3.4.4, Rails 7.2.x
cloud_functions cloud functions code folder cloud_functions/README.md Various AWS Lambda functions
infrastructure The Terraform project for TiTiler COG tiler as AWS lambda infrastructure/README.md Terraform, AWS
data data folder where diverse scripts for data management lives data/README.md Various data processing tools

CI/CD Process

The project uses GitHub Actions for continuous integration and deployment. The CI/CD workflows are organized into comprehensive testing and deployment categories:

Testing Workflows

The project implements comprehensive testing with Docker-based workflows:

Backend Tests (backend_tests.yml)

  • Testing: RSpec test suite with PostgreSQL database
  • System Tests: Capybara-based browser tests for admin interface using Chrome
  • Linting: RuboCop code style checks
  • Security: Brakeman security analysis and Bundle Audit for dependency vulnerabilities
  • Triggers: Runs on pushes/PRs to the backend/ directory

Frontend Tests (frontend_tests.yml)

  • Unit Testing: Jest tests for components and utilities
  • E2E Testing: Cypress tests on Chrome and Firefox browsers
  • Linting: ESLint and TypeScript validation
  • Build Verification: Ensures application builds successfully
  • Triggers: Runs on pushes/PRs to the frontend/ directory

Integration Tests (integration_tests.yml)

  • Full-Stack Testing: Complete frontend-backend integration testing
  • API Testing: Backend integration tests focused on API endpoints
  • Performance Testing: Basic response time validation
  • Data Consistency: Verifies data flows correctly between systems
  • Triggers: Runs on pushes/PRs to develop and main branches

Key testing features:

  • Docker-based isolated test environments
  • Multi-browser E2E testing (Chrome and Firefox)
  • System tests for admin interface using Capybara and Chrome
  • Comprehensive test reporting with JUnit integration
  • Test artifacts collection (screenshots, videos on failure)
  • Health checks and service dependency management

Build Optimization

The project uses advanced Docker buildx caching strategies to significantly speed up CI/CD builds:

Caching Features

  • Content-based cache keys: Cache invalidation based on Dockerfile and dependency file changes
  • Multi-level fallback: Progressive cache key fallback for maximum cache reuse
  • GitHub Actions cache: Persistent caching across workflow runs (10GB limit)
  • Registry-based caching: Future-ready for cross-repository layer sharing
  • Coordinated builds: Docker Bake configuration for multi-service coordination

Performance Benefits

  • 50-80% reduction in build times for incremental changes
  • 90%+ cache hit rate for dependency-only changes
  • Parallel build execution with shared cache layers
  • Reduced GitHub Actions minutes consumption

Developer Tools

  • Cache validation script: ./test-docker-cache.sh for local testing
  • Cache analytics: Build-time performance monitoring
  • Documentation: Comprehensive caching strategy in .github/DOCKER_CACHE_STRATEGY.md

Cache keys are generated based on:

  • Dockerfile content hashes
  • Dependency file hashes (Gemfile.lock, package-lock.json)
  • Runtime versions (Ruby, Node.js)
  • Daily cache refresh for staleness prevention

See .github/TESTING.md for detailed testing documentation.

EC2 Deployment Workflows

The project uses AWS EC2 instances for deployment with separate workflows for staging and production:

Staging Deployment (ec2_deploy_staging.yml)

  • Triggers: Pushes to the develop branch (after tests pass)
  • Target: staging.resilienceatlas.org
  • Features: Deploys directly to EC2 instance using Docker Compose
  • Environment: Uses staging-specific environment variables and secrets
  • Database Refresh: Automatically copies production database to staging before deployment

Production Deployment (ec2_deploy_production.yml)

  • Triggers: Pushes to the main branch (after all tests pass)
  • Target: resilienceatlas.org
  • Features: Deploys directly to EC2 instance using Docker Compose
  • Environment: Uses production-specific environment variables and secrets

Key deployment features:

  • Direct EC2 deployment using Docker Compose
  • Application Load Balancer for traffic routing
  • Just-in-time SSH access during deployment
  • Automatic database refresh for staging environment
  • Health checks and rollback capabilities
  • AWS Secrets Manager for secure credential management
  • Deployment only proceeds after all relevant tests pass
  • Staging database refresh: Production data automatically copied to staging for realistic testing

TiTiler COGs Workflows

The TiTiler COGs service has dedicated workflows for AWS Lambda deployment:

TiTiler COGs Deployment (titiler_cogs_deployment.yaml)

  • Feature Branch Deployment: Automatically deploys feature branches to isolated AWS stacks for testing
  • Production Deployment: Deploys master branch to production stack
  • Manual Deployment: Supports workflow dispatch for manual deployments
  • Triggers: Runs on pushes to cloud_functions/titiler_cogs/ directory

Key features:

  • Uses AWS SAM CLI for serverless application deployment
  • Creates isolated stacks for each feature branch with unique FQDNs
  • Container-based builds for consistent environments
  • Role-based AWS authentication for secure deployments
  • Supports custom domain names via Route53

TiTiler COGs Cleanup (titiler_cogs_cleanup.yaml)

  • Automatic Cleanup: Removes AWS stacks when feature branches are deleted
  • Manual Cleanup: Supports workflow dispatch for manual stack deletion
  • Cost Optimization: Prevents accumulation of unused AWS resources

The TiTiler COGs service provides dynamic tile generation for Cloud Optimized GeoTIFFs (COGs) and is deployed as AWS Lambda functions behind API Gateway. See cloud_functions/titiler_cogs/README.md for detailed deployment and usage instructions.

Production Deployment

AWS EC2 Deployment

The application is deployed directly to AWS EC2 instances using Docker Compose for both staging and production environments:

Deployment Architecture

  • Hosting: EC2 instances running Docker Compose
  • Load Balancing: Application Load Balancer for traffic distribution and SSL termination
  • Secret Management: Environment variables and AWS Secrets Manager for secure configuration
  • SSH Access: Just-in-time SSH access during deployments for security
  • Monitoring: CloudWatch logs and instance metrics

Setting Up EC2 Deployment

  1. Prerequisites: AWS account with appropriate IAM permissions, Python 3.8+, AWS CLI configured

  2. Infrastructure Setup:

    cd scripts
    pip install -r requirements.txt
    ./setup_complete_infrastructure.sh
    
  3. Configure GitHub Actions: Set up repository secrets for automatic deployments

  4. Environment Configuration: Update environment files and AWS secrets with real values

See scripts/README.md for detailed setup instructions and script documentation.

Docker Setup

The project includes Docker configuration for easy development and deployment. There are three Docker Compose configurations:

  • docker-compose.yml - Production setup (frontend + backend only)
  • docker-compose.dev.yml - Development setup (includes PostgreSQL database)
  • docker-compose.test.yml - Test environment for running automated tests

Prerequisites

Quick Start

  1. Clone the repository and navigate to the project root

  2. Set up environment variables

    cp .env.example .env
    # Edit .env with your configuration values
    
  3. For development (includes database):

    docker compose -f docker-compose.dev.yml up --build
    

    This will start:

  4. For production:

    docker compose up --build
    

    This will start:

    Note: For production, you need to provide your own PostgreSQL database via the DATABASE_URL environment variable.

Running Tests

Backend Tests (RSpec)

# Run all backend tests (linting, security, unit tests - excludes system tests by default)
docker compose -f docker-compose.test.yml run --rm backend-test ./bin/test

# Run all tests including system tests
docker compose -f docker-compose.test.yml run --rm backend-test ./bin/test rspec

# Run specific test commands
docker compose -f docker-compose.test.yml run --rm backend-test ./bin/test rspec
docker compose -f docker-compose.test.yml run --rm backend-test ./bin/test lint
docker compose -f docker-compose.test.yml run --rm backend-test ./bin/test security
docker compose -f docker-compose.test.yml run --rm backend-test ./bin/test audit

# Run specific test file
docker compose -f docker-compose.test.yml run --rm backend-test ./bin/test rspec spec/models/user_spec.rb

# Show all available commands
docker compose -f docker-compose.test.yml run --rm backend-test ./bin/test help

Frontend Tests (ESLint/TypeScript/Prettier)

# Run all frontend checks (linting, type-check, prettier, build)
docker compose -f docker-compose.test.yml run --rm --no-deps frontend-test ./bin/test

# Run specific test commands
docker compose -f docker-compose.test.yml run --rm --no-deps frontend-test ./bin/test lint
docker compose -f docker-compose.test.yml run --rm --no-deps frontend-test ./bin/test type-check
docker compose -f docker-compose.test.yml run --rm --no-deps frontend-test ./bin/test prettier
docker compose -f docker-compose.test.yml run --rm --no-deps frontend-test ./bin/test build

# Run Cypress e2e tests (requires backend services)
docker compose -f docker-compose.test.yml run --rm frontend-test ./bin/test cypress

# Show all available commands
docker compose -f docker-compose.test.yml run --rm --no-deps frontend-test ./bin/test help

System Tests (Browser-based)

System tests use Capybara with Chrome to test the admin interface and user interactions:

# Run system tests only (with Chrome verification)
docker compose -f docker-compose.test.yml run --rm backend-test ./bin/test system

# Run system tests (skip Chrome verification)
docker compose -f docker-compose.test.yml run --rm backend-test ./bin/test system-force

# Verify Chrome setup for system tests
docker compose -f docker-compose.test.yml run --rm backend-test ./bin/test verify-chrome

# Run specific system test file
docker compose -f docker-compose.test.yml run --rm backend-test ./bin/test system spec/systems/admin/auth_spec.rb

System tests cover:

  • Admin authentication and authorization
  • CRUD operations for all admin models (layers, indicators, journeys, etc.)
  • File uploads and data management
  • User interface interactions
  • Browser-based workflows

Note: System tests require Chrome and Xvfb for headless browser testing. They are excluded from the default test run due to longer execution time.

Integration Tests (Full E2E)

docker compose -f docker-compose.test.yml up --abort-on-container-exit

Fixing Linting Issues

The project uses ESLint and RuboCop for code quality enforcement. Common issues and their fixes:

Backend (RuboCop)

# Auto-fix most RuboCop issues
docker compose -f docker-compose.test.yml run --rm backend-test bash -c "bundle exec rubocop -A"

# Run specific checks
docker compose -f docker-compose.test.yml run --rm backend-test ./bin/test lint

Frontend (ESLint)

Common ESLint warnings and fixes:

  1. Console statements: Add // eslint-disable-next-line no-console before console statements in development code
  2. Unused variables: Remove unused imports and variables, or prefix with underscore if needed for interface compliance
  3. React Hook dependencies: Add missing dependencies to useEffect, useCallback, and useMemo dependency arrays
  4. TypeScript any types: Add `// eslint-disable-next-line @typescript-eslint/no-explicit

Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 26 days ago

Total Commits: 2,030
Total Committers: 27
Avg Commits per committer: 75.185
Development Distribution Score (DDS): 0.661

Commits in past year: 18
Committers in past year: 1
Avg Commits per committer in past year: 18.0
Development Distribution Score (DDS) in past year: 0.0

Name Email Commits
Clara Linos c****a@s****s 689
David Inga d****a@v****m 221
Alvaro Leal p****e@g****m 163
martintomas m****t@g****m 111
Alex Zvoleff a****f@c****g 95
Simao Rodrigues a****o@g****m 80
Clément Prod'homme c****e@v****m 72
paulahaertel p****l@m****g 67
Gerardo g****o@v****m 65
Miguel Mendoza m****a@v****m 63
Tiago Garcia t****g@g****m 61
Alicia a****a@g****m 52
Alicia a****a@M****l 46
Sebastian Schkudlara s****a@g****m 40
Tiago Santos s****o@g****m 39
Adeel Kamal Malik a****7@h****m 35
Agnieszka Figiel a****l@g****m 29
Miguel Mendoza i****o@m****j 29
Miguel Barrenechea m****a@s****s 23
Andrés González a****s@s****s 13
Andrés González Muñoz a****z@v****m 11
Gerardo Pacheco g****o@s****s 8
dependabot[bot] 4****] 7
Adeel Kamal Malik a****k@g****m 5
Ajay Ranipeta a****a@g****m 4
Gerardo g****t@g****m 1
bitTal a****z@g****m 1

Committer domains:


Issue and Pull Request metadata

Last synced: 4 days ago

Total issues: 11
Total pull requests: 220
Average time to close issues: N/A
Average time to close pull requests: about 2 months
Total issue authors: 5
Total pull request authors: 14
Average comments per issue: 0.09
Average comments per pull request: 0.77
Merged pull request: 147
Bot issues: 0
Bot pull requests: 70

Past year issues: 0
Past year pull requests: 2
Past year average time to close issues: N/A
Past year average time to close pull requests: less than a minute
Past year issue authors: 0
Past year pull request authors: 2
Past year average comments per issue: 0
Past year average comments per pull request: 0.0
Past year merged pull request: 1
Past year bot issues: 0
Past year bot pull requests: 1

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/ConservationInternational/resilienceatlas

Top Issue Authors

  • azvoleff (9)
  • funkycoda (3)
  • MLNoon (3)
  • aagm (2)
  • vermeulendivan (1)
  • dependabot[bot] (1)

Top Pull Request Authors

  • dependabot[bot] (85)
  • Bluesmile82 (34)
  • martintomas (31)
  • davidsingal (15)
  • agnessa (15)
  • clementprdhomme (9)
  • tiagojsag (9)
  • santostiago (9)
  • AdeelKamalMalik (7)
  • Copilot (6)
  • andresgnlez (4)
  • SARodrigues (3)
  • aagm (3)
  • azvoleff (3)
  • funkycoda (2)

Top Issue Labels

  • Kartoza (1)
  • bug (1)
  • frontend (1)
  • dependencies (1)
  • javascript (1)

Top Pull Request Labels

  • dependencies (85)
  • backend (65)
  • frontend (48)
  • javascript (48)
  • infrastructure (4)
  • ruby (4)
  • python (3)
  • WIP (2)
  • on hold (1)
  • blocked (1)

Package metadata

proxy.golang.org: github.com/conservationinternational/resilienceatlas


Dependencies

.github/workflows/titiler_cogs_cleanup.yaml actions
  • actions/checkout v3 composite
  • aws-actions/configure-aws-credentials v2 composite
  • aws-actions/setup-sam v2 composite
.github/workflows/titiler_cogs_deployment.yaml actions
  • actions/checkout v3 composite
  • aws-actions/configure-aws-credentials v2 composite
  • aws-actions/setup-sam v2 composite
cloud_functions/titiler_cogs/titiler_cogs/Dockerfile docker
  • public.ecr.aws/lambda/python 3.9 build
data/docker-compose.yml docker
  • ghcr.io/developmentseed/titiler latest
data/notebooks/Dockerfile docker
  • base latest build
  • mambaorg/micromamba 1.4 build
data/streamlit-app/Dockerfile docker
  • python 3.10-slim-buster build
frontend/Dockerfile docker
  • node 18.15.0-bullseye build
frontend/docker-compose.yml docker
  • cypress/included 12.7.0
cloud_functions/analysis_histogram/package.json npm
  • @google-cloud/functions-framework ^3.2.0
  • @google/earthengine ^0.1.354
cloud_functions/raster_interaction/package.json npm
  • @google-cloud/functions-framework ^3.2.0
  • @google/earthengine ^0.1.354
frontend/package.json npm
  • @transifex/cli ^5.2.0 development
  • @types/google.maps ^3.52.5 development
  • @types/leaflet ^1.4.4 development
  • @types/leaflet-draw ^0.4.14 development
  • @types/node 18.14.6 development
  • @types/react ^18.0.28 development
  • @types/react-dom ^18.0.11 development
  • @types/react-foundation ^0.9.8 development
  • @types/react-slick ^0.23.10 development
  • @typescript-eslint/eslint-plugin 5.13.0 development
  • @typescript-eslint/parser 5.13.0 development
  • cypress ^12.7.0 development
  • eslint 8.23.1 development
  • eslint-config-next 12.2.3 development
  • eslint-config-prettier 8.6.0 development
  • eslint-import-resolver-typescript 3.5.1 development
  • eslint-plugin-import 2.26.0 development
  • eslint-plugin-prettier 4.2.1 development
  • husky ^1.3.1 development
  • lint-staged ^13.1.2 development
  • prettier 2.8.3 development
  • start-server-and-test ^2.0.0 development
  • typescript 4.5.2 development
  • @carto/carto.js 4.2.2
  • @googlemaps/js-api-loader ^1.15.1
  • @headlessui/react ^1.7.14
  • @reactour/tour ^3.3.0
  • @tanstack/react-query ^4.28.0
  • @transifex/native ^5.2.0
  • @transifex/react ^5.2.0
  • @turf/bbox-polygon ^6.5.0
  • axios ^0.21.2
  • classnames ^2.3.2
  • date-fns ^2.30.0
  • dotenv ^16.0.3
  • dotenv-cli ^7.1.0
  • foundation-sites 6.7.5
  • html-react-parser ^3.0.16
  • leaflet 1.4.0
  • leaflet-active-area 1.1.0
  • leaflet-utfgrid 0.3.0
  • leaflet.pm 2.0.3
  • lodash ^4.17.11
  • moment ^2.24.0
  • next 12.3.4
  • next-redux-wrapper ^8.1.0
  • normalize.css ^8.0.1
  • normalizr ^3.3.0
  • numeral ^2.0.6
  • qs ^6.9.7
  • react 17.0.2
  • react-beautiful-dnd ^11.0.0-beta.3
  • react-cookie ^4.1.1
  • react-dangerous-html ^1.0.0
  • react-datepicker ^4.11.0
  • react-dom 17.0.2
  • react-dropzone ^10.1.4
  • react-foundation 0.9.7
  • react-iframe ^1.8.0
  • react-modal ^3.16.1
  • react-redux 6.0.1
  • react-router ^4.3.1
  • react-slick 0.29.0
  • recharts ^1.5.0
  • redux ^4.0.1
  • redux-devtools-extension ^2.13.8
  • redux-form ^8.2.3
  • redux-thunk ^2.3.0
  • reselect ^4.0.0
  • resilience-layer-manager https://github.com/ConservationInternational/resilienceatlas-layermanager.git#1.0.4
  • sass ^1.58.3
  • slick-carousel ^1.8.1
  • use-debounce ^9.0.4
  • vega 5.23.0
  • vega-lib 4.4.0
  • vizzuality-components ^1.1.1
  • yup ^0.32.11
cloud_functions/download_image/requirements.txt pypi
  • earthengine-api ==0.1.354
  • oauth2client ==4.1.3
cloud_functions/sparc_plots/requirements.txt pypi
  • earthengine-api ==0.1.232
  • rollbar ==0.14.7
cloud_functions/titiler_cogs/titiler_cogs/requirements.txt pypi
  • mangum ==0.17.0
  • requests ==2.29.0
  • titiler.application ==0.11.6
data/streamlit-app/requirements.txt pypi
  • leafmap ==0.19.0
  • localtileserver ==0.6.4
  • palettable ==3.3.0
  • scikit-learn ==1.2.2
  • streamlit ==1.21.0
  • streamlit_folium ==0.11.1
backend/Gemfile rubygems
  • annotate >= 0 development
  • awesome_print >= 0 development
  • better_errors >= 0 development
  • binding_of_caller >= 0 development
  • brakeman >= 0 development
  • bundler-audit >= 0 development
  • byebug >= 0 development
  • capistrano ~> 3.9 development
  • capistrano-bundler >= 0 development
  • capistrano-passenger >= 0 development
  • capistrano-rails >= 0 development
  • capistrano-rbenv ~> 2.2 development
  • capybara >= 3.26 development
  • cuprite >= 0 development
  • faker >= 0 development
  • foreman >= 0 development
  • letter_opener_web >= 0 development
  • rspec-collection_matchers >= 0 development
  • rspec-request_snapshot >= 0 development
  • rspec-retry >= 0 development
  • rswag-specs >= 0 development
  • super_diff >= 0 development
  • web-console >= 0 development
  • webmock >= 0 development
  • active_admin-sortable_tree >= 0
  • active_admin_theme >= 0
  • active_model_serializers >= 0
  • active_storage_validations >= 0
  • activeadmin >= 0
  • activeadmin-globalize >= 0
  • activeadmin_addons >= 0
  • acts_as_list >= 0
  • addressable >= 0
  • ancestry >= 0
  • bcrypt_pbkdf >= 0
  • cancancan >= 0
  • devise >= 0
  • dotenv-rails >= 0
  • ed25519 >= 0
  • factory_bot_rails >= 0
  • ffi >= 0
  • globalize >= 0
  • image_processing >= 0
  • importmap-rails >= 0
  • jbuilder >= 0
  • json-schema >= 0
  • jwt >= 0
  • matrix >= 0
  • pg >= 0
  • prawn >= 0
  • prawn-table >= 0
  • puma >= 0
  • rack-cors >= 0
  • rails >= 0
  • ransack >= 0
  • rspec-rails >= 0
  • rswag >= 0
  • rubyzip >= 0
  • seed_dump >= 0
  • shrine >= 0
  • simple_command >= 0
  • slim-rails >= 0
  • sparkpost_rails >= 0
  • standard >= 0
  • terser >= 0
  • will_paginate >= 0
backend/Gemfile.lock rubygems
  • 194 dependencies
.github/workflows/ec2_deploy_production.yml actions
  • actions/checkout v4 composite
  • appleboy/ssh-action v1.0.0 composite
  • aws-actions/configure-aws-credentials v4 composite
.github/workflows/ec2_deploy_staging.yml actions
  • actions/checkout v4 composite
  • appleboy/ssh-action v1.0.0 composite
  • aws-actions/configure-aws-credentials v4 composite
docker-compose.staging.yml docker
  • postgis/postgis 15-3.3
integration-tests/package.json npm
  • axios ^1.7.7
.github/workflows/backend_tests.yml actions
  • actions/cache v4 composite
  • actions/checkout v4 composite
  • docker/setup-buildx-action v3 composite
  • dorny/test-reporter v1 composite
.github/workflows/frontend_tests.yml actions
  • actions/cache v4 composite
  • actions/checkout v4 composite
  • docker/setup-buildx-action v3 composite
.github/workflows/integration_tests.yml actions
  • actions/cache v4 composite
  • actions/checkout v4 composite
  • actions/upload-artifact v4 composite
  • docker/setup-buildx-action v3 composite
  • dorny/test-reporter v1 composite
backend/Dockerfile docker
  • base latest build
  • ruby 3.4.4-bullseye build
docker-compose.dev.yml docker
  • node 18.15.0-bullseye
  • postgis/postgis 15-3.3
docker-compose.test.yml docker
  • cypress/included 13.6.2
  • postgis/postgis 15-3.3
  • redis 7-alpine
docker-compose.yml docker

Score: -Infinity