This is an interactive map of Superfund contaminated toxic waste sites across the U.S.
americantoxics.com or read the background
bun i
bun dev- Install the Supabase CLI (if you haven’t already):
bun i -g supabase
- Initialize Supabase in this project:
supabase init
- Configure your database credentials in
.env:NEXT_PUBLIC_SUPABASE_URL=<your-supabase-url> NEXT_PUBLIC_SUPABASE_ANON_KEY=<your-supabase-anon-key> SUPABASE_SERVICE_ROLE_KEY=<your-service-role-key> # for server-side operations
- Run the migration to create the
sitestable:supabase db push # or, manually: # psql $SUPABASE_DB_URL -f supabase/migrations/0001_create_sites_table.sql
- Import the site data JSON into your database:
bun lib/tasks/import-sites.ts
- Run the migration to create the
scorestable:supabase db push # or, manually: # psql $SUPABASE_DB_URL -f supabase/migrations/0002_create_scores_table.sql
Now, import and use the client from lib/supabaseClient.ts:
import { supabase } from "@/lib/supabaseClient";
// Fetch all sites
const { data: sites, error } = await supabase.from("sites").select("*");- Download core CSV from EPA to
lib/data/sites-raw.csvcurl -L "https://hub.arcgis.com/api/v3/datasets/c2b7cdff579c41bbba4898400aa38815_0/downloads/data?format=csv&spatialRefId=3857&where=1%3D1" \ -o lib/data/sites-raw.csv - Download GeoJSON from EPA to
lib/data/sites.geojson(gitignored because huge) bun run lib/tasks/csv-to-json.tsto convert to JSONbun x @mrodrig/json-2-csv-cli lib/data/sites.json -o lib/data/sites-processed.csvif you want to convert back to CSV
| Variable | Description |
|---|---|
| OpenAI for chat completions | OPENAI_API_KEY |
| Supabase database: key | NEXT_PUBLIC_SUPABASE_ANON_KEY |
| Supabase database: URL | NEXT_PUBLIC_SUPABASE_URL |
| Supabase: server-side operations | SUPABASE_SERVICE_ROLE_KEY |
| Mapbox for maps | NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN |
MIT License