<?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 Supunnilakshana on Medium]]></title>
        <description><![CDATA[Stories by Supunnilakshana on Medium]]></description>
        <link>https://medium.com/@supunnilakshana1999?source=rss-fa44b358fa50------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*G777fjnmHqBCxkpS</url>
            <title>Stories by Supunnilakshana on Medium</title>
            <link>https://medium.com/@supunnilakshana1999?source=rss-fa44b358fa50------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 03:45:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@supunnilakshana1999/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[The Art of Context Switching: Why We Are Exhausted Before Lunch]]></title>
            <link>https://medium.com/@supunnilakshana1999/the-art-of-context-switching-why-we-are-exhausted-before-lunch-048c153395e5?source=rss-fa44b358fa50------2</link>
            <guid isPermaLink="false">https://medium.com/p/048c153395e5</guid>
            <category><![CDATA[deep-work]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Supunnilakshana]]></dc:creator>
            <pubDate>Sun, 04 Oct 2026 17:53:23 GMT</pubDate>
            <atom:updated>2026-10-04T17:53:23.589Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever log off for the day feeling completely wiped out, only to realize your main project has not moved an inch? You are not losing your edge, and your time management is not broken. You are just getting crushed by context switching. We have all been there. Bouncing between deep architecture work, putting out quick Slack fires, and trying to help the team. But every time we jump between tasks, our brains leave a little piece of themselves behind. If we are tired of our mental battery draining before noon, here is a look at the silent killer of developer productivity and the exact routines we can use to protect our focus.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_0VirZ9Ei1qry44P" /></figure><p>It is 9:00 AM. Your coffee is fresh, your code editor is open, and you are completely in the zone. You are mapping out a complex Azure serverless deployment, writing the Terraform configurations, and tracing exactly how your Azure Managed Identities are going to authenticate across the cloud infrastructure. You are holding a massive, invisible architecture in your mind like a fragile house of cards.</p><p>Then, at 9:15 AM, Slack or Teams or whatever chat app your company uses pings.</p><p>A junior developer on the team is completely blocked. They are tangled in a complex crash issue in the mobile app, and the QA team is waiting on the build. Almost simultaneously, an email slides across the screen from a stakeholder asking for a quick status update.</p><p>Your immediate instinct is the same as every developer. We instantly hit Alt Tab, open the IDE, and start putting out the fire. By 9:45 AM, we have unblocked the developer and replied to the email. We switch back to our Azure architecture. But as we stare at the screen, our minds are entirely blank. We spend the next twenty minutes just trying to remember why we had that specific authentication script open.</p><p>Suddenly, it is 1:00 PM. We feel completely burned out. Our brain is a drained battery, yet when we look at the screen, we realize we have not written a single line of our main infrastructure code.</p><p><strong>The Silent Killer: Attention Residue</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MetE7YAPNXGVgKJg" /></figure><p>That exhaustion we feel at 1 PM is not a time management failure. It happens because the human brain is not a computer processor. It cannot seamlessly swap out threads.</p><p>When we forcefully terminate a deep focus task to jump into a different environment, like moving from declarative cloud infrastructure to a mobile app codebase, our brains do not instantly pivot. A fraction of our cognitive capacity remains stuck on the previous task. This phenomenon is called attention residue. When we switch contexts twenty times a morning, we build up so much residue that our working memory simply runs out of space.</p><p>Mastering context switching is not about switching faster. It is about intentionally closing one mental application before opening the next.</p><p><strong>Creating a Mental “Save State”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fI6Uye7z7I7AsXbz" /></figure><p>Think of the brain like a virtual machine. Before we step away to help a teammate or answer a message, we need to save our state.</p><p>If we get interrupted while writing a database query, we should not just walk away. Keep a plain text scratchpad open on the computer. Take thirty seconds to write a message to our future selves. Write something like this: Tracing the auth flow. The machine token is returning null. Next step is to verify the JWT claims. Then, run a quick local Work In Progress commit in the terminal.</p><p>Our heavy lifting is now safely suspended in cryogenic sleep. We have given our brains permission to completely let go of the problem, knowing we have an exact map to get back into it later.</p><p><strong>The Digital Shield</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uC8mBn6wY76t45uV0LaRIg.png" /></figure><p>To stop external interruptions, we have to put up a Digital Shield. We cannot rely on willpower to ignore a flashing notification badge. When we are stepping into a block of deep work, we need to turn on Do Not Disturb on our operating systems and pause our chat notifications.</p><p>Protecting focus is a team sport. If a teammate has their status set to busy, we need to respect it. Unless production is actively crashing, we should not interrupt them. Defaulting to asynchronous communication and realizing that not every message requires an instant reply gives everyone the breathing room to actually get their work done.</p><p><strong>The Internal “Parking Lot”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rle6cv_z0friuKFi" /></figure><p>Sometimes the worst distractions are not chat notifications. They are our own internal thoughts. We are deep in our code, and suddenly we remember we need to register for a class or reply to an email.</p><p>We should not open our inbox. We should not open a new browser tab.</p><p>Keep a physical notepad on the desk. This is our Parking Lot. The second an unrelated thought pops into our heads, we write it down on the paper, and instantly return our eyes to the code. We have successfully parked the thought. Our brains no longer have to spend energy trying to remember it, and our current focus remains entirely unbroken.</p><p><strong>The “Air Lock” Transition</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*g-Mr035AnM76GwD9" /></figure><p>Senior engineers and technical leads operate on two conflicting timelines. Designing system architecture requires a Maker schedule, which means long blocks of deep focus without interruptions. Code reviews, meetings, and unblocking teammates run on a Manager schedule, which relies on short and frequent interactions. Mixing the two destroys both.</p><p>We need to establish an air lock.</p><p>We cannot walk out of an intense architectural planning session and immediately start fixing a mobile app crash issue. The brain needs a buffer. Before we switch tasks, we should physically push our chairs back. Stand up, look out the window, or get a glass of water for five minutes. Let the previous system fade out of our working memory. When we sit back down, change the environment by swapping the editor theme or moving to a different virtual desktop. Visually signal to the brain that it is time to load a new set of rules.</p><p>We cannot be seamlessly productive across cloud infrastructure, mobile development, backend systems, and monitoring all at the exact same moment. But by intentionally managing our mental state, we can orchestrate the chaos, moving seamlessly between these different zones without ever dropping a single thread.</p><p>I would absolutely love to hear how all of you handle this. Did I miss anything major? Drop a comment below with your own strategies for staying focused, share your ideas, and let us start a thread on how we can all build better boundaries around our deep work.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=048c153395e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How AI Transformed Our PostgreSQL Database Workflows]]></title>
            <link>https://medium.com/@supunnilakshana1999/how-ai-transformed-our-postgresql-database-workflows-477e6719bf9b?source=rss-fa44b358fa50------2</link>
            <guid isPermaLink="false">https://medium.com/p/477e6719bf9b</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[mcp-server]]></category>
            <dc:creator><![CDATA[Supunnilakshana]]></dc:creator>
            <pubDate>Sun, 20 Jul 2025 14:54:02 GMT</pubDate>
            <atom:updated>2025-07-20T14:54:02.964Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1GQq7PfiLj1uu0XjVG_tfw.png" /></figure><h3>A real-world case study of intelligent schema management and API query generation</h3><p>Picture this: It’s 2 AM, your e-commerce platform is down, and a critical database migration is the only thing standing between you and a total outage. Traditionally, this meant waking up your senior engineer, writing manual migrations under pressure, and hoping nothing breaks.</p><p>We thought there had to be a better way — and there was.</p><h3>The Problem That Nearly Broke Us</h3><p>At TechCorp (name changed), our platform’s database had grown into a complex web of interconnected tables, security policies, and API layers. Development velocity slowed to a crawl. Migrations were painful, error-prone, and often required emergency fixes. Frontend teams struggled with constructing PostgREST queries. Something had to change.</p><h3>Enter the AI Database Assistant</h3><p>We built an <strong>AI-powered database assistant</strong> — a Model Context Protocol (MCP) server that works with Claude to deliver:</p><p>✅ <strong>AI-Enhanced Migration Management</strong><br>✅ <strong>Natural Language Query Generation for PostgREST</strong></p><p>The results? A complete shift in how we develop and manage our database. Migrations that once took hours now take seconds. Query development no longer requires deep backend knowledge.</p><h3>How It Works</h3><p>The system combines schema analysis, AI reasoning, and learned conventions to auto-generate:</p><p>Safe, reversible database migrations</p><ul><li><strong>PostgREST-compatible queries from plain English</strong></li><li><strong>Policies and indexes that follow internal standards</strong></li><li><strong>Automatic relationship discovery for optimized queries</strong></li></ul><p>All of this happens without the developer needing to write a single line of SQL manually.</p><h3>Behind the Scenes: Schema Compression &amp; Pattern Learning</h3><p>One challenge we faced was the sheer size and complexity of our schema. To solve this, the assistant uses <strong>intelligent schema compression</strong> powered by Gemini AI — shrinking our schema into a format AI can fully understand.</p><p>It also learns from our existing migrations to follow naming conventions, policy formats, and deployment strategies, ensuring team-wide consistency without anyone lifting a finger.</p><h3>Real Emergency Response</h3><p>During a recent crisis, a missing constraint caused a critical integrity issue. Instead of scrambling through hours of manual debugging, we simply asked the assistant what went wrong. It identified the issue, proposed a fix with rollback procedures, and gave us a safe deployment path — <strong>in minutes</strong>.</p><h3>What We Learned</h3><p><strong>What worked well:</strong></p><ul><li>Natural language interfaces removed friction</li><li>Learned patterns created consistency</li><li>Real-time relationship discovery made query building effortless</li><li>Built-in validation and rollback improved confidence</li></ul><p><strong>What we’re still refining:</strong></p><ul><li>The assistant requires tuning for very large schemas</li><li>Custom conventions benefit from explicit training</li><li>Team adoption improves with gradual rollout</li></ul><h3>Still in Development — Open Source and Evolving</h3><p>This is still an <strong>active development project</strong>. Bugs can happen. Feedback is gold.</p><p>We’re sharing this as an <strong>open-source tool</strong> because we believe developers everywhere can benefit from intelligent schema and API tooling. Whether you’re managing a small app or a complex architecture, this approach scales.</p><h3>Want to Try It?</h3><p>The AI Database Assistant is available as an open-source MCP server. All you need is a Postgres database and a few environment variables. Pair it with Claude, and you’re ready to chat with your database.</p><p>Have you explored AI for your database workflows? Are manual migrations still slowing your team down? Let’s talk in the comments. We’d love to hear how you’re handling database complexity.</p><p>🔗 <strong>Links:</strong></p><ul><li><a href="https://github.com/supunnilakshana/pg-schema-sage"><strong>AI Database Assistant GitHub Repository</strong></a></li><li><a href="https://modelcontextprotocol.io/introduction"><strong>Model Context Protocol Documentation</strong></a></li><li><a href="https://docs.postgrest.org/en/v13/"><strong>PostgREST API Docs</strong></a></li></ul><p><strong>#AI #PostgreSQL #DatabaseManagement #DevOps #Claude #OpenSource #Automation #MachineLearning #DeveloperTools #SoftwareEngineering</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=477e6719bf9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Power of Layered Architecture in a Self-Hosted E-Commerce Next.js Application]]></title>
            <link>https://medium.com/@supunnilakshana1999/the-power-of-layered-architecture-in-a-self-hosted-e-commerce-next-js-application-795d5784f2c2?source=rss-fa44b358fa50------2</link>
            <guid isPermaLink="false">https://medium.com/p/795d5784f2c2</guid>
            <category><![CDATA[layered-architecture]]></category>
            <category><![CDATA[repository-pattern]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[nextjsecommerce]]></category>
            <category><![CDATA[postgresqlprisma]]></category>
            <dc:creator><![CDATA[Supunnilakshana]]></dc:creator>
            <pubDate>Sun, 23 Feb 2025 08:38:15 GMT</pubDate>
            <atom:updated>2025-02-23T08:38:15.817Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*LamKRsTfuITwotNuc95WeQ.png" /></figure><h3>Introduction</h3><p>Imagine you’re launching your own self-hosted e-commerce platform. At first, things are simple — you have a handful of products, a basic checkout system, and a minimal customer base. But as your business grows, so does the complexity of your application.</p><p>Now, you’re dealing with thousands of products, customer reviews, different payment gateways, inventory tracking, and shipping calculations. Without a structured approach, your application becomes an unmanageable mess.</p><p>This is where <strong>layered architecture</strong> comes in — a structured way to separate concerns, making your codebase cleaner, scalable, and easy to maintain.</p><h3>Why Layered Architecture? A Story of Two Developers</h3><p>Meet Alex and Sam, two developers working on their e-commerce platform.</p><ul><li><strong>Alex’s Approach</strong>: Alex writes everything in a single file. Database queries, UI components, and business logic are all mixed together. As the application grows, making changes becomes a nightmare. A simple update breaks multiple parts of the system, leading to frustration and hours of debugging.</li><li><strong>Sam’s Approach</strong>: Sam follows a <strong>layered architecture</strong>. She separates the UI, business logic, and database interactions into distinct layers. When she needs to update a feature, she knows exactly where to go, and changes are isolated from the rest of the system. Her application remains structured, scalable, and easy to maintain.</li></ul><p>By the time their applications reach thousands of users, <strong>Alex’s app is crumbling under its own complexity, while Sam’s app continues to run smoothly.</strong></p><p>The takeaway? <strong>A well-structured architecture saves time, reduces bugs, and makes scaling effortless.</strong></p><h3>The Five Layers of a Well-Structured E-Commerce App</h3><p>To better understand the structure, refer to the diagram below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zmjxj3ZPGJQKfSgBakdcZA.png" /></figure><p>Here’s how you can structure your Next.js e-commerce platform using a layered architecture</p><h3>1. Presentation Layer (UI — Pages/Components)</h3><p>This is where users interact with your store. It includes:</p><ul><li><strong>Pages (</strong><strong>app/ directory)</strong> – Product listings, checkout, user profiles, and order history.</li><li><strong>Components</strong> — Shopping cart, filters, product cards, and navigation.</li></ul><p><strong>How it helps:</strong> Keeps the UI clean by separating logic from visual elements.</p><h3>2. Application Layer (Controllers &amp; Routes)</h3><p>This acts as a bridge between the frontend and backend.</p><ul><li><strong>Routes (</strong><strong>app/api/products/route.ts)</strong> – API endpoints handling requests.</li><li><strong>Controllers (</strong><strong>ProductController, </strong><strong>OrderController)</strong> – Process API requests, validate data, and send responses.</li></ul><p><strong>How it helps:</strong> Ensures UI components don’t directly interact with business logic, making debugging and updates easier.</p><h3>3. Business Logic Layer (Services &amp; DTOs)</h3><p>The heart of your application, where core logic lives.</p><ul><li><strong>Services (</strong><strong>ProductService, </strong><strong>OrderService, </strong><strong>PaymentService)</strong> – Handle calculations, stock updates, and payment verification.</li><li><strong>DTOs (Data Transfer Objects)</strong> — Standardized data structures to move information between layers.</li></ul><p><strong>How it helps:</strong> Ensures business rules are centralized, preventing duplicated logic across the application.</p><h3>4. Data Access Layer (Repositories &amp; Prisma Models)</h3><p>This layer handles database interactions efficiently.</p><ul><li><strong>Repositories (</strong><strong>ProductRepository, </strong><strong>OrderRepository)</strong> – Encapsulate data fetching and manipulation.</li><li><strong>Prisma Models (</strong><strong>schema.prisma)</strong> – Define database tables for products, orders, users, and payments.</li></ul><p><strong>How it helps:</strong> Provides a clear abstraction for data handling, making database migrations and optimizations easier.</p><h3>5. Database Layer (PostgreSQL)</h3><p>The foundation of your platform, storing all essential data.</p><ul><li><strong>Stores</strong> product inventory, customer profiles, orders, and payments.</li><li><strong>Ensures</strong> fast and secure transactions.</li></ul><p><strong>How it helps:</strong> Separates database concerns, making switching databases or optimizing queries straightforward.</p><h3>Why Use the Repository Pattern? A Tale of Two Fixes</h3><p>Imagine a scenario where you need to <strong>optimize product queries</strong> for better performance.</p><ul><li><strong>Without Repository Pattern</strong>: You must search and update database queries scattered across the entire application, risking breaking unrelated features.</li><li><strong>With Repository Pattern</strong>: You update the ProductRepository, and the change is automatically reflected everywhere. Your application remains stable.</li></ul><p><strong>The repository pattern ensures maintainability, scalability, and performance optimization.</strong></p><h3>Bringing It All Together: A Real-World Example</h3><p>Here’s how the layers work together when a user places an order:</p><ol><li><strong>A customer views a product (</strong><strong>app/products/page.tsx).</strong></li><li>The UI makes an API call to <strong>GET /api/products.</strong></li><li>The <strong>Route Handler</strong> (<strong>route.ts</strong>) processes the request and forwards it to <strong>ProductController</strong>.</li><li><strong>ProductController</strong> calls <strong>ProductService</strong> to check stock availability.</li><li><strong>ProductService</strong> retrieves data via ProductRepository.</li><li><strong>ProductRepository</strong> fetches product data from PostgreSQL using Prisma.</li><li>The product details are sent back through the layers and displayed to the user.</li><li>When the user proceeds to checkout:</li></ol><ul><li>The UI sends a <strong>POST /api/orders</strong> request.</li><li><strong>OrderController</strong> validates stock and forwards the request to <strong>OrderService</strong>.</li><li><strong>PaymentService</strong> handles the payment transaction.</li><li>The order is saved using <strong>OrderRepository</strong>.</li></ul><p><strong>Each layer plays a distinct role, keeping the code clean and organized.</strong></p><h3>Conclusion</h3><p>By implementing <strong>layered architecture</strong> in your <strong>self-hosted Next.js e-commerce platform</strong>, you create a system that is:</p><ul><li><strong>Easy to Maintain-</strong> Each component has a clear responsibility.</li><li><strong>Scalable</strong> — New features can be added without affecting existing functionality.</li><li><strong>Secure</strong> — Sensitive operations are contained within appropriate layers.</li><li><strong>Optimized for Performance</strong> — Queries are structured efficiently using the repository pattern.</li></ul><p>If you want to build an <strong>e-commerce app that grows effortlessly with your business</strong>, following this structured approach is the way to go.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=795d5784f2c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Robust Self-Hosted E-Commerce App: The Perfect Tech Stack for Success]]></title>
            <link>https://medium.com/@supunnilakshana1999/building-a-robust-self-hosted-e-commerce-app-the-perfect-tech-stack-for-success-254bb9713e33?source=rss-fa44b358fa50------2</link>
            <guid isPermaLink="false">https://medium.com/p/254bb9713e33</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[top-tech-stacks]]></category>
            <category><![CDATA[e-commerce-business]]></category>
            <category><![CDATA[selfhost]]></category>
            <dc:creator><![CDATA[Supunnilakshana]]></dc:creator>
            <pubDate>Sat, 08 Feb 2025 16:43:22 GMT</pubDate>
            <atom:updated>2025-02-08T16:43:22.478Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*ccFciyihRvJTpP3glBCI6g.png" /></figure><p>Building a self-hosted, single-vendor eCommerce app is no small feat. The goal is clear: create a <strong>reliable</strong>, <strong>efficient</strong>, and <strong>scalable</strong> platform while being lightweight and easily manageable. With businesses’ increasing need to take control of their online presence, self-hosting allows for flexibility and independence without relying on third-party services. But choosing the right tech stack is the foundation for success.</p><p>In this journey, we opted for a tech stack that balances performance, scalability, and ease of use — <strong>Full-Stack Next.js with PWA</strong>, <strong>TypeScript</strong>, <strong>PostgreSQL</strong>, <strong>Prisma</strong>, and <strong>Docker</strong>. Each of these technologies was chosen for its ability to keep the app streamlined, lightweight, and ready for growth.</p><h3>Next.js: A Seamless Full-Stack Solution with PWA Support</h3><p>For a self-hosted eCommerce app, we needed a framework that could effortlessly handle both the front-end and back-end. Enter <strong>Next.js</strong>. This React-based framework allows us to build the entire application with full-stack capabilities, meaning we don’t need to worry about managing separate front-end and back-end systems. Using <strong>server-side rendering (SSR)</strong> and <strong>static site generation (SSG)</strong>, Next.js ensures the app loads quickly and performs well, even for users with slower internet speeds.</p><p>One of the standout features is its support for <strong>Progressive Web App (PWA)</strong> functionality, allowing the app to provide an <strong>app-like experience</strong> on mobile devices. This means the e-commerce platform will be fast and work offline, offering users a seamless shopping experience no matter where they are.</p><p>Next.js allowed us to simplify the architecture, ensuring that we didn’t add unnecessary complexity while still offering high performance.</p><h3>TypeScript: Building a Reliable and Scalable Codebase</h3><p>While JavaScript is the go-to language for most web applications, we embraced <strong>TypeScript</strong> to ensure our codebase would remain <strong>reliable</strong>, <strong>maintainable</strong>, and <strong>scalable</strong>. Adding <strong>static typing</strong> in TypeScript means we can catch errors early in the development process, making the app more secure and less prone to runtime issues. Given that eCommerce platforms often handle sensitive customer data and transactions, ensuring type safety is non-negotiable.</p><p>TypeScript also enhances <strong>developer productivity</strong> by providing better tools for code completion, documentation, and refactoring. Managing a large codebase without sacrificing clarity is key as the application grows. <strong>TypeScript</strong> ensures that our app’s code remains <strong>organized</strong> and <strong>easy to maintain</strong>, making future updates and feature additions more manageable.</p><h3>PostgreSQL: A Reliable Database for Growth and Flexibility</h3><p>For the database, we chose <strong>PostgreSQL</strong>, a powerful relational database system known for its reliability and performance. In e-commerce, data consistency and integrity are critical, especially when dealing with sensitive information like orders, customer details, and inventory. <strong>PostgreSQL</strong> ensures that all transactions are <strong>ACID-compliant</strong> and <strong>reliable</strong>, <strong>consistent</strong>, and <strong>safe</strong>.</p><p>One of PostgreSQL’s advantages is its ability to handle <strong>complex queries</strong> and large datasets efficiently, which is exactly what we need as the eCommerce platform grows. Additionally, <strong>PostgreSQL</strong> supports <strong>JSONB</strong> for storing unstructured data, allowing us to evolve our database schema without limitations.</p><p>With PostgreSQL, we can scale the app seamlessly while maintaining high <strong>data integrity</strong> and <strong>performance</strong>.</p><h3>Prisma ORM: Simplifying Database Interaction</h3><p>While PostgreSQL handles the heavy lifting, we needed a tool to make interacting with the database more straightforward and efficient. <strong>Prisma</strong>, an ORM (Object-Relational Mapping) tool, simplifies working with databases by providing an intuitive API that integrates perfectly with <strong>TypeScript</strong>.</p><p>Prisma <strong>streamlines database queries</strong> and ensures that all interactions with the database are <strong>type-safe</strong>, further reducing the likelihood of errors. This ease of use allows us to focus more on developing business logic and features than managing raw SQL queries. Moreover, Prisma’s migration tool makes it easier to evolve the database schema without interruptions or downtime.</p><p>By incorporating <strong>Prisma</strong>, we simplified managing our PostgreSQL database, keeping the app’s back-end clean, efficient, and easy to scale.</p><h3>Docker: Streamlining Deployment and Scaling</h3><p>For a self-hosted app, <strong>Docker</strong> was a natural choice for containerization. Docker allows us to package the entire application — front-end, back-end, and database — into isolated containers, ensuring the app runs consistently across all environments. Whether in development, staging, or production, Docker guarantees that the application will behave the same way, reducing issues related to environment discrepancies.</p><p>Docker’s lightweight nature allows us to scale the application as needed quickly, adding more containers to handle increased traffic or more resources for specific services. This scalability is crucial for a self-hosted platform that is expected to grow over time.</p><p>Furthermore, Docker speeds up the deployment process. Continuous integration and deployment (CI/CD) pipelines are simplified, allowing the team to quickly deploy updates and ensure the app runs smoothly at all times.</p><h3>Bringing It All Together</h3><p>The combination of <strong>Next.js</strong>, <strong>TypeScript</strong>, <strong>PostgreSQL</strong>, <strong>Prisma</strong>, and <strong>Docker</strong> perfectly balances <strong>performance</strong>, <strong>scalability</strong>, and <strong>simplicity</strong>. This tech stack allows us to build an eCommerce platform that is both <strong>lightweight</strong> and capable of handling <strong>complex business requirements</strong>.</p><ul><li><strong>Next.js</strong> gives us a seamless full-stack solution with excellent performance, PWA support, and ease of development.</li><li><strong>TypeScript</strong> ensures that the code is reliable and easy to maintain.</li><li><strong>PostgreSQL</strong> offers a robust database solution that grows with the app’s needs, all while maintaining data integrity.</li><li><strong>Prisma</strong> simplifies database interaction, making scaling and maintaining the database layer easier.</li><li><strong>Docker</strong> ensures consistency and scalability in deployment, allowing us to manage and scale the app as the business grows easily.</li></ul><p>This tech stack offers <strong>reliability</strong>, <strong>efficiency</strong>, and <strong>growth potential</strong> without overcomplicating the architecture. It’s an ideal choice for a <strong>self-hosted, single-vendor eCommerce app</strong> that is lightweight, easy to maintain, and ready to scale.</p><h3>Conclusion: Why This Tech Stack?</h3><p>This stack provides everything we need to ensure <strong>performance</strong>, <strong>scalability</strong>, and <strong>ease of use</strong> for a self-hosted, single-vendor e-commerce platform. By combining <strong>Next.js</strong>, <strong>TypeScript</strong>, <strong>PostgreSQL</strong>, <strong>Prisma</strong>, and <strong>Docker</strong>, we’ve created a solution that is both powerful and simple, allowing the app to grow with the business while keeping overhead low.</p><p>The choices we made in selecting this stack ensure that the platform will perform well today and be <strong>flexible enough to evolve</strong> as new challenges and opportunities arise. Building with these tools gives us the confidence that the app will be ready for the future while offering a smooth, seamless experience for developers and users alike.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=254bb9713e33" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlock Full Control with HostNShop: The Self-Hosted, Open-Source E-Commerce Solution]]></title>
            <link>https://medium.com/@supunnilakshana1999/unlock-full-control-with-hostnshop-the-self-hosted-open-source-e-commerce-solution-4900cc29bf35?source=rss-fa44b358fa50------2</link>
            <guid isPermaLink="false">https://medium.com/p/4900cc29bf35</guid>
            <category><![CDATA[e-commerce-business]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Supunnilakshana]]></dc:creator>
            <pubDate>Sat, 08 Feb 2025 16:00:20 GMT</pubDate>
            <atom:updated>2025-02-08T16:00:20.993Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*e_U0ELBvFdJizmIS11Uz0A.png" /></figure><p>In today’s world, building an online store has become essential for businesses of all sizes, especially small and medium-sized businesses (SMBs). However, the journey to creating an effective digital presence isn’t always easy, particularly when the solutions available come with hefty price tags, lack flexibility, and often feel out of reach for SMBs. Many business owners are left to choose between expensive, subscription-based platforms or basic, limited solutions that don’t give them enough control over their stores.</p><p>This is where <strong>HostNShop</strong> comes in. Imagine a platform that gives you full control, is entirely customizable, and — best of all — doesn’t come with recurring subscription fees. Sounds too good to be true? Well, it’s not. HostNShop is here to revolutionize the way SMBs can run their e-commerce stores, and it’s entirely open-source!</p><p>Let’s dive into what makes HostNShop stand out, why it’s such a game-changer for SMBs, and how it can help you build and manage your online store with ease.</p><h3>The Problem SMBs Face: Why Existing Solutions Aren’t Enough</h3><p>Let’s start by considering the challenges small business owners face when trying to set up their online stores. Today, many e-commerce platforms are either too expensive or come with limited flexibility, forcing businesses to settle for options that don’t meet their unique needs.</p><p>For example:</p><ul><li><strong>Subscription Costs</strong>: Many platforms charge annual or monthly fees for hosting and maintenance, which can add up quickly.</li><li><strong>Limited Customization</strong>: The ability to make the store truly your own is often limited, restricting branding and functionality.</li><li><strong>Control over Data</strong>: Most platforms don’t offer full control over customer data, which can be a major concern for business owners who want to ensure privacy and security.</li></ul><p>Now, imagine a platform that allows you to manage your store exactly how you want — without worrying about ongoing costs. <strong>HostNShop</strong> provides exactly that: an affordable, self-hosted e-commerce solution that’s both customizable and fully under your control.</p><h3>What is HostNShop?</h3><p><strong>HostNShop</strong> is a self-hosted, open-source e-commerce dashboard and Progressive Web App (PWA) designed specifically for small and medium-sized businesses, as well as developers who need a flexible, customizable platform. By offering full control over everything — from branding to data to infrastructure — HostNShop lets you manage your online store just the way you envision.</p><p>Instead of relying on a third-party service that charges you every year and restricts your freedom, HostNShop allows you to host and control your store on your own terms. And the best part? It’s entirely open-source, meaning you can modify, extend, and contribute to the platform however you see fit.</p><h3>Key Features of HostNShop</h3><p>What sets HostNShop apart from the rest of the crowd is its thoughtful, robust feature set. Here’s a closer look at what makes HostNShop truly special:</p><h4>1. E-Commerce Dashboard with Complete Store Management</h4><p>With HostNShop, you can manage every aspect of your store from a user-friendly, centralized dashboard. Some of the key functionalities include:</p><ul><li><strong>Product Management</strong>: Add, edit, and organize your products easily. Whether you have a few items or a large inventory, you can keep everything in order.</li><li><strong>Order Tracking</strong>: Keep track of incoming orders, their statuses, and manage returns and refunds seamlessly.</li><li><strong>Branding Customization</strong>: Customize your store’s look and feel — upload your logo, choose colors, and design a theme that represents your brand.</li></ul><h4>2. Progressive Web App (PWA) for a Seamless, App-Like Experience</h4><p>No more struggling with slow websites or clunky user interfaces. HostNShop includes a <strong>Progressive Web App (PWA)</strong>, ensuring your customers enjoy a fast, app-like experience, no matter what device they’re on. Key features include:</p><ul><li><strong>Offline Support</strong>: Users can browse and shop even when they’re not connected to the internet, making for a smoother shopping experience.</li><li><strong>Speedy Load Times</strong>: The app is designed to load quickly, offering a better user experience and reducing bounce rates.</li><li><strong>Add-to-Home Screen</strong>: Users can add your store to their home screen for easy, direct access — just like a native mobile app!</li></ul><h4>3. Easy Deployment with Docker-Based Containerization</h4><p>HostNShop is built for easy deployment across different environments, thanks to Docker-based containerization. This ensures that your store behaves the same way in all environments — whether it’s your local development setup, a testing server, or production. No more worrying about compatibility issues between different systems!</p><h3>Technology Stack: Why We Chose These Tools</h3><p>The backbone of HostNShop’s capabilities lies in its carefully selected <strong>technology stack</strong>. Here’s a deeper look at the tools we use to power HostNShop and why they’re the best choice for building scalable and reliable e-commerce platforms.</p><h4>1. Next.js with TypeScript</h4><p>For building the frontend and backend of HostNShop, we chose <strong>Next.js</strong>, a powerful full-stack framework for React. This allows us to have both frontend and backend in one unified framework, providing a seamless development experience. We also use <strong>TypeScript</strong> for added <strong>type safety</strong>, ensuring fewer bugs and improving code quality.</p><ul><li><strong>Server-Side Rendering (SSR)</strong>: Next.js comes with SSR, which helps improve SEO and makes your store’s pages load faster.</li><li><strong>Type Safety</strong>: TypeScript reduces runtime errors by ensuring type correctness during development.</li></ul><h4>2. PostgreSQL Database</h4><p>For data storage, we use <strong>PostgreSQL</strong>, a reliable, open-source relational database that is ideal for handling e-commerce data. With its scalability and robustness, PostgreSQL ensures your store can handle growing amounts of data without compromising performance.</p><h4>3. Docker</h4><p>We use <strong>Docker</strong> to containerize the application, which ensures a consistent and portable environment. This makes it easier to develop, test, and deploy HostNShop, regardless of the infrastructure being used.</p><h4>4. GitHub for Version Control</h4><p>Since HostNShop is an open-source project, we use <strong>GitHub</strong> for version control and collaboration. This allows anyone to contribute to the project, suggest improvements, or report issues, making it a truly community-driven platform.</p><h3>How HostNShop’s Architecture Supports Scalability and Maintenance</h3><p>HostNShop is designed with a <strong>modular, layered architecture</strong>, which means that different parts of the system are separated into distinct layers. This makes the system more scalable, maintainable, and easier to debug. The layers include:</p><ol><li><strong>Presentation Layer</strong>: This manages everything the user interacts with — the interface, routing, and overall experience.</li><li><strong>Application Layer</strong>: This layer handles all the business logic, including the workflows that manage products, orders, and customer interactions.</li><li><strong>Data Access Layer</strong>: This layer manages how the application interacts with the database and ensures that all data is accessed securely and efficiently.</li><li><strong>Database Layer</strong>: The PostgreSQL database layer stores and secures all the information, including product details, orders, and customer data.</li></ol><h3>Who Should Use HostNShop?</h3><p>HostNShop is ideal for:</p><ul><li><strong>Small and Medium-Sized Businesses (SMBs)</strong>: If you’re an entrepreneur looking for a cost-effective way to manage your online store without paying hefty subscription fees, HostNShop is the perfect solution.</li><li><strong>Developers and Tech Enthusiasts</strong>: If you enjoy working with open-source software and want a highly customizable e-commerce platform, HostNShop provides a solid foundation for you to build on.</li><li><strong>Single-Vendor Stores</strong>: If you run a single-vendor store and need a straightforward e-commerce platform with powerful features, HostNShop has you covered.</li></ul><h3>Join the HostNShop Community</h3><p>HostNShop is more than just a platform — it’s a community of like-minded entrepreneurs, developers, and enthusiasts who believe in the power of open-source software. By contributing to GitHub, providing feedback, and sharing your experiences, you can help shape the future of HostNShop and open-source e-commerce.</p><p>So, whether you’re looking to create a digital store for your business or you want to contribute to an open-source project, <strong>HostNShop</strong> is here to help you succeed.</p><p>Let’s build the future of e-commerce together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4900cc29bf35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Progress SQL is a Great Choice for Modern Database Management]]></title>
            <link>https://medium.com/@supunnilakshana1999/why-progress-sql-is-a-great-choice-for-modern-database-management-ecf24cec46cd?source=rss-fa44b358fa50------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecf24cec46cd</guid>
            <dc:creator><![CDATA[Supunnilakshana]]></dc:creator>
            <pubDate>Sun, 26 Jan 2025 19:19:07 GMT</pubDate>
            <atom:updated>2025-01-26T19:19:07.395Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*waoWgt6y0u03LnswpVgQSQ.png" /></figure><h3>Introduction</h3><p>In today’s data-driven world, choosing the right database management system is crucial for any business or project. Progress SQL is one of the standout options for modern database management, offering a unique blend of features tailored for today’s demanding applications. Whether you’re building a robust enterprise solution or scaling your startup, Progress SQL provides a reliable and efficient way to manage your data. In this article, we’ll explore why Progress SQL deserves your attention.</p><h3>What is Progress SQL?</h3><p>Progress SQL is a high-performance database management system designed to simplify and enhance businesses’ data management. At its core, Progress SQL combines the power of SQL — a widely used language for querying and managing relational databases — with advanced features that enable developers to create, manipulate, and optimize databases efficiently.</p><p>Unlike traditional database systems, Progress SQL operates as part of Progress OpenEdge, a comprehensive development platform. It is built to handle complex data structures while maintaining high performance and scalability. Put, Progress SQL helps businesses organize, access, and analyze their data seamlessly.</p><h3>Understanding Object-Relational Database Systems</h3><p>Progress SQL belongs to the family of object-relational database systems (ORDBMS). These systems bridge the gap between traditional relational databases and object-oriented programming. While relational databases store data in tables with rows and columns, object-relational systems support additional features such as custom data types, classes, and inheritance, making them ideal for handling complex data models.</p><p>For example, let’s say you’re designing a database for an e-commerce platform. With ORDBMS, you can store product information in a way that directly maps to your application’s object-oriented code. This simplifies the process of querying and manipulating data, especially for developers accustomed to working with objects in their programming language.</p><h3>Key Features of Progress SQL</h3><p>Progress SQL offers several features that set it apart from other database systems:</p><ol><li><strong>High Performance</strong>: Progress SQL is optimized for speed and efficiency, ensuring that even large-scale applications run smoothly.</li><li><strong>Scalability</strong>: Whether you’re managing a small dataset or a massive enterprise database, Progress SQL can scale to meet your needs.</li><li><strong>Data Security</strong>: Built-in security features, such as encryption and access controls, help protect sensitive data.</li><li><strong>Integration with Progress OpenEdge</strong>: Progress SQL is seamlessly integrated with the Progress OpenEdge platform, enabling rapid application development and deployment.</li><li><strong>Support for Advanced Features</strong>: It includes capabilities like stored procedures, triggers, and custom data types to handle complex business logic.</li><li><strong>Cross-Platform Compatibility</strong>: Progress SQL supports multiple operating systems and environments, making it a versatile choice for diverse projects.</li></ol><h3>Comparison with MySQL and MS SQL</h3><p>When compared to popular systems like MySQL and MS SQL, Progress SQL stands out for its specialized focus and unique capabilities:</p><ul><li><strong>MySQL</strong>: Known for its simplicity and widespread use, MySQL is an excellent choice for web applications and small to medium-sized projects. However, it may lack some of the advanced features and scalability offered by Progress SQL.</li><li><strong>MS SQL</strong>: Microsoft SQL Server is a powerful enterprise-grade database system with robust support for analytics and integration. While MS SQL is feature-rich, Progress SQL’s integration with Progress OpenEdge makes it a better choice for specific business applications.</li></ul><p>Progress SQL’s emphasis on high performance, scalability, and integration gives it a distinct edge for businesses looking for a comprehensive solution.</p><h3>Ideal Use Cases for Progress SQL</h3><p>Progress SQL excels in several industries and applications, including:</p><ul><li><strong>Enterprise Resource Planning (ERP)</strong>: With its scalability and performance, Progress SQL is an excellent choice for managing complex ERP systems.</li><li><strong>Healthcare</strong>: Its robust security features make it ideal for handling sensitive patient data.</li><li><strong>Retail and E-commerce</strong>: Progress SQL’s flexibility supports dynamic product catalogs and transaction management.</li><li><strong>Financial Services</strong>: The ability to process large datasets efficiently makes it a strong contender for financial applications.</li><li><strong>Custom Business Applications</strong>: Its seamless integration with Progress OpenEdge makes it perfect for businesses building tailored software solutions.</li></ul><h3>Conclusion</h3><p>Progress SQL offers a robust and reliable solution for modern database management, especially for businesses leveraging the Progress OpenEdge platform. Its combination of performance, scalability, security, and advanced features makes it a compelling choice for developers and enterprises alike. Whether you’re managing an ERP system or building a custom application, Progress SQL provides the tools you need to succeed in today’s fast-paced digital landscape.</p><p>If you’re looking for a database system that can keep up with the demands of modern applications while offering robust functionality, Progress SQL might be the perfect fit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecf24cec46cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Flexible Flutter Apps Without the Hassle: The Power of Dependency Injection]]></title>
            <link>https://medium.com/@supunnilakshana1999/building-flexible-flutter-apps-without-the-hassle-the-power-of-dependency-injection-aa7f194d3265?source=rss-fa44b358fa50------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa7f194d3265</guid>
            <dc:creator><![CDATA[Supunnilakshana]]></dc:creator>
            <pubDate>Tue, 07 Jan 2025 20:16:17 GMT</pubDate>
            <atom:updated>2025-01-07T20:18:53.867Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dnZKQj5-ePUQRPzeWH0sfA.png" /></figure><p>Imagine you’re a developer at a small tech company, and you’ve just built a Flutter app using the <strong>dio</strong> package for network requests. Everything is working great—until one day, the client calls with a change request.</p><p>“We’d like to switch from <strong>dio</strong> to the <strong>http</strong> package for network requests,&quot; the client says. &quot;It aligns better with our backend&#39;s standards.&quot;</p><p>You groan inwardly. Switching network packages sounds simple, but as you dive into the code, you realize the gravity of the task. Every API call in your app is tightly coupled to the <strong>dio</strong> package. Replacing it with <strong>http</strong> means manually updating all instances of <strong>dio</strong> in the app. It’s time-consuming, error-prone, and downright frustrating.</p><p>This is where Dependency Injection (DI) comes to the rescue. Let’s explore how DI can save you from such headaches, using Flutter and the <strong>get_it</strong> package as our toolkit.</p><h3>The Problem: Tight Coupling</h3><p>Without DI, your app might look something like this:</p><pre>import &#39;package:dio/dio.dart&#39;;<br><br>class APIService {<br>  final Dio _dio = Dio();<br><br>  Future&lt;dynamic&gt; get(String url) async {<br>      final response = await _dio.get(url);<br>      return response.data;<br>    }<br>}<br><br>void main() {<br>  final apiService = APIService();<br>  apiService.get(&#39;https://example.com&#39;);<br>}</pre><p>Here, the <strong>APIService</strong> class is tightly coupled to <strong>dio</strong>. If you need to switch to another package like <strong>http</strong>, you’ll have to rewrite the <strong>APIService</strong> class entirely, along with every place it’s used. This lack of flexibility makes the code brittle and difficult to maintain.</p><h3>The Solution is Dependency Injection</h3><p>Dependency Injection separates the creation of dependencies from their use, making your code more modular, testable, and maintainable. Instead of hardcoding <strong>dio</strong> into the <strong>APIService</strong>, we’ll use an abstract interface and provide the specific implementation dynamically.</p><p>Let’s refactor the app step by step.</p><h4>Step 1: Define an Abstract Interface</h4><p>Start by creating an <strong>IAPIService</strong> abstract class with generic methods for HTTP operations:</p><pre>abstract class IAPIService {<br><br>  Future&lt;dynamic&gt; get(String url);<br>  Future&lt;dynamic&gt; post(String url, dynamic data);<br>  Future&lt;dynamic&gt; put(String url, dynamic data);<br>  Future&lt;dynamic&gt; delete(String url);<br><br>}</pre><h4>Step 2: Create Concrete Implementations</h4><p>Next, create two implementations,</p><p>one for <strong>dio</strong> and another for <strong>http</strong>.</p><p><strong>Dio Implementation:</strong></p><pre>import &#39;package:dio/dio.dart&#39;;<br>import &#39;iapi_service.dart&#39;;<br><br>class APIServiceDio implements IAPIService {<br>  final Dio _dio = Dio();<br><br>  @override<br>  Future&lt;dynamic&gt; get(String url) async {<br>    final response = await _dio.get(url);<br>    return response.data;<br>  }<br><br>  @override<br>  Future&lt;dynamic&gt; post(String url, dynamic data) async {<br>    final response = await _dio.post(url, data: data);<br>    return response.data;<br>  }<br><br>  @override<br>  Future&lt;dynamic&gt; put(String url, dynamic data) async {<br>    final response = await _dio.put(url, data: data);<br>    return response.data;<br>  } <br><br> @override<br>  Future&lt;dynamic&gt; delete(String url) async {<br>    final response = await _dio.delete(url);<br>    return response.data;<br>  }<br><br>}</pre><p><strong>HTTP Implementation:</strong></p><pre>import &#39;package:http/http.dart&#39; as http;<br>import &#39;dart:convert&#39;;<br>import &#39;iapi_service.dart&#39;;<br><br>class APIServiceHTTP implements IAPIService {<br><br>  @override<br>  Future&lt;dynamic&gt; get(String url) async {<br>    final response = await http.get(Uri.parse(url));<br>    return json.decode(response.body);<br>  } <br><br> @override<br>  Future&lt;dynamic&gt; post(String url, dynamic data) async {<br>    final response = await http.post(Uri.parse(url), body: json.encode(data));<br>    return json.decode(response.body);<br>  }<br><br>  @override<br>  Future&lt;dynamic&gt; put(String url, dynamic data) async {<br>    final response = await http.put(Uri.parse(url), body: json.encode(data));<br>    return json.decode(response.body);<br>  } <br><br> @override<br>  Future&lt;dynamic&gt; delete(String url) async {<br>    final response = await http.delete(Uri.parse(url));<br>    return json.decode(response.body);<br>  }<br><br>}</pre><h4>Step 3: Set Up get_it for DI</h4><p>The <strong>get_it</strong> package helps us manage dependency injection effortlessly. Let’s configure it:</p><p><strong>Install </strong><strong>get_it</strong></p><p>Add <strong>get_it</strong> to your <strong>pubspec.yaml</strong>:</p><pre>dependencies:<br>  get_it: &lt;latest&gt;</pre><p><strong>Register Services:</strong></p><p>Create a service locator:</p><pre>import &#39;package:get_it/get_it.dart&#39;;<br>import &#39;iapi_service.dart&#39;;<br>import &#39;api_service_dio.dart&#39;;<br>import &#39;api_service_http.dart&#39;;<br><br>final GetIt getIt = GetIt.instance;void setupLocator() {<br><br>  // Switch between implementations easily<br>  getIt.registerLazySingleton&lt;IAPIService&gt;(() =&gt; APIServiceDio());<br>  // To use APIServiceHTTP instead:<br>  // getIt.registerLazySingleton&lt;IAPIService&gt;(() =&gt; APIServiceHTTP());<br><br>}</pre><p><strong>Use the Service:</strong></p><p>Fetch the service dynamically wherever needed:</p><pre>void main() {<br><br>  setupLocator();<br>  final apiService = getIt&lt;IAPIService&gt;();<br>    apiService.get(&#39;https://example.com&#39;).then((data) {<br>      print(data);<br>    });<br>}</pre><h3>The Benefits</h3><ol><li><strong>Modularity:</strong> You can switch between <strong>dio</strong> and <strong>http</strong> without modifying the core logic.</li><li><strong>Testability:</strong> You can mock <strong>IAPIService</strong> for unit tests.</li><li><strong>Scalability:</strong> Adding new implementations is seamless.</li><li><strong>Maintainability:</strong> Changes in one service won’t cascade through the codebase.</li></ol><h3>Conclusion</h3><p>Dependency Injection isn’t just a fancy design pattern; it’s a lifesaver for Flutter developers. By decoupling dependencies and using a tool like <strong>get_it</strong>, you can write code that’s cleaner, more maintainable, and easier to adapt to future changes.</p><p>So, the next time a client requests a change in network packages, you can smile and say, “No problem!”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa7f194d3265" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streamlining Flutter Development: An Introduction to Stacked Architecture]]></title>
            <link>https://medium.com/@supunnilakshana1999/streamlining-flutter-development-an-introduction-to-stacked-architecture-d6c02c5035b0?source=rss-fa44b358fa50------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6c02c5035b0</guid>
            <dc:creator><![CDATA[Supunnilakshana]]></dc:creator>
            <pubDate>Sun, 05 Jan 2025 20:45:22 GMT</pubDate>
            <atom:updated>2025-01-05T20:47:30.821Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Mn-miY8n-K5p5tq6Nn1lg.png" /></figure><h3>Introduction</h3><p><strong>What is Stacked Architecture in Flutter?</strong><br> Stacked is a Flutter architecture designed to create clean, maintainable, and scalable applications. It is based on the MVVM (Model-View-ViewModel) pattern, which separates the UI from business logic. This clear structure allows developers to focus on individual components and ensures that apps can grow and evolve without becoming unmanageable.</p><p><strong>Why Do We Need It?</strong><br> In the process of developing Flutter apps, developers often face challenges related to state management, business logic, and UI complexity. As apps grow, maintaining a clean and modular structure becomes essential to avoid technical debt. Stacked solves this by providing a structured approach to organizing code and managing common concerns like navigation, state, and data persistence. This makes development more efficient and the app easier to maintain in the long run.</p><h3>Benefits of Stacked Architecture</h3><p><strong>1. Scalability</strong><br> One of the primary benefits of Stacked is its ability to scale with your application. As the complexity of your app grows, Stacked allows you to keep your codebase organized. Its clear separation between the UI and business logic means that you can add new features without drastically altering the existing code structure.</p><p><strong>2. Code Organization</strong><br> With Stacked, the code is divided into distinct layers. The View layer (UI) interacts with the ViewModel layer (business logic), while the Services layer handles external interactions (e.g., APIs, databases). This organization improves code readability and debugging.</p><p><strong>3. Maintainability</strong><br> Stacked encourages best practices such as unit testing, modularization, and dependency injection, which ensures that your code is maintainable. By keeping the business logic separate from the UI, you can easily modify or extend one part of the app without affecting other parts.</p><h3>How to Use Stacked Architecture</h3><p><strong>Using Stacked CLI</strong><br> To use Stacked with Flutter, you can either manually set up the architecture or use the Stacked CLI (Command Line Interface) for a more streamlined approach. The CLI tool simplifies the process by generating a project structure with predefined folders and files, so you can start building your app right away.</p><ol><li><strong>Install Stacked CLI</strong><br> To install the Stacked CLI, use the following command:</li></ol><pre>dart pub global activate stacked_cli</pre><p><strong>2. Create a New Stacked App</strong><br> Once the CLI is installed, create a new Flutter project with Stacked using:</p><pre>stacked create app my_first_app</pre><p>This will generate a project with a predefined structure, including directories for views, viewmodels, and services.</p><p><strong>3. Run the App</strong><br> After generating the app, you can run it with:</p><pre>flutter run</pre><p><strong>Manually Setting Up Stacked Without CLI</strong><br> If you prefer not to use the Stacked CLI, you can manually set up Stacked in your Flutter project by following these steps:</p><ol><li><strong>Add Dependencies</strong><br> Open your pubspec.yaml file and add the following dependencies:</li></ol><pre>dependencies:<br>   flutter:<br>    sdk: flutter<br>  stacked: ^3.4.3<br>  stacked_services: ^1.5.1<br></pre><p><strong>2. Create ViewModels and Views</strong><br> Set up your ViewModel and View layers. The ViewModel contains the business logic, while the View contains the UI components. Views will listen to the ViewModel for state changes and update the UI accordingly.</p><p><strong>3. Set Up Services</strong><br> Create a services directory to handle external data interactions, such as fetching data from APIs or interacting with a local database.</p><p><strong>3. Set Up Routing</strong><br> To handle navigation, use the Stacked StackedRouter service, which allows you to define routes and navigate through the app efficiently.</p><h3>Features of Stacked Architecture</h3><p><strong>Routes: How Navigation is Handled</strong>Navigation in Stacked is simplified with the StackedRouter. This router helps centralize route definitions, making it easier to manage navigation throughout the app. You can define named routes and handle parameterized routing, reducing the need to manually manage navigation stacks and state.</p><p><strong>Services: Managing Business Logic</strong><br>The services layer is where the core business logic is stored. These services can interact with external data sources, handle API calls, and perform computations. Keeping this logic separate from the UI helps maintain a clean structure and makes your app easier to test.</p><p><strong>State Management: Managing State Across the App</strong><br>State management is handled using ViewModels in Stacked. The ViewModel reacts to changes in the business logic and updates the UI accordingly. This centralized management of state ensures that state changes are consistent and the app remains responsive.</p><h3>Conclusion</h3><p>Stacked architecture is a fantastic choice for developers building scalable, maintainable, and clean Flutter applications. Its separation of concerns (UI, business logic, and services) allows for efficient code management, making it easier to grow and maintain your app over time. The combination of CLI tools and manual setup options gives developers the flexibility to choose their preferred approach.</p><p>For more detailed instructions on setting up and using Stacked in your Flutter project, refer to the official <a href="https://stacked.filledstacks.com/docs/getting-started/overview">Stacked Documentation</a>.</p><p>By adopting Stacked, Flutter developers can build apps with a clear structure and maintainability in mind. If you’re ready to take your Flutter app development to the next level, Stacked is definitely worth exploring!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6c02c5035b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building and Deploying .NET Microservices on Kubernetes: A Learning Journey]]></title>
            <link>https://medium.com/@supunnilakshana1999/building-and-deploying-net-microservices-on-kubernetes-a-learning-journey-8b817ec6f814?source=rss-fa44b358fa50------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b817ec6f814</guid>
            <category><![CDATA[rabbitmq]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[grpc]]></category>
            <dc:creator><![CDATA[Supunnilakshana]]></dc:creator>
            <pubDate>Thu, 06 Jun 2024 18:16:11 GMT</pubDate>
            <atom:updated>2024-06-06T18:16:11.137Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building and Deploying .NET Microservices on Kubernetes: A Learning Journey</h3><p>Microservices architecture is one of the building blocks of scalable, maintainable, and efficient application development. This paper documents my recent learning project — building two microservices by leveraging ASP.NET Core 6 for developing purposes, followed by deployment in a Kubernetes cluster. The technologies to be used in the project include REST API, API Gateway, gRPC, RabbitMQ, Docker, and Kubernetes. They will demonstrate how to create, deploy, and communicate between microservices over a cloud-native environment.</p><h3>Overview of Tech Stack</h3><p><strong>ASP.NET Core 6</strong></p><p>ASP.NET Core is a high-performing cross-platform framework for building modern, cloud-based, internet-connected applications. Released with new features and improvements that further enhance the developer experience and application performance, its Version 6 REST API stands for Representational State Transfer; it is an architectural style used for network application design. In most, communication between the client and server components of an application is stateless and happens by using HTTP. RESTful APIs enable effective and uniform access to materials by other applications.</p><p><strong>API Gateway</strong></p><p>An API Gateway is a reverse proxy that takes in all calls of an API, aggregates the various services needed to serve the request, and returns the corresponding results; thus, client access can be made more accessible, and it has a place where system entry starts.</p><p><strong>Docker</strong></p><p>A container-based application enabling the development, shipping, and running of applications encapsulated in containers. Containers package an application with just its dependencies, ensuring the consistency of this application’s operation across every platform.</p><p><strong>Kubernetes</strong></p><p>Kubernetes is an open-source platform that automates scaling, deployment, and running application containers. It allows users to deploy and update containers based on desired state configuration, thereby enabling the scaling of containerized applications.</p><p><strong>Comparison of HTTP and gRPC:</strong></p><p>HTTP, or Hypertext Transfer Protocol, is a base protocol of how data is exchanged on the Web. It is for moving hypertext requests and information among browsers and servers. gRPC is an advanced open-source, high-performance Remote Procedure Call (RPC) framework that can work in any environment. It connects services within and across data centers in a pluggable way. It also supports load balancing, tracing, health checking, and authentication.</p><p><strong>RabbitMQ</strong></p><p>RabbitMQ is a message broker through which applications can communicate with each other by passing on messages containing information. RabbitMQ runs AMQP as a proper message queuing solution to reliably and flexibly handle the scaling of microservices.</p><h3>Solution Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*A1_GVB3Ve6kb4O8AedYQpw.png" /></figure><p>The solution architecture can be then represented as follows:</p><p><strong>API Gateway</strong>: considered the entry point to the overall system requests originating externally are all directed to the API Gateway from where it is to be routed to the appropriate microservice.</p><p><strong>Platform Service</strong>: Interacts by way of REST API and gRPC with a single SQL Server dedicated to persistence. The Command Service also exposes a REST API and, through gRPC, interacts with other services — all supported by an in-memory database.</p><p><strong>RabbitMQ Message Bus : </strong>This allows services to act independently and asynchronously, providing publish/subscribe messaging patterns between them.</p><h3><strong>Project Implementation</strong></h3><p><strong>Building Two .NET Microservices</strong></p><p>This project will implement two microservices using ASP.NET Core 6:</p><p><strong>Platform Service</strong> : This service will handle any form of data and operations related to the platform by interaction with a persistence layer in an SQL Server database.</p><p><strong>Command Service </strong>: This will be responsible for command-related data and actions. The persistence layer of the Command Service interacts with an in-memory database. Both services expose features through REST APIs, allowing seamless communication and integration.</p><p><strong>Data Persistence</strong></p><p>Each microservice has its persistence layer independent of the others:</p><p>Platform Service: The service uses an SQL server to persist data about the platform.</p><p>Command Service: The commands are persisted in an in-memory database, such that they can be quickly retrieved — the associated commands from a versionable aggregate root persistence over time.</p><p><strong>Deployment in Kubernetes</strong></p><p>Microservices are containerized using Docker and deployed in a Kubernetes cluster. Kubernetes orchestrates the deployment, scaling, and management of containers, resolving availability and resilience concerns.</p><p><strong>API Gateway</strong></p><p>An API Gateway routes call to the appropriate microservice. This pattern provides a single entry point for the client into all of the microservices, simplifies the code on the client side, and allows for extensible security and scalability.</p><p><strong>Synchronous Messaging</strong></p><p>The way the communication happens between the microservices is synchronous. They initiate the HTTP and gRPC connections:</p><p><strong>HTTP : </strong>Standard RESTful communication for most of the communication.</p><p><strong>gRPC : </strong>High-performance, contract-based communication for more specific use cases where data needs to flow back and forth very quickly.</p><p><strong>Asynchronous Messaging</strong></p><p>Asynchronous messaging is achieved by using RabbitMQ as an event bus. Microservices can publish and subscribe to events, giving rise to non-blocking, decoupled, and scalable interactions.</p><h3>Conclusion</h3><p>This project represents the actual implementation of modern microservices architecture with .NET Core 6, Docker, and Kubernetes. By combining REST APIs, API Gateway, HTTP, gRPC, and RabbitMQ with Kubernetes, one receives a potent and versatile system able to handle the most complex interactions. Additionally, deployment on Kubernetes provides a high level of service resilience, scalability, and manageability.</p><p>Detailed walkthroughs on the code and steps in deployment can be found in my GitHub repository:<a href="https://github.com/supunnilakshana/micro-service-learn">https://github.com/supunnilakshana/micro-service-learn</a>. I also followed the commands from this thorough YouTube tutorial that serves as an excellent guide to setting up the entire solution.</p><p>I followed this excellent <a href="https://www.youtube.com/watch?v=DgVjEo3OGBI">YouTube </a>tutorial which provided a comprehensive guide on setting up the entire solution!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b817ec6f814" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>