Last page update

Making of: LOCTALK

About a year ago on a long bus ride, my friend and I brainstormed ideas for our future personal projects. My friend mentioned something about a chat app that would be regionally locked—an app where you could chat with random people near you. Something like Omegle but LOCAL. I was immediately interested.

At that time, I couldn’t even imagine what it would take to actually create something like this. But somehow, I didn’t care. I actually didn’t care even enough to research what apps already did something similar and if the project had any potential for a fanbase. I just wanted to create!

Topology choice

At first, I figured that for an app of this scale, I would need a very powerful main server or to be able to run everything serverless. I had a lot of ideas about using some variation of P2P chains or circle topology for message sending and receiving, but my knowledge of these things was severely limited. Therefore, after discovering that Oracle gives out free servers, the answer was clear.

First steps

The initial idea was to store all the messages in files named appropriately so that each file name would track back to the real world in 100 by 100 meter blocks.

LAT = Latitude LON = Longitude

As seen in the professionally drawn diagram above, the user would get messages from the nearest 9 (blocks ⇒ files) around him and sort the messages by timestamp of the message. The message sent from the user would end up in the (block ⇒ file) where the user is currently standing.

And so I started coding. I decided that the backend would be in Python, as that was the language I was most comfortable with, and I couldn’t imagine learning a new language when this project was already on the bounds of my skill. After setting everything up with HTTP, I arrived at my first problem: the Earth isn’t flat!

After some testing, I figured my naive approach of taking the LAT, LON, dividing them by 360, then multiplying by the Earth’s circumference (40,000,000 m) to get the location of the user in meters wouldnt work!

\[ \text{Position}_{\text{LAT}}\, [\text{m}] = \text{LAT} \times \left( \frac{40\,000\,000}{360^\circ} \right) \]\[ \text{Position}_{\text{LON}}\, [\text{m}] = \text{LON} \times \left( \frac{40\,000\,000}{360^\circ} \right) \]

It would squish my horizontal distance to other blocks to about 60% of what it should have been on the equator, meaning you wouldn’t get the full 100m range horizontally. 🙁

The solution

This was devastating at first, but after some quick napkin math, I figured out a “solution.”

Instead of calculating

\[ \text{Position}_{\text{LON}}\, [\text{m}] = \text{LON} \times \left( \frac{40\,000\,000}{360^\circ} \right) \]

I could just multiply this by cos(LAT) and therefore “unsqueezing” my horizontal distance to other blocks.

\[ \text{Position}_{\text{LON}}\, [\text{m}] = \text{LON} \times \left( \frac{40\,000\,000}{360^\circ} \right) \times \cos(\text{LAT}) \]

Simple on paper and much harder to implement, this solution fixed the squishing problem and my app could finally work!

After all this, I just made a live map where you can see where the current active users are and the messages that they left.

Avalable here

Future of the project

For now, this project is at least in my eyes finished, and I don’t have any further plans for development.

More obout the project here


Comments

5 responses to “Making of: LOCTALK”

  1. FEKTstudent Avatar
    FEKTstudent

    Looks great, but… is it open source?
    Why it needs google services enabled?
    But most importantly… why the hell is this server in China, Hangzhou? That’s sus.

    1. FEKTstudent Avatar
      FEKTstudent

      oh.. it’s not in china, it is oracle cloud, sorry for missinformation.

    2. The mobile app is open source: https://github.com/aizej/LOC-TALK
      The server side is currently not open source. But will be in the future!
      And yea this site and the server side of LOC TALK runs on an oracle instance because its the most cost efficient (free) solution.

  2. FEKTstudent Avatar
    FEKTstudent

    oh wow, so it is open source
    I recommend to put that information somewhere, because people who are interested in these alternative chat apps often care about it the most.
    Also nothing wrong with oracle cloud computing and I even recommend it (paid servers may rise questions how could be project sustainable)
    Btw you can get also for free some subdomain (it is nicer than just using plain IP address). For instance “is-a.dev” looks cool + you can use Let’s encrypt for free tls certificate (that will make your web https).
    Last recommendation: by adding the app to alternative repositories such as IzzyOnDroid or F-Droid can find new people who might be interested in this application.
    Good luck!

    1. Thanks. The idea to put it on non mainstream app-stores should have been obvious to me. I will definitely do that!

Leave a Reply

Your email address will not be published. Required fields are marked *