Lessons I learned while creating my first backend
Obstacle #1: how to store images in the database?
Since storing images is a huge part of the innovation of my website, I had to study the topic a lot in order to find the best way. For me, the most optimal scenario would be somehow storing them as text. This way, I learned about Base64, which I ended up using in the final work. However, I had to figure out by myself how some stuff worked: how to convert an image to Base64, how to display a Base64, etc. But, despite it giving me work, I liked the result: my images were super cool.
Obstacle #2: fine tunning Dall-E prompts
My website depends heavily on making Dall-E create accurate representations of the content of a post. However, it's so easy to make Dall-E create cursed images... This way, I integrated with ChatGPT and would ask it to create the best prompt to Dall-E that represented the post. All of this made me anxious because last time I had tried using OpenAI's API it was a mess. However, this time, everything went extremely smoothly. The only drawback is the amount of time it takes to generate an image, for it calls two different APIs, but I was satisfied with the final result.
Obstacle #3: busy work
There were many places where I found myself doing busy work. When creating a post, for instance, I had to add it to every user's main feed. When deleting an user, I had to delete all their posts. When deleting a post, I had to delete every attachment they had with tags. I found myself having to think about every little change that I had to make when adding or removing a resource, and of course I didn't find them all — I had to go back to my implementation several times while doing the frontend. It was frustrating because I had a huge frontend assignment ahead of me and I constantly felt the urge to rearchitect my entire backend. Next time, I plan to centralize more things in a single concept, if it means that some concepts won't be as modular as I envisioned them to be.
Obstacle #4: referencing ids
I found myself torn between accepting ids or, for some resources, names. For instance, when you delete a tag, should you call it by its id or by its name? Although for some places it makes more sense to do ids, I thought it very dirty to make a call with the tag's name to find the id and only then call the removal endpoint. This was something for which I wasn't able to come up with a good fix, and my frontend is proof. I felt terrible creating all this logic in the frontend, and it compromised a lot of my modularity.
In conclusion, the journey of developing my first backend was a rich learning experience, marked by the successful navigation of diverse challenges. These obstacles not only strengthened my technical skills but also honed my problem-solving abilities. As I look ahead to future projects, I am equipped with valuable insights and a deeper understanding of backend development, and hopefully greater abilities to design my architecture and my concepts in a smarter way.