Introduction to Actionmap
Relevant source files
The following files were used as context for generating this wiki page:
Actionmap is a Ruby on Rails application designed to empower users with information about their political representatives, local political events, and news items. The platform serves as an aggregator and sharing hub for news specific to a user's locality, allowing for a structured exploration of political landscapes at national, state, and county levels.
Sources: README.md:5-7, package.json:13-28
Core Features and Functionality
The application provides a multi-tiered approach to political engagement, utilizing interactive maps and data aggregation.
| Feature | Description |
|---|---|
| National View | An interactive map of the United States allowing users to select specific states. |
| State/County View | Detailed maps showing counties and subdivisions within a selected state. |
| Representative Search | Look up representatives based on address or location. |
| News Management | Aggregate, rate, and share news items related to specific representatives and issues. |
| Event Tracking | View and manage political events linked to specific counties. |
Sources: README.md:5-7, config/routes.rb:14-16, app/javascript/packs/national_states_map.js:45-50
System Architecture
Actionmap follows a standard Ruby on Rails architecture, integrating a JavaScript-heavy frontend for map visualizations with a PostgreSQL-backed (or similar relational) backend.
Frontend Map Visualization
The frontend utilizes D3.js and TopoJSON to render interactive geographical data. The application maintains two primary levels of mapping: national and state-level.
- National Map: Uses
d3.geoAlbersUsaprojection to display the US states. - State Map: Uses
d3.geoMercator(ord3.geoConicEqualAreafor Alaska) to display county-level data.
Data Processing Pipeline
The application includes a specialized pipeline for handling geographical shapefiles. Using the mapshaper library, the system fetches census shapefiles, simplifies them (e.g., to 10% or 40% detail), and converts them into lightweight TopoJSON for frontend delivery.
Sources: lib/task_helpers/topojson_task_helper.rb:29-55, lib/task_helpers/state_shapefile_request.rb:32-37
Data Model and Schema
The backend schema is structured around the hierarchy of political divisions and the entities associated with them.
Primary Database Entities
| Table | Key Fields | Purpose |
|---|---|---|
states | name, symbol, fips_code | Stores US state metadata and FIPS codes. |
counties | name, state_id, fips_code | Links local regions to their parent states. |
representatives | name, party, ocdid, address | Contains profile information for political figures. |
news_items | title, link, representative_id, issue | Stores aggregated news linked to specific representatives. |
users | uid, provider, email | Manages authentication (supporting Google/Github OAuth). |
Sources: db/schema.rb:15-115
News and Issues Integration
The MyNewsItemsController handles the logic for associating news articles with representatives and specific political issues. It interacts with an external News API to fetch relevant content, which users can then rate and save.
Routing and API Endpoints
The application defines clear paths for navigation and AJAX data retrieval.
- Map Navigation:
GET /: Root national map view.GET /state/:state_symbol: Individual state view.GET /ajax/state/:state_symbol: Returns JSON list of counties.
- Representative Search:
GET /search/(:address): Search for reps by address.
- News/Events:
GET /representatives/:id/news_items: Lists news for a representative.GET /events: Lists political events.
Sources: config/routes.rb:1-60
Summary
Actionmap provides a comprehensive technical framework for visualizing US political geography and correlating it with real-time news and events. By leveraging Rails for robust data management and D3.js for interactive mapping, the system offers a layered user experience from national overview down to localized representative data.