3FanYu

3FanYu

Hey everyone!

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.

Cheers,

project:

Showing Posts 1 to 9

derek-zhou

derek-zhou

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.

3FanYu

3FanYu OP

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​:sweat_smile:)

BTW, huge thanks for the feedback! I really appreciate it.

tfwright

tfwright

From your README:

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” :slight_smile:

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? :joy:

3FanYu

3FanYu OP

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 :laughing:

tj0

tj0

Ha, isn’t that the fun part though?

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 personally think the most interesting parts are:

  • Section 3.4.2 - shows the limits of an external system due to memory speeds
  • Section 3.5.2 - on generating a better uuid is useful as it generates a sortable id that is better than a general uuid.

First time sharing anywhere, so if it’s handy, let me know and maybe I’ll clean it up some.

tfwright

tfwright

I can assure you your English is excellent

I think something might be getting lost in translation here though :wink:

3FanYu

3FanYu OP

Awesome! thanks for sharing. I will definitely check it out!

3FanYu

3FanYu OP

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 :rofl:

tfwright

tfwright

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!

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4663 61218 595
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
515 12931 101
New
wmnnd
Hey folks, I wanted to share with you a project I’ve been working on for a while: It’s an Open Source (AGPLv3) newsletter tool. Think Ma...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
sntran
In my third year of college, around 2010, I found Erlang. A few years later, I found Elixir. I liked the ideas at once: many small proces...
New
Ganna
Hi everyone, I have 8 years of production experience with Erlang/OTP and I’m just starting to get to know Elixir. What would you learn f...
New
gtcode
I’ve been tinkering with Lynx (by José) via hold_ledger. I used AI to write the code, a separate specification, the tests, and the Lean p...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews