Project Story: PolicyPulse
One-Sentence Pitch
Web app with tools that scrapes government posts and looks for keywords/wording to determine which industries and companies are prime for investment.
Problem Statement
Allows investors who use government policy for decision-making to receive prime candidate companies that will be affected by incoming policy, reducing research time.
Inspiration
The intersection of government policy and financial markets has always fascinated us. Every day, Congressional bills are introduced that can dramatically impact entire industries—from healthcare to technology, energy to finance.
Consider a bill like H.R. 4346 from the 117th Congress. Buried within its hundreds of pages of legislative text are signals about which industries will benefit, which will face challenges, and which companies are positioned to capitalize on the changes. Yet, this critical information remains inaccessible to most investors who lack the time or expertise to parse through dense government documents.
The Problem: Policy-driven investors spend countless hours manually researching bills, identifying keywords, analyzing industry impacts, and finding relevant companies. This process is:
- Time-consuming: Reading and analyzing full bill text can take hours
- Error-prone: Missing critical keywords or misinterpreting policy language
- Incomplete: Difficult to identify all affected industries and companies
- Inefficient: The same research is repeated by different investors
Our Solution: We built an AI-powered platform that automatically:
- Scrapes and processes government posts (Congressional bills)
- Analyzes keywords and wording patterns using AI
- Identifies affected industries with impact percentages
- Recommends prime investment candidate companies
We were inspired by the question: What if we could automate the entire policy-to-investment pipeline?
Our platform was born from the realization that:
- Congressional bills contain valuable signals about future market trends
- AI can process and analyze complex legislative language at scale, identifying keywords and patterns humans might miss
- Investors need actionable insights, not just raw data
- The connection between policy impact and investment opportunities is often overlooked
- Time is money—reducing research time directly increases investment opportunities
We wanted to create a tool that transforms hours of manual research into minutes of automated analysis, making policy-driven investing accessible to everyone.
What We Learned
Technical Skills
Next.js & React Ecosystem
- Built our first production-ready Next.js application using the App Router
- Mastered Server Components vs Client Components for optimal performance
- Implemented proper authentication flows with Supabase SSR
- Learned to structure API routes for both server-side and client-side consumption
AI Integration
- Integrated OpenRouter API to leverage multiple AI models (Google Gemini 2.5 Flash)
- Discovered the art and science of prompt engineering—crafting system prompts that produce structured, reliable outputs
- Learned to handle streaming vs non-streaming AI responses
- Understood the importance of error handling when working with external AI services
Data Processing & APIs
- Worked with the Congress.gov API to fetch real-time legislative data
- Implemented fuzzy search using Fuse.js for intelligent policy discovery
- Learned to structure and cache API responses efficiently
- Gained experience with JSON data transformation and normalization
Authentication & Security
- Implemented cookie-based authentication with Supabase
- Learned about middleware patterns for session management
- Understood the importance of environment variable validation
- Discovered best practices for protecting API keys and sensitive data
Domain Knowledge
- Legislative Process: Gained deep understanding of how bills move through Congress, their structure, and key metadata
- Financial Analysis: Learned how to translate policy impacts into quantifiable industry effects
- Investment Strategy: Understood the relationship between regulatory changes and market opportunities
How We Built It
Architecture Overview
Our platform follows a modern full-stack architecture:
┌─────────────────┐
│ Next.js App │
│ (Frontend) │
└────────┬────────┘
│
┌────┴────┬──────────────┬─────────────┐
│ │ │ │
┌───▼───┐ ┌──▼────┐ ┌────▼────┐ ┌────▼────┐
│Supabase│ │Congress│ │OpenRouter│ │ Static │
│ Auth │ │ API │ │ AI │ │ Data │
└────────┘ └────────┘ └─────────┘ └─────────┘
Technology Stack
Frontend
- Next.js 16 with App Router and Turbopack for blazing-fast development
- React 19 with modern hooks and server components
- Tailwind CSS v3 for responsive, modern UI design
- shadcn/ui components for consistent, accessible interfaces
- Fuse.js for intelligent search functionality
Backend & Services
- Supabase for authentication and user management
- Congress.gov API for real-time legislative data
- OpenRouter API with Google Gemini 2.5 Flash for AI-powered analysis
- Next.js API Routes for server-side logic and data aggregation
Development Tools
- TypeScript for type safety and better developer experience
- ESLint for code quality
- Git for version control
Key Features Implementation
1. Policy Search & Discovery
We implemented a powerful search system that allows users to:
- Search through thousands of Congressional bills
- Filter by Congress session, bill type, and origin chamber
- View detailed bill information including latest actions and status
- Access direct links to official bill documents
Technical Challenge: Processing large datasets efficiently. We solved this by:
- Implementing client-side fuzzy search with Fuse.js
- Using React's
useMemoto optimize search performance - Structuring data for fast lookups
2. Government Post Scraping & Keyword Analysis
Our core innovation: automatically scraping government posts and using AI to identify keywords and wording patterns that signal investment opportunities.
The Scraping Process:
- Integrates with Congress.gov API to fetch bill text and metadata
- Processes full bill text (often hundreds of pages)
- Extracts key sections, titles, and legislative language
- Handles various bill formats and structures
Keyword & Wording Analysis: The AI analyzes bills to identify:
- Regulatory keywords: Terms like "mandate", "prohibition", "subsidy", "tax credit"
- Industry-specific language: Technical terms that signal sector impact
- Financial implications: Language indicating funding, grants, or penalties
- Temporal signals: Deadlines, phase-in periods, grandfather clauses
Stage 1: Industry Impact Analysis
Bill Selection → Bill Text → AI Analysis → Industry Impact Scores by Company
The AI receives a bill and analyzes its contents to return a JSON array:
[
{ "industry_name": "Renewable Energy", "company_name": "First Solar", "percentage": 85 },
{ "industry_name": "Fossil Fuels", "company_name": "Exxon", "percentage": -30 }
]
The percentage indicates how much each company is affected (positive = benefit, negative = challenge).
Stage 2: Company Recommendations
Industry → AI Analysis → Prime Investment Candidates
For each affected industry, the AI provides:
- Recommended companies that are prime investment candidates
- Investment rationale based on policy impact
- Key strengths and market position
- How the company will be affected by the policy
Technical Implementation:
- Custom system prompts engineered for keyword detection and structured output
- AI model trained to recognize policy language patterns
- Error handling for malformed AI responses
- Loading states and user feedback
- JSON parsing and validation
3. User Authentication
We implemented secure authentication using Supabase:
- Password-based sign-up and login
- Session management with HTTP-only cookies
- Protected routes with middleware
- Password reset functionality
Key Learning: The importance of proper session handling in Next.js App Router, especially with server components.
4. Government Post Scraping & Real-Time Data Integration
- Congress API integration for scraping bill text and metadata
- Automatic extraction of bill content, titles, and legislative language
- Proper error handling for API rate limits and failures
- Caching strategy using Next.js revalidation to reduce API calls
- Fallback to static JSON data when API is unavailable
- Loading states and error boundaries for better UX
Data Flow
Here's how data flows through our system:
- Scrape government post → Congress API fetches bill text and metadata
- User searches for a bill → Fuse.js searches through scraped/API data
- User selects a bill → Full bill details and text displayed
- User requests analysis → Bill text sent to OpenRouter API with keyword analysis system prompt
- AI analyzes bill's contents → Identifies patterns and returns industry impact percentages
- Results displayed → Formatted, actionable investment insights with company recommendations, grouped by company
The Value: What used to take hours of manual keyword searching and analysis now happens in seconds, automatically identifying which industries and companies are prime for investment based on policy changes.
Challenges We Faced
1. AI Prompt Engineering
Challenge: Getting consistent, structured output from the AI model.
Initial Problem: The AI would sometimes return:
- Plain text instead of JSON
- Incomplete data
- Inconsistent formatting
- Hallucinated industry names
Solution:
- Iteratively refined system prompts with clear instructions
- Added explicit JSON format requirements
- Implemented validation and error handling
- Created fallback mechanisms for malformed responses
Example of our prompt evolution:
Initial: "Analyze this bill and suggest industries"
Final: "You are an investment advisor... Return ONLY a JSON array
of objects with industry_name and percentage variables."
2. Cost Reduction of AI Prompts
Challenge: Minimizing the costs of AI prompts to keep analysis scalable as bill volumes grow.
Initial Problem:
- Bills are thousands of words; identifying meaningful language is difficult
- Regulatory phrasing is indirect (e.g., “shall not prohibit” vs. “shall require”)
- The same keyword can mean different things depending on context
- High risk of false positives from generic terms that appear frequently
Solution:
- Wrote system prompts that target regulatory, financial, and industry-specific language
- Added clear examples of positive and negative signals
- Used semantic interpretation (not just keyword spotting) to capture context
- Iteratively refined prompts based on real outputs
- Combined lightweight keyword filtering with deeper semantic analysis to reduce token usage
Key Insight: Accurate analysis requires understanding the context and intent of bill language—not just searching for keywords.
3. API Rate Limiting & Error Handling
Challenge: The Congress API has rate limits, and external APIs can be unreliable.
Solutions:
- Implemented proper error boundaries
- Added retry logic with exponential backoff
- Created fallback to static JSON data
- Used Next.js revalidation for caching
- Graceful degradation when services are unavailable
4. Data Structure Complexity
Challenge: Congressional bills have complex, nested structures with inconsistent formatting.
Solution:
- Created TypeScript interfaces for type safety
- Normalized data structures
- Built robust parsing functions
- Handled edge cases (missing fields, null values)
5. Authentication Flow
Challenge: Implementing secure authentication that works across server and client components.
Solution:
- Used Supabase SSR package for cookie-based auth
- Implemented middleware for session refresh
- Created proper error handling for auth failures
- Ensured session persistence across page navigations
6. Environment Variable Management
Challenge: Multiple API keys and configuration values needed proper validation.
Solution:
- Created validation functions for environment variables
- Added helpful error messages when config is missing
- Implemented checks for placeholder values
- Documented required environment variables
7. Performance Optimization
Challenge: Large datasets and AI API calls can be slow.
Solutions:
- Implemented client-side search to reduce server load
- Used React memoization for expensive computations
- Added loading states for better UX
- Optimized API calls
Future Enhancements
If we had more time, we would add:
- Historical Analysis: Track how past bills affected industries over time
- Portfolio Integration: Connect to brokerage APIs for direct investment
- Real-time Alerts: Notify users when bills affecting their industries are introduced
- Sentiment Analysis: Analyze bill language sentiment for additional insights
- Visualization: Charts and graphs showing impact trends
- Multi-model AI: Compare results across different AI models
- Bill Tracking: Follow specific bills through the legislative process
- Caching AI Prompts and Bills: Reduce the number of requests made to external APIs and LLMs (for cost reduction)
Conclusion
Building this platform taught us that the most powerful applications come from connecting disparate data sources with intelligent analysis. We learned that:
- AI is a tool, not a solution—careful prompt engineering and validation are essential, especially for keyword detection and wording analysis
- Time is the ultimate value proposition—reducing hours of manual research to seconds of automated analysis is transformative
- Keyword analysis requires context—pure keyword matching fails; understanding legislative language nuances is crucial
- User experience matters—complex data needs simple, intuitive interfaces
- Error handling is critical—external APIs will fail, and you need graceful fallbacks
- Type safety saves time—TypeScript caught countless bugs before runtime
- Iteration is key—our first version was far from perfect, but each iteration improved it
The Impact: Our platform transforms the workflow of policy-driven investors. What once required hours of manual keyword searching, bill reading, and industry research now happens automatically. By scraping government posts and analyzing keywords/wording patterns, we've created a tool that identifies prime investment candidates in seconds—not hours.
We're proud of what we built in this hackathon, and we believe this platform demonstrates the potential of combining government data scraping, AI-powered keyword analysis, and modern web technologies to create actionable investment intelligence that saves time and reduces research overhead.
Built with ❤️ at HackNYU
Built With
- eslint
- javascript-frameworks-&-libraries:-next.js-15-(app-router)
- json-(static-data)-platforms:-vercel-(deployment-ready)
- languages:-typescript
- lucide-react-backend-&-services:-supabase-(authentication-&-database)-openrouter-api-(ai/ml-google-gemini-2.5-flash)-congress.gov-api-(government-data)-development-tools:-typescript
- node.js-ui-&-styling:-tailwind-css
- postcss-data-&-search:-fuse.js-(fuzzy-search)
- radix-ui
- react-19
- shadcn/ui
- supabase
- turbopack
Log in or sign up for Devpost to join the conversation.