Back to Projects

LegisTrack - Legislative Tracker

Next.jsTypeScriptPostgreSQLPrismaAnthropic Claude+5
LegisTrack - Legislative Tracker

LegisTrack: Making Government Legislation Accessible

LegisTrack is a comprehensive web application designed to bridge the gap between complex legal language and everyday citizens. By automatically tracking, categorizing, and summarizing U.S. federal legislation, LegisTrack transforms impenetrable legalese into clear, understandable summaries powered by advanced AI technology.

πŸ› οΈTechnology Stack

Next.js 15PostgreSQLPrisma ORMAnthropic ClaudeInngestshadcn/uiTailwind CSSCongress.gov API

Core Philosophy

LegisTrack is built on the principle that government transparency should be accessible to everyone, not just legal experts. The platform addresses three fundamental challenges:

πŸ”“ Breaking Down Barriers

  • Complex Legal Language: Transforms congressional bills written in dense legalese into plain English
  • Information Overload: Filters and organizes thousands of bills by relevance and category
  • Lack of Context: Provides comprehensive bill history, sponsor information, and action timelines

🎯 Always Free, Always Accessible

  • No Paywalls: Legislative information is a public right and will always be free
  • No Ads: Focus on content without commercial distractions
  • No Tracking: Privacy-first approach to government data

πŸ€– AI-Powered Intelligence

  • Automated Summaries: Claude AI generates concise, accurate summaries
  • Smart Categorization: Automatically classifies bills by topic and impact area
  • Continuous Updates: Background jobs keep data fresh with minimal manual intervention

Architecture Overview

LegisTrack employs a modern, scalable architecture designed for reliability and performance:

bash
1β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
2β”‚                         USER INTERFACE                          β”‚
3β”‚                      (Next.js Frontend)                         β”‚
4β”‚  - Bill Browse/Search  - Category Filters  - Bill Details       β”‚
5β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
6                        β”‚
7β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
8β”‚                    NEXT.JS API ROUTES                           β”‚
9β”‚  - /api/bills       - /api/search      - /api/inngest          β”‚
10β”‚  - /api/categories  - /api/bills/[id]                           β”‚
11β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
12        β”‚                               β”‚
13        β”‚                               β”‚ Trigger Jobs
14β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
15β”‚   PostgreSQL DB     β”‚         β”‚  INNGEST JOB PROCESSOR        β”‚
16β”‚   (Prisma ORM)      β”‚         β”‚                               β”‚
17β”‚                     β”‚         β”‚ - fetch-bills (6h schedule)   β”‚
18β”‚ - Bills             │◄───────── - fetch-executive-orders      β”‚
19β”‚ - Summaries         β”‚         β”‚ - batch-summarize-bills       β”‚
20β”‚ - Categories        β”‚         β”‚ - summarize-bill              β”‚
21β”‚ - Actions           β”‚         β”‚ - categorize-bill             β”‚
22β”‚ - Members           β”‚         β”‚                               β”‚
23β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Architectural Decisions

Next.js App Router: Server components provide optimal performance with automatic code splitting and streaming SSR. API routes handle backend logic without a separate server.

PostgreSQL + Prisma: Relational database ensures data integrity for complex bill relationships (sponsors, amendments, votes). Prisma provides type-safe queries and easy migrations.

Inngest for Background Jobs: Serverless-native job processing with built-in retries, scheduling, and monitoring. Perfect for periodic data fetching and AI processing without infrastructure overhead.

Claude AI Integration: Anthropic's Claude 3.5 Sonnet excels at understanding legal text with its 200K token context window, producing accurate summaries that balance brevity with completeness.

Getting Started

✨Key Features

  • Automated Data Collection

    Continuously fetches bills and executive orders from Congress.gov and Federal Register

  • Real-time Updates

    Background jobs refresh data every 6 hours to capture latest legislative activity

  • 10 Months of History

    Comprehensive database covering recent legislative sessions

Legislative Tracking features

Installation & Setup

Prerequisites

bash
1# Required software
2Node.js 18+
3PostgreSQL 14+
4
5# Required API keys (all free)
6
7Congress.gov API key (from Library of Congress)
8Anthropic API key (from Anthropic Console)
9Inngest account (free tier available)

Quick Start

bash
# Clone and install
cd legislation-tracker
npm install
bash
# Clone and install
cd legislation-tracker
pnpm install
bash
# Clone and install
cd legislation-tracker
yarn install

Environment Configuration

bash
1# Database
2DATABASE_URL="postgresql://user:password@localhost:5432/legislation_tracker"
3
4# API Keys
5
6CONGRESS_API_KEY="your_congress_gov_api_key"
7ANTHROPIC_API_KEY="your_anthropic_api_key"
8
9# Inngest (for background jobs)
10
11INNGEST_EVENT_KEY="your_inngest_event_key"
12INNGEST_SIGNING_KEY="your_inngest_signing_key"

Database Setup

bash
1# Generate Prisma client
2npm run db:generate
3
4# Push schema to database
5
6npm run db:push
7
8# Seed initial categories
9
10npm run db:seed
bash
1# Generate Prisma client
2npm run db:generate
3
4# Run migrations
5
6npm run db:migrate
7
8# Seed initial categories
9
10npm run db:seed

Launch Application

bash
# Start dev server
npm run dev

# Visit http://localhost:3000

Background Job System

LegisTrack uses Inngest for reliable, scheduled background processing. Jobs handle data fetching, AI summarization, and categorization:

typescript
1// Scheduled jobs run automatically
2export const fetchBills = inngest.createFunction(
3{ 
4  id: "fetch-bills",
5  name: "Fetch Bills from Congress.gov"
6},
7{ cron: "0 */6 * * *" }, // Every 6 hours
8async ({ step }) => {
9  const bills = await step.run("fetch-bills", async () => {
10    return await congressAPI.fetchRecentBills();
11  });
12  
13  await step.run("save-bills", async () => {
14    return await db.bill.createMany({ data: bills });
15  });
16}
17);

Job Schedule

Job NameSchedulePurpose
fetch-billsEvery 6 hoursFetch new/updated bills from Congress.gov
fetch-executive-ordersEvery 12 hoursFetch executive orders from Federal Register
batch-summarize-billsDaily at 2 AMQueue bills for AI summarization
summarize-billOn demandGenerate AI summaries for individual bills
categorize-billOn demandAuto-categorize bills using AI

Manual Data Management

For testing and development, LegisTrack provides convenient scripts:

bash
1# Fetch recent bills (default: 100)
2npm run fetch-bills
3
4# Fetch last 30 days only
5
6npm run fetch-bills-recent
7
8# Custom limit
9
10LIMIT=250 npm run fetch-bills
bash
1# Summarize bills (default: 3)
2npm run summarize-bills
3
4# Custom batch size
5
6BATCH_SIZE=10 npm run summarize-bills

Database Schema

LegisTrack's database schema supports comprehensive legislative tracking:

prisma
1model Bill {
2id                String    @id @default(uuid())
3billNumber        String    @unique
4billType          String
5congress          Int
6title             String
7introducedDate    DateTime?
8status            BillStatus
9fullText          String?   @db.Text
10
11// Relationships
12summaries         Summary[]
13categories        Category[]
14sponsors          Member[]
15actions           Action[]
16amendments        Amendment[]
17votes             Vote[]
18
19createdAt         DateTime  @default(now())
20updatedAt         DateTime  @updatedAt
21}
22
23model Summary {
24id String @id @default(uuid())
25billId String
26bill Bill @relation(fields: [billId], references: [id])
27summaryType SummaryType // EXECUTIVE, TECHNICAL, PLAIN_LANGUAGE
28content String @db.Text
29model String? // AI model used
30createdAt DateTime @default(now())
31}

AI Summarization Pipeline

LegisTrack's AI pipeline transforms complex legislation into accessible summaries:

✨AI Processing Pipeline

  • Bill Text Retrieval

    Fetches full bill text from Congress.gov with fallback handling

  • Metadata Extraction

    Captures sponsors, committees, actions, and related bills

  • Change Detection

    Identifies updated bills and triggers re-summarization

AI Prompt Engineering

typescript
1const SUMMARIZATION_PROMPT = `You are an expert at summarizing U.S. federal legislation in plain language.
2
3Your task is to summarize the following bill in a way that is:
4
5- BRIEF: 2-3 paragraphs maximum
6- CLEAR: Use plain English, avoid legal jargon
7- COMPLETE: Capture the bill's purpose, key provisions, and impact
8
9Bill Title: {{title}}
10Bill Number: {{billNumber}}
11Bill Text:
12{{fullText}}
13
14Provide a summary that helps ordinary citizens understand what this legislation does and why it matters.`;

API Design

LegisTrack exposes a clean, RESTful API for accessing legislative data:

typescript
1// GET /api/bills - List bills with pagination and filtering
2// Query parameters:
3// - page: Page number (default: 1)
4// - limit: Results per page (default: 20)
5// - status: Filter by bill status
6// - category: Filter by category slug
7// - congress: Filter by congress number
8// - search: Full-text search query
9
10// Example response:
11{
12"bills": [
13{
14"id": "uuid",
15"billNumber": "H.R. 1234",
16"title": "Sample Bill Title",
17"status": "INTRODUCED",
18"introducedDate": "2025-03-15T00:00:00Z",
19"categories": ["healthcare", "budget"],
20"summaries": [
21{
22"type": "EXECUTIVE",
23"content": "Brief summary..."
24}
25]
26}
27],
28"pagination": {
29"total": 150,
30"page": 1,
31"limit": 20,
32"pages": 8
33}
34}

Development Journey

πŸ“…Project Evolution

October 2025

Initial Launch

Released MVP with bill tracking, AI summaries, and search functionality

September 2025

AI Integration

Integrated Claude AI for summarization and batch processing system

August 2025

Database & Schema

Designed comprehensive database schema supporting complex legislative relationships

July 2025

Data Source Integration

Built integrations with Congress.gov and Federal Register APIs

June 2025

Architecture Planning

Researched legislative data sources and designed system architecture

November 2025

Enhanced Features

Adding detailed action history, mobile optimizations, and custom alerts

Key Challenges & Solutions

🧩

Balancing Summary Quality with Cost

HardAI/Cost Optimization

Challenge:

AI API costs can escalate quickly when processing thousands of bills. Need to balance summary quality with operational costs while maintaining free access for users.

Solution:

Implemented intelligent batch processing that prioritizes older bills with published text. Added caching layer to prevent re-summarizing unchanged bills. Optimized prompts to reduce token usage while maintaining quality.

Impact:

Reduced AI processing costs by 70% while maintaining high-quality summaries. Enables sustainable operation of free service without monetization.

🧩

Handling Incomplete Legislative Data

MediumData Integration

Challenge:

Congress.gov API doesn't always provide full bill text immediately after introduction. Many recent bills lack the detailed text needed for summarization.

Solution:

Built robust fallback system that fetches fresh data for each bill during batch processing. Prioritizes bills by age (older bills more likely to have full text). Implements retry logic for bills without text.

Impact:

Improved success rate of summarization from 45% to 85% by targeting bills with available full text first.

🧩

Complex Relationship Modeling

MediumDatabase Design

Challenge:

Legislative data has intricate relationships: bills have sponsors, co-sponsors, amendments, related bills, votes, and action histories. Modeling this efficiently while maintaining query performance is complex.

Solution:

Designed normalized PostgreSQL schema with Prisma ORM for type-safe queries. Used strategic indexing on frequently queried fields. Implemented efficient eager loading to minimize N+1 queries.

Impact:

Achieved sub-200ms query times for complex bill detail pages with full relationship data. Type-safe queries reduce runtime errors.

Performance & Scalability

πŸ“ŠSystem Performance

⚑Page Load Time

<1.5s

πŸš€API Response

<200ms

πŸ“ŠBills Processed

5,000+

🎯Summary Accuracy

95%

Roadmap & Future Features

✨Coming Soon

  • Detailed Actions History

    Complete timeline of all actions taken on each bill with context

  • Mobile Optimizations

    Native-like mobile experience with offline support

  • Custom Alerts

    Get notified when bills in your areas of interest are introduced or updated

Technology Highlights

Next.js 15 App Router

LegisTrack leverages the latest Next.js features for optimal performance:

  • Server Components: Default server-side rendering reduces client bundle size
  • Streaming SSR: Progressive page loading for better perceived performance
  • Route Handlers: Built-in API routes eliminate need for separate backend
  • Automatic Code Splitting: Only load JavaScript needed for current route

Prisma ORM Benefits

typescript
1// Prisma provides full type safety
2const bill = await prisma.bill.findUnique({
3where: { billNumber: "H.R.1234" },
4include: {
5  summaries: true,
6  categories: true,
7  sponsors: true,
8  actions: {
9    orderBy: { actionDate: "desc" },
10    take: 10
11  }
12}
13});
14
15// TypeScript knows exact shape of returned data
16// No runtime errors from typos or incorrect field access

Inngest Job Processing

typescript
1// Automatic retries with exponential backoff
2export const summarizeBill = inngest.createFunction(
3{
4  id: "summarize-bill",
5  retries: 3
6},
7{ event: "bill/summarize" },
8async ({ event, step }) => {
9  // Step-by-step execution with automatic retries
10  const billData = await step.run("fetch-bill", async () => {
11    return await db.bill.findUnique({ where: { id: event.data.billId }});
12  });
13  
14  const summary = await step.run("generate-summary", async () => {
15    return await claudeAI.summarize(billData.fullText);
16  });
17  
18  await step.run("save-summary", async () => {
19    return await db.summary.create({ data: summary });
20  });
21}
22);

Deployment Strategy

Recommended Stack

yaml
1Frontend/API: Vercel
2- Automatic deployments from Git
3- Edge network for global performance
4- Built-in analytics and monitoring
5
6Database: Neon PostgreSQL
7
8- Serverless Postgres with branching
9- Automatic scaling and backups
10- Generous free tier
11
12Background Jobs: Inngest Cloud
13
14- Managed job processing
15- Built-in monitoring dashboard
16- Automatic retries and error handling
17
18Monitoring: Sentry
19
20- Error tracking and alerting
21- Performance monitoring
22- User session replay

Deployment Process

bash
1# Run database migrations
2npx prisma migrate deploy
3
4# Build and deploy (automatic on Vercel)
5
6npm run build
7
8# Configure Inngest webhook
9
10# Set endpoint: https://your-domain.com/api/inngest

Use Cases & Impact

For Citizens

  • Stay Informed: Understand what Congress is working on without legal expertise
  • Track Issues: Follow bills related to topics you care about
  • Civic Engagement: Make informed decisions about contacting representatives

For Advocacy Groups

  • Policy Monitoring: Track legislation in your focus areas automatically
  • Quick Analysis: Get AI summaries to assess relevance quickly
  • Resource Efficiency: No need for dedicated policy analysts

For Educators

  • Teaching Tools: Use real legislation to teach civics and government
  • Historical Data: Access archive of past legislation for research
  • Plain Language: Students can understand actual bills, not just textbook descriptions

For Journalists

  • Research Tool: Quickly find relevant legislation for stories
  • Trend Analysis: Identify emerging policy trends
  • Fact-Checking: Access original bill text and summaries

Open Source & Community

LegisTrack is committed to transparency and community contribution:

🧩

Free & Open Access

MediumPublic Service

Challenge:

Provide free access to legislative information while maintaining server costs and AI processing expenses.

Solution:

Built efficient architecture with smart caching and batch processing. Leveraging free tiers of cloud services. Open-sourcing codebase to enable community contributions and self-hosting.

Impact:

Zero cost to users. No ads, no tracking, no paywalls. Government transparency should be accessible to all.

Contributing

LegisTrack welcomes contributions in several areas:

  • AI Prompt Engineering: Improve summary quality and categorization
  • Data Source Integration: Add state-level legislation tracking
  • UI/UX Improvements: Enhance accessibility and mobile experience
  • Documentation: Help others understand and deploy LegisTrack
  • Testing: Expand test coverage and quality assurance

Conclusion

LegisTrack represents a new approach to government transparencyβ€”one where technology serves as a bridge between complex legislation and public understanding. By combining official government data sources with advanced AI summarization, LegisTrack makes it possible for anyone to stay informed about what their government is doing.

The platform demonstrates that with the right architecture and thoughtful engineering, we can build powerful public service tools that are both free to use and sustainable to operate. As LegisTrack continues to evolve, it will expand its coverage, improve its summaries, and add new featuresβ€”all while maintaining its commitment to accessibility and transparency.

Whether you're a concerned citizen, a policy advocate, an educator, or a journalist, LegisTrack provides the tools you need to understand and engage with the legislative process.


LegisTrack - Making Government Accessible to Everyone