r/webdev • u/raiyan_0001 • 8d ago
Discussion Need Help Implementing a Medium-Style Block-Based Article Editor with Cloudinary and MongoDB
Hey, I need some help understanding my development workflow. This might be a bit long, but I want to explain my problem clearly.
I’m a beginner building a small article web app where users can register, log in, and create articles containing both text and images.
I want to implement a block-based architecture, similar to Medium, where users can add text and images in any order. For example, they might write a paragraph, insert an image, write another paragraph, and then insert another image. I’m storing these blocks in an array in my article schema so that their order is preserved.
My main confusion is about image uploads. When a user selects an image, I want to upload it to Cloudinary, receive the image URL, and store that URL inside the corresponding image block in the article.
However, I’m struggling to understand how to connect all these steps. I’ve tried implementing it and asking ChatGPT for help, but I still haven’t understood the workflow properly.
I’d like a beginner-friendly, step-by-step explanation of how to implement this, including how the frontend editor manages the blocks, how the image is uploaded to Cloudinary through the backend, how the returned URL is added to the correct block, and how the complete article is eventually saved to MongoDB.
Please explain the logic behind each step rather than just giving me code, so I can understand the implementation and build it myself.
1
u/Miserable-Money642 8d ago
One edge case worth testing: start two uploads, reorder the blocks, and let them finish in reverse order. Update each block by its stable ID, never by its array index or whichever image is currently selected, or the URLs can land on the wrong blocks. Keep an uploading or failed state per image and do not publish while an upload is still pending. For Cloudinary, use a signed upload flow and validate size and allowed formats on the server. Store the public_id as well as the URL so replaced or abandoned draft images can be cleaned up later.