back to home

Rusty Gas Prices

Gas Price Monitoring & Pattern Analysis System

rustgraphqlreqwestserdetokiodata analysis

I was speaking with a friend about having some kind of app to monitor gas prices throughout the year, but moreso throughout shorter time periods, study their patterns in hopes of analyzing gas prices across locations. And I took matters into my own hands to get my friends their optimum gas stations after reading a reddit thread of how someone programmed their home assistant to monitor gas prices.

Tech Stack

  • Rust programming language for performance and safety
  • Reqwest HTTP Client for API requests
  • GraphQL API with Apollo Server
  • Serde for JSON parsing
  • Tokio for asynchronous runtime
  • GasBuddy API integration

Challenges

  • Handling complex API responses and identifying reliable fuel price data
  • Managing large JSON structures across multiple cities
  • Started with small cities in IL, expanded to support any city in the USA or valid zipcode
  • Built to be compatible with any valid US zipcode
  • Nearly 2GB of storage required for the project data

API Integration

  • Set up GraphQL API using Apollo Server to integrate with GasBuddy API
  • Fetches gas station data based on user searches
  • Created functions to parse payload for better user understanding
  • Built comparison functions for analyzing gas station statistics

Data Analysis

  • Home assistant integration with visual alerts (green for cheap, red for expensive)
  • Pattern detection to forecast future prices
  • Location-based gas station data retrieval
  • Price analysis for cheapest and most expensive stations
  • Fuel type categorization (cash and credit)
  • Trends visualization and insights

Technical Decisions

  • Leveraged Rust for strong type safety and efficient performance in networked applications
  • Used Reqwest for HTTP requests and Serde for JSON handling
  • Defined GasStation schema with fields like name, address, and price
  • Resolvers process search parameters like location or fuel type
  • Streamlined retrieval of precise, filtered gas station information through structured GraphQL queries

Development Process

  • Built using Rust for performance and safety
  • Scraper utilizes the GasBuddy GraphQL API to fetch and process gas price data efficiently
  • Working on converting to a native app due to storage requirements
  • Future plans include enhanced pattern detection and predictive analytics

Core Features

  • Real-time gas price monitoring across US locations
  • Smart pattern detection for price forecasting
  • Location-based retrieval with zipcode support
  • Fuel type comparison (cash vs credit pricing)
  • Home assistant integration with visual alerts
  • Comprehensive data analysis and visualization