How alexrosario/delegatorbackend works
Delegator is a civic-engagement backend: constituents register and verify their identity/address, browse legislation, inspect representative and recorded-vote information, and participate through votes and bill discussions. A separate scheduled ingestion workflow refreshes Congress bills, members, and roll calls, then supports delegation reconciliation. The graph follows the server’s mounted routes and sampled worker/ingestion calls; unsampled major routes are represented by their exact source paths, but their internal dependencies are not inferred.
Main entry points: server.ts HTTP server · prisma.ts Application database · auth.router.ts Account and auth · auth-utils.ts Session utilities
Components 29
API and identity
- HTTP server
server.ts - Account and auth
src/router/auth.router.ts - Session utilities
src/utils/auth-utils.ts - Request schemas
src/zodSchema.ts - Contact messages
src/router/contact.router.ts
Legislative engagement
- Bill discovery
src/router/bill.router.ts - Constituent votes
src/router/vote.router.ts - Representative data
src/router/rep.router.ts - Address lookup
src/router/location.router.ts - Advocacy lookup
src/router/external/fivecalls.router.ts - Bill translation
src/router/external/translate.router.ts
Legislative data ingestion
- Daily bill job
src/workers/dailyBillIngest.ts - Daily member job
src/workers/dailyMemberIngest.ts - Delegation reconcile
src/workers/reconcileDelegations.ts - Ingestion tracking
src/ingestion/runIngestion.ts - Bill batch ingest
src/ingestion/ingestBillsBatch.ts - Bill ingestion
src/ingestion/ingestBill.ts - Bill normalization
src/ingestion/normalizeBill.ts - Bill persistence
src/ingestion/upsertBill.ts - Member batch ingest
src/ingestion/ingestMembersBatch.ts - Roll-call persistence
src/ingestion/upsertRollCalls.ts
External data services
- Congress.gov API
src/services/congressGovClient.ts - District resolver
src/services/districtResolver.ts - Donor summaries
src/services/donorService.ts - FEC data client
src/services/fecClient.ts - FEC candidate mapping
src/services/fecMapping.ts - Email provider
src/services/emailProvider.ts
Other components
- Constituent
- Application database
prisma/prisma.ts
Connections 48
- Constituent → HTTP server: requests
server.ts - HTTP server → Account and auth: mounts
server.ts - HTTP server → Bill discovery: mounts
server.ts - HTTP server → Constituent votes: mounts
server.ts - HTTP server → Representative data: mounts
server.ts - HTTP server → Contact messages: mounts
server.ts - HTTP server → Address lookup: mounts
server.ts - HTTP server → Advocacy lookup: mounts
server.ts - HTTP server → Bill translation: mounts
server.ts - Account and auth → Application database: reads and writes
src/router/auth.router.ts - Account and auth → District resolver: resolves address
src/router/auth.router.ts - Account and auth → Email provider: sends verification
src/router/auth.router.ts - Account and auth → Request schemas: validates input
src/router/auth.router.ts - Account and auth → Session utilities: creates session
src/router/auth.router.ts - Bill discovery → Application database: queries corpus
src/router/bill.router.ts - Bill discovery → Congress.gov API: fetches missing bill
src/router/bill.router.ts - Bill discovery → Session utilities: reads session
src/router/bill.router.ts - Bill discovery → Request schemas: validates comments
src/router/bill.router.ts - Constituent votes → Application database: records votes
src/router/vote.router.ts - Constituent votes → Request schemas: validates votes
src/router/vote.router.ts - Constituent votes → Session utilities: checks session
src/router/vote.router.ts - Representative data → Application database: reads representatives
src/router/rep.router.ts - Representative data → Donor summaries: loads donor summary
src/router/rep.router.ts - Representative data → Session utilities: checks session
src/router/rep.router.ts - Address lookup → District resolver: resolves district
src/router/location.router.ts - Contact messages → Application database: stores messages
src/router/contact.router.ts - Contact messages → Session utilities: checks session
src/router/contact.router.ts - Advocacy lookup → Session utilities: checks session
src/router/external/fivecalls.router.ts - Bill translation → Application database: reads stored text
src/router/external/translate.router.ts - Daily bill job → Ingestion tracking: tracks run
src/workers/dailyBillIngest.ts - Daily bill job → Bill batch ingest: ingests batch
src/workers/dailyBillIngest.ts - Daily member job → Ingestion tracking: tracks run
src/workers/dailyMemberIngest.ts - Daily member job → Member batch ingest: ingests members
src/workers/dailyMemberIngest.ts - HTTP server → Daily bill job: schedules job
server.ts - HTTP server → Daily member job: schedules job
server.ts - HTTP server → Delegation reconcile: runs after refresh
server.ts - Ingestion tracking → Application database: records run state
src/ingestion/runIngestion.ts - Bill batch ingest → Congress.gov API: lists bills
src/ingestion/ingestBillsBatch.ts - Bill batch ingest → Bill ingestion: ingests each bill
src/ingestion/ingestBillsBatch.ts - Bill ingestion → Congress.gov API: fetches bill resources
src/ingestion/ingestBill.ts - Bill ingestion → Bill persistence: persists bill
src/ingestion/ingestBill.ts - Bill ingestion → Roll-call persistence: stores recorded votes
src/ingestion/ingestBill.ts - Bill ingestion → Application database: commits transaction
src/ingestion/ingestBill.ts - Bill persistence → Bill normalization: normalizes record
src/ingestion/upsertBill.ts - Member batch ingest → Congress.gov API: fetches members
src/ingestion/ingestMembersBatch.ts - Member batch ingest → Application database: persists members
- Delegation reconcile → District resolver: resolves delegations
src/workers/reconcileDelegations.ts - Delegation reconcile → Application database: updates mappings
src/workers/reconcileDelegations.ts