Inspiration

We all grocery shop. We all try to save money. But nobody knows if driving to that second store is actually worth the gas. We built CartWise to answer that question with real math.

What it does

CartWise is a grocery list optimizer. You build your shopping list in the app, and it compares prices for every item across multiple nearby stores — different brands, sizes, and per-unit costs. Then it calculates the smartest way to buy everything, factoring in gas cost, driving distance, and store hours.

It generates two plans: the Cheapest Route (lowest total cost including gas) and the Shortest Route (least driving). It compares them and tells you which one is the better financial decision.

How we built it

  • Backend: Python FastAPI with async MongoDB (Motor driver)
  • Frontend: Next.js 16 with TypeScript, Tailwind CSS, and Leaflet.js for maps
  • Database: MongoDB Atlas (cloud) with 100,000 products across 1,000 store locations
  • External API: Kroger Product API with OAuth2 authentication (integrated, pending activation)
  • Algorithm: Custom route optimizer with store pre-filtering, quick-score pruning, and nearest-neighbor routing

We designed a three-collection database: users (shopper profiles with location and vehicle info), stores (1,000 locations from Walmart, Kroger, Target, Costco, Trader Joe's with open hours and visit penalties), and products (100,000 items with realistic pricing based on USDA market data).

The optimization algorithm pre-filters 1,000 stores down to ~15 relevant nearby ones, prunes bad combinations early, and uses greedy nearest-neighbor routing instead of brute-force permutations. This brings response time under 2 seconds.

Challenges we ran into

  • Performance: With 1,000 stores, naive combinations exploded to 20,000+. We optimized with pre-filtering, pruning, and nearest-neighbor routing.
  • Kroger API: We fully integrated OAuth2 authentication but their Certification environment took longer than expected to activate credentials. The system works with seeded data and will switch to live data automatically.
  • Schema evolution: We redesigned our data model twice during the hackathon. MongoDB's flexible schema made this painless.
  • Team coordination: Three people on backend, frontend, and data simultaneously. Git branching and Discord kept us in sync.

Accomplishments that we're proud of

  • 100,000 realistic grocery products with unbiased pricing across 1,000 stores
  • Working optimization algorithm that compares routes in under 2 seconds
  • Full user system with login, profiles, trip tracking, and personalized recommendations
  • Clean three-table database design that scales to any number of stores

What we learned

  • How to design a route optimization algorithm that balances accuracy with speed
  • Async MongoDB operations with Motor for non-blocking database queries
  • The real complexity of grocery pricing — same product, different brand, different size, different store, different price
  • How to coordinate a three-person team on a full-stack project in 24 hours

What's next for CartWise

  • Activate Kroger API for live pricing (code is ready)
  • Add Walmart and Target APIs
  • Price history tracking with sale alerts
  • Mobile app with Flutter (backend API is already mobile-ready)
  • Loyalty card awareness (Kroger Plus, Target Circle)

Built With

Share this project:

Updates