Project Info
Inspiration
A recent survey showed that 70% of Americans lacked basic civic literacy on topics related to the US Government. In a democracy, it’s not just a privilege but almost a necessity to form opinions that help shape the government we follow. source Today’s generation has a new way of absorbing information, and it’s through short forms of content (Reels/Tiktoks/etc). So the idea of reading through a newspaper, let alone an entire bill, feels completely out of the question. But these same bills have the power to affect our day-to-day, and make a lasting impact on our lives. So why shouldn’t there be a way for our generation to stay informed in a format that actually fits how we consume content? The Solution We built an iOS app that meets you where you are. InShort uses AI to learn what matters to you: your lifestyle, your interests, your needs, and then explains the bills that affect you most, simply and clearly. It’s like TikTok but for laws and political awareness. InShort is designed for convenience. You only need to tell us the causes you care about, and we’ll take care of notifying you. If you feel strongly about a pending law, we give you the ability to contact your lawmaker with 1 click.
How we built it
We started off with an initial MVP using iOS native frameworks, and then we used Congress API to scrape over 500+ Congressional bills from which we made a vector database so that we can establish a recommender system for people to find the bills that are most relevant to them. Then we added an AI chatbot using Groq personalized to the user, and familiar with Congressional law. For our recommender system, we fine-tuned the parameters for the cosine similarity search function to improve relevance for the user. We hosted the backend for these AI features on an OVH server. Then we established a notification system that notifies people about the bills that they would care about. Lastly, we improved user experience by providing people with a forum for public discourse that uses reinforcement learning to suggest more of what you would engage with. An algorithm suited for you. And finally, we added the option to contact your lawmaker with a click of a button. Who we are We met on the Slack Intro channel, where we quickly connected over a shared passion for using technology to make civic engagement easier. What started as a group chat with 4 strangers, quickly turned into hours of brainstorming, building and problem solving together! For some of us, this was our first hackathon!
Challenges we ran into
We started a step behind. Our team spent the first few hours just brainstorming, throwing out ideas, scrapping them, and trying to find something we could all genuinely believe in. We didn’t want to build just another project for the sake of it, we wanted something that would stick. That took time. We also had issue being that most of us have never worked on an IOS application before, and setting up a back-end server in within hackathon time constraints was pretty hard. How we overcame them Once we locked in on the idea, we divided work based on strengths, stayed up all night debugging the backend and connecting it to the frontend, and somehow put it all together just in time. (everything was broken at 4 AM). Integration was honestly the hardest part, between the AI API, the recommender system, and the app UI, getting it to feel seamless was rough. But we made it work. Next steps! InShort was limited by the scope of this Hackathon, but we hope to partner with nonprofits like Pew research in the future to spread civic engagement for people who grew up in the digital generation. Furthermore, this would generally be helpful for everyday people to keep track of the changes that matter.
InShort: Personalized Bill Recommendations
InShort is a mobile application designed to help users discover and understand legislative bills that are relevant to their personal interests and location. Using a powerful AI backend, the app delivers personalized bill recommendations and custom-tailored summaries, making complex legislation accessible and engaging.
Features
- Personalized Recommendations: Leverages a vector database (Pinecone) to find bills that semantically match a user's unique profile, including their interests, location, and occupation.
- AI-Generated Summaries: Uses a Large Language Model (Groq) to generate concise, easy-to-understand summaries of bills, personalized to be relevant to the user.
- Dynamic Profile Updates: Seamlessly updates recommendations when a user changes their profile interests.
- SwiftUI Frontend: A modern, reactive iOS application built with SwiftUI and the MVVM pattern.
- FastAPI Backend: A robust and efficient Python backend serving the recommendation engine.
Architecture
The project is a monorepo containing two main components: a SwiftUI frontend and a Python backend.
Frontend (iOS App)
- Language: Swift
- UI Framework: SwiftUI
- Architecture: Model-View-ViewModel (MVVM)
- Views: SwiftUI views define the UI and bind to ViewModel properties.
- ViewModels: Contain the presentation logic and state for the views.
- Models: Represent the data structures of the app (e.g.,
Bill,UserProfile). - Services: Handle networking (
BillService,UserService) and other shared logic (NotificationService).
- Data Persistence:
UserDefaultsis used to persist the user's profile locally. - Concurrency:
Combineandasync/awaitare used for managing asynchronous operations and state updates.
Backend (Python Server)
- Framework: FastAPI
- Database: Pinecone (Vector Database for semantic search)
- AI Services:
- OpenAI: Used to generate vector embeddings for text data.
- Groq: Used to generate personalized bill summaries with a fast LLM.
- Core Logic: The
BillRecommenderclass inRAG/encapsulates the logic for querying the vector database and formatting results.
Getting Started
Prerequisites
- macOS with Xcode installed.
- Python 3.8+
pipfor Python package management.
1. Backend Setup
First, set up and run the Python server.
-
Navigate to the Backend Directory:
cd InShort -
Create an Environment File: Create a file named
.envin theInShort/directory and add your API keys:PINECONE_API_KEY="YOUR_PINECONE_KEY" OPENAI_API_KEY="YOUR_OPENAI_KEY" GROQ_API_KEY="YOUR_GROQ_KEY" -
Install Dependencies:
pip install -r requirements.txt -
Populate the Database: Run the upsert script to populate your Pinecone index with bill data. Make sure your Pinecone index is configured for 384 dimensions to match the
text-embedding-3-smallmodel.python3 RAG/pcupsert.py -
Run the Server:
uvicorn api:app --reloadThe server will be running at
http://127.0.0.1:8000.
2. Frontend Setup
With the backend running, you can now launch the iOS application.
-
Navigate to the Frontend Project:
cd ../InShortFrontEnd -
Open in Xcode: Open the
InShort.xcodeprojfile in Xcode.open InShort.xcodeproj -
Build and Run: Select an iOS Simulator (e.g., iPhone 15 Pro) or a physical device and press the "Run" button (or
Cmd+R). The app will launch and connect to your local backend.
Project Structure
.
├── InShort/ # Python Backend
│ ├── api.py # FastAPI application endpoints
│ ├── requirements.txt # Python dependencies
│ ├── .env.example # Example environment file
│ └── RAG/
│ ├── billRecommender.py # Core recommendation logic
│ └── pcupsert.py # Script to populate Pinecone
│
└── InShortFrontEnd/ # iOS Frontend
└── InShort/
├── InShort.xcodeproj # Xcode Project
└── InShort/
├── Models/ # Data models (Bill, UserProfile)
├── ViewModels/ # ViewModel layer (NewsViewModel, etc.)
├── Views/ # SwiftUI views
└── Services/ # Networking and data services
Prerequisites
-
Congress.gov API Key: Get a free API key from Congress.gov API
- Visit https://api.congress.gov/
- Sign up for a free account
- Generate your API key
- Already there in google docs file
-
Groq API Key: Get an API key from Groq
- Visit https://console.groq.com/
- Sign up for an account
- Generate your API key
- Already there in google docs file
-
Python Dependencies: Install the required packages
pip install -r requirements.txt
Project Structure
full_bill_scraper.py- Scrapes comprehensive bill data from Congress.govinshort_summarizer.py- Generates personalized AI summaries using Groqinshort_bills.json- Bill data (generated by scraper)requirements.txt- Python dependenciesREADME.md- This file
Quick Start
Step 1: Set up API Keys
Set your API keys as environment variables:
# Set Congress.gov API key
export CONGRESS_API_KEY="your_congress_api_key_here"
# Set Groq API key
export GROQ_API_KEY="your_groq_api_key_here"
Step 2: Scrape Bill Data
Run the bill scraper to collect comprehensive bill data:
python3 full_bill_scraper.py
This will:
- Fetch the most recent 100 bills from Congress.gov
- Collect full details including sponsors, actions, amendments, text, and more
- Save the data to
inshort_bills.json
Step 3: Generate AI Summaries
Run the AI summarizer to create personalized summaries:
python3 inshort_summarizer.py
This will:
- Load the bill data from
inshort_bills.json - Generate personalized summaries for different user profiles
- Show how the same bill affects different users differently
Detailed Usage
Bill Scraper Options
The full_bill_scraper.py script collects comprehensive bill data:
# Basic usage (collects 100 bills)
python3 full_bill_scraper.py
# The script automatically:
# - Fetches bills from the 119th Congress
# - Collects full details for each bill
# - Saves data to inshort_bills.json
AI Summarizer Features
The inshort_summarizer.py script generates personalized summaries for:
- Sarah (25yo, Texas, recent graduate) - Focus on student loans, job market, housing
- Mike (45yo, California, small business owner) - Focus on business regulations, taxes, healthcare
- Lisa (62yo, Florida, retired teacher) - Focus on Medicare, Social Security, education
- David (35yo, New York, tech worker) - Focus on tech regulations, privacy, immigration
Each summary is tailored to show how the bill specifically impacts that user's situation.
Example Output
Bill Scraper Output
Fetching bills 0 to 10...
Getting full details for HR1234 (119th Congress)...
Title: Homebuyers Privacy Protection Act...
✓ Successfully collected full details (1/100)
Total bills with full details collected: 100
Saved 100 bills with full details to inshort_bills.json
AI Summarizer Output
📱 Sarah (25yo, Texas, recent graduate)
--------------------------------------------------
📋 Bill 1: Homebuyers Privacy Protection Act
💡 This bill directly impacts your ability to buy a home! It protects your personal
financial information when applying for mortgages, preventing lenders from sharing
your sensitive data without permission. As a recent graduate looking to buy your
first home, this gives you more control over your financial privacy and could
help you avoid predatory lending practices.
📋 Bill 2: Student Loan Forgiveness Act
💡 Great news for your student debt! This bill expands loan forgiveness programs
for recent graduates working in public service or low-income areas. You could
qualify for partial or full forgiveness of your student loans if you work in
education, healthcare, or government for 10 years.
Configuration
Environment Variables
Create a .env file or set environment variables:
# Congress.gov API
CONGRESS_API_KEY=your_congress_api_key
# Groq API
GROQ_API_KEY=your_groq_api_key
Customizing User Profiles
Edit the user profiles in inshort_summarizer.py to match your target audience:
USER_PROFILES = [
{
"name": "Your Custom Profile",
"age": 30,
"location": "Your State",
"occupation": "Your Job",
"interests": ["relevant", "topics", "here"]
}
]
API Rate Limits
- Congress.gov: 1,000 requests per hour (free tier)
- Groq: Varies by plan, typically 100+ requests per minute
The scripts include rate limiting to stay within these limits.
Troubleshooting
Common Issues
- Invalid API Keys: Make sure your API keys are correct and active
- Rate Limit Exceeded: Wait before making more requests
- Python Command Not Found: Use
python3instead ofpython - Environment Variable Not Set: Export your API keys in the terminal
Error Messages
Invalid API Key: Check your API key is correctRate Limit Exceeded: Wait before retryingFile Not Found: Make sureinshort_bills.jsonexists
Data Privacy
- API keys are stored as environment variables (not in code)
- Bill data is public information from Congress.gov
- User profiles are fictional examples for demonstration
Legal Notice
This tool is for educational and research purposes. Please respect the Congress.gov and Groq API terms of service and rate limits. The bill data is provided by the United States Congress and is in the public domain.
RAG System and Bill Recommender
InShort now includes a RAG (Retrieval-Augmented Generation) system that uses Pinecone for vector storage and Groq for generating summaries.
Prerequisites for RAG System
-
Pinecone API Key: Get a free API key from Pinecone
- Visit https://www.pinecone.io/
- Sign up for a free account
- Generate your API key
-
OpenAI API Key: For generating embeddings
- Visit https://platform.openai.com/
- Generate your API key
Set your additional API keys:
# Set Pinecone API key
export PINECONE_API_KEY="your_pinecone_api_key_here"
# Set OpenAI API key (for embeddings)
export OPENAI_API_KEY="your_openai_api_key_here"
Step 4: Store Bills in Vector Database
First, update the bills in Pinecone with summaries:
python3 upsert_bills.py
This will:
- Read the bill data from
inshort_bills.json - Extract summaries from the bill data
- Generate embeddings for each bill
- Store everything in Pinecone with metadata including summaries
Step 5: Test Bill Recommender
Test the bill recommender with Groq integration:
python3 test_bill_recommender.py
Or run the recommender directly:
python3 RAG/billRecommender.py
Bill Recommender Features
The updated BillRecommender class provides:
- Vector Search: Uses embeddings to find relevant bills based on user interests
- Groq Integration: Automatically generates summaries using Groq when not available in metadata
- Personalized Recommendations: Returns bills ranked by relevance to user interests
- Comprehensive Metadata: Includes bill title, sponsor, congress, and summary
Example RAG Output
Based on your interests, we recommend the following bills:
#1 - HR1234 (Score: 0.856)
📋 Title: Student Loan Forgiveness Act
👤 Sponsor: Sponsored by John Smith
🏛️ Congress: 119
📖 Summary: This bill expands student loan forgiveness programs for graduates working in public service. It could save you thousands of dollars on your student debt if you work in education, healthcare, or government for 10 years. This affects you.
--------------------------------------------------
RAG System Architecture
- Vector Storage: Pinecone stores bill embeddings and metadata
- Embedding Generation: OpenAI's text-embedding-3-small model
- Summary Generation: Groq's llama3-8b-8192 model
- Retrieval: Semantic search based on user interests
- Generation: AI-generated summaries when not available in metadata
Customizing the RAG System
You can modify the BillRecommender class to:
- Change Search Parameters: Adjust
top_kandmin_scorethresholds - Customize Summaries: Modify the Groq prompt for different summary styles
- Add User Profiles: Integrate with the personalized summarizer
- Filter Results: Add additional filtering based on bill status, date, etc.
InShort Backend
This is the backend server for the InShort app, which provides API endpoints for the iOS app to communicate with.
Setup and Running
-
Install the required dependencies:
pip install -r requirements.txt -
Create a
.envfile with your API keys (seeexample.envfor reference). -
Run the FastAPI server:
uvicorn api:app --reload --host 0.0.0.0 --port 8000This will start the server on
http://localhost:8000.
API Endpoints
/chat/: Chat with the bill agent/recommendations/: Get bill recommendations based on user profile/bills/: Get all bills/bills/details/{bill_id}: Get details for a specific bill/bills/like/{bill_id}: Like a bill/bills/dislike/{bill_id}: Dislike a bill/bills/subscribe/{bill_id}: Subscribe to a bill/bills/unsubscribe/{bill_id}: Unsubscribe from a bill
Troubleshooting Swift-Python Communication
If you're experiencing issues with the Swift app communicating with the Python backend:
-
Make sure the backend server is running on the correct port (default: 8000).
-
Check that the Swift app is using the correct API URL:
- For local development:
http://localhost:8000 - For production:
https://test.rudolfmetro.it
- For local development:
-
Ensure the request format matches what the API expects:
- The chat endpoint expects a JSON object with
user_input,session_id, anduser_profilefields. - The
user_profileshould include fields likename,age,gender,location,interests, etc.
- The chat endpoint expects a JSON object with
-
Check the console logs in Xcode for detailed error messages.
-
If using a simulator, make sure it can access localhost (this should work by default).
-
If using a physical device on the same network as the server, use the computer's local IP address instead of localhost.
Chatbot Implementation
The chatbot functionality is implemented using LangGraph and LangChain. The main components are:
inShort_agent.py: Contains the agent graph definition and logic for processing user input.api.py: Contains the FastAPI endpoints, including the/chat/endpoint that interfaces with the agent.fetch_bills.py: Contains tools for fetching bill information that the agent can use.
The agent uses a system message that includes the user's profile to personalize responses about bills and legislation.
Analysis
View
Metric
- 8
- 7
- 7
- 3
Figures cover GitHub contributors during the hackathon window. A co-authored commit counts in full for each author, so per-member totals add up to more than the whole-team figures.
Technology
- FastAPIIn code
- Hugging FaceIn code
- LangChainIn code
- OpenAIIn code
- PythonIn code
- PyTorchIn code
- PostgreSQLClaimed
- SwiftClaimed
- Tailwind CSSClaimed
- TypeScriptClaimed
- VercelClaimed
6 of 11 appear in the indexed code. 5 claimed on Devpost could not be matched to code, which may simply mean the tool leaves no trace in the repository.
AI coding agents
No AI coding agent signals were found in this repository.
Detected from committed agent config files and commit authorship. Absence of a signal is not proof an agent was unused.
Codebase size
Source size
121 KB
Source files
14
Counts recognized source files only; vendored directories, binaries and lockfiles are excluded, so this is smaller than the repository on disk.
Repository
siddharthhtyagi/InShort
19 files · 4.3 MB · @ 8ed82a6
Structure
Application logic
15 files · 79%Domain rules, services and shared utilities.
Supporting
Layers are inferred from where files sit in the tree, not from reading the code. A project that names its directories unconventionally will read oddly here — open the file browser to check anything the diagram implies.
Languages
- Python86%
- Markdown13%
- Shell0%
Share of indexed source by file size. Binary and vendored files are excluded.
Dependencies
requirements.txt
pypi · 74- annotated-types
- anyio
- certifi
- charset-normalizer
- click
- distro
- fastapi
- filelock
- fsspec
- groq
- h11
- hf-xet
- httpcore
- httpx
- huggingface-hub
- idna
- Jinja2
- jiter
- +56 more
Declared in the repository’s manifests at the indexed commit. A declared package is not proof it is used, and runtime dependencies are listed first.
This project’s features have not been analysed yet.
Export this project's context (description, README, evidence, key source files) to chat with an AI agent elsewhere.