How Do They Lobby?
Tools: Svelte, SvelteKit, Typescript, Tailwind CSS, Supabase (open-source Firebase alternative), PostgreSQL, Pandas (Python)
How Do They Lobby? is a web portal for searching and visualizing an original dataset of lobbying records soon to be published by the Brown Climate and Development Lab.
This project is exciting because it’s the first comprehensive dataset of lobbying activity in state legislatures, providing a way to systematically analyze the behavior of interest groups. We hope the portal will be used by researchers, policymakers, advocacy groups, and journalists to create more transparency in our government.
The Data
The dataset consists of four main tables stored in a PostgreSQL server hosted on Supabase:
- Interest groups/clients. The organizations that lobby bills. Often companies, unions, and non-profit organizations.
- Bills. The state legislation which interest groups lobby on.
- Positions. A stance taken by an interest group on a given bill.
- Lobbying Coalitions. Coalitions of interest groups generated using stochastic block modelling. These coalitions will tend to take similar positions on a similar subset of bills.
Exploring Lobbying Coalitions
The developer before me implemented interactive coalition graphs to show the (dis)agreement between lobbying coalitions in a given state.
I refactored the app to retrieve the graph data from a REST API created using SvelteKit, rather than from the database directly. I also implemented:
- The ability to view a coalition graph by issue area. For example, you might want to see the coalition graph for energy bills specificallly.
- Improved intra-coalition networks. I refined the interest group networks you see when zooming in on a specific coalition. I scaled nodes based on their activity, added text labels and tooltips, and linked nodes to their interest group page.
Searching Specific Records
I ideated and implemented the site’s search functionality. You can search across the clients (interest groups), bills, and positions table, returning results that link to detailed pages on a given bill/interest group. Highlights include:
- Implementing lazy loading, so components that rely on async data loading render progressively as promises are fulfilled.
- Creating a search endpoint that supports pagination and faceting in our internal REST API, inspired by Typesense’s Search API.
- Building in fuzzy searching on certain columns using
pg_trgm
, PostgreSQL’s trigram matching module. - Lots of SQL query optimization by building better indices and limiting I/O.