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

deforestation forest-monitoring archived wri-api climate measur biodiversity transforms projection half-earth

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
frontend Frontend application frontend/README.md
backend The Ruby on Rails backend application (API + backoffice) backend/README.md
cloud_functions cloud functions code folder cloud_functions/README.md
infrastructure The Terraform project for TiTiler COG tiler as AWS lambda infrastructure/README.md
data data folder where diverse scripts for data management lives data/README.md

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

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

ECS Deployment Workflows

The project uses AWS ECS (Elastic Container Service) for deployment with separate workflows for staging and production:

Staging Deployment (ecs_deploy_staging.yml)

  • Triggers: Pushes to the develop branch (after tests pass)
  • Target: staging.resilienceatlas.org
  • Features: Builds and deploys both frontend and backend containers to ECS
  • Environment: Uses staging-specific environment variables and secrets
  • Database Refresh: Automatically copies production database to staging before deployment

Production Deployment (ecs_deploy_production.yml)

  • Triggers: Pushes to the main branch (after all tests pass)
  • Target: resilienceatlas.org
  • Features: Builds and deploys both frontend and backend containers to ECS
  • Environment: Uses production-specific environment variables and secrets

Key deployment features:

  • Containerized deployment using Docker multi-stage builds
  • AWS ECR for container image storage
  • ECS with EC2-based cluster for container orchestration
  • Application Load Balancers for traffic distribution
  • AWS Secrets Manager for secure credential management
  • Automatic health checks and service stability verification
  • 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 ECS Deployment

The application is deployed to AWS ECS (Elastic Container Service) using EC2-based clusters for both staging and production environments:

Deployment Architecture

  • Container Registry: AWS ECR for storing Docker images
  • Orchestration: AWS ECS with EC2 cluster (resilienceatlas-cluster)
  • Load Balancing: Application Load Balancers for traffic distribution
  • Secret Management: AWS Secrets Manager for secure credential storage
  • Monitoring: CloudWatch logs and ECS service metrics

Setting Up ECS Deployment

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

  2. Infrastructure Setup:

    cd scripts
    pip install -r requirements.txt
    python setup_ecs_infrastructure.py --account-id YOUR_AWS_ACCOUNT_ID
    
  3. Services Creation:

    python create_ecs_services.py --account-id YOUR_AWS_ACCOUNT_ID
    
  4. Configure Secrets: Update AWS Secrets Manager entries with real database URLs and application secrets

  5. GitHub Actions: Configure repository secrets for automatic deployments

See DOCKER.md for detailed setup instructions and scripts/README.md for 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: 7 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: 1 day 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

  • funkycoda (3)
  • MLNoon (3)
  • azvoleff (2)
  • aagm (2)
  • vermeulendivan (1)

Top Pull Request Authors

  • dependabot[bot] (70)
  • Bluesmile82 (36)
  • martintomas (33)
  • davidsingal (16)
  • agnessa (16)
  • tiagojsag (10)
  • clementprdhomme (9)
  • santostiago (9)
  • AdeelKamalMalik (7)
  • aagm (4)
  • andresgnlez (4)
  • SARodrigues (3)
  • azvoleff (2)
  • funkycoda (1)

Top Issue Labels

  • frontend (2)
  • Kartoza (1)
  • bug (1)
  • enhancement (1)

Top Pull Request Labels

  • dependencies (70)
  • backend (66)
  • frontend (50)
  • javascript (37)
  • infrastructure (5)
  • WIP (2)
  • ruby (2)
  • on hold (1)
  • blocked (1)
  • python (1)

Package metadata

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


Dependencies

.github/workflows/backend_ci_cd.yml actions
  • actions/checkout v3 composite
  • miloserdow/capistrano-deploy v3 composite
  • ruby/setup-ruby v1 composite
  • postgis/postgis 14-master docker
.github/workflows/frontend_ci_cd.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • actions/upload-artifact v3 composite
  • cypress-io/github-action v5 composite
  • miloserdow/capistrano-deploy v3 composite
  • ruby/setup-ruby v1 composite
.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/analysis_histogram/yarn.lock npm
  • 168 dependencies
cloud_functions/raster_interaction/package.json npm
  • @google-cloud/functions-framework ^3.2.0
  • @google/earthengine ^0.1.354
cloud_functions/raster_interaction/yarn.lock npm
  • 168 dependencies
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
frontend/yarn.lock npm
  • 939 dependencies
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
frontend/Gemfile rubygems
  • bcrypt_pbkdf >= 0
  • capistrano ~> 3.9
  • capistrano-nvm >= 0
  • capistrano-passenger >= 0
  • capistrano-rbenv ~> 2.2
  • capistrano-yarn >= 0
  • ed25519 >= 0
frontend/Gemfile.lock rubygems
  • airbrussh 1.4.1
  • bcrypt_pbkdf 1.1.0
  • bundler 2.4.8
  • capistrano 3.17.2
  • capistrano-nvm 0.0.7
  • capistrano-passenger 0.2.1
  • capistrano-rbenv 2.2.0
  • capistrano-yarn 2.0.2
  • concurrent-ruby 1.2.2
  • ed25519 1.3.0
  • i18n 1.12.0
  • net-scp 4.0.0
  • net-ssh 7.1.0
  • rake 13.0.6
  • sshkit 1.21.4

Score: -Infinity