<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ireshan Ananda on Medium]]></title>
        <description><![CDATA[Stories by Ireshan Ananda on Medium]]></description>
        <link>https://medium.com/@ireshanananda?source=rss-463f0c9cb56d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*lMp3DHRDLqz5jG81</url>
            <title>Stories by Ireshan Ananda on Medium</title>
            <link>https://medium.com/@ireshanananda?source=rss-463f0c9cb56d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 03:49:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ireshanananda/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building an Admin Panel to Manage Users and Products in a Scalable E-Commerce Platform]]></title>
            <link>https://medium.com/@ireshanananda/building-an-admin-panel-to-manage-users-and-products-in-a-scalable-e-commerce-platform-6ebda1212a47?source=rss-463f0c9cb56d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ebda1212a47</guid>
            <category><![CDATA[role-based-access-control]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ecommerce]]></category>
            <dc:creator><![CDATA[Ireshan Ananda]]></dc:creator>
            <pubDate>Thu, 15 May 2025 12:19:53 GMT</pubDate>
            <atom:updated>2025-05-15T12:19:53.830Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In any serious e-commerce platform, an admin panel is more than just a feature — it’s a necessity. For GreenCart LK, the admin panel acts as the control center, empowering platform administrators to manage user accounts, verify eco-friendly product listings, and monitor the system’s health. This article explains how we built a secure and functional admin dashboard using <strong>React</strong> for the frontend and <strong>.NET Core</strong> for the backend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*auv7t8xdZ2i0sFAIQ6b41w.png" /></figure><h3>The Challenge: Centralized Control with Role-Based Access</h3><p>Admins need the ability to:</p><ul><li>View and manage all users (buyers, sellers)</li><li>Moderate or remove products listed on the platform</li><li>Access usage statistics or logs</li><li>Restrict access to only authorized personnel</li></ul><p>Our solution had to be secure, scalable, and simple to use.</p><h3>Frontend: Structuring the Admin Panel in React</h3><p>We created a dedicated /admin route in the app, protected by role-based routing.</p><pre>&lt;Route<br>  path=&quot;/admin&quot;<br>  element={<br>    &lt;ProtectedRoute allowedRoles={[&quot;Admin&quot;]} userRole={currentUserRole}&gt;<br>      &lt;AdminDashboard /&gt;<br>    &lt;/ProtectedRoute&gt;<br>  }<br>/&gt;</pre><p>Inside AdminDashboard, we organized tabs or cards for:</p><ul><li>✅ User Management</li><li>📦 Product Management</li></ul><p>Each section fetched and rendered backend data in a responsive table with basic actions.</p><pre>useEffect(() =&gt; {<br>  axios.get(&quot;/api/admin/users&quot;).then((res) =&gt; setUsers(res.data));<br>}, []);</pre><h3>Backend: Securing Admin APIs in .NET Core</h3><p>We created admin-only API endpoints with [Authorize(Policy = &quot;RequireAdminRole&quot;)] to restrict access.</p><pre>[Authorize(Policy = &quot;RequireAdminRole&quot;)]<br>[HttpGet(&quot;/api/admin/users&quot;)]<br>public IActionResult GetAllUsers()<br>{<br>    var users = _context.Users.ToList();<br>    return Ok(users);<br>}</pre><p>Admin actions (like delete or block) were implemented as PUT/DELETE endpoints:</p><pre>[HttpDelete(&quot;/api/admin/products/{id}&quot;)]<br>public IActionResult DeleteProduct(int id)<br>{<br>    var product = _context.Products.Find(id);<br>    if (product == null) return NotFound();<br><br>    _context.Products.Remove(product);<br>    _context.SaveChanges();<br>    return NoContent();<br>}</pre><h3>Designing the UI for Efficiency</h3><p>We focused on a minimal but functional interface:</p><ul><li>Table view with pagination</li><li>Dropdown filters (by user role, product category)</li><li>Buttons for quick actions (delete, approve, block)</li></ul><p>Example table structure in React:</p><pre>&lt;table&gt;<br>  &lt;thead&gt;<br>    &lt;tr&gt;<br>      &lt;th&gt;User&lt;/th&gt;&lt;th&gt;Role&lt;/th&gt;&lt;th&gt;Status&lt;/th&gt;&lt;th&gt;Actions&lt;/th&gt;<br>    &lt;/tr&gt;<br>  &lt;/thead&gt;<br>  &lt;tbody&gt;<br>    {users.map(user =&gt; (<br>      &lt;tr key={user.id}&gt;<br>        &lt;td&gt;{user.name}&lt;/td&gt;<br>        &lt;td&gt;{user.role}&lt;/td&gt;<br>        &lt;td&gt;{user.isBlocked ? &quot;Blocked&quot; : &quot;Active&quot;}&lt;/td&gt;<br>        &lt;td&gt;<br>          &lt;button onClick={() =&gt; handleBlock(user.id)}&gt;Block&lt;/button&gt;<br>        &lt;/td&gt;<br>      &lt;/tr&gt;<br>    ))}<br>  &lt;/tbody&gt;<br>&lt;/table&gt;</pre><h3>Tips for Real-World Admin Panels</h3><ul><li>✅ Add confirmation dialogs before destructive actions</li><li>✅ Show feedback messages after updates</li><li>✅ Paginate data to avoid long load times</li><li>✅ Audit admin actions (logging is key for security)</li></ul><h3>Conclusion</h3><p>The admin panel is the backbone of platform management for GreenCart LK. With a secure backend, clear frontend logic, and thoughtful UX, we now have the tools to manage users and products efficiently. This setup also lays the foundation for more advanced features like analytics, moderation queues, or eco-data validation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ebda1212a47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing a Shopping Cart System with Quantity Management and Persistence]]></title>
            <link>https://medium.com/@ireshanananda/implementing-a-shopping-cart-system-with-quantity-management-and-persistence-83f4ec7c54c8?source=rss-463f0c9cb56d------2</link>
            <guid isPermaLink="false">https://medium.com/p/83f4ec7c54c8</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[ux-design]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Ireshan Ananda]]></dc:creator>
            <pubDate>Thu, 01 May 2025 14:46:05 GMT</pubDate>
            <atom:updated>2025-05-01T14:51:31.640Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>For any e-commerce platform, a shopping cart is a mission-critical feature. It acts as the central point where users collect, manage, and review items before placing an order. In GreenCart LK — a platform focused on eco-conscious shopping — the cart also plays a role in encouraging sustainable purchasing habits. This article explores how to build a <strong>responsive, persistent, and user-friendly shopping cart</strong> in a React + .NET Core application.</p><h3>The Challenge: Creating a Cart That Works Seamlessly Across Pages</h3><p>The cart must be:</p><ul><li>Easy to update (adding/removing items, changing quantities)</li><li>Persistent across browser refreshes and sessions</li><li>Scalable for future enhancements like promo codes or impact metrics</li></ul><p>Many developers struggle with syncing cart state across components or persisting it across sessions, so let’s break it down step by step.</p><h3>The Solution: Cart State + Local Storage + Dynamic Updates</h3><p>We focused on three core goals:</p><p>1️⃣ Smooth cart management using React state</p><p>2️⃣ Persistent data using localStorage</p><p>3️⃣ Real-time total calculation and item updates</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*GXaE26BSuD48IUcMVvtQZA.png" /></figure><h3>Step 1: Structuring the Cart State in React</h3><p>We used useState (or optionally useContext for global access) to manage cart items.</p><pre>const [cartItems, setCartItems] = useState([]);<br><br>const addToCart = (product) =&gt; {<br>  setCartItems((prev) =&gt; {<br>    const exists = prev.find((item) =&gt; item.id === product.id);<br>    if (exists) {<br>      return prev.map((item) =&gt;<br>        item.id === product.id ? { ...item, quantity: item.quantity + 1 } : item<br>      );<br>    }<br>    return [...prev, { ...product, quantity: 1 }];<br>  });<br>};</pre><p>✅ <strong>Why this works:</strong></p><ul><li>Dynamically adds and updates products</li><li>Keeps quantity in sync if the same product is added twice</li></ul><h3>Step 2: Persisting Cart in localStorage</h3><p>To avoid losing the cart on page refresh, we use localStorage:</p><pre>useEffect(() =&gt; {<br>  const storedCart = localStorage.getItem(&quot;cartItems&quot;);<br>  if (storedCart) setCartItems(JSON.parse(storedCart));<br>}, []);<br><br>useEffect(() =&gt; {<br>  localStorage.setItem(&quot;cartItems&quot;, JSON.stringify(cartItems));<br>}, [cartItems]);</pre><p>✅ <strong>Why this works:</strong></p><ul><li>Restores the cart automatically when the user returns</li><li>Maintains cart even if the page is closed</li></ul><h3>Step 3: Quantity Management + Total Calculation</h3><p>Cart items often need direct quantity adjustments:</p><pre>const updateQuantity = (id, newQty) =&gt; {<br>  setCartItems((prev) =&gt;<br>    prev.map((item) =&gt;<br>      item.id === id ? { ...item, quantity: Math.max(1, newQty) } : item<br>    )<br>  );<br>};<br><br>const removeItem = (id) =&gt; {<br>  setCartItems((prev) =&gt; prev.filter((item) =&gt; item.id !== id));<br>};<br><br>const totalPrice = cartItems.reduce((acc, item) =&gt; acc + item.price * item.quantity, 0);</pre><p>✅ <strong>Why this works:</strong></p><ul><li>Allows real-time updates and item removal</li><li>Shows accurate cart total dynamically</li></ul><h3>Tips for Real-World Use</h3><ul><li>Add basic validation to prevent adding out-of-stock or zero-priced items</li><li>Show a mini-cart in the navbar with a total count</li><li>Separate guest vs. logged-in carts using backend storage when users authenticate</li><li>Optionally add toast messages for user feedback (e.g., “Item removed”)</li></ul><h3>Conclusion</h3><p>Implementing a shopping cart with quantity controls and persistence is a foundational step in any e-commerce platform — especially for projects like <strong>GreenCart LK</strong>, where smooth UX and reusability matter. With simple use of React state and localStorage, we were able to build a reliable, extensible cart that serves as the base for future features like checkout, coupons, and analytics.</p><p>Have you built a custom cart system before? What challenges did you face? Let us know in the comments! 🛒</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83f4ec7c54c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Role-Based Access Control (RBAC) in React and .NET Core APIs]]></title>
            <link>https://medium.com/@ireshanananda/implementing-role-based-access-control-rbac-in-react-and-net-core-apis-4afbd0ffd976?source=rss-463f0c9cb56d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4afbd0ffd976</guid>
            <category><![CDATA[role-based-access-control]]></category>
            <category><![CDATA[jwt-authentication]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <dc:creator><![CDATA[Ireshan Ananda]]></dc:creator>
            <pubDate>Fri, 14 Mar 2025 18:15:37 GMT</pubDate>
            <atom:updated>2025-03-14T18:29:19.597Z</atom:updated>
            <content:encoded><![CDATA[<h3>Implementing Role-Based Access Control (RBAC) in React and .NET Core APIs</h3><h3>Introduction</h3><p>Managing user roles and permissions is a critical aspect of building scalable e-commerce platforms. In GreenCart LK, we needed a system where admins, sellers, and customers have appropriate access based on their roles. This article covers the complete implementation of <strong>Role-Based Access Control (RBAC)</strong> using React on the frontend and .NET Core APIs on the backend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xxZWmGJBpD3t_Fn304-HnQ.png" /></figure><h3>The Challenge: Ensuring Secure &amp; Scalable Role Management</h3><p>An e-commerce platform involves various user roles, each with different permissions:</p><ul><li><strong>Admin:</strong> Manages users, monitors activity, and handles platform-level configurations.</li><li><strong>Seller:</strong> Adds, edits, and deletes their own products.</li><li><strong>Customer:</strong> Browses products, adds them to the cart, and makes purchases.</li></ul><p>Challenges faced:</p><ul><li>Ensuring <strong>secure role validation</strong> on the frontend and backend.</li><li>Preventing unauthorized users from accessing restricted routes.</li><li>Managing roles dynamically from the database.</li></ul><h3>The Solution: Integrating RBAC with React &amp; .NET Core API</h3><p>Our approach involves two key parts:<br> 1️⃣ <strong>Implementing RBAC in the React frontend.</strong><br> 2️⃣ <strong>Building a secure .NET Core API with role validation.</strong></p><h3>Step 1: Implementing Role-Based Routing in React (Frontend)</h3><p>We’ll build a protected route mechanism where only authorized users can access certain pages.</p><pre>// ProtectedRoute.jsx<br>import { Navigate } from &quot;react-router-dom&quot;;<br><br>const ProtectedRoute = ({ children, allowedRoles, userRole }) =&gt; {<br>  if (!allowedRoles.includes(userRole)) {<br>    return &lt;Navigate to=&quot;/unauthorized&quot; replace /&gt;;<br>  }<br>  return children;<br>};<br><br>export default ProtectedRoute;</pre><p>Using this component:</p><pre>&lt;Route<br>  path=&quot;/admin&quot;<br>  element={<br>    &lt;ProtectedRoute allowedRoles={[&quot;Admin&quot;]} userRole={currentUserRole}&gt;<br>      &lt;AdminPanel /&gt;<br>    &lt;/ProtectedRoute&gt;<br>  }<br>/&gt;</pre><p>✅ <strong>Why this works:</strong></p><ul><li>Prevents unauthorized access at the routing level.</li><li>Easily integrates with existing routing systems.</li></ul><h3>Step 2: Securing APIs with Role-Based Authorization in .NET Core (Backend)</h3><p>Now, we’ll protect API endpoints by using <strong>policies and attributes</strong> in .NET Core.</p><pre>// Startup.cs (Configuration)<br>services.AddAuthorization(options =&gt;<br>{<br>    options.AddPolicy(&quot;RequireAdminRole&quot;, policy =&gt; policy.RequireRole(&quot;Admin&quot;));<br>    options.AddPolicy(&quot;RequireSellerRole&quot;, policy =&gt; policy.RequireRole(&quot;Seller&quot;));<br>});</pre><p>Protecting an endpoint:</p><pre>[Authorize(Policy = &quot;RequireAdminRole&quot;)]<br>[Route(&quot;api/admin&quot;)]  <br>[ApiController]<br>public class AdminController : ControllerBase<br>{<br>    [HttpGet]<br>    public IActionResult GetAdminData()<br>    {<br>        return Ok(&quot;Welcome Admin&quot;);<br>    }<br>}</pre><p>✅ <strong>Why this works:</strong></p><ul><li>Ensures only authorized users can access specific API routes.</li><li>Simple integration with JWT or session-based authentication.</li></ul><h3>Step 3: Integrating Frontend &amp; Backend</h3><p>To ensure consistent security, we store the user role in the <strong>JWT token</strong>. The frontend checks this token to restrict route access.</p><p>Example API response:</p><pre>{<br>  &quot;token&quot;: &quot;abc123xyz&quot;,<br>  &quot;userRole&quot;: &quot;Admin&quot;<br>}</pre><p>And in React:</p><pre>const currentUserRole = localStorage.getItem(&quot;userRole&quot;);</pre><h3>Conclusion</h3><p>Implementing <strong>Role-Based Access Control (RBAC)</strong> effectively secures routes and APIs, ensuring that users only access what they’re authorized to. This approach can be applied to any application needing permission-based access management.</p><p>Have you implemented RBAC in your projects? Share your experience below! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4afbd0ffd976" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizing Image Upload and Preview for a Scalable E-Commerce Platform]]></title>
            <link>https://medium.com/@ireshanananda/optimizing-image-upload-and-preview-for-a-scalable-e-commerce-platform-f583b7ce553f?source=rss-463f0c9cb56d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f583b7ce553f</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[image-optimization]]></category>
            <dc:creator><![CDATA[Ireshan Ananda]]></dc:creator>
            <pubDate>Thu, 27 Feb 2025 18:50:01 GMT</pubDate>
            <atom:updated>2025-02-27T19:01:51.735Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Handling image uploads is a common but complex challenge in e-commerce platforms. When developing <strong>GreenCart LK</strong>, we needed an efficient way to allow sellers to upload product images while ensuring:<br> ✅ <strong>Real-time preview</strong> before submission.<br> ✅ <strong>Efficient storage and compression</strong> to save bandwidth.<br> ✅ <strong>Smooth user experience</strong> without slowing down the frontend.</p><p>This article explores a scalable approach to <strong>handling image uploads with previews</strong>, <strong>optimizing file sizes</strong>, and <strong>storing them efficiently</strong>, making it useful for any developer facing similar challenges.</p><h3>The Challenge: Real-Time Preview &amp; Optimized Storage</h3><p>E-commerce platforms require high-quality product images, but handling them improperly can cause:</p><ul><li><strong>Slow uploads</strong> due to large file sizes.</li><li><strong>High storage costs</strong> if not compressed.</li><li><strong>Unoptimized previews</strong> that slow down user experience.</li><li><strong>Potential security risks</strong> (e.g., malicious files).</li></ul><p>We needed a solution where sellers could <strong>upload, preview, and store optimized images</strong> without compromising performance.</p><h3>The Solution: Combining FileReader, Image Compression, and Cloud Storage</h3><p>Our approach involved three key steps:<br> 1️⃣ <strong>Real-time preview using the FileReader API.</strong><br> 2️⃣ <strong>Compressing images before upload to optimize performance.</strong><br> 3️⃣ <strong>Uploading to a cloud storage service for scalability.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DdsBLInfhtYuYo3_5wlFOg.png" /></figure><h3>Step 1: Implementing Real-Time Image Preview</h3><p>Before uploading, sellers should see a preview of their selected image. We used the <strong>FileReader API</strong> to display the image instantly.</p><pre>import { useState } from &quot;react&quot;;<br><br>const ImageUploader = () =&gt; {<br>  const [preview, setPreview] = useState(null);<br><br>  const handleImageUpload = (event) =&gt; {<br>    const file = event.target.files[0];<br>    if (file) {<br>      const reader = new FileReader();<br>      reader.onloadend = () =&gt; {<br>        setPreview(reader.result); // Display image preview<br>      };<br>      reader.readAsDataURL(file);<br>    }<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;input type=&quot;file&quot; accept=&quot;image/*&quot; onChange={handleImageUpload} /&gt;<br>      {preview &amp;&amp; &lt;img src={preview} alt=&quot;Preview&quot; style={{ maxWidth: &quot;300px&quot; }} /&gt;}<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default ImageUploader;</pre><p>✅ <strong>Why this works:</strong></p><ul><li>Allows users to <strong>instantly see</strong> their selected image.</li><li>Uses <strong>FileReader</strong>, avoiding unnecessary uploads before confirmation.</li><li>Prevents <strong>wasting bandwidth</strong> by avoiding premature server uploads.</li></ul><h3>Step 2: Compressing Images Before Upload</h3><p>Large image files can slow down uploads and increase storage costs. We integrated <strong>image compression</strong> using browser-image-compression:</p><pre>npm install browser-image-compression</pre><p>Then, we modified our uploader to <strong>compress images before uploading</strong>:</p><pre>import { useState } from &quot;react&quot;;<br>import imageCompression from &quot;browser-image-compression&quot;;<br><br>const ImageUploader = () =&gt; {<br>  const [preview, setPreview] = useState(null);<br>  const [compressedFile, setCompressedFile] = useState(null);<br><br>  const handleImageUpload = async (event) =&gt; {<br>    const file = event.target.files[0];<br>    if (!file) return;<br><br>    // Compression settings<br>    const options = { maxSizeMB: 1, maxWidthOrHeight: 800, useWebWorker: true };<br>    <br>    try {<br>      const compressedFile = await imageCompression(file, options);<br>      setCompressedFile(compressedFile);<br><br>      // Create preview<br>      const reader = new FileReader();<br>      reader.onloadend = () =&gt; setPreview(reader.result);<br>      reader.readAsDataURL(compressedFile);<br>    } catch (error) {<br>      console.error(&quot;Compression error:&quot;, error);<br>    }<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;input type=&quot;file&quot; accept=&quot;image/*&quot; onChange={handleImageUpload} /&gt;<br>      {preview &amp;&amp; &lt;img src={preview} alt=&quot;Preview&quot; style={{ maxWidth: &quot;300px&quot; }} /&gt;}<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default ImageUploader;</pre><p>✅ <strong>Why this works:</strong></p><ul><li>Reduces image size <strong>without losing quality</strong>.</li><li>Faster uploads = <strong>better user experience</strong>.</li><li>Saves storage space on the server.</li></ul><h3>Step 3: Uploading Images to Cloud Storage</h3><p>For scalability, we store images in <strong>Amazon S3 (AWS), Firebase Storage, or Cloudinary</strong>. Here’s an example using <strong>Firebase Storage</strong>:</p><pre>npm install firebase</pre><p>Then, configure Firebase in firebaseConfig.js:</p><pre>import { initializeApp } from &quot;firebase/app&quot;;<br>import { getStorage } from &quot;firebase/storage&quot;;<br><br>const firebaseConfig = {<br>  apiKey: &quot;your-api-key&quot;,<br>  authDomain: &quot;your-app.firebaseapp.com&quot;,<br>  projectId: &quot;your-app-id&quot;,<br>  storageBucket: &quot;your-app.appspot.com&quot;,<br>  messagingSenderId: &quot;your-messaging-id&quot;,<br>  appId: &quot;your-app-id&quot;<br>};<br><br>const app = initializeApp(firebaseConfig);<br>const storage = getStorage(app);<br><br>export { storage };</pre><p>Modify the uploader to store the <strong>compressed file</strong> in Firebase:</p><pre>import { useState } from &quot;react&quot;;<br>import { storage } from &quot;./firebaseConfig&quot;;<br>import { ref, uploadBytes, getDownloadURL } from &quot;firebase/storage&quot;;<br>import imageCompression from &quot;browser-image-compression&quot;;<br><br>const ImageUploader = () =&gt; {<br>  const [preview, setPreview] = useState(null);<br>  const [uploadURL, setUploadURL] = useState(null);<br><br>  const handleImageUpload = async (event) =&gt; {<br>    const file = event.target.files[0];<br>    if (!file) return;<br><br>    // Compress the image<br>    const options = { maxSizeMB: 1, maxWidthOrHeight: 800, useWebWorker: true };<br>    const compressedFile = await imageCompression(file, options);<br><br>    // Create preview<br>    const reader = new FileReader();<br>    reader.onloadend = () =&gt; setPreview(reader.result);<br>    reader.readAsDataURL(compressedFile);<br><br>    // Upload to Firebase Storage<br>    const storageRef = ref(storage, `uploads/${file.name}`);<br>    await uploadBytes(storageRef, compressedFile);<br>    const downloadURL = await getDownloadURL(storageRef);<br><br>    setUploadURL(downloadURL);<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;input type=&quot;file&quot; accept=&quot;image/*&quot; onChange={handleImageUpload} /&gt;<br>      {preview &amp;&amp; &lt;img src={preview} alt=&quot;Preview&quot; style={{ maxWidth: &quot;300px&quot; }} /&gt;}<br>      {uploadURL &amp;&amp; &lt;p&gt;Image uploaded: &lt;a href={uploadURL} target=&quot;_blank&quot; rel=&quot;noopener noreferrer&quot;&gt;View Image&lt;/a&gt;&lt;/p&gt;}<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default ImageUploader;</pre><p>✅ <strong>Why this works:</strong></p><ul><li>Uploads images <strong>directly to Firebase Storage</strong>.</li><li>Returns a <strong>public URL</strong> to use in the database.</li><li><strong>Compressed images</strong> reduce server load and improve speed.</li></ul><h3>Conclusion</h3><p>By combining <strong>real-time preview, compression, and cloud storage</strong>, we optimized the image upload experience for an e-commerce platform.</p><ul><li><strong>Preview before upload</strong> = Better user experience.</li><li><strong>Compressed files</strong> = Faster uploads and storage savings.</li><li><strong>Cloud storage integration</strong> = Scalable and secure image handling.</li></ul><p>This approach is essential for <strong>any web app that handles user-uploaded images</strong>, ensuring <strong>performance, efficiency, and scalability</strong>.</p><p>👉 Have you faced image upload challenges in your projects? Share your experiences! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f583b7ce553f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Importance of Using Microservices for an E-commerce Platform]]></title>
            <link>https://medium.com/@ireshanananda/the-importance-of-using-microservices-for-an-e-commerce-platform-703781b82196?source=rss-463f0c9cb56d------2</link>
            <guid isPermaLink="false">https://medium.com/p/703781b82196</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Ireshan Ananda]]></dc:creator>
            <pubDate>Mon, 17 Feb 2025 18:28:17 GMT</pubDate>
            <atom:updated>2025-02-17T18:28:17.109Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s rapidly evolving digital landscape, e-commerce businesses must be agile, scalable, and resilient to stay competitive. Traditional monolithic architectures often struggle to meet these demands, leading to inefficiencies, slower development cycles, and challenges in scaling. This is where <strong>microservices architecture</strong> comes into play, offering a modern and highly efficient approach to building and maintaining e-commerce platforms.</p><figure><img alt="Diagram Concept: A central E-commerce Platform box Multiple Microservices surrounding it, each handling a specific function, User Authentication, Product Catalog, Order Management, Payment Processing, Recommendation Engine, Shipping &amp; Delivery. Each microservice should be connected to the central e-commerce platform via APIs. A Database layer can be depicted separately, indicating that each microservice can have its own database." src="https://cdn-images-1.medium.com/max/1024/1*t6Vlwbz-7kZ95tL5kBEJ7g.png" /></figure><p><strong>What is Microservices Architecture?</strong></p><p>Microservices architecture is an approach to software development where an application is composed of multiple small, independent services that communicate through APIs. Each microservice is responsible for a specific function, such as product catalog management, user authentication, payment processing, and order fulfillment. Unlike monolithic applications, microservices enable organizations to develop, deploy, and scale different parts of an application independently.</p><p><strong>Key Benefits of Microservices for E-commerce Platforms</strong></p><p><strong>1. Scalability</strong></p><p>E-commerce platforms experience fluctuating traffic, especially during peak seasons like Black Friday and holiday sales. Microservices allow businesses to scale individual services independently, ensuring optimal resource allocation. For instance, the payment processing service can be scaled separately from the product catalog to handle high transaction loads.</p><p><strong>2. Faster Development and Deployment</strong></p><p>With microservices, development teams can work on different services simultaneously, reducing development time. Each service can be developed, tested, and deployed independently, leading to faster feature releases and improvements.</p><p><strong>3. Improved Fault Isolation and Resilience</strong></p><p>In a monolithic system, a failure in one part of the application can bring down the entire system. Microservices enhance fault isolation by ensuring that if one service fails (e.g., the recommendation engine), the rest of the platform (e.g., order processing) continues to function normally.</p><p><strong>4. Enhanced Flexibility and Technology Diversity</strong></p><p>Microservices enable e-commerce platforms to use different technologies for different services. For example, the search service can leverage Elasticsearch, while the payment service might use Node.js with a PostgreSQL database. This flexibility allows businesses to choose the best tools for specific tasks.</p><p><strong>5. Better Performance and User Experience</strong></p><p>By optimizing each service separately, microservices improve overall performance and response times. For instance, caching mechanisms can be applied to frequently accessed services like product listings, ensuring faster load times and an enhanced user experience.</p><p><strong>6. Easier Maintenance and Upgrades</strong></p><p>Microservices make it easier to update and maintain applications without affecting the entire system. Developers can update individual services without causing downtime, ensuring a seamless shopping experience for customers.</p><p><strong>7. Enhanced Security and Compliance</strong></p><p>Security in e-commerce platforms is crucial, especially for handling sensitive customer data. Microservices allow businesses to implement security measures for specific services, such as encrypting payment transactions separately from user authentication.</p><p><strong>Real-World Example: How Amazon Leverages Microservices</strong></p><p>Amazon, one of the largest e-commerce platforms, transitioned from a monolithic architecture to microservices to enhance scalability and performance. By breaking down its platform into thousands of microservices, Amazon improved service availability, reduced downtime, and ensured seamless shopping experiences even during peak demand periods.</p><p><strong>Challenges of Implementing Microservices in E-commerce</strong></p><p>Despite the numerous benefits, transitioning to a microservices architecture comes with challenges:</p><ul><li><strong>Increased Complexity:</strong> Managing multiple services requires robust DevOps practices and orchestration tools like Kubernetes.</li><li><strong>Inter-Service Communication:</strong> Effective API design and message brokering (e.g., using RabbitMQ or Kafka) are essential for seamless communication between services.</li><li><strong>Data Management:</strong> Ensuring data consistency across services requires proper database management strategies, such as event sourcing and distributed transactions.</li></ul><p><strong>Conclusion</strong></p><p>For e-commerce platforms aiming to achieve scalability, agility, and improved customer experience, adopting microservices is a game-changer. While it introduces some complexities, the long-term benefits — faster development, resilience, performance optimization, and security — make it a worthy investment. As e-commerce continues to grow, businesses that embrace microservices will gain a competitive edge in delivering seamless and efficient online shopping experiences.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=703781b82196" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Value of Using Design Tokens in Figma Designs]]></title>
            <link>https://medium.com/@ireshanananda/the-value-of-using-design-tokens-in-figma-designs-f3fbba2bb22b?source=rss-463f0c9cb56d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3fbba2bb22b</guid>
            <category><![CDATA[modern-design-practices]]></category>
            <category><![CDATA[ui-design]]></category>
            <category><![CDATA[figma]]></category>
            <category><![CDATA[ux-design]]></category>
            <category><![CDATA[token-design]]></category>
            <dc:creator><![CDATA[Ireshan Ananda]]></dc:creator>
            <pubDate>Sun, 05 Jan 2025 18:23:27 GMT</pubDate>
            <atom:updated>2025-01-05T18:23:27.516Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*B8fJX1yBJfJUs3ya2FYnHQ.png" /></figure><p>Design tokens are a relatively new concept in the design world, but they have quickly become a fundamental part of creating scalable and consistent design systems. Whether you’re a seasoned designer or just starting out, understanding the value of design tokens can transform how you approach your design projects in Figma.</p><p><strong>What Are Design Tokens?</strong></p><p>Design tokens are the smallest elements of a design system — essentially, they are named entities that store visual design attributes such as colors, typography, spacing, and more. Instead of hardcoding these values directly into your designs, you use tokens to ensure consistency and scalability across all design artifacts.</p><p><strong>Benefits of Using Design Tokens in Figma</strong></p><ul><li><strong>Consistency Across Designs</strong> : Design tokens ensure that all design elements adhere to a consistent style. By defining colors, fonts, and spacing as tokens, you can apply the same look and feel throughout your entire project effortlessly.</li><li><strong>Scalability</strong> : As projects grow, maintaining consistency can become a challenge. Design tokens simplify scaling your design system. Update a token once, and the change propagates across all instances where that token is used, saving time and reducing the risk of inconsistencies.</li><li><strong>Collaboration and Handoff</strong> : Design tokens bridge the gap between designers and developers. By using a common language (tokens), designers can communicate design specifications clearly, ensuring that the final implementation matches the design vision. This streamlined handoff process reduces errors and misunderstandings.</li><li><strong>Ease of Updates</strong> : Change is inevitable in design projects. Whether it’s rebranding or minor tweaks, design tokens make updates painless. Since tokens are centralized, updating a token value automatically reflects those changes wherever the token is used, ensuring that your design remains up-to-date with minimal effort.</li><li><strong>Customization and Theming</strong> : Design tokens are powerful tools for theming. By swapping out token values, you can create different themes for your designs easily. This flexibility is particularly valuable for brands that need to support multiple themes or variations of their product.</li><li><strong>Enhanced Efficiency</strong> : Using design tokens can significantly speed up your design workflow. Rather than manually adjusting styles across multiple elements, you can use tokens to apply and modify styles uniformly. This efficiency allows you to focus more on creativity and less on repetitive tasks.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ya85OuKsThZXmZVfybTOlQ.jpeg" /></figure><p><strong>Implementing Design Tokens in Figma</strong></p><ul><li><strong>Define Your Tokens</strong> : Start by identifying the design attributes you want to turn into tokens (e.g., colors, typography, spacing). Create a naming convention that is intuitive and easy to understand.</li><li><strong>Create a Tokens File</strong> : In Figma, create a dedicated file for your design tokens. This file will serve as the single source of truth for your design system. Use components and styles to store token values.</li><li><strong>Apply Tokens to Your Designs</strong> : Use the tokens from your tokens file across your design projects. Ensure that all elements reference the tokens to maintain consistency.</li><li><strong>Collaborate and Document</strong> : Share your tokens file with your team and document the usage guidelines. This ensures that everyone involved in the project understands how to use and implement design tokens effectively.</li></ul><p><strong>Conclusion</strong></p><p>Design tokens are more than just a trendy buzzword; they are an essential part of modern design systems. By incorporating design tokens into your Figma projects, you can achieve greater consistency, scalability, and efficiency in your designs. Whether you’re collaborating with a team or working solo, the benefits of design tokens make them an invaluable tool for any designer looking to create cohesive and scalable designs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3fbba2bb22b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>