<?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 Naveethan Logitharasa on Medium]]></title>
        <description><![CDATA[Stories by Naveethan Logitharasa on Medium]]></description>
        <link>https://medium.com/@naveethannaveethan13?source=rss-0ae9ab162afe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pG65ELw20rNNoCG2mvbW_w.jpeg</url>
            <title>Stories by Naveethan Logitharasa on Medium</title>
            <link>https://medium.com/@naveethannaveethan13?source=rss-0ae9ab162afe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 15:50:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@naveethannaveethan13/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[MongoDB: A Complete Guide for Beginners]]></title>
            <link>https://medium.com/@naveethannaveethan13/mongodb-a-complete-guide-for-beginners-c5fcf66f7998?source=rss-0ae9ab162afe------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5fcf66f7998</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[nonsql]]></category>
            <category><![CDATA[sql-server]]></category>
            <dc:creator><![CDATA[Naveethan Logitharasa]]></dc:creator>
            <pubDate>Mon, 24 Feb 2025 09:30:39 GMT</pubDate>
            <atom:updated>2025-02-24T09:30:39.949Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UOa817l9eJ1bed9JZDqXVA.png" /><figcaption>MONGO DB</figcaption></figure><p>MongoDB is one of the most popular NoSQL databases, offering high scalability, flexibility, and powerful performance. Whether you are a beginner or an advanced user, this guide will help you understand the fundamentals and dive into advanced concepts.</p><h3>Introduction to MongoDB</h3><p>MongoDB is a document-oriented NoSQL database that stores data in BSON (Binary JSON) format. Unlike relational databases, it provides a dynamic schema, making it a great choice for modern applications.</p><h3>Why Choose MongoDB?</h3><ul><li><strong>Schema-less</strong>: Store data in flexible JSON-like documents without requiring a predefined structure.</li><li><strong>Scalability</strong>: Supports horizontal scaling using sharding to handle large amounts of data efficiently.</li><li><strong>Performance</strong>: Fast read and write operations with efficient indexing.</li><li><strong>Replication &amp; High Availability</strong>: Uses replica sets to ensure data availability and fault tolerance.</li></ul><h3>Installing and Setting Up MongoDB</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MChGDXalnTD7Pk-er5XVlA.png" /></figure><p><a href="https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-windows/#std-label-install-mdb-community-windows">https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-windows/#std-label-install-mdb-community-windows</a></p><h3>Step 1: Install MongoDB</h3><ol><li>Download and install MongoDB Community Edition from the <a href="https://www.mongodb.com/try/download/community">official website</a>.</li><li>Follow the installation steps based on your operating system (Windows, macOS, Linux).</li></ol><h3>Step 2: Start MongoDB Server</h3><p>Once installed, start the MongoDB server with:</p><pre>mongod</pre><h3>Step 3: Access MongoDB Shell</h3><p>To interact with MongoDB, use the command:</p><pre>mongo</pre><p>This opens the MongoDB shell where you can execute commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KTkaqjNGRg_20tynbuRqZg.png" /></figure><p><a href="https://www.mongodb.com/try/download/shell">https://www.mongodb.com/try/download/shell</a></p><h3>Understanding BSON &amp; JSON in MongoDB</h3><p>MongoDB stores data as BSON (Binary JSON), which supports additional data types such as Dates and Binary data.</p><p>Example of a JSON document:</p><pre>{<br>  &quot;name&quot;: &quot;John Doe&quot;,<br>  &quot;age&quot;: 30,<br>  &quot;email&quot;: &quot;john@example.com&quot;<br>}</pre><p>The same document in BSON format is efficiently stored with type information.</p><h3>Core Concepts: Databases, Collections &amp; Documents</h3><ul><li><strong>Database</strong>: A container for collections (similar to a database in SQL).</li><li><strong>Collection</strong>: A group of documents (similar to a table in SQL).</li><li><strong>Document</strong>: A single record stored in BSON format.</li></ul><p>Example of creating a database and collection:</p><pre>use myDatabase<br>db.createCollection(&quot;users&quot;)</pre><blockquote><strong>Mongo DB Compass</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VXF7iGJBsmQb-swINS-ayQ.png" /><figcaption>Connection with Localhost</figcaption></figure><h3>CRUD Operations in MongoDB</h3><h3>Create a Document</h3><pre>db.users.insertOne({ &quot;name&quot;: &quot;Alice&quot;, &quot;age&quot;: 25, &quot;email&quot;: &quot;alice@example.com&quot; })</pre><h3>Read Documents</h3><pre>db.users.find()</pre><h3>Update a Document</h3><pre>db.users.updateOne({ &quot;name&quot;: &quot;Alice&quot; }, { $set: { &quot;age&quot;: 26 } })</pre><h3>Delete a Document</h3><pre>db.users.deleteOne({ &quot;name&quot;: &quot;Alice&quot; })</pre><h3>Indexes for Performance Optimization</h3><p>Indexes improve query performance by making searches more efficient.</p><pre>db.users.createIndex({ &quot;name&quot;: 1 })</pre><p>Indexes help speed up read operations but require extra storage.</p><h3>Advanced Topics</h3><h3>Aggregation Framework</h3><p>Aggregation is used for data processing and transformation.</p><pre>db.sales.aggregate([<br>  { $match: { status: &quot;completed&quot; } },<br>  { $group: { _id: &quot;$product&quot;, total: { $sum: &quot;$amount&quot; } } }<br>])</pre><h3>Replication &amp; Sharding</h3><ul><li><strong>Replication</strong>: Ensures high availability by maintaining multiple copies of data across servers.</li><li><strong>Sharding</strong>: Distributes large datasets across multiple machines to improve scalability.</li></ul><h3>Transactions in MongoDB</h3><p>Transactions allow multiple operations to be executed together while maintaining ACID properties.</p><pre>session = db.getMongo().startSession()<br>session.startTransaction()<br>db.users.insertOne({ &quot;name&quot;: &quot;Bob&quot;, &quot;balance&quot;: 100 }, { session })<br>session.commitTransaction()</pre><h3>MongoDB Performance Optimization Tips</h3><ul><li>Use <strong>indexes</strong> to optimize queries.</li><li>Avoid <strong>storing excessively large documents</strong> to maintain efficiency.</li><li>Utilize <strong>aggregation pipelines</strong> for complex data processing.</li></ul><h3>Integrating MongoDB with C#</h3><p>Example of connecting MongoDB with C#:</p><pre>var client = new MongoClient(&quot;mongodb://localhost:27017&quot;);<br>var database = client.GetDatabase(&quot;myDatabase&quot;);<br>var collection = database.GetCollection&lt;BsonDocument&gt;(&quot;users&quot;);</pre><p>And also we can use MongoDB shell with VS Code Extension</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3yJDJtPjZh1zaYr-TfurPA.png" /></figure><h3>Final Thoughts</h3><p>MongoDB is a powerful NoSQL database designed for scalable and high-performance applications. By mastering both basic and advanced features, developers can create efficient and flexible applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5fcf66f7998" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Introduction to Middleware in API Development.”]]></title>
            <link>https://medium.com/@naveethannaveethan13/introduction-to-middleware-in-api-development-75e8f9169464?source=rss-0ae9ab162afe------2</link>
            <guid isPermaLink="false">https://medium.com/p/75e8f9169464</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[middleware]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Naveethan Logitharasa]]></dc:creator>
            <pubDate>Wed, 19 Feb 2025 08:36:39 GMT</pubDate>
            <atom:updated>2025-02-19T08:36:39.083Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OyHeejgP6iixm4wI56xMGA.png" /></figure><p>Middleware is a crucial component in API development, particularly in ASP.NET Core, where it acts as an intermediary between HTTP requests and API endpoints. Middleware components are executed in a pipeline and can modify incoming requests and outgoing responses.</p><blockquote>For Example,</blockquote><p>Imagine you are at an <strong>airport security checkpoint</strong> before boarding a flight. Your journey from entering the airport to reaching your plane resembles how middleware processes an API request:</p><ul><li><strong>Logging Middleware → Security cameras recording all passengers</strong> (logs requests before processing).</li><li><strong>Authentication Middleware → Passport control verifying your identity</strong> (verifies user credentials).</li><li><strong>Authorization Middleware → Immigration checking if you have the correct visa</strong> (ensures user has necessary permissions).</li><li><strong>Validation Middleware → Baggage scanning for prohibited items</strong> (ensures request data is valid and safe).</li><li><strong>Exception Handling Middleware → Help desk assisting passengers with issues</strong> (catches and processes errors before proceeding).</li></ul><p>Just like how an airport ensures smooth, secure, and valid passenger entry, middleware ensures a secure and structured request processing in an API.</p><h3>Why Do We Need Middleware?</h3><p>Middleware plays a vital role in structuring API request processing by:</p><ol><li><strong>Centralizing Common Logic</strong> — Instead of writing repetitive code in controllers, middleware centralizes operations like authentication, logging, and error handling.</li><li><strong>Security Enforcement</strong> — Ensures authentication and authorization before requests reach the API endpoints.</li><li><strong>Performance Optimization</strong> — Middleware can handle caching, compression, and response modifications to enhance performance.</li><li><strong>Request &amp; Response Modification</strong> — Can modify incoming requests or outgoing responses as needed.</li><li><strong>Global Exception Handling</strong> — Ensures consistent error responses across the application.</li></ol><h3>When Do We Need Middleware?</h3><p>Middleware is useful in scenarios such as:</p><ul><li>Logging HTTP requests and responses for debugging and monitoring.</li><li>Validating authentication tokens (JWT, OAuth, etc.) before processing requests.</li><li>Restricting access based on roles and permissions.</li><li>Modifying or formatting responses before sending them to the client.</li><li>Handling exceptions globally instead of using try-catch blocks in every controller.</li></ul><h3>Terminal vs. Non-Terminal Middleware</h3><p>Middleware components execute in sequence, processing the request and determining whether it continues down the pipeline.</p><h3>1. Non-Terminal Middleware (Pass-Through)</h3><ul><li><strong>Definition:</strong> These middleware components <strong>process</strong> the request but <strong>pass it along</strong> to the next middleware.</li><li><strong>Analogy:</strong> Think of <strong>airport security checks</strong>. You go through multiple security layers, such as passport control and baggage scanning, before reaching your boarding gate.</li><li><strong>Example:</strong> Logging, authentication, and request validation middleware.</li></ul><pre>app.Use(async (context, next) =&gt;<br>{<br>    Console.WriteLine(&quot;Request received&quot;);<br>    await next(); // Passes to the next middleware<br>    Console.WriteLine(&quot;Response sent&quot;);<br>});</pre><h3>2. Terminal Middleware (Stops the Pipeline)</h3><ul><li><strong>Definition:</strong> These middleware components <strong>do not call the next middleware</strong>; instead, they <strong>end the request processing</strong>.</li><li><strong>Analogy:</strong> Think of <strong>passport control rejecting an invalid passport</strong>. If a passenger is denied entry, they won’t proceed further to baggage checks or boarding.</li><li><strong>Example:</strong> UseEndpoints(), exception handling, and serving static files.</li></ul><pre>app.Use(async (context, next) =&gt;<br>{<br>    if (context.Request.Path == &quot;/stop&quot;)<br>    {<br>        await context.Response.WriteAsync(&quot;Request stopped here.&quot;);<br>        return; // Does NOT call next()<br>    }<br>    await next();<br>});</pre><h3>Middleware Execution Order</h3><p>The <strong>order in which middleware is registered matters</strong>, as ASP.NET Core executes them <strong>in the sequence they appear</strong> in Program.cs.</p><h3>Example: Wrong Order (Breaks Authentication)</h3><pre>var builder = WebApplication.CreateBuilder(args);<br>var app = builder.Build();</pre><pre>// Incorrect order<br>app.UseAuthorization(); // Runs before authentication (won&#39;t work properly)<br>app.UseAuthentication(); // User is not authenticated yet<br>app.UseRouting();<br>app.UseEndpoints(endpoints =&gt;<br>{<br>    endpoints.MapControllers();<br>});</pre><pre>app.Run();</pre><h3>Example: Correct Order (Ensures Proper Execution)</h3><pre>var builder = WebApplication.CreateBuilder(args);<br>var app = builder.Build();</pre><pre>app.UseRouting(); // Determines the route first<br>app.UseAuthentication(); // Authenticates the user<br>app.UseAuthorization(); // Checks if the user has permission<br>app.UseEndpoints(endpoints =&gt;<br>{<br>    endpoints.MapControllers();<br>});</pre><pre>app.Run();</pre><h3>Key Takeaways:</h3><p>✅ Always place <strong>UseRouting</strong> before authentication and authorization.<br>✅ <strong>UseAuthentication</strong> must come before <strong>UseAuthorization</strong> to avoid security issues.<br>✅ Placing <strong>UseEndpoints</strong> last ensures that middleware logic is executed before the request reaches the controller.</p><h3>How Middleware Works</h3><p>Middleware components are executed in a sequential pipeline, where each middleware can process, modify, or pass the request to the next middleware.</p><h3>Middleware Request-Response Flow</h3><pre>Client (Sends HTTP Request)<br>     │<br>     ▼<br>──────────────────────────────────────<br> Middleware Pipeline (Processing Layer)<br>──────────────────────────────────────<br>     │<br>     ├── [Logging Middleware]        → Logs request details (method, URL, time)<br>     │<br>     ├── [Authentication Middleware] → Checks if the user is logged in<br>     │<br>     ├── [Authorization Middleware]  → Ensures user has correct permissions<br>     │<br>     ├── [Validation Middleware]     → Validates input data (e.g., required fields)<br>     ▼<br>──────────────────────────────────────<br> Controller (Business Logic Execution)<br>──────────────────────────────────────<br>     │<br>     ▼<br>──────────────────────────────────────<br> Middleware Pipeline (Response Layer)<br>──────────────────────────────────────<br>     │<br>     ├── [Response Formatting Middleware] → Formats response (JSON, XML, compression)<br>     │<br>     ├── [Exception Handling Middleware]  → Catches &amp; processes errors<br>     ▼<br>Client (Receives Processed Response)</pre><h3>How to Use Middleware in ASP.NET Core</h3><h3>1. Built-in Middleware in ASP.NET Core (With Examples)</h3><p>ASP.NET Core provides several built-in middleware components:</p><h3>1. UseRouting — Determines request routing</h3><pre>app.UseRouting();</pre><h3>2. UseAuthentication &amp; UseAuthorization — Handling user login and access control</h3><pre>app.UseAuthentication();<br>app.UseAuthorization();</pre><h3>3. UseExceptionHandler — Global error handling</h3><pre>app.UseExceptionHandler(&quot;/error&quot;);</pre><h3>4. UseStaticFiles — Serving static files (CSS, JS, images)</h3><pre>app.UseStaticFiles();</pre><h3>2. Creating Custom Middleware</h3><p>You can create custom middleware by defining a middleware class and registering it in the pipeline.</p><h4>Example: Logging Middleware</h4><pre>public class LoggingMiddleware<br>{<br>    private readonly RequestDelegate _next;</pre><pre>    public LoggingMiddleware(RequestDelegate next)<br>    {<br>        _next = next;<br>    }</pre><pre>    public async Task Invoke(HttpContext context)<br>    {<br>        Console.WriteLine($&quot;Request: {context.Request.Method} {context.Request.Path}&quot;);<br>        await _next(context); // Call the next middleware<br>        Console.WriteLine($&quot;Response: {context.Response.StatusCode}&quot;);<br>    }<br>}</pre><h4>Register Middleware in Program.cs</h4><pre>app.UseMiddleware&lt;LoggingMiddleware&gt;();</pre><h3>Conclusion</h3><p>Middleware is an essential part of API development in ASP.NET Core. It helps in logging, authentication, authorization, validation, and error handling by processing HTTP requests before they reach the controllers. By leveraging middleware effectively, developers can improve code organization, security, and API performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75e8f9169464" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“A Beginner’s Guide to State Management in Flutter & Provider.”]]></title>
            <link>https://medium.com/@naveethannaveethan13/a-beginners-guide-to-state-management-in-flutter-provider-1138d46db3e7?source=rss-0ae9ab162afe------2</link>
            <guid isPermaLink="false">https://medium.com/p/1138d46db3e7</guid>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[state]]></category>
            <category><![CDATA[widgets-in-flutter]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[provider]]></category>
            <dc:creator><![CDATA[Naveethan Logitharasa]]></dc:creator>
            <pubDate>Tue, 18 Feb 2025 08:58:46 GMT</pubDate>
            <atom:updated>2025-02-18T08:58:46.327Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jTGPE_bG-jehl49xSjxMDA.png" /></figure><h3>What is State?</h3><p>In Flutter, <strong>state</strong> refers to the data that changes over time in your application. It’s the dynamic information that affects the app’s behavior and UI. For example, the count in a counter app, the text in a text field, or the user’s selection in a dropdown — all of these are examples of state.</p><h3>setState — The Basic State Management Approach</h3><p>The setState() method is Flutter&#39;s default way of managing state. It is used within a StatefulWidget to notify the framework that the widget’s state has changed, and the UI should be rebuilt.</p><pre>setState(() {<br>  // Update your state here<br>});</pre><p>However, setState() works best for small applications or specific cases. When the complexity grows, this simple method starts to show its limitations.</p><h3>How to Use setState?</h3><p>setState is a function that’ll retrigger the creation of a widget tree when a state change occurs. For small apps, setState can be a direct and effective way to manage state changes. All that’s required is attaching a setState command inside a function to trigger a UI rebuild after the state change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*TopGGOpIpgDMwq9ahZGstw.png" /></figure><p>In the example above, put the setState command inside a StatefulWidget. It’s for triggering the UI change on every button toggle and rebuilding the widget every time.</p><h3>When setState is Not Enough</h3><p>As your app grows, setState() may no longer be enough to manage state effectively. Here are a few reasons why:</p><ol><li><strong>State is confined to a single widget</strong>: If multiple widgets need access to the same state, you must pass it manually, which can be cumbersome.</li><li><strong>Performance issues</strong>: When state changes, setState() rebuilds the entire widget tree, which can slow down your app, especially with large UIs.</li><li><strong>Code gets messy</strong>: With an increasing number of widgets needing access to state, your code can become difficult to maintain and debug.</li></ol><p>That’s where <strong>advanced state management solutions</strong> like Provider, Riverpod, and Bloc come in.</p><h3>What is State Management?</h3><p><strong>State management</strong> is the technique used to handle and update UI data efficiently when state changes. In Flutter, when the state changes, the UI must rebuild to reflect those changes. State management ensures that the UI only rebuilds when necessary, avoiding unnecessary performance hits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5VKiO2zRwE2JzQEEaENWmw.jpeg" /></figure><h3>Why Do We Need State Management?</h3><ol><li><strong>UI Needs to Update When Data Changes</strong><br>Imagine a simple counter app where you press a button to increase the count. Without state management, the UI wouldn’t know when to update itself. State management ensures that when the count changes, the UI updates to reflect it.</li><li><strong>Managing State Across Multiple Widgets</strong><br>For example, if you add an item to a shopping cart, widgets like the Cart Icon in the App Bar, the Product Page, and the Cart Page should update simultaneously. Using setState(), you would need to manually pass the data between all widgets. With state management, the data is stored centrally, and all widgets automatically reflect changes.</li><li><strong>Performance Optimization</strong><br>If you use setState(), every change causes the entire widget tree to rebuild. For instance, if you &quot;like&quot; a post in a feed, the entire feed might rebuild, leading to unnecessary lag. State management solutions like Provider and Bloc only rebuild the widgets that are affected by the state change, improving performance.</li><li><strong>Cleaner, More Maintainable Code</strong><br>Using setState() everywhere can make your code messy. State management allows you to keep data separate from the UI, making the code more organized and easier to maintain.</li><li><strong>Required for Complex Apps</strong><br>For simple apps, setState() might be sufficient. But for real-world, complex apps, state management is essential to ensure performance and maintainability.</li></ol><h3>Introduction to Provider</h3><p><strong>Provider</strong> is one of the most popular state management solutions in Flutter. It’s simple to use, efficient, and scales well for large apps. Flutter officially recommends it because it centralizes your app’s state and ensures efficient UI updates. Let’s dive into why you might choose Provider for your Flutter apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jimufrpqvCacNtDsfM1yQQ.jpeg" /></figure><h4>Why Use Provider?</h4><ul><li><strong>Manages Global State</strong>: Provider centralizes your app’s state, eliminating the need to manually pass data between widgets.</li><li><strong>Efficient UI Updates</strong>: Unlike setState(), which rebuilds the entire widget tree, Provider only rebuilds the widgets that depend on the changed state.</li><li><strong>Simplicity</strong>: Provider is lightweight and integrates easily with Flutter, making it a great choice for most apps.</li></ul><h3>Key Concepts of Provider</h3><ol><li><strong>State Management</strong><br>Provider helps manage state in Flutter apps. The state refers to data that changes over time, such as user input or network responses. Provider ensures that the UI updates whenever this state changes.</li><li><strong>ChangeNotifier</strong><br>To use Provider, you create a class that extends ChangeNotifier. This class holds the state and provides methods to update it. When the state changes, it calls notifyListeners() to update any widgets that depend on the state.</li><li><strong>Provider Setup</strong><br>To set up Provider, you need to wrap your app with a ChangeNotifierProvider at the top level (usually in main.dart). This makes the state available to the entire widget tree.</li><li><strong>Accessing State with Provider.of</strong><br>To access the data provided by the Provider, you use Provider.of&lt;T&gt;(context), where T is the type of data you&#39;re accessing. This allows you to retrieve the state in a widget.</li><li><strong>Efficiency</strong><br>One of the major benefits of using Provider is that it only rebuilds the widgets that are listening to the state. This ensures efficient updates and avoids unnecessary rebuilds, which is a common issue with setState().</li></ol><h3>How Provider Works in State Management</h3><ol><li><strong>State Class</strong>: Create a class (e.g., Counter) that holds the app&#39;s state and extends ChangeNotifier.</li><li><strong>Providing the State</strong>: Use ChangeNotifierProvider to make the state available to the widget tree.</li><li><strong>Accessing the State</strong>: Widgets access the state using Provider.of&lt;T&gt;(context) or Consumer&lt;T&gt;.</li><li><strong>Efficient Updates</strong>: Only widgets that listen to the state will rebuild when the state changes.</li><li><strong>Multiple Providers</strong>: Use MultiProvider to manage different pieces of state in larger applications.</li></ol><h3>Conclusion</h3><p>Provider is a simple yet powerful state management solution for Flutter apps. It helps you manage and share state across your app, making your code more maintainable, efficient, and scalable. Whether you’re building a simple counter or a complex shopping cart system, Provider helps keep your UI in sync with your app’s state, ensuring smooth performance and easier debugging.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1138d46db3e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“A Comprehensive Guide to Service-to-Service Communication: Synchronous and Asynchronous Approaches.]]></title>
            <link>https://medium.com/@naveethannaveethan13/a-comprehensive-guide-to-service-to-service-communication-synchronous-and-asynchronous-approaches-8798060d39b4?source=rss-0ae9ab162afe------2</link>
            <guid isPermaLink="false">https://medium.com/p/8798060d39b4</guid>
            <category><![CDATA[asynchronouscommunication]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[synchronous]]></category>
            <category><![CDATA[architecture]]></category>
            <dc:creator><![CDATA[Naveethan Logitharasa]]></dc:creator>
            <pubDate>Fri, 14 Feb 2025 09:11:39 GMT</pubDate>
            <atom:updated>2025-02-14T09:33:10.727Z</atom:updated>
            <content:encoded><![CDATA[<h3>“A Comprehensive Guide to Service-to-Service Communication: Synchronous and Asynchronous Approaches.”</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eR2EUb6SmmFhFgLuSN3-rw.png" /></figure><h3>What is Service-to-Service(S2S) Communication?</h3><p>Service-to-service communication refers to how different microservices (or services within distributed systems) interact with each other to exchange data and execute operations. Since microservices are independent and loosely coupled, they must communicate effectively to work as a complete system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*_tAs0nHaLD2ly1ROBMOolw.jpeg" /></figure><h3>Example in an E-commerce System:</h3><p>In an e-commerce application, different microservices may include:</p><ul><li><strong>User Service</strong> (handles user authentication and profiles)</li><li><strong>Order Service</strong> (manages orders)</li><li><strong>Payment Service</strong> (processes payments)</li><li><strong>Inventory Service</strong> (tracks stock levels)</li></ul><p>When a customer places an order, these services must communicate to:</p><ul><li><strong>Verify the user</strong> (User Service)</li><li><strong>Check inventory</strong> (Inventory Service)</li><li><strong>Process the payment</strong> (Payment Service)</li><li><strong>Confirm the order</strong> and send a <strong>notification</strong> (Order Service)</li></ul><p>This entire process requires effective <strong>service-to-service communication</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*5rzvN5nhNPqyp-CHdLb6rg.png" /><figcaption>Flow of the process.</figcaption></figure><h3>Why Do We Need Service-to-Service Communication?</h3><p>Effective service-to-service communication provides several benefits for the system’s architecture:</p><ul><li><strong>Decoupled &amp; Scalable Architecture</strong><br>Services can work independently and scale based on demand.<br><em>Example:</em> If the <strong>Payment Service</strong> is overloaded, it won’t affect the <strong>User Service</strong>.</li><li><strong>Reusability &amp; Maintainability</strong><br>Services can be reused across multiple applications.<br><em>Example:</em> A <strong>Notification Service</strong> can be used by both <strong>Order Service</strong> and <strong>User Service</strong>.</li><li><strong>Fault Isolation &amp; Resilience</strong><br>If one service fails, the entire system doesn’t crash.<br><em>Example:</em> If the <strong>Inventory Service</strong> is down, the checkout process can still continue and retry later.</li><li><strong>Technology Flexibility</strong><br>Different services can be built using different technologies.<br><em>Example:</em> You can have a <strong>User Service</strong> in <strong>.NET</strong> and a <strong>Payment Service</strong> in <strong>Node.js</strong>.</li><li><strong>Better Load Management</strong><br>Requests can be distributed across services for better performance.<br><em>Example:</em> If there’s a high load on <strong>Order Service</strong>, it can be scaled without affecting other services.</li></ul><h3>Synchronous Communication</h3><h3>What is Synchronous Communication?</h3><p>Synchronous communication occurs when a service sends a request and <strong>waits for a response</strong> before proceeding with the next task.</p><h3>Example in E-commerce:</h3><p>When the <strong>Order Service</strong> requests <strong>payment authorization</strong> from the <strong>Payment Service</strong>, it waits for payment approval or rejection before continuing with the next steps (e.g., confirming the order).</p><h3>Advantages:</h3><ul><li>Simple to implement and understand.</li><li>Easier flow and error handling.</li></ul><h3>Disadvantages:</h3><ul><li>Slower response times due to waiting for each service’s response.</li><li>Potential system bottlenecks if one service becomes slow or unresponsive.</li></ul><h3>Asynchronous Communication</h3><h3>What is Asynchronous Communication?</h3><p>In asynchronous communication, a service sends a request and <strong>does not wait for an immediate response</strong>. It can continue performing other tasks while awaiting the response.</p><h3>Example in E-commerce:</h3><p>When the <strong>Order Service</strong> places an order, it sends a request to the <strong>Inventory Service</strong> to update stock levels, but it doesn’t wait for the update to complete before confirming the order to the customer.</p><h3>Advantages:</h3><ul><li>Improved system performance and responsiveness.</li><li>Greater fault tolerance and scalability.</li></ul><h3>Disadvantages:</h3><ul><li>Increased complexity in error handling and managing system state.</li><li>Potential for message duplication or loss if not properly managed.</li></ul><h3>Synchronous vs. Asynchronous Communication</h3><blockquote><strong>Choosing Between Synchronous and Asynchronous Communication:</strong></blockquote><ul><li><strong>When to Use Synchronous Communication</strong>: If real-time response is crucial, like in payment processing.</li><li><strong>When to Use Asynchronous Communication</strong>: For tasks that don’t require immediate feedback, like sending notifications or updating inventory.</li></ul><p>Choosing between <strong>synchronous</strong> and <strong>asynchronous communication</strong> depends on the task’s requirements.</p><ul><li><strong>Synchronous</strong> is ideal for tasks where real-time feedback is essential, like <strong>payment processing</strong>.</li><li><strong>Asynchronous</strong> is perfect for tasks that can happen in the background, like updating <strong>inventory</strong> or sending <strong>notifications</strong>.</li></ul><p>By understanding these approaches, you can design more efficient and scalable microservices that suit your system’s needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8798060d39b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Monolithic & Microsoft Architecture]]></title>
            <link>https://medium.com/@naveethannaveethan13/monolithic-microsoft-architecture-e259b7091566?source=rss-0ae9ab162afe------2</link>
            <guid isPermaLink="false">https://medium.com/p/e259b7091566</guid>
            <category><![CDATA[microservice-architecture]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[monolithic-architecture]]></category>
            <category><![CDATA[monolithic]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Naveethan Logitharasa]]></dc:creator>
            <pubDate>Thu, 13 Feb 2025 06:43:08 GMT</pubDate>
            <atom:updated>2025-02-14T03:38:20.371Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Vr4wq06QTPxdimD4eyMS4Q.png" /></figure><h3>Why is Software Architecture Needed? 🤔</h3><p>Software architecture is like the <strong>blueprint</strong> of a software system — it defines how different components interact, ensuring scalability, maintainability, and efficiency. Without it, the software can become chaotic, difficult to manage, and prone to failures.</p><p><strong>For Example,</strong></p><p>Think of software architecture like city planning. If there’s no plan, <strong>roads will be built randomly</strong>, leading to traffic jams and confusion. Similarly, software without architecture can become a <strong>maintenance nightmare</strong>, causing inefficiencies and growth challenges.</p><h3>Types of Software Architecture</h3><p>There are two primary architectural styles we’ll explore:</p><p><strong>1.</strong> <strong>Monolithic Architecture</strong> 🏢<br><strong>2.</strong> <strong>Microservices Architecture</strong> 🌐</p><h3>1. Monolithic Architecture</h3><p>A <strong>monolithic architecture</strong> is a <strong>single, unified system</strong> where all components — UI, business logic, and database — are tightly integrated into one application. Everything is connected in one large block, making it easier to develop initially but more challenging to scale and maintain as the system grows.</p><p>In a monolithic system:</p><ul><li>All components (like the <strong>frontend</strong>, <strong>backend</strong>, and <strong>database interaction</strong>) are developed and deployed together as one unit.</li><li>Changes require the <strong>entire application to be rebuilt and redeployed</strong>. This means that scaling the application requires scaling the <strong>whole system</strong> rather than individual parts.</li></ul><p><strong>For Example,</strong></p><p>Imagine a <strong>single highway</strong> that connects an entire city:</p><ul><li>All vehicles (cars, buses, trucks) must use this <strong>one highway</strong> to travel anywhere.</li><li>The highway has multiple lanes, but they all belong to the same system, meaning:</li><li>A <strong>traffic jam in one part</strong> of the highway affects the entire system.</li><li>If there’s roadwork or an accident, <strong>everyone is stuck</strong> because there are no alternative routes.</li></ul><h3>Advantages of Monolithic Architecture</h3><p>✔️ <strong>Quick to develop initially</strong>: Everything in one place, so it’s easy to get started.<br>✔️ <strong>Simpler to manage in small-scale systems</strong>: A single unit is easier to deploy and maintain.</p><h3>Challenges of Monolithic Architecture</h3><p>❌ <strong>Hard to scale</strong>: As the application grows, scaling becomes increasingly difficult because you need to scale the entire application at once.<br>❌ <strong>Single point of failure</strong>: If one part of the system fails, it can bring down the whole application.<br>❌ <strong>Slower updates</strong>: Every time you need to change something, you have to redeploy the entire system, which can slow down the development process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*AStC_ez5VyxikstYtY8c9g.png" /><figcaption><strong>MONOLITHIC REQUEST FLOW</strong></figcaption></figure><h3>2. Microservices Architecture</h3><p>Microservices architecture involves breaking down the application into <strong>small, independent services</strong>, each responsible for a specific business function. These services communicate with each other via APIs (like <strong>REST</strong> or <strong>gRPC</strong>), and each service can be deployed and scaled independently.</p><p>In a microservices system:</p><ul><li>Each service is an <strong>independent unit</strong> with its own codebase and database.</li><li>Services communicate with each other through <strong>APIs</strong>, allowing them to evolve independently.</li><li>Each service can be scaled separately depending on demand, meaning you don’t have to scale the whole system.</li></ul><p><strong>Now</strong>, imagine a <strong>modern city with multiple highways, flyovers, and service roads</strong>:</p><ul><li><strong>Expressways</strong> handle long-distance traffic (e.g., core business logic).</li><li><strong>Local streets</strong> serve short trips (e.g., user authentication).</li><li><strong>Dedicated bus lanes and metro systems</strong> handle specific services, such as payment or notifications.</li></ul><p>Each road operates independently, but they are all connected, allowing for smooth traffic flow. If one road is under construction, traffic can be rerouted through alternative routes without disrupting the whole system.</p><h3>Advantages of Microservices Architecture</h3><p>✔️ <strong>Highly scalable</strong>: You can scale individual services independently, allowing you to allocate resources efficiently.<br>✔️ <strong>Fault isolation</strong>: If one service fails, it doesn’t impact the others, ensuring <strong>resilience</strong> in the system.<br>✔️ <strong>Faster development cycles</strong>: Teams can develop, deploy, and update services independently, speeding up development and release cycles.</p><h3>Challenges of Microservices Architecture</h3><p>❌ <strong>Complexity</strong>: With multiple services, managing communication between them (via <strong>API gateways</strong> or <strong>message queues</strong>) becomes complicated.<br>❌ <strong>Data consistency</strong>: Since each service may have its own database, maintaining data consistency across services can be tricky.<br>❌ <strong>Initial setup effort</strong>: Setting up a microservices system requires careful planning, including deciding how services will communicate and how you’ll manage their deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*PMJArArzPsO6NUhZbKB-qQ.png" /><figcaption><strong>MICRO SERVICE REQUEST FLOW</strong></figcaption></figure><h3>Which Architecture Should You Choose?</h3><ul><li><strong>Monolithic</strong> is great for <strong>smaller applications</strong> or early-stage projects where quick development is key. It’s simple, but it becomes difficult to manage as the application scales.</li><li><strong>Microservices</strong> is better suited for <strong>large, complex systems</strong> that need scalability, flexibility, and fault tolerance. While it requires more initial setup, it pays off in the long run as it allows independent scaling and development of services.</li></ul><figure><img alt="Folder structure of Monolithic Architecture" src="https://cdn-images-1.medium.com/max/831/1*Gueq5TM1qXhZCORh1iLkEw.png" /><figcaption><strong>Monolithic Architecture</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*Aj51demATCZhv7T3tYaaGg.png" /><figcaption>Micro Service Architecture.</figcaption></figure><p>When we go through the folder structures ,</p><ul><li><strong>Monolithic</strong>: All parts of the application are housed in a <strong>single folder structure</strong>. Easier to start with but becomes complex as the application grows.</li><li><strong>Microservices</strong>: Each microservice has its <strong>own independent folder structure</strong>, making it easier to manage large-scale, distributed applications. Each service can be scaled and deployed independently, allowing for more flexibility.</li></ul><h3>Conclusion</h3><p>Both monolithic and microservices architectures have their place depending on the size, complexity, and scalability needs of the application. Monolithic architecture is like a <strong>single highway</strong>, easy to build but hard to scale, whereas microservices is like a <strong>well-planned road network</strong>, offering flexibility and scalability but requiring more effort to set up and manage.</p><p>By understanding both approaches, you can choose the one that best fits your project’s requirements. 🌱</p><h3>Reference</h3><p>The following link helped me to learn about monolithic and micro service architecture easily. It can lead you to understand the basic concept of those architectures in 5 min.</p><p><a href="https://youtu.be/6-Wu178sOEE?si=Crf3m5PvtL2QBo3Y">https://youtu.be/6-Wu178sOEE?si=Crf3m5PvtL2QBo3Y</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e259b7091566" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>