<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: khanjan jha</title>
    <description>The latest articles on DEV Community by khanjan jha (@khanjan_jha_612c168d7d77c).</description>
    <link>https://dev.to/khanjan_jha_612c168d7d77c</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3602264%2F32bd4b26-a856-4905-8159-4418d1088ccc.png</url>
      <title>DEV Community: khanjan jha</title>
      <link>https://dev.to/khanjan_jha_612c168d7d77c</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/khanjan_jha_612c168d7d77c"/>
    <language>en</language>
    <item>
      <title>Three Ways to Upload Files: What I Learned While Building My Backend</title>
      <dc:creator>khanjan jha</dc:creator>
      <pubDate>Tue, 18 Nov 2025 15:55:27 +0000</pubDate>
      <link>https://dev.to/khanjan_jha_612c168d7d77c/three-ways-to-upload-files-what-i-learned-while-building-my-backend-17o3</link>
      <guid>https://dev.to/khanjan_jha_612c168d7d77c/three-ways-to-upload-files-what-i-learned-while-building-my-backend-17o3</guid>
      <description>&lt;p&gt;As i was learning more about the backend tech. I got curious upon some thing HOW EXCTLY ARE WE UPLOADING THE FILE FROM FRONTEND TO BACKEND. Then i went on to see some ways to implement it as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Upload the file directly into the database (ALTHOUGH NOT AN IDEAL WAY).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Frontend → Backend → Third-Party Storage&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;means frontend will call the api and backend is still receiving it but instead of storing the file directly into the database it stores it in a service provider in my case IMAGE KIT. Implementation is as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;USER CALLS THE API&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmmzsol4zu7d75l3mvwa1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmmzsol4zu7d75l3mvwa1.png" alt=" " width="597" height="706"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;_BACKEND HANDLE IT LIKE THIS _&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqxqnzqr6ao2x2tx20ola.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqxqnzqr6ao2x2tx20ola.png" alt=" " width="603" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fer48i793fkgo0vukfrbz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fer48i793fkgo0vukfrbz.png" alt=" " width="546" height="488"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;so then i thought nice this should be the optimal way to handle upload files in backend but no there are some drawback of this also:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;backend still acts as the middleman that receives the file. So server load doesn’t actually reduce.&lt;br&gt;
Since your backend handles every file, scaling becomes hard. like bigger file means bigger memory usage.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;so then i got to know about a new method which is &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Frontend → Direct Upload via Presigned URL&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this method, the frontend doesn’t send the file to the backend at all.&lt;br&gt;
Instead, the backend only generates a presigned URL (a temporary, secure upload link) and sends that URL back to the frontend.&lt;/p&gt;

&lt;p&gt;The frontend then uploads the file directly to the storage provider using that presigned URL.&lt;br&gt;
Once the upload is successful, the storage provider returns the final file URL, and that URL is what we store in our backend/database. (In my case i used SUPABASE as a service provider).&lt;/p&gt;

&lt;p&gt;although the implmentation of this took me a while to understand it implementaion. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For the first step we have a create a new route for the presigned URL generation. like this &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-then &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqrmxz85r00a54ef2103z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqrmxz85r00a54ef2103z.png" alt=" " width="428" height="140"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;the work of this url is to just create a presigned url when called from backend.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;then from the frontend it will be called like this.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdjldcm6ov466gbq2bqt7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdjldcm6ov466gbq2bqt7.png" alt=" " width="697" height="907"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;so for the function of this to call the url from the backend for the presigned URL then upload the file into that presigned URL then store that path into the backend.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;then the most painfull part for me was to create the backend of it (although it looks easy but it took me a while to figure it out).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fynx96tqeuhlbsfbsmcw5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fynx96tqeuhlbsfbsmcw5.png" alt=" " width="773" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;this function helped me generate the presigned url &lt;/p&gt;

&lt;p&gt;-then for the service creation part. It goes like this &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqskli4iw8vp8ks27jtqi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqskli4iw8vp8ks27jtqi.png" alt=" " width="627" height="747"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;oh one more thing the url that is stored in the database is not accesible we have to create a seperate function for it to get the publicUrl that will be used in the frontend.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffrs9pdbcjdx77uio1vsh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffrs9pdbcjdx77uio1vsh.png" alt=" " width="623" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;so for me at this point i got exhausted and stopped my thinking there&lt;/p&gt;

&lt;p&gt;but let me share the advantage of this loooong implementation:&lt;br&gt;
. Zero Load on Backend for File Uploads as backend is just used to generate the presigned url&lt;br&gt;
. Much Faster Uploads time that will reduce the upload time &lt;br&gt;
. And most of all it is scalable.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When u create a bucket in supabase make sure to make it public other wise the generated public url will just show BUCKET NOT FOUND (it is silly but it took me a while to figure it out).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;so it just didn't end there, there are other ways also but its on me that i felt a little overwhelmed. Althought the scalablity and efficiency of this  will be checked when i apply this in real world product. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Anyways if u find any wrong in this please correct me any constructive comment will be highly appreciated&lt;/strong&gt;. &lt;/p&gt;

</description>
      <category>backend</category>
      <category>node</category>
      <category>architecture</category>
      <category>database</category>
    </item>
    <item>
      <title>Inside My 3D Car Configurator: Architecture, Challenges, and Lessons Learned</title>
      <dc:creator>khanjan jha</dc:creator>
      <pubDate>Sat, 08 Nov 2025 09:57:05 +0000</pubDate>
      <link>https://dev.to/khanjan_jha_612c168d7d77c/inside-my-3d-car-configurator-architecture-challenges-and-lessons-learned-4imf</link>
      <guid>https://dev.to/khanjan_jha_612c168d7d77c/inside-my-3d-car-configurator-architecture-challenges-and-lessons-learned-4imf</guid>
      <description>&lt;p&gt;So this is the very first time i am writing a blog so please don't mind my mistakes. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Part 1: Models&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For the models i have downloaded them from SKETCHFAB (&lt;a href="https://sketchfab.com/" rel="noopener noreferrer"&gt;https://sketchfab.com/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;As for my project i have downloaded 4 models from there&lt;/p&gt;

&lt;p&gt;&lt;em&gt;LESSON&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;For the react project download the model in gltf or glb format.&lt;/li&gt;
&lt;li&gt;As for the size look out for the triangle counts larger the count more time it will take be rendered on the screen&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;PART 2: Using models in React&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As for using the model in your react project u can directly load them through the useGLTF provided by @react-three/drei. This hook will help u load the model in ur browser.&lt;/p&gt;

&lt;p&gt;Now for the custom modification for the project i converted the 3d model file into JSX component by GLTF to JSX. And then use that JSX component to make the changes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhut4x0w2op4q7jrepzx0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhut4x0w2op4q7jrepzx0.png" alt=" " width="227" height="157"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9o1kxgq65y659dwcjncx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9o1kxgq65y659dwcjncx.png" alt=" " width="222" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;LESSON&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Its not the best practice to do it.(but i didn't think of any other thing at that time).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;PART 3: Optimizing the models&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As i have mention earlier the greater the models complexity is the greater the triangle count will be and the greater the count the bigger of the size it will have and to load it for first it is already a very heavy practice and by having a heavy model make things worse.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;LESSON&lt;/em&gt;&lt;br&gt;
As for my lesson i searched quite some ways to optimize it and the things that i found out was these:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;npm install -g @gltf-transform/cli&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;gltf-transform compress your-file.glb your-file-new-name.glb --draco&lt;/code&gt; &lt;br&gt;
this draco command will compress your gltf/glb file quite a bit.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;gltf-transform prune your-file.glb your-file-new-name.glb&lt;/code&gt;&lt;br&gt;
this command will delete the Unused textures, materials, meshes, nodes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Though i tried it and it does compress it a lot but beware while compressing the texture it can bring errors.( It did for me)&lt;/p&gt;

&lt;p&gt;While also i compressed the big models from 10mb to 2.4mb. (so give them a go).&lt;/p&gt;

&lt;p&gt;*AND IF U DONT WANNA DO THIS THEN LEARN BLENDER.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PART 4: Handling the States for the model&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Well for simple loading the models is quite simple by just creating a single state and alter the model based on the click at first i also did so but that was not good because later on i have add those custom accessories, scene alteration, color changes and paint type changes and so on. so for that i could have handles it by creating many states for it, but it was not a good approach as i searched around a bit because as the modification grows creating many different states will make the project complex unnecessarily.&lt;/p&gt;

&lt;p&gt;like this: &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3gvgtzf5kc0nf2aaugeg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3gvgtzf5kc0nf2aaugeg.png" alt=" " width="491" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then i stumble upon "useReducer" that is used for complex state handling (and also a good opportunity to try my hands on it).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;LESSON&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;As the project grow depending on useState can create a clutter so look for better state management.(i used useReducer).&lt;/li&gt;
&lt;li&gt;Too much props drilling is also bad as the props changes it load the whole components connected to it weather needed or not.
****
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxikjiaahjtmg091xafcd.png" alt=" " width="622" height="926"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;with this setup i can pass around many states in different files and use it for the customization. like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0hfh4fjynpoipjw5g77u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0hfh4fjynpoipjw5g77u.png" alt=" " width="511" height="175"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Though, I am still doing props drilling its a bad approach to do it cuz as the project grows this can be hectic but for the current scale of my project it was working. (so i didn't think much)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;IN SHORT&lt;/em&gt;&lt;br&gt;
Switching to useReducer made my state handling much cleaner, scalable, and future-proof as my configurator’s complexity increased.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PART 5: Preloading the models&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now as for the last part about preloading the models so let me explain what it is and what is my thinking behind it. So as for this project while a single model load at a time i think why not pre load the remaining model behind the scene while the user is on the first model i tried to preload the remaining model behind the scene such that it will decrease the loading period.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0mjv6p06yvdk4dfpubwo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0mjv6p06yvdk4dfpubwo.png" alt=" " width="736" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;useGtlf provide a prebuild function names as preload that help loads the model priorly behind the scene. And called it in my main file.&lt;/p&gt;

&lt;p&gt;Sooo as for now this mark the end of my blog post about the project. I know there still many amateur practices that i have done but feel free to help me correct it any constructive comments or ideas will be highly appreciated. &lt;/p&gt;

&lt;p&gt;Thanks for your attention&lt;br&gt;
GITHUB Link: (&lt;a href="https://github.com/jkhanjan/lambo.git)" rel="noopener noreferrer"&gt;https://github.com/jkhanjan/lambo.git)&lt;/a&gt;)&lt;br&gt;
Live Link: (&lt;a href="https://carsimulator.vercel.app/" rel="noopener noreferrer"&gt;https://carsimulator.vercel.app/&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>react</category>
      <category>glsl</category>
      <category>webdev</category>
      <category>ui</category>
    </item>
  </channel>
</rss>
