This program uses facts about zipcodes in the United States to deduce a user's possible state location based on the first digit of their zipcode if location access is not available/provided.
This is intended as logical scaffolding to optimize what listings to show in the absence of user location access for a project I work on.
If we know based on the first digit of a user's zipcode where the user cannot be, that means we can render fewer total listings. At the same time, the listings we do render are closer to where the user might be.
Compared to rendering all listings for the entire United States, this approach is way more efficient. The absolute worst case scenario would involve rendering listings for 30 states. That still means the listings for 20 states do not have to be rendered at all. 🙂
Image Source: https://en.wikipedia.org/wiki/ZIP_Code
This is some of the scratch work I did via ExcaliDraw (awesome tool, highly recommend) when I was working through the idea of implementing this repo.
I wanted to account for edge cases, like if the user is on the near the border of two different zipcode groups. I thought a graph would be perfect for this since it will show all the possible scenarios of bordering zipcode groups based on how connected the nodes are.