# merlinvaldez/votefeed.org architecture

> Architecture diagram of the GitHub repository merlinvaldez/votefeed.org, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/merlinvaldez/votefeed.org
- Repository: https://github.com/merlinvaldez/votefeed.org
- Video tour (about a minute): https://gitdiagram.com/merlinvaldez/votefeed.org/video

## Overview

VoteFeed is a civic-engagement app: constituents find their district’s House representative, follow their voting record, and respond to bills; signed-in users can save their district and take part in the feed. The graph includes documented vote and roster synchronization, notification delivery, AI summaries, and comment-related capabilities. Several backend routes and sync implementations are represented by their exact tree paths, but their internal calls were not sampled, so uncertain wiring is omitted.

Main entry points: [`server/app.js`](https://github.com/merlinvaldez/votefeed.org/blob/main/server/app.js) (Express application), [`server/src/db/queries`](https://github.com/merlinvaldez/votefeed.org/tree/main/server/src/db/queries) (Data queries), [`client/src/App.jsx`](https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/App.jsx) (Web app), [`server/src/api/districts.js`](https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/districts.js) (District lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Constituent experience"]
  node_webapp["Web app<br/>[App.jsx]"]
  node_address["Address entry<br/>[AddressFields.jsx]"]
  node_feed["District feed<br/>[Feed.jsx]"]
  node_billpage["Bill details<br/>[BillPage.jsx]"]
  node_interactions_ui["User interactions<br/>[RepCard.jsx]"]
  node_onboarding["Account onboarding<br/>[Onboarding.jsx]"]
  node_auth["Authentication<br/>[AuthContext.jsx]"]
  node_authfetch["Authenticated fetch"]
end

subgraph group_api["Application API"]
  node_server["Express application<br/>[app.js]"]
  node_district_api["District lookup<br/>[districts.js]"]
  node_reps_api["Representative API<br/>[reps.js]"]
  node_bills_api["Bills API<br/>[bills.js]"]
  node_votes_api["House votes API<br/>[houseVotes.js]"]
  node_users_api["User profile API<br/>[users.js]"]
  node_interactions_api["Interactions API<br/>[interactions.js]"]
  node_comments_api["Comments API<br/>[comments.js]"]
end

subgraph group_records["Civic records"]
  node_district_service["Census geocoder"]
  node_congress["Congress.gov"]
end

subgraph group_storage["Persistent data"]
  node_queries["Data queries"]
  node_database[("Application database<br/>[client.js]")]
end

subgraph group_automation["Sync and engagement"]
  node_sync_votes["Vote synchronization<br/>[index.ts]"]
  node_sync_reps["Roster synchronization<br/>[index.ts]"]
  node_notify["Vote notifications<br/>[index.ts]"]
  node_email["Resend email"]
  node_ai_summary["Bill AI summaries"]
  node_contact_draft["Contact drafts"]
  node_moderation["Comment moderation"]
end

node_constituent(("Constituent"))
node_openai["OpenAI"]
node_clerk["Clerk"]

node_constituent -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_address
node_webapp -->|"routes to"| node_feed
node_webapp -->|"routes to"| node_billpage
node_webapp -->|"routes to"| node_onboarding
node_onboarding -->|"uses"| node_auth
node_authfetch -->|"gets token"| node_clerk
node_server -->|"mounts"| node_district_api
node_server -->|"mounts"| node_reps_api
node_server -->|"mounts"| node_bills_api
node_server -->|"mounts"| node_votes_api
node_server -->|"mounts"| node_users_api
node_server -->|"mounts"| node_interactions_api
node_server -->|"mounts"| node_comments_api
node_address -->|"requests lookup"| node_district_api
node_district_api -->|"geocodes address"| node_district_service
node_district_api -->|"queries"| node_queries
node_reps_api -->|"queries"| node_queries
node_bills_api -->|"queries"| node_queries
node_votes_api -->|"queries"| node_queries
node_users_api -->|"queries"| node_queries
node_interactions_api -->|"queries"| node_queries
node_comments_api -->|"queries"| node_queries
node_queries -->|"reads and writes"| node_database
node_sync_votes -->|"imports votes"| node_congress
node_sync_votes -->|"stores votes"| node_database
node_sync_reps -->|"refreshes roster"| node_congress
node_sync_reps -->|"updates roster"| node_database
node_notify -->|"reads queue and users"| node_database
node_notify -->|"sends notifications"| node_email
node_ai_summary -->|"generates summaries"| node_openai
node_contact_draft -->|"generates drafts"| node_openai
node_moderation -.->|"moderates comments"| node_openai
node_interactions_ui -->|"submits stance"| node_interactions_api
node_feed -->|"loads vote record"| node_votes_api
node_billpage -->|"loads bill details"| node_bills_api

click node_webapp "https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/App.jsx"
click node_address "https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/AddressFields.jsx"
click node_feed "https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/Feed.jsx"
click node_billpage "https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/BillPage.jsx"
click node_interactions_ui "https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/RepCard.jsx"
click node_onboarding "https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/Onboarding.jsx"
click node_auth "https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/AuthContext.jsx"
click node_authfetch "https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/useClerkAuthFetch.js"
click node_server "https://github.com/merlinvaldez/votefeed.org/blob/main/server/app.js"
click node_district_api "https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/districts.js"
click node_reps_api "https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/reps.js"
click node_bills_api "https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/bills.js"
click node_votes_api "https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/houseVotes.js"
click node_users_api "https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/users.js"
click node_interactions_api "https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/interactions.js"
click node_comments_api "https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/comments.js"
click node_queries "https://github.com/merlinvaldez/votefeed.org/tree/main/server/src/db/queries"
click node_database "https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/db/client.js"
click node_sync_votes "https://github.com/merlinvaldez/votefeed.org/blob/main/supabase/functions/sync-votes/index.ts"
click node_sync_reps "https://github.com/merlinvaldez/votefeed.org/blob/main/supabase/functions/sync-reps/index.ts"
click node_notify "https://github.com/merlinvaldez/votefeed.org/blob/main/supabase/functions/send-vote-notifications/index.ts"
click node_ai_summary "https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/utils/aiSummaryPipeline.js"
click node_contact_draft "https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/utils/contactDraftPipeline.js"
click node_moderation "https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/ai/commentModeration.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapp,node_address,node_feed,node_billpage,node_interactions_ui,node_onboarding,node_auth,node_authfetch toneBlue
class node_server,node_district_api,node_reps_api,node_bills_api,node_votes_api,node_users_api,node_interactions_api,node_comments_api toneAmber
class node_district_service,node_congress toneMint
class node_queries,node_database toneRose
class node_sync_votes,node_sync_reps,node_notify,node_email,node_ai_summary,node_contact_draft,node_moderation,node_constituent,node_openai,node_clerk toneIndigo
```

## Components

### Constituent experience

- [Web app](https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Address entry](https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/AddressFields.jsx): `client/src/AddressFields.jsx`
- [District feed](https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/Feed.jsx): `client/src/Feed.jsx`
- [Bill details](https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/BillPage.jsx): `client/src/BillPage.jsx`
- [User interactions](https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/RepCard.jsx): `client/src/RepCard.jsx`
- [Account onboarding](https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/Onboarding.jsx): `client/src/Onboarding.jsx`
- [Authentication](https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/AuthContext.jsx): `client/src/AuthContext.jsx`
- [Authenticated fetch](https://github.com/merlinvaldez/votefeed.org/blob/main/client/src/useClerkAuthFetch.js): `client/src/useClerkAuthFetch.js`

### Application API

- [Express application](https://github.com/merlinvaldez/votefeed.org/blob/main/server/app.js): `server/app.js`
- [District lookup](https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/districts.js): `server/src/api/districts.js`
- [Representative API](https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/reps.js): `server/src/api/reps.js`
- [Bills API](https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/bills.js): `server/src/api/bills.js`
- [House votes API](https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/houseVotes.js): `server/src/api/houseVotes.js`
- [User profile API](https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/users.js): `server/src/api/users.js`
- [Interactions API](https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/interactions.js): `server/src/api/interactions.js`
- [Comments API](https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/api/comments.js): `server/src/api/comments.js`

### Civic records

- **Census geocoder**
- **Congress.gov**

### Persistent data

- [Data queries](https://github.com/merlinvaldez/votefeed.org/tree/main/server/src/db/queries): `server/src/db/queries`
- [Application database](https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/db/client.js): `server/src/db/client.js`

### Sync and engagement

- [Vote synchronization](https://github.com/merlinvaldez/votefeed.org/blob/main/supabase/functions/sync-votes/index.ts): `supabase/functions/sync-votes/index.ts`
- [Roster synchronization](https://github.com/merlinvaldez/votefeed.org/blob/main/supabase/functions/sync-reps/index.ts): `supabase/functions/sync-reps/index.ts`
- [Vote notifications](https://github.com/merlinvaldez/votefeed.org/blob/main/supabase/functions/send-vote-notifications/index.ts): `supabase/functions/send-vote-notifications/index.ts`
- **Resend email**
- [Bill AI summaries](https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/utils/aiSummaryPipeline.js): `server/src/utils/aiSummaryPipeline.js`
- [Contact drafts](https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/utils/contactDraftPipeline.js): `server/src/utils/contactDraftPipeline.js`
- [Comment moderation](https://github.com/merlinvaldez/votefeed.org/blob/main/server/src/ai/commentModeration.js): `server/src/ai/commentModeration.js`

### Other components

- **Constituent**
- **OpenAI**
- **Clerk**

## Connections

- Constituent → Web app: uses
- Web app → Address entry: routes to
- Web app → District feed: routes to
- Web app → Bill details: routes to
- Web app → Account onboarding: routes to
- Account onboarding → Authentication: uses
- Authenticated fetch → Clerk: gets token
- Express application → District lookup: mounts
- Express application → Representative API: mounts
- Express application → Bills API: mounts
- Express application → House votes API: mounts
- Express application → User profile API: mounts
- Express application → Interactions API: mounts
- Express application → Comments API: mounts
- Address entry → District lookup: requests lookup
- District lookup → Census geocoder: geocodes address
- District lookup → Data queries: queries
- Representative API → Data queries: queries
- Bills API → Data queries: queries
- House votes API → Data queries: queries
- User profile API → Data queries: queries
- Interactions API → Data queries: queries
- Comments API → Data queries: queries
- Data queries → Application database: reads and writes
- Vote synchronization → Congress.gov: imports votes
- Vote synchronization → Application database: stores votes
- Roster synchronization → Congress.gov: refreshes roster
- Roster synchronization → Application database: updates roster
- Vote notifications → Application database: reads queue and users
- Vote notifications → Resend email: sends notifications
- Bill AI summaries → OpenAI: generates summaries
- Contact drafts → OpenAI: generates drafts
- Comment moderation → OpenAI: moderates comments
- User interactions → Interactions API: submits stance
- District feed → House votes API: loads vote record
- Bill details → Bills API: loads bill details
