A Ruby on Rails application for tracking and visualizing traffic fatality incidents in Tulsa. The application provides an interactive dashboard with maps and data management capabilities for documenting traffic-related fatalities.
- Interactive map visualization using Mapbox GL JS with 3D building extrusions
- GeoJSON API endpoints for incident data
- Automatic geocoding of incident locations
- Resizable dashboard panes for flexible layout
- Quick entry workflow for streamlined data input
- Public read access with authenticated write operations
- Verification status tracking (unverified, partially verified, verified)
- Ruby: 3.2.2
- Rails: 8.0
- Database: PostgreSQL with PostGIS extension
- Frontend: Hotwired (Turbo + Stimulus), TypeScript
- Build Tools: Webpack 5, esbuild
- Mapping: Mapbox GL JS
- Styling: TailwindCSS
- Package Manager: Bun
- Ruby 3.2.2
- PostgreSQL with PostGIS extension
- Bun (or npm/yarn)
- Bundler
- Clone the repository:
git clone <repository-url>
cd tulsaurbanist- Install dependencies:
bundle install
bun install- Set up environment variables:
cp .env.example .envEdit .env and configure:
ADMIN_USERNAME- Username for HTTP Basic Auth (default: 'admin')ADMIN_PASSWORD- Password for HTTP Basic Auth (default: 'changeme')DATABASE_URL- PostgreSQL connection string (optional, will use defaults)MAPBOX_ACCESS_TOKEN- Your Mapbox access token for maps
- Create and migrate the database:
rails db:create
rails db:migrate- Start the development server:
foreman startThis starts both the Rails server and webpack dev server concurrently.
Visit http://localhost:3000 to view the application.
For production or one-time builds:
bun run webpackFor development with watch mode:
webpack --watchrails testAlternatively, use Docker Compose:
docker-compose upThis will start both the Rails application and PostgreSQL database.
The application is configured for deployment on Railway:
- Connect your GitHub repository to Railway
- Set environment variables in the Railway dashboard:
ADMIN_USERNAMEADMIN_PASSWORDMAPBOX_ACCESS_TOKEN- Railway will auto-provision PostgreSQL and set
DATABASE_URL
- Ensure the PostgreSQL plugin has PostGIS extension enabled
- Deploy - migrations run automatically via
rails db:preparein the Dockerfile
The railway.toml configuration includes:
- Dockerfile-based builds
- Automatic restart policy on failure
- Health check configuration
The included Dockerfile and nginx.conf support deployment to any container platform. The application automatically runs rails db:prepare before starting to handle migrations.
Write operations (create, edit, update, delete) require HTTP Basic Authentication. Configure credentials via environment variables:
ADMIN_USERNAMEADMIN_PASSWORD
Read operations (index, show) are publicly accessible.
GET /api/v1/incidents/geojson- Returns all incidents as GeoJSON FeatureCollectionGET /api/v1/incidents/:id/geojson- Returns single incident as GeoJSON Feature
GET /- Home pageGET /dashboard- Main dashboard interface/incidents- Standard Rails resource routesGET /incidents/quick_new- Quick entry formPOST /incidents/quick_create- Quick entry submission
- Incident: Primary model tracking traffic fatalities with geocoded location, fatality counts by type, verification status, and timestamps
- AdditionalInformation: Supplementary information linked to incidents
- Source: Optional reference for incident data sources
- DashboardController (
app/javascript/controllers/dashboard_controller.ts): Manages dashboard pane system - SplitPaneController (
app/javascript/controllers/split_pane_controller.ts): Provides resizable pane functionality - RedesignMapController (
app/javascript/controllers/redesign_map_controller.ts): Handles interactive map visualization
tsconfig.json- TypeScript configurationwebpack.config.js- Webpack build configurationpostcss.config.js- PostCSS/TailwindCSS configurationDockerfile- Container build configurationdocker-compose.yml- Local Docker setuprailway.toml- Railway deployment configurationProcfile- Process management (Foreman)
The application uses a custom color palette defined in the palette SVG. Reference this palette when adding new UI components or styling.
When contributing to this project:
- Follow Rails MVC conventions
- Use TypeScript for all new JavaScript
- Create Stimulus controllers for interactive UI components
- Leverage the dashboard pane system for new components
- Maintain strong typing in TypeScript code
- Do not add code comments unless absolutely necessary
[Add your license information here]
[Add contact information here]