Greetings from Taiwan! Iām new around here and super excited to dive into this awesome community.
Iāve recently jumped into learning Elixir and am loving the journey so far. After getting my feet wet with the basics, I figured, why not build something cool? so I started to build a URL shortener using the Phoenix framework.
Iām all about learning by doing, but I know that going solo can sometimes lead me down the rabbit hole. So Iāve decided to open up a topic and invite everyone who happens to have spare time to review my code. I am open to any types of feedbacks. Whether itās a high-five for whatās working or a heads-up on where I can improve, all your thoughts are welcome.
If you feel like dropping some wisdom or just want to chat about the project, you can hit me up here or swing by my GitHub. Every bit of feedback will be greatly appreciated.
I read the readme but not the code yet. Since you use a database, why not just use the auto increment key as the key, ie: you could have shortened URL like https://example.com/url/123 Much of the complexity described in the readme would just disappear.
Hi there! Thanks for pointing that out!
My initial design was aiming to use MongoDB because it could be easier to do horizontal scaling. Given that the uuid generated by Mongo is at least the length of 32, which is too long for my short url. Therefore Iāve decided to create my own unique id using timestamps. I only switched to Postgres because it is the recommended DB of Phoenix and Iām curious Iāve never tried it out.
With that being said, youāre right, I sure can be using incremental IDs from Postgres. But I also think it is a good practice to not rely on DBs mechanism in my design, so my application donāt couple up with the DB.
(Who knows, it might be an over-designš )
BTW, huge thanks for the feedback! I really appreciate it.
There are many tools to choose from when it comes to memory caching, Redis is one of the no brainer that is used by many production services.
You donāt mention them, so if youāre not aware, Elixir has many built in options to handle memory stores that can be used as a cache, ets, GenServer etc. If you are aware, curious why you thought Redis was a āno brainerā
Great document by the way. Gives nice insight into your thought process which seems very thorough!
EDIT: started looking at your code and looks like youāre using ets after all?
Big oops from me!
I was originally planning on using Redis really. No much reasons though, just because I use it in my current job and it is used by a lot of companies.
Anyway, I googled my way through the process of developing the project, and discovered ETS unintentionally. Being a half-hearted man, I quickly decided to try it out without remembering to update my design XD
Thanks for the reminder! I will do some more research til I can explain clearly why to choose ETS, and update the README ASAP!
BTW thanks for the compliment on my documentary. As a non-native speaker, Iām still seeking ways to improve my English especially in writing, so your noticing really means a lot to me
Regarding scaling, you may find this url shortener scaling example handy (still in draft from and completely unfinished from several years ago). It goes over 3 different possible designs. Anyway, Iām not much of a writer, so I never quite finished it. Nor how to build a CDN, a web server, a storage layer, etc.
I was trying to describe my state of indecisiveness and wavering when it comes to picking a tool. Like I tend to change my mind when I see something cool LOL
I thought Iāve seen someone us the term half-hearted , but nevermind it
I thought Iāve seen someone us the term half-hearted
Oh for sure, but in English the phrase means almost the opposite of what it sounds like youāre trying to say. Rather than changing your mind because youāre too excited by everything being āhalf-heartedā, and especially as a general characteristic (āhalf-hearted manā) implies a lack of enthusiasm in general. Think of an employee doing a task they really donāt want to do, or a person on a date with someone they donāt like that much. Curious if thereās a word youāre translating, because thereās not really a good single word or phrase in English for indecisiveness due to too much enthusiasm. Capricious? Fickle? Not quiteā¦ Language is amazing!