A Rails 8 application for visualizing employment data affected by environmental and economic stressors across different regions and sectors.
BeyondCarbon provides an interactive platform to explore how various stressors—including climate impacts (heat stress, sea level rise, air pollution) and economic changes (automation, policy transitions)—affect employment across different economic sectors in multiple countries.
The application allows users to:
- Compare employment impacts across 10 global regions
- Analyze 5 different types of stressors
- Visualize data across 10 economic sectors
- Toggle between absolute employment figures and percentage share metrics
- Sort and filter data dynamically with an interactive chart interface
- Interactive Dashboard: Real-time filtering and visualization using Turbo Frames
- Multi-dimensional Analysis: Explore data by region, stressor type, sector, and metric
- Dynamic Charts: Visualize employment data with customizable sorting and filtering
- Responsive Design: Clean, modern interface that works across devices
- Sample Data: Pre-populated demonstration dataset for immediate exploration
- Framework: Ruby on Rails 8.0.2
- Ruby Version: 3.4.5
- Database: SQLite3
- Frontend:
- Hotwire (Turbo & Stimulus)
- Importmap for JavaScript
- Propshaft for assets
- Background Jobs: Solid Queue
- Caching: Solid Cache
- WebSockets: Solid Cable
- Testing: RSpec, Capybara, Selenium WebDriver
- Code Quality: RuboCop (Rails Omakase), Brakeman
- Deployment: Kamal, Docker, Thruster
- Ruby 3.4.5 or higher
- SQLite3
- Node.js (for JavaScript dependencies)
- Docker (optional, for containerized deployment)
-
Clone the repository
git clone https://github.com/shotgundebugging/beyondcarbon.git cd beyondcarbon -
Install dependencies
bundle install
-
Setup the database
bin/rails db:create bin/rails db:migrate
-
Seed the database with sample data
bin/rails db:seed
This will create:
- 10 regions (USA, GBR, FRA, DEU, BRA, ZAF, IND, CHN, AUS, CAN)
- 10 sectors (Agriculture, Manufacturing, Services, Tourism, Energy, Construction, Transport, Healthcare, Education, Technology)
- 5 stressors (Heat Stress, Sea Level Rise, Air Pollution, Automation, Policy Transition)
- 500 employment data records
Start the Rails server:
bin/rails serverVisit http://localhost:3000 in your browser.
For development with automatic reloading:
bin/devThe project uses RSpec for testing.
bundle exec rspecbundle exec rspec spec/requests/employment_request_spec.rb
bundle exec rspec spec/services/employment_sample_spec.rbRun RuboCop for style checking:
bundle exec rubocopRun Brakeman for security analysis:
bundle exec brakemancode: Country code (e.g., USA, GBR)name: Full country name
region_id: Foreign key to regionssector: Economic sector namestressor: Type of environmental or economic stressorvalue: Employment figure (number of people)
beyondcarbon/
├── app/
│ ├── controllers/
│ │ └── employment_controller.rb # Main controller for data visualization
│ ├── models/
│ │ ├── region.rb # Region model (countries)
│ │ └── employment_data.rb # Employment data model
│ └── views/
│ └── employment/
│ ├── index.html.erb # Main dashboard
│ ├── _chart.html.erb # Chart partial
│ └── _map.html.erb # Map partial
├── db/
│ ├── migrate/ # Database migrations
│ └── seeds.rb # Sample data seeder
├── spec/ # RSpec tests
├── config/
│ ├── routes.rb # Application routes
│ └── deploy.yml # Kamal deployment configuration
└── Dockerfile # Container configuration
Build the Docker image:
docker build -t beyondcarbon .Run the container:
docker run -d -p 80:80 -e RAILS_MASTER_KEY=<your-master-key> --name beyondcarbon beyondcarbonThis application is configured for deployment with Kamal. Update config/deploy.yml with your server details, then:
kamal setup
kamal deployFor more information, see the Kamal documentation.
RAILS_MASTER_KEY: Required for production deployment (fromconfig/master.key)RAILS_ENV: Environment setting (development, test, production)
Database settings are in config/database.yml. By default:
- Development: SQLite database at
storage/development.sqlite3 - Test: SQLite database at
storage/test.sqlite3 - Production: SQLite database at
storage/production.sqlite3
GET /- Main dashboard (employment index)GET /employment/index- Employment data visualization with filters- Query parameters:
region: Region code (e.g., USA, GBR)stressor: Stressor typemetric: Display metric (people or share)topn: Number of top sectors to displaysort: Sort order (desc, asc, or alpha)
- Query parameters:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow the Ruby style guide enforced by RuboCop
- Write tests for new features
- Run the test suite before submitting PRs
- Keep commits focused and atomic
This project is available for use under the terms specified by the project owner.
For issues, questions, or contributions, please open an issue on the GitHub repository.
Built with Ruby on Rails 8 and modern web technologies.