<?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 Arindam Ghosh on Medium]]></title>
        <description><![CDATA[Stories by Arindam Ghosh on Medium]]></description>
        <link>https://medium.com/@meaghosh?source=rss-40464c9971b8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ctLgpNWgNz3806O62ZA5Fg.jpeg</url>
            <title>Stories by Arindam Ghosh on Medium</title>
            <link>https://medium.com/@meaghosh?source=rss-40464c9971b8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 07:13:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@meaghosh/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[Android Interview Questions & Answers Part:2 (Kotlin & Jetpack Compose)]]></title>
            <link>https://medium.com/@meaghosh/android-interview-questions-answers-part-2-kotlin-jetpack-compose-4fc687fb970c?source=rss-40464c9971b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fc687fb970c</guid>
            <category><![CDATA[android-interviews]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Arindam Ghosh]]></dc:creator>
            <pubDate>Thu, 18 Jun 2026 06:42:07 GMT</pubDate>
            <atom:updated>2026-06-18T06:42:07.700Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zAqqwkhy21B90z99U8YU8g.jpeg" /></figure><ol><li><strong>Explain the difference between </strong><strong>val and </strong><strong>const val in Kotlin with examples. When would you choose one over the other?</strong></li></ol><h4><strong>val</strong></h4><p>A val is a read-only variable. Its value is assigned once and cannot be changed later.</p><pre>val name = &quot;Arindam&quot;<br>val currentTime = System.currentTimeMillis()</pre><p>This is valid because the value can be determined at runtime.</p><h4>const val</h4><p>A const val is a compile-time constant. The value must be known when the code is compiled.</p><pre>const val API_VERSION = &quot;v1&quot;<br>const val MAX_RETRY = 3</pre><p>❌ Not allowed:</p><pre>const val currentTime = System.currentTimeMillis() // Error</pre><p>because the value is not known until runtime.</p><p>Where can const val be declared?</p><p>Only at: Top Level</p><pre>const val BASE_URL = &quot;https://api.example.com&quot;</pre><p>Inside an object</p><pre>object Constants {<br>    const val API_KEY = &quot;abc123&quot;<br>}</pre><p>Inside a companion object</p><pre>class Config {<br>    companion object {<br>        const val VERSION = &quot;1.0&quot;<br>    }<br>}</pre><p>❌ Not inside a regular class:</p><pre>class Config {<br>    const val VERSION = &quot;1.0&quot; // Error<br>}</pre><p>Use val for everything else</p><pre>val repository = UserRepository()<br>val currentUser = getCurrentUser()<br>val formattedDate = LocalDate.now().toString()</pre><p><strong>2. What are the differences between SharedPreferences, DataStore, and EncryptedSharedPreferences (Secure SharedPreferences) in Android? When should each one be used?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Nv0AfmmpEosg_WfZpR0Fw.png" /></figure><ol><li><strong>SharedPreferences</strong></li></ol><p>Traditional Android API for storing key-value pairs.</p><pre>val sharedPref = getSharedPreferences(&quot;app_prefs&quot;, MODE_PRIVATE)<br><br>sharedPref.edit()<br>    .putString(&quot;username&quot;, &quot;Arindam&quot;)<br>    .apply()</pre><h4><strong>Pros</strong></h4><ul><li>Easy to use</li><li>Good for simple settings</li></ul><h4>Cons</h4><ul><li>Stores data as plain text XML</li><li>Synchronous API</li><li>Can block the main thread</li><li>Not suitable for large-scale apps</li></ul><p><strong>2. DataStore</strong></p><p>Modern replacement for SharedPreferences introduced by Google.</p><pre>dataStore.edit { prefs -&gt;<br>    prefs[USERNAME] = &quot;Arindam&quot;<br>}</pre><p>Reading:</p><pre>val username = dataStore.data.map {<br>    it[USERNAME]<br>}</pre><h4>Pros</h4><ul><li>Coroutine-based</li><li>Non-blocking</li><li>Better error handling</li><li>Supports Flow</li><li>Type-safe with Proto DataStore</li></ul><h4>Cons</h4><ul><li>Slightly more setup</li></ul><p><strong>3. EncryptedSharedPreferences (Secure SharedPreferences)</strong></p><p>Stores data in encrypted form using Android Keystore.</p><pre>val encryptedPrefs =<br>    EncryptedSharedPreferences.create(<br>        &quot;secure_prefs&quot;,<br>        masterKey,<br>        context,<br>        EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,<br>        EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM<br>    )<br><br>encryptedPrefs.edit()<br>    .putString(&quot;token&quot;, &quot;abc123&quot;)<br>    .apply()</pre><h4>Pros</h4><ul><li>Data is encrypted at rest</li><li>Uses Android Keystore</li><li>Protects sensitive information</li></ul><h4>Cons</h4><ul><li>Slightly slower due to encryption</li><li>Still based on SharedPreferences architecture</li></ul><p><strong>3. What is a Coroutine Builder in Kotlin? Explain the different coroutine builders and when to use each of them.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BVtpMy79-3i7-egZWByejg.png" /></figure><ol><li>launch</li></ol><p>Most commonly used.</p><pre>viewModelScope.launch {<br>    println(&quot;Running&quot;)<br>}</pre><h4>Features</h4><ul><li>Starts coroutine</li><li>Returns Job</li><li>No result</li></ul><p>Real use:</p><pre>viewModelScope.launch {<br>    repository.getData()<br>}</pre><p>👉 API call<br> 👉 DB insert<br> 👉 UI update</p><p>2. async</p><p>Used when you need a result.</p><pre>val deferred = async {<br>    10<br>}<br><br>val result = deferred.await()</pre><h4>Features</h4><ul><li>Returns Deferred&lt;T&gt;</li><li>Must call await()</li></ul><h4>Real use</h4><p>Parallel API calls:</p><pre>viewModelScope.launch {<br><br>    val user = async {<br>        api.getUser()<br>    }<br><br>    val posts = async {<br>        api.getPosts()<br>    }<br><br>    println(user.await())<br>    println(posts.await())<br>}</pre><p>3. runBlocking</p><p>Blocks current thread.</p><pre>runBlocking {<br>    delay(1000)<br>}</pre><h4>Features</h4><ul><li>Blocks thread</li><li>Mainly for testing</li></ul><p>❌ Don’t use in Android UI</p><pre>runBlocking {<br>    api.call()<br>}</pre><p>UI freeze / ANR</p><p>4. produce</p><p>Less common.</p><pre>val channel = produce {<br>    send(1)<br>    send(2)<br>}</pre><p>Used with Channels</p><h4>Why called “builder”?</h4><p>Because these functions:</p><ul><li>create coroutine</li><li>define scope/context</li><li>start execution</li></ul><p><strong>4. Can you explain how Jetpack Compose knows what to recompose when state changes? Also, where does Compose store state between recompositions, and how does </strong><strong>remember preserve values if composable functions are re-executed?</strong></p><p>Compose tracks which composables read a state object. When that state changes, only the affected composables are recomposed. remember stores values in Compose&#39;s Slot Table, outside the composable function, allowing state to survive recompositions even though the composable function itself is re-executed.</p><h4>Part 1: How does Compose know what to recompose?</h4><p>Compose tracks which composables read which state objects.</p><p>Example:</p><pre>@Composable<br>fun Counter() {<br>    var count by remember { mutableStateOf(0) }<br><br>    Text(&quot;Count: $count&quot;)<br><br>    Button(<br>        onClick = { count++ }<br>    ) {<br>        Text(&quot;Increment&quot;)<br>    }<br>}</pre><blockquote>what happens :</blockquote><ol><li>Text reads count</li><li>Compose records: Text depends on count</li><li>User clicks button</li><li>count changes</li><li>Compose marks only the composables that read count as invalid</li><li>Those composables are recomposed</li></ol><h4>Part 2: But composable functions run again every time!</h4><p>A common misconception is:</p><pre>@Composable<br>fun Counter() {<br>    var count by remember { mutableStateOf(0) }<br>}</pre><blockquote>people think:</blockquote><pre>Function runs again<br>↓<br>count recreated<br>↓<br>State lost</pre><p>But that’s not what happens.</p><h4>Part 3: Where is state actually stored?</h4><blockquote>Compose stores remembered values inside a special structure called the <strong>Slot Table</strong>.</blockquote><pre>Compose Runtime<br>│<br>├── Slot 0 -&gt; count<br>├── Slot 1 -&gt; username<br>├── Slot 2 -&gt; theme</pre><p>The values are NOT stored inside the composable function. They are stored in Compose Runtime memory.</p><h4>Part 4: How does remember work?</h4><p>First composition:</p><pre>var count by remember {<br>    mutableStateOf(0)<br>}</pre><p>compose:</p><pre>No value exists<br>↓<br>Create mutableStateOf(0)<br>↓<br>Store in Slot Table<br>↓<br>Return value</pre><p>Recomposition:</p><pre>var count by remember {<br>    mutableStateOf(0)<br>}</pre><p>Compose:</p><pre>Function runs again<br>↓<br>remember checks slot table<br>↓<br>Value already exists<br>↓<br>Return existing object</pre><p>The lambda is NOT executed again.</p><h4>Visual Example:</h4><p>First composition:</p><pre>Counter()<br>    remember<br>       ↓<br>   create state<br>       ↓<br> SlotTable[0] = count</pre><p>After button click:</p><pre>Counter() recomposes<br>       ↓<br>remember<br>       ↓<br>SlotTable[0] already exists<br>       ↓<br>return existing state</pre><p>State survives.</p><h4>5. remember vs rememberSaveable</h4><blockquote>remember</blockquote><p>Survives recomposition</p><pre>val count = remember {<br>    mutableStateOf(0)<br>}</pre><p>Survives:</p><p>✅ Recomposition</p><p>Does NOT survive:</p><p>❌ Configuration change<br> ❌ Process death</p><blockquote>rememberSaveable</blockquote><pre>val count = rememberSaveable {<br>    mutableStateOf(0)<br>}</pre><p>Survives:</p><p>✅ Recomposition<br> ✅ Screen rotation<br> ✅ Activity recreation</p><h4>6. What is a Qualifier in Hilt/Dagger, and how can you create and use a custom Qualifier annotation in Android?</h4><p>A <strong>Qualifier</strong> is used when Hilt finds <strong>multiple bindings of the same type</strong> and doesn’t know which one to inject.</p><h4>Problem Example</h4><p>Suppose you have two OkHttpClient objects:</p><pre>@Provides<br>fun provideAuthClient(): OkHttpClient {<br>    return OkHttpClient()<br>}<br><br>@Provides<br>fun provideNormalClient(): OkHttpClient {<br>    return OkHttpClient()<br>}</pre><p>Now:</p><pre>@Inject<br>lateinit var client: OkHttpClient</pre><p>Hilt will throw an error:</p><pre>Multiple bindings for OkHttpClient found.</pre><p>Because it doesn’t know which OkHttpClient to inject.</p><p>This is where <strong>Qualifiers</strong> help.</p><blockquote>Creating a Custom Qualifier:</blockquote><p>Step 1: Create Annotation</p><pre>@Qualifier<br>@Retention(AnnotationRetention.BINARY)<br>annotation class AuthClient<br><br>@Qualifier<br>@Retention(AnnotationRetention.BINARY)<br>annotation class NormalClient</pre><p>Step 2: Use in Module</p><pre>@Module<br>@InstallIn(SingletonComponent::class)<br>object NetworkModule {<br><br>    @AuthClient<br>    @Provides<br>    fun provideAuthClient(): OkHttpClient {<br>        return OkHttpClient()<br>    }<br><br>    @NormalClient<br>    @Provides<br>    fun provideNormalClient(): OkHttpClient {<br>        return OkHttpClient()<br>    }<br>}</pre><p>Step 3: Inject the Required Dependency</p><pre>class UserRepository @Inject constructor(<br>    @AuthClient<br>    private val client: OkHttpClient<br>)</pre><p>Now Hilt knows exactly which instance to inject.</p><p>AnnotationRetention Types:</p><pre>AnnotationRetention.SOURCE<br>AnnotationRetention.BINARY<br>AnnotationRetention.RUNTIME</pre><h4>1. SOURCE Retention</h4><pre>@Retention(AnnotationRetention.SOURCE)<br>annotation class MyAnnotation</pre><p>Lifecycle</p><pre>Source Code<br>    ↓<br>Compiler sees it<br>    ↓<br>Removed during compilation<br>    ↓<br>Not present in .class file</pre><h4>Use Cases</h4><ul><li>Code analysis</li><li>Lint checks</li><li>Documentation</li><li>Compile-time validation</li></ul><p>Example:</p><pre>@Retention(AnnotationRetention.SOURCE)<br>annotation class DebugOnly</pre><h4>2. BINARY Retention</h4><pre>@Retention(AnnotationRetention.BINARY)<br>annotation class AuthClient</pre><p>Lifecycle</p><pre>Source Code<br>    ↓<br>Stored in .class file<br>    ↓<br>Available to annotation processors<br>    ↓<br>Not available via reflection</pre><h4>Use Cases</h4><ul><li>Hilt</li><li>Dagger</li><li>KSP</li><li>KAPT</li><li>Room annotations processed during compilation</li></ul><h4>Why Hilt Uses BINARY?</h4><p>Because Hilt only needs the annotation during compilation to generate dependency injection code. Keeping it at runtime would waste memory.</p><h4>3. RUNTIME Retention</h4><pre>@Retention(AnnotationRetention.RUNTIME)<br>annotation class JsonField</pre><p>Lifecycle:</p><pre>Source Code<br>    ↓<br>Stored in .class file<br>    ↓<br>Available at Runtime<br>    ↓<br>Reflection can access it</pre><h4>Use Cases</h4><ul><li>Reflection</li><li>Serialization frameworks</li><li>Custom runtime processing</li></ul><p>Example:</p><pre>@Retention(AnnotationRetention.RUNTIME)<br>annotation class Author(<br>    val name: String<br>)<br><br>@Author(&quot;Arindam&quot;)<br>class UserRepository</pre><p>Runtime access:</p><pre>val annotation =<br>    UserRepository::class.annotations</pre><p>The annotation is available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*udZET4ZmoomFn0n7dbZwiw.png" /></figure><p><strong>7. How do you secure APIs in a mobile application?</strong></p><p>API security should be implemented in multiple layers:</p><ol><li>HTTPS/TLS for encrypted communication.</li><li>SSL Pinning to prevent MITM attacks.</li><li>Authentication using OAuth2/JWT tokens.</li><li>Short-lived Access Tokens.</li><li>Refresh Tokens for obtaining new Access Tokens.</li><li>Store tokens securely (EncryptedSharedPreferences or Keystore).</li><li>Backend authorization checks.</li><li>API Rate Limiting.</li><li>Request signing (HMAC).</li><li>Device attestation (Play Integrity API).</li><li>API Gateway and WAF protection.</li></ol><p>Never rely on only one mechanism.</p><p><strong>8. What is SSL Pinning?</strong></p><p>SSL Pinning is a security technique where the app trusts only a specific server certificate or public key instead of all system-trusted Certificate Authorities.</p><p>Benefits:</p><ul><li>Prevents MITM attacks.(Man-In-The-Middle)</li><li>Protects users on compromised networks.</li><li>Prevents traffic interception using rogue certificates.</li></ul><p>Example:</p><pre>val certificatePinner = CertificatePinner.Builder()<br>    .add(<br>        &quot;api.company.com&quot;,<br>        &quot;sha256/xxxxxxxxxxxxxxxxxx&quot;<br>    )<br>    .build()</pre><p><strong>9. Why HTTPS alone is not enough?</strong></p><p>HTTPS only verifies that the certificate is signed by a trusted CA.(Certificate Authority)</p><p>If:</p><ul><li>Device has a malicious CA installed</li><li>CA gets compromised</li></ul><p>then attackers may intercept traffic.</p><p>SSL Pinning adds an additional verification layer.</p><p><strong>10. Can SSL Pinning completely secure APIs?</strong></p><p>No. A rooted device or reverse-engineered app may bypass SSL pinning.SSL pinning is one security layer, not a complete solution.Security must be layered.</p><p><strong>11. How do you store Access Tokens securely in Android?</strong></p><p><strong><em>EncryptedSharedPreferences or Android Keystore</em></strong> . because encryption keys are protected by hardware-backed security where available</p><p><strong>12. What is Android Keystore?</strong></p><p>Android Keystore securely stores cryptographic keys.</p><p>Benefits:</p><ul><li>Keys cannot be extracted.</li><li>Hardware-backed security.</li><li>Supports biometric authentication.</li></ul><p>Used for:</p><ul><li>Token encryption</li><li>Certificate management</li><li>Digital signatures</li></ul><p><strong>13. What is JWT Token?</strong></p><p>JWT (JSON Web Token) is a compact token format used for authentication.</p><p>Structure:</p><pre>Header.Payload.Signature</pre><p>Example:</p><pre>eyJhbGci...</pre><p>Contains:</p><ul><li>User ID</li><li>Expiry time</li><li>Roles/Permissions</li></ul><p>Server validates signature before trusting it.</p><p><strong>14.Difference between Access Token and Refresh Token?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bW0bzyg7JBTHRJofbBBzvA.png" /></figure><p><strong>15. What happens when Access Token expires?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j5Yy7Y2W4Aktc6Z5qYZDkg.png" /></figure><p><strong>16. What happens if Refresh Token expires?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OKOT52wNp5vCJikjn2X4rw.png" /></figure><p><strong>17. How do you prevent API calls from outside your Android app?</strong></p><p>You cannot completely prevent it.</p><p>APK can be reverse engineered.</p><p>But you can make abuse difficult using:</p><ul><li>Authentication Tokens</li><li>SSL Pinning</li><li>Request Signing</li><li>Play Integrity API</li><li>Device Attestation</li><li>Backend Validation</li><li>Rate Limiting</li><li>App Check from Firebase</li></ul><p><strong>18. What is Request Signing?</strong></p><p>Client generates a signature using request data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jy4xzCCwoKvgIXY5qq_f2w.png" /></figure><p><strong>19. What is a Replay Attack?</strong></p><p>Attacker captures a valid request and sends it again.<br>Captured request replayed multiple times.</p><p>Protection:</p><ul><li>Timestamp</li><li>Nonce</li><li>Request signing</li></ul><p><strong>20. What is API Rate Limiting?</strong></p><p>Limit requests per user/device/IP.</p><p>Example:</p><pre>100 requests/minute</pre><p>Prevents:</p><ul><li>Brute force attacks</li><li>DDoS attempts</li><li>Abuse</li></ul><p>Implemented on backend.</p><p><strong>21. What is OAuth 2.0?</strong></p><p>Industry-standard authorization framework.</p><pre>User Login<br>      ↓<br>Authorization Server<br>      ↓<br>Access Token<br>      ↓<br>Protected APIs</pre><p>Common in:</p><ul><li>Google Login</li><li>Microsoft Login</li><li>GitHub Login</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fc687fb970c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Interview Questions & Answers Part:1 (Kotlin & Jetpack Compose)]]></title>
            <link>https://medium.com/@meaghosh/android-interview-questions-answers-part-1-kotlin-jetpack-compose-39448b764fd9?source=rss-40464c9971b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/39448b764fd9</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android-interviews]]></category>
            <dc:creator><![CDATA[Arindam Ghosh]]></dc:creator>
            <pubDate>Tue, 02 Jun 2026 05:53:11 GMT</pubDate>
            <atom:updated>2026-06-02T05:53:11.966Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zAqqwkhy21B90z99U8YU8g.jpeg" /></figure><ol><li><strong>What is the difference between MVVM and MVI, and when would you choose one over the other?</strong></li></ol><p>MVVM uses two-way data binding with a ViewModel exposing LiveData/StateFlow. MVI enforces a strict unidirectional data flow — Intent → Model → View — making state changes fully predictable and testable. MVI shines in complex UIs with many user interactions (e.g. a real-time map screen), where shared mutable state in MVVM can cause bugs.</p><p><strong>2. How does Clean Architecture work in a multi-module Android project?</strong></p><p>Clean Architecture splits code into layers: Presentation (Compose/ViewModel), Domain (UseCases, Entities — pure Kotlin, no Android deps), and Data (Repositories, APIs, DB). In a multi-module project each layer becomes its own Gradle module. The Domain module is the most important — it has zero Android dependencies, making it fully unit-testable and reusable in KMP. <em>The Data module depends on Domain, and Presentation depends on Domain only, never Data directly.</em> This keeps dependencies pointing inward.</p><p><strong>3. What is structured concurrency in Kotlin Coroutines and why does it matter?</strong></p><p>Structured concurrency means every coroutine has a parent scope, and if the parent is cancelled, all children are cancelled too. This prevents coroutine leaks. In Android, viewModelScope is tied to the ViewModel lifecycle — when the ViewModel clears, all coroutines cancel automatically. The key guarantee: a parent coroutine won’t complete until all its children complete. This makes async code behave predictably. Contrast with GlobalScope — launching there escapes the hierarchy and can cause leaks and crashes.</p><p><strong>4. Explain Flow vs SharedFlow vs StateFlow — when do you use each?</strong></p><p>Cold Flow: emits only when collected, no state, best for one-shot operations like a network call. StateFlow: hot, always has a value, replays the latest to new collectors — perfect for UI state. SharedFlow: hot, configurable replay and buffer, best for one-time events like navigation or error toasts. Common mistake: using StateFlow for navigation events causes re-navigation on config changes. Use SharedFlow(replay=0) for events instead.</p><h4><strong>Flow (cold stream)</strong></h4><p>A Flow starts emitting <strong>only when you collect it</strong>.</p><pre>fun simpleFlow(): Flow&lt;Int&gt; = flow {<br>    println(&quot;Flow started&quot;)<br>    emit(1)<br>    emit(2)<br>    emit(3)<br>}<br><br>fun main() = runBlocking {<br>    simpleFlow().collect { value -&gt;<br>        println(&quot;Collector 1: $value&quot;)<br>    }<br><br>    simpleFlow().collect { value -&gt;<br>        println(&quot;Collector 2: $value&quot;)<br>    }<br>}</pre><h4>Output behavior:</h4><ul><li>&quot;Flow started&quot; prints <strong>twice</strong></li><li>Because each collector <strong>re-triggers the flow</strong></li></ul><h4><strong>StateFlow (state holder, hot stream)</strong></h4><ul><li>Always has a <strong>current value</strong></li><li>Emits <strong>latest state only</strong></li><li>New collectors immediately get <strong>latest value</strong></li></ul><pre>val stateFlow = MutableStateFlow(0)<br><br>fun main() = runBlocking {<br>    launch {<br>        stateFlow.collect {<br>            println(&quot;Collector 1: $it&quot;)<br>        }<br>    }<br><br>    delay(100)<br>    stateFlow.value = 1<br>    stateFlow.value = 2<br><br>    launch {<br>        stateFlow.collect {<br>            println(&quot;Collector 2: $it&quot;)<br>        }<br>    }<br>}</pre><h4>Behavior:</h4><ul><li>Collector 2 will <strong>immediately get </strong><strong>2 (latest value)</strong></li></ul><p>👉 Think: <em>StateFlow = LiveData / UI state</em></p><h4>SharedFlow (event stream, hot)</h4><ul><li>No default value</li><li>Used for <strong>events</strong> (toast, navigation, one-time actions)</li><li>Can configure <strong>replay</strong></li></ul><pre>val sharedFlow = MutableSharedFlow&lt;Int&gt;()<br><br>fun main() = runBlocking {<br>    launch {<br>        sharedFlow.collect {<br>            println(&quot;Collector 1: $it&quot;)<br>        }<br>    }<br><br>    sharedFlow.emit(1)<br>    sharedFlow.emit(2)<br>}</pre><p>Collector gets values <strong>only after it starts collecting</strong></p><h4>SharedFlow with replay</h4><p>Replay defines:<br> 👉 “How many past values should new collectors receive?”</p><p><strong>replay = 0 (default)</strong></p><pre>val sharedFlow = MutableSharedFlow&lt;Int&gt;(replay = 0)</pre><h4>Behavior:</h4><ul><li>New collectors get <strong>nothing from past</strong></li><li>Only future emissions</li><li>👉 Use case: <strong>Events (navigation, toast)</strong></li></ul><p><strong>replay = 1</strong></p><pre>val sharedFlow = MutableSharedFlow&lt;Int&gt;(replay = 1)<br><br>fun main() = runBlocking {<br>    sharedFlow.emit(10)<br><br>    launch {<br>        sharedFlow.collect {<br>            println(&quot;Collector: $it&quot;)<br>        }<br>    }<br>}</pre><h4>Behavior:</h4><ul><li>Collector gets <strong>last emitted value (10)</strong></li></ul><p>👉 Similar to <strong>StateFlow but without requiring initial value</strong></p><p><strong>replay = 2</strong></p><pre>val sharedFlow = MutableSharedFlow&lt;Int&gt;(replay = 2)<br><br>fun main() = runBlocking {<br>    sharedFlow.emit(1)<br>    sharedFlow.emit(2)<br>    sharedFlow.emit(3)<br><br>    launch {<br>        sharedFlow.collect {<br>            println(&quot;Collector: $it&quot;)<br>        }<br>    }<br>}</pre><h4><strong>Behavior:</strong></h4><ul><li>Collector gets <strong>last 2 values → 2, 3</strong></li></ul><h4>StateFlow → UI State</h4><pre>val uiState = MutableStateFlow(&quot;Loading&quot;)<br><br>// UI observes<br>uiState.value = &quot;Success&quot;</pre><h4>SharedFlow → One-time Events</h4><pre>val events = MutableSharedFlow&lt;String&gt;(replay = 0)<br><br>// Send event<br>events.emit(&quot;Navigate to Home&quot;)</pre><h4>5. How does recomposition work in Jetpack Compose and how do you optimise it?</h4><p>Recomposition is the process where Compose re-executes composable functions when observed state changes. Compose tracks state reads and only recomposes affected UI. To optimize it, I use immutable models (@Immutable), stable keys in LazyColumn, remember, derivedStateOf, collectAsStateWithLifecycle, and I split large composables into smaller ones to minimize recomposition scope.</p><h4>Use Immutable Models</h4><p>An @Immutable data class should not contain any var or mutable types.</p><p>❌ Bad</p><pre>data class User(<br>    var name: String<br>)</pre><p>Compose can’t trust this.</p><p>✅ Good</p><pre>@Immutable<br>data class Message(<br>    val id: String,<br>    val text: String,<br>    val isRead: Boolean<br>)</pre><p>Benefits:</p><ul><li>Better skip decisions</li><li>Less recomposition</li></ul><h4>Use Stable Keys in LazyColumn</h4><p>❌ Bad</p><pre>items(messages)</pre><p>✅ Good</p><pre>items(<br>    messages,<br>    key = { it.id }<br>)</pre><p>Without keys:</p><pre>List changed<br>↓<br>Compose may recompose many items</pre><p>With keys:</p><pre>Only affected item recomposes</pre><h4>Update Using copy()</h4><p>❌ Bad</p><pre>messages[1].text = &quot;New&quot;</pre><p>Mutation causes unpredictable recomposition.</p><p>✅ Good</p><pre>message.copy(text = &quot;New&quot;)</pre><p>New immutable object.</p><h4>Use derivedStateOf</h4><p>❌ Bad</p><pre>val isButtonEnabled =<br>    text.length &gt; 5</pre><p>Calculated every recomposition.</p><p>✅ Good</p><pre>val isButtonEnabled by remember {<br>    derivedStateOf {<br>        text.length &gt; 5<br>    }<br>}</pre><p>Recomputes only when needed.</p><h4>Use @Stable</h4><p>Example of @Stable</p><pre>@Stable<br>class MessageState(<br>    text: String<br>) {<br>    var text by mutableStateOf(text)<br>}</pre><p>Usage:</p><pre>@Composable<br>fun MessageItem(state: MessageState) {<br>    Text(text = state.text)<br>}</pre><p>When state.text changes:</p><ul><li>Compose <strong>recomposes automatically</strong></li><li>Because it’s backed by mutableStateOf</li></ul><h4>Scenario: Chat input field (real app)</h4><p>You have:</p><ul><li>Text input</li><li>Typing state</li><li>Maybe validation</li></ul><p>👉 This state <strong>changes frequently</strong><br> 👉 You don’t want to recreate the whole object using copy() every time</p><p>❌ If you try @Immutable here (not ideal)</p><pre>@Immutable<br>data class InputState(<br>    val text: String<br>)</pre><p>Then every keystroke:</p><pre>state = state.copy(text = newText)</pre><p>Works, but:</p><ul><li>Creates new object every time</li><li>Not ideal for <strong>high-frequency UI updates</strong></li></ul><h4>✅ Real use case for @Stable</h4><pre>import androidx.compose.runtime.*<br><br>@Stable<br>class InputState(<br>    initialText: String = &quot;&quot;<br>) {<br>    var text by mutableStateOf(initialText)<br>    var isTyping by mutableStateOf(false)<br>}</pre><h4>Compose usage</h4><pre>@Composable<br>fun ChatInput(state: InputState) {<br><br>    println(&quot;Recomposing Input&quot;)<br><br>    Column {<br>        TextField(<br>            value = state.text,<br>            onValueChange = {<br>                state.text = it<br>                state.isTyping = it.isNotEmpty()<br>            }<br>        )<br><br>        if (state.isTyping) {<br>            Text(&quot;Typing...&quot;)<br>        }<br>    }<br>}</pre><h4>What happens now?</h4><ul><li>User types → state.text changes</li><li>Compose <strong>automatically recomposes only this part</strong></li><li>No need to recreate object (copy())</li></ul><h4>Why @Stable works here</h4><p>. mutableStateOf notifies Compose</p><p>.@Stable tells Compose: “Trust me, I will notify you when something changes”</p><h4>🧠 Simple Rule (remember this)</h4><h4>✅ Use @Immutable when:</h4><ul><li>Data comes from API / DB</li><li>You use copy()</li><li>No internal mutation</li></ul><h4>✅ Use @Stable when:</h4><ul><li>Object holds UI state</li><li>Uses mutableStateOf</li><li>Changes frequently (typing, animations, toggles)</li></ul><h4>6. Extension Functions:</h4><p>✅ Example: Format price in app</p><p>instead of:</p><pre>fun formatPrice(price: Double): String {<br>    return &quot;₹%.2f&quot;.format(price)<br>}</pre><p>Use extension:</p><pre>fun Double.toPrice(): String {<br>    return &quot;₹%.2f&quot;.format(this)<br>}</pre><p>Usage:</p><pre>val price = 99.5<br>println(price.toPrice()) // ₹99.50</pre><h4>Why use extension?</h4><ul><li>Makes code <strong>readable</strong></li><li>Feels like part of the class</li><li>Avoids utility classes</li></ul><h4>Higher-Order Functions (HOF)</h4><p>Function that takes function OR returns function</p><pre>// Higher-order function: takes another function as parameter<br>fun calculate(<br>    a: Int,<br>    b: Int,<br>    operation: (Int, Int) -&gt; Int<br>): Int {<br>    return operation(a, b)<br>}<br><br>fun main() {<br><br>    // Passing lambda for addition<br>    val result = calculate(10, 20) { x, y -&gt;<br>        x + y<br>    }<br><br>    println(&quot;Addition Result: $result&quot;)<br>}</pre><pre>Addition Result: 30</pre><h4>Why use HOF?</h4><ul><li>Reusability</li><li>Cleaner logic</li><li>Functional style</li></ul><h4>Inline Functions</h4><p>Used to <strong>avoid lambda overhead</strong></p><pre>inline fun execute(action: () -&gt; Unit) {<br>    action()<br>}</pre><p>Usage:</p><pre>execute {<br>    println(&quot;Hello&quot;)<br>}</pre><p>Compiler replaces function call → no lambda object</p><h4>Why use inline?</h4><ul><li>Removes lambda allocation</li><li>Improves performance (hot paths)</li></ul><h4>Use Extension when:</h4><ul><li>You want <strong>clean syntax</strong></li><li>Utility tied to a type</li></ul><p>👉 Example: String.isValidEmail()</p><h4>Use HOF when:</h4><ul><li>You want <strong>flexible behavior</strong></li><li>Reusable logic (callbacks, APIs)</li></ul><p>👉 Example: safeApiCall {}</p><h4>Use Inline when:</h4><ul><li>HOF is used <strong>frequently</strong></li><li>Performance matters (loops, Compose)</li></ul><p>👉 Example: forEach, Compose lambdas</p><h4>7. Explain data class, sealed class, and enum class — and when to use each.</h4><p><strong>data class</strong> — auto-generates equals(), hashCode(), copy(), toString(), componentN(). Best for DTOs/models.<br><strong>sealed class </strong>— restricted class hierarchy, all subclasses known at compile time. Enables exhaustive when expressions. Perfect for UI state (Loading, Success, Error) or Result wrappers.<br><strong>enum class</strong> — fixed set of constants with identity. All instances are singletons. Less flexible than sealed — can’t carry different data per variant.</p><h4>8. Explain let, run, apply, also, with — the scope functions. How do you choose?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zLwZc0FvjsNdvSNK3em2kw.png" /></figure><h3>let</h3><p>Use when:</p><ul><li>Handling nullable objects</li><li>Performing transformations</li><li>Avoiding repeated object names</li></ul><pre>val name: String? = &quot;Arindam&quot;<br><br>name?.let {<br>    println(&quot;Length = ${it.length}&quot;)<br>}</pre><h3>run</h3><p>Use when:</p><ul><li>Need multiple operations on an object</li><li>Want to return a computed value</li></ul><pre>val result = &quot;Android&quot;.run {<br>    println(length)<br>    uppercase()<br>}<br><br>println(result)</pre><h3>apply</h3><p>Use when:</p><ul><li>Configuring or initializing objects</li></ul><pre>val paint = Paint().apply {<br>    color = Color.RED<br>    strokeWidth = 10f<br>    isAntiAlias = true<br>}</pre><h3>also</h3><p>Use when:</p><ul><li>Performing side effects</li><li>Logging</li><li>Debugging</li><li>Analytics</li></ul><pre>val numbers = mutableListOf(1, 2, 3)<br>    .also {<br>        println(&quot;Before: $it&quot;)<br>    }</pre><h3>with</h3><p>Use when:</p><ul><li>Object already exists</li><li>Need to call multiple methods on it</li></ul><pre>val user = User(&quot;Arindam&quot;, 30)<br><br>with(user) {<br>    println(name)<br>    println(age)<br>}</pre><h4>9. What is object, companion object, and how are they different from static in Java?</h4><p><strong>object declaration </strong>— creates a singleton class. Thread-safe, lazy on first access. Use for utility classes, DAOs.<br><strong>companion object</strong> — lives inside a class, accessed via the class name. Replaces Java static. Can implement interfaces. Members are NOT truly static — they compile to a companion class instance, but @JvmStatic makes them truly static for Java interop.<br><strong>object expression </strong>— anonymous object, replaces Java anonymous classes (e.g. listeners)</p><h4>10. What is a suspend function? How is it different from a regular async call?</h4><p>A suspend function can pause execution without blocking the thread. The compiler transforms it using a state machine with a Continuation parameter — it saves the call stack and resumes when ready. Unlike callbacks or RxJava, the code looks synchronous but runs asynchronously. Unlike threads, suspending is cheap — no OS context switch.</p><pre>// Looks synchronous, runs async<br>suspend fun fetchUser(id: String): User {<br>    val token = authRepo.getToken()     // suspends here<br>    return apiService.getUser(token, id) // suspends here<br>}<br><br>// Under the hood, compiler generates roughly:<br>fun fetchUser(id: String, cont: Continuation&lt;User&gt;) {<br>    // state machine with labels 0, 1, 2...<br>}</pre><h4>11. What is the difference between launch and async?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nX0mI10gx1bY_L4sMBbQgw.png" /></figure><h4>12. Explain Dispatchers — IO, Main, Default, Unconfined. Which do you use when?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sAckE_1lSVfS37d9hAnnZA.png" /></figure><h4>13. Explain data class, sealed class, and enum class — and when to use each.</h4><p><strong>data class</strong> — auto-generates equals(), hashCode(), copy(), toString(), componentN(). Best for DTOs/models.</p><p><strong>sealed class</strong> — restricted class hierarchy, all subclasses known at compile time. Enables exhaustive when expressions. Perfect for UI state (Loading, Success, Error) or Result wrappers.</p><p><strong>enum class</strong> — fixed set of constants with identity. All instances are singletons. Less flexible than sealed — can’t carry different data per variant.</p><h4>14. How does ViewModel survive configuration changes like screen rotation?</h4><p>ViewModel is stored in a ViewModelStore which is retained by the system across config changes. The Activity/Fragment is destroyed and recreated, but ViewModelStore is not. The new Activity gets the same ViewModel instance from the store.</p><p>ViewModel is only cleared when the Activity finishes for real (user presses back, or finish() is called) — at which point onCleared() is called. This is where you cancel coroutines or close resources.</p><pre>// ViewModelStore survives rotation:<br>// Activity destroyed → recreated → ViewModelProvider returns SAME instance<br>val vm: MyViewModel by viewModels()<br><br>// ViewModel cleared only on real finish:<br>override fun onCleared() {<br>    super.onCleared()<br>    // cancel subscriptions, close DB connections<br>}</pre><h4>15. How do I handle onPause() and onResume() in Jetpack Compose? Since Compose typically uses a Single Activity architecture, what&#39;s the equivalent way to observe Activity lifecycle events inside a Composable?</h4><p>No, a Composable cannot override onPause() or onResume() because it is a function, not a lifecycle-aware component. Lifecycle callbacks belong to Activities and Fragments. In Jetpack Compose, lifecycle events are observed using LocalLifecycleOwner and LifecycleEventObserver, while screen entry and exit are typically handled using LaunchedEffect and DisposableEffect. Even in a Single Activity architecture, the Activity lifecycle still exists and can be overridden normally when needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z-OywqS01d0Ct9lzyRoRAw.png" /></figure><p>Then how do Composables know about lifecycle events?</p><p>Compose provides access to the lifecycle through:</p><pre>LocalLifecycleOwner.current</pre><p>This gives the current LifecycleOwner (usually the Activity or NavBackStackEntry).</p><p>You can observe lifecycle events using:</p><pre>LifecycleEventObserver</pre><p>Example:</p><pre>@Composable<br>fun HomeScreen() {<br><br>    val lifecycleOwner = LocalLifecycleOwner.current<br><br>    DisposableEffect(lifecycleOwner) {<br><br>        val observer = LifecycleEventObserver { _, event -&gt;<br><br>            when(event) {<br><br>                Lifecycle.Event.ON_RESUME -&gt; {<br>                    println(&quot;Screen Resumed&quot;)<br>                }<br><br>                Lifecycle.Event.ON_PAUSE -&gt; {<br>                    println(&quot;Screen Paused&quot;)<br>                }<br><br>                else -&gt; Unit<br>            }<br>        }<br><br>        lifecycleOwner.lifecycle.addObserver(observer)<br><br>        onDispose {<br>            lifecycleOwner.lifecycle.removeObserver(observer)<br>        }<br>    }<br>}</pre><p>This is the Compose equivalent of:</p><pre>override fun onResume() {<br>}<br><br>override fun onPause() {<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39448b764fd9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Side Effeects in Jetpack Compose-Complete Explanation]]></title>
            <link>https://medium.com/@meaghosh/side-effeects-in-jetpack-compose-complete-explanation-46a97bac382f?source=rss-40464c9971b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/46a97bac382f</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[side-effects]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <dc:creator><![CDATA[Arindam Ghosh]]></dc:creator>
            <pubDate>Tue, 02 Jun 2026 05:47:31 GMT</pubDate>
            <atom:updated>2026-06-02T05:47:31.550Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wx7KiJT01L0SN5aS4TX_7Q.png" /></figure><h4>Side Effects in Jetpack Compose — Complete Explanation</h4><p>One of the biggest mindset shifts when moving from XML + Activity/Fragment to Compose is understanding <strong>side effects</strong>.</p><h4>What is a Side Effect?</h4><p>A <strong>side effect</strong> is any operation that affects something outside the composable function</p><p>Examples:</p><p>✅ API call<br> ✅ Database query<br> ✅ Show Toast<br> ✅ Navigation<br> ✅ Logging<br> ✅ Starting a coroutine<br> ✅ Registering listeners<br> ✅ Analytics events</p><p>Not side effects:</p><pre>Text(&quot;Hello&quot;)<br>val name = &quot;Arindam&quot;</pre><p>These simply describe UI.</p><h4>Why do we need Side Effect APIs?</h4><p>Composable functions can be called many times.</p><p>If you do this:</p><pre>@Composable<br>fun MyScreen() {<br><br>    apiCall()<br><br>    Text(&quot;Hello&quot;)<br>}</pre><p>Every recomposition will trigger:</p><pre>API Call<br>API Call<br>API Call<br>API Call</pre><p>Which is a disaster.</p><p>Compose therefore provides special APIs to safely perform side effects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X0mKpPAreSfep3eH-EjMfQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hM7AfhbwCHVkPbkutIIx1g.png" /></figure><h4>1.LaunchedEffect</h4><p>Runs a coroutine tied to the composable lifecycle.</p><pre>@Composable<br>fun HomeScreen() {<br><br>    LaunchedEffect(Unit) {<br>        println(&quot;Runs once&quot;)<br>    }<br>}</pre><p>Output:</p><pre>Runs once</pre><blockquote><strong>Even if recomposition happens Still only once</strong></blockquote><h4>Key-based LaunchedEffect</h4><pre>LaunchedEffect(userId) {<br><br>    viewModel.loadUser(userId)<br>}</pre><p>when userId = 1 it will run. if userId=2 (changes) it will run</p><blockquote><strong>Previous coroutine cancel, New coroutine start</strong></blockquote><h4>2.DisposableEffect</h4><p>Used when you need cleanup. and you need to remove listner</p><p>Example:</p><pre>DisposableEffect(lifecycleOwner) {<br><br>    val observer = LifecycleEventObserver { _, event -&gt;<br>    }<br><br>    lifecycleOwner.lifecycle.addObserver(observer)<br><br>    onDispose {<br>        lifecycleOwner.lifecycle.removeObserver(observer)<br>    }<br>}</pre><h4>3.SideEffect</h4><p>Runs after every successful recomposition.</p><pre>SideEffect {<br>    println(&quot;Recomposed&quot;)<br>}</pre><p>whenever state change:</p><pre>Recomposed<br>Recomposed<br>Recomposed</pre><h4>Use Cases</h4><p>Update external objects.</p><pre>SideEffect {<br>    analytics.setUser(user.name)<br>}</pre><blockquote><strong>like Analytics SDK or needs synchronization</strong></blockquote><h4>4.derivedStateOf</h4><p>Optimization API.</p><p>Imagine:</p><pre>val fullName =<br>    firstName + lastName</pre><p>Without optimization:</p><pre>fullName</pre><p>recalculates often.</p><p>Use:</p><pre>val fullName by remember {<br>    derivedStateOf {<br>        &quot;$firstName $lastName&quot;<br>    }<br>}</pre><blockquote><strong>Recomputes only when dependencies change.</strong></blockquote><h4>5.rememberCoroutineScope</h4><p>Launch coroutine from UI events.</p><p>Wrong:</p><pre>Button(<br>    onClick = {<br>        launch {<br>        }<br>    }<br>)</pre><p>No scope available.</p><p>Use:</p><pre>val scope = rememberCoroutineScope()<br><br>Button(<br>    onClick = {<br>        scope.launch {<br>            snackbarHostState.showSnackbar(&quot;Saved&quot;)<br>        }<br>    }<br>)</pre><h4>Use Cases</h4><ul><li>Button click</li><li>Snackbar</li><li>Navigation</li><li>User interactions</li></ul><h4>6.rememberUpdatedState</h4><p>One of the most misunderstood APIs.</p><p>Problem:</p><pre>LaunchedEffect(Unit) {<br><br>    delay(5000)<br><br>    onTimeout()<br>}</pre><p>Suppose onTimeout changes during recomposition. Coroutine still holds old reference.</p><p>Fix:</p><pre>val currentOnTimeout by rememberUpdatedState(onTimeout)<br><br>LaunchedEffect(Unit) {<br><br>    delay(5000)<br><br>    currentOnTimeout()<br>}</pre><p>Always get latest value</p><h4>Use Cases</h4><ul><li>Long-running coroutine</li><li>Timers</li><li>Delays</li><li>Callbacks</li></ul><h4>7.produceState</h4><p>Convert external data into Compose State.</p><p>Example:</p><pre>val user by produceState&lt;User?&gt;(null) {<br><br>    value = repository.getUser()<br>}</pre><p>now User become compose state</p><h4>Use Cases</h4><ul><li>API calls</li><li>Repository data</li><li>Callback APIs</li></ul><h4>8.snapshotFlow</h4><p>Convert Compose State → Flow</p><pre>snapshotFlow {<br>    searchText<br>}<br>.collect {<br>    println(it)<br>}</pre><p>Whenever seachText chnages</p><pre>A<br>Ar<br>Ari<br>Arin<br>Arindam</pre><p>emited as a flow</p><h4>Use Cases</h4><ul><li>Search</li><li>Analytics</li><li>Debounce</li><li>Paging</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46a97bac382f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Clean Architecture with MVVM & MVI — A Complete Guide (Bloc + Cubit)]]></title>
            <link>https://medium.com/@meaghosh/flutter-clean-architecture-with-mvvm-mvi-a-complete-guide-bloc-cubit-49f1c7c21849?source=rss-40464c9971b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/49f1c7c21849</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[cubit]]></category>
            <category><![CDATA[bloc-cubit]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Arindam Ghosh]]></dc:creator>
            <pubDate>Sun, 31 May 2026 09:48:48 GMT</pubDate>
            <atom:updated>2026-05-31T09:48:48.098Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*liZqjLcmBfvleb1HLwyo2A.png" /></figure><p><em>If you’re coming from Android development and want to build Flutter apps the right way — this guide is for you.</em></p><h3>Why This Article?</h3><p>I recently migrated an Android project built with <strong>Clean Architecture + MVVM + MVI</strong> (using Kotlin, ViewModel, StateFlow, and Hilt) to Flutter. The concepts are identical — only the tools change.</p><p>This article walks you through the complete Flutter equivalent, side by side with Android, so you can map everything you already know.</p><p>By the end you’ll have a working <strong>Coin App</strong> that fetches live crypto data from CoinPaprika and demonstrates both MVVM (Cubit) and MVI (Bloc) in the same project.</p><h3>The Android → Flutter Mental Map</h3><p>Before writing a single line of code, understand this mapping:</p><p>Android (Kotlin)Flutter (Dart)PurposeViewModelCubit / BlocState managementStateFlowBlocBuilderReactive UI updatesHiltget_it + injectableDependency injectionRetrofitDioHTTP networkingdata classFreezed abstract classImmutable modelssealed classFreezed unionState variantsCoinIntentCoinEventUser actions (MVI)@Inject@injectableDI annotation@Singleton@lazySingletonSingleton scope@Binds@LazySingleton(as: X)Interface binding@Module @Provides@moduleExternal dependencies</p><h3>Architecture — 3 Layers</h3><p>Clean Architecture is the same in Flutter as Android. Three layers, each with a single responsibility:</p><pre>┌─────────────────────────────────────┐<br>│         Presentation Layer          │<br>│   Cubit (MVVM) │ Bloc (MVI)  │ UI  │<br>└────────────────┬────────────────────┘<br>                 │ calls<br>┌────────────────▼────────────────────┐<br>│           Domain Layer              │<br>│   UseCases │ Models │ Repository    │<br>│              Interface              │<br>└────────────────┬────────────────────┘<br>                 │ implements<br>┌────────────────▼────────────────────┐<br>│            Data Layer               │<br>│   API │ DTO │ Mapper │ Repository   │<br>│              Impl                   │<br>└─────────────────────────────────────┘</pre><p><strong>Golden rule:</strong> Each layer only knows about the layer below it. The domain layer knows nothing about the API or UI. This is the whole point of Clean Architecture.</p><h3>Project Structure</h3><pre>lib/<br>├── data/<br>│   ├── remote/<br>│   │   ├── api/<br>│   │   │   └── coin_api.dart<br>│   │   └── dto/<br>│   │       └── coin_dto.dart<br>│   ├── mapper/<br>│   │   └── coin_mapper.dart<br>│   └── repository/<br>│       └── coin_repository_impl.dart<br>│<br>├── domain/<br>│   ├── model/<br>│   │   └── coin_domain_model.dart<br>│   ├── repository/<br>│   │   └── coin_repository.dart<br>│   └── usecase/<br>│       └── get_coins_usecase.dart<br>│<br>├── presentation/<br>│   ├── cubit/<br>│   │   ├── coin_cubit.dart<br>│   │   └── coin_state.dart<br>│   ├── bloc/<br>│   │   ├── coin_bloc.dart<br>│   │   ├── coin_event.dart<br>│   │   └── coin_state.dart<br>│   └── screens/<br>│       └── coin_screen.dart<br>│<br>└── di/<br>    └── injection.dart</pre><h3>Dependencies — pubspec.yaml</h3><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  flutter_bloc: ^9.1.1<br>  get_it: ^9.2.1<br>  injectable: ^3.0.0<br>  dio: ^5.7.0<br>  freezed_annotation: ^3.1.0<br>  json_annotation: ^4.9.0</pre><pre>dev_dependencies:<br>  flutter_test:<br>    sdk: flutter<br>  build_runner: ^2.15.0<br>  freezed: ^3.2.5<br>  injectable_generator: ^3.0.2<br>  json_serializable: ^6.9.5</pre><h3>Data Layer</h3><h3>1. DTO — Raw API Response Model</h3><p>The DTO maps directly to the JSON shape from the API. It knows nothing about your business logic.</p><blockquote><em>⚠️ </em><strong><em>Important Freezed 3.x gotcha:</em></strong><em> Always use </em><em>abstract class — not just </em><em>class. Without </em><em>abstract, you&#39;ll get a cryptic &quot;missing implementations&quot; error.</em></blockquote><pre>import &#39;package:freezed_annotation/freezed_annotation.dart&#39;;</pre><pre>part &#39;coin_dto.freezed.dart&#39;;<br>part &#39;coin_dto.g.dart&#39;;</pre><pre>@freezed<br>abstract class CoinDto with _$CoinDto {<br>  const factory CoinDto({<br>    @JsonKey(name: &#39;id&#39;) required String id,<br>    @JsonKey(name: &#39;name&#39;) required String name,<br>    @JsonKey(name: &#39;symbol&#39;) required String symbol,<br>    @JsonKey(name: &#39;rank&#39;) required int rank,<br>    @JsonKey(name: &#39;is_new&#39;) @Default(false) bool isNew,<br>    @JsonKey(name: &#39;is_active&#39;) @Default(true) bool isActive,<br>    @JsonKey(name: &#39;type&#39;) @Default(&#39;&#39;) String type,<br>  }) = _CoinDto;</pre><pre>  factory CoinDto.fromJson(Map&lt;String, dynamic&gt; json) =&gt;<br>      _$CoinDtoFromJson(json);<br>}</pre><p>This is the Flutter equivalent of a Kotlin data class annotated with @SerializedName.</p><h3>2. API Client — Dio</h3><pre>import &#39;package:dio/dio.dart&#39;;<br>import &#39;package:injectable/injectable.dart&#39;;<br>import &#39;../dto/coin_dto.dart&#39;;</pre><pre>@injectable<br>class CoinApi {<br>  final Dio _dio;</pre><pre>  CoinApi(this._dio);</pre><pre>  // Android equivalent:<br>  // @GET(&quot;coins&quot;)<br>  // suspend fun getCoins(): List&lt;CoinDto&gt;<br>  Future&lt;List&lt;CoinDto&gt;&gt; getCoins() async {<br>    final response = await _dio.get(&#39;coins&#39;);<br>    final List&lt;dynamic&gt; data = response.data;<br>    return data.map((json) =&gt; CoinDto.fromJson(json)).toList();<br>  }<br>}</pre><h3>3. Mapper — DTO to Domain</h3><p>The mapper keeps layers decoupled. The API shape can change without touching domain logic.</p><pre>import &#39;../remote/dto/coin_dto.dart&#39;;<br>import &#39;../../domain/model/coin_domain_model.dart&#39;;</pre><pre>class CoinMapper {<br>  static CoinDomainModel toDomain(CoinDto dto) {<br>    return CoinDomainModel(<br>      id: dto.id,<br>      name: dto.name,<br>      symbol: dto.symbol,<br>      rank: dto.rank,<br>      isActive: dto.isActive,<br>      type: dto.type,<br>    );<br>  }</pre><pre>  static List&lt;CoinDomainModel&gt; toDomainList(List&lt;CoinDto&gt; dtos) {<br>    return dtos.map((dto) =&gt; toDomain(dto)).toList();<br>  }<br>}</pre><h3>4. Repository Implementation</h3><pre>import &#39;package:injectable/injectable.dart&#39;;<br>import &#39;../remote/api/coin_api.dart&#39;;<br>import &#39;../mapper/coin_mapper.dart&#39;;<br>import &#39;../../domain/model/coin_domain_model.dart&#39;;<br>import &#39;../../domain/repository/coin_repository.dart&#39;;</pre><pre>// @LazySingleton(as: CoinRepository) tells get_it:<br>// &quot;When someone asks for CoinRepository, give them THIS&quot;<br>// Android equivalent: @Binds in a Hilt module<br>@LazySingleton(as: CoinRepository)<br>class CoinRepositoryImpl implements CoinRepository {<br>  final CoinApi _api;</pre><pre>  CoinRepositoryImpl(this._api);</pre><pre>  @override<br>  Future&lt;List&lt;CoinDomainModel&gt;&gt; getCoins() async {<br>    final dtos = await _api.getCoins();<br>    return CoinMapper.toDomainList(dtos);<br>  }<br>}</pre><h3>Domain Layer</h3><h3>1. Domain Model — Pure Business Entity</h3><pre>import &#39;package:freezed_annotation/freezed_annotation.dart&#39;;</pre><pre>part &#39;coin_domain_model.freezed.dart&#39;;</pre><pre>@freezed<br>abstract class CoinDomainModel with _$CoinDomainModel {<br>  const factory CoinDomainModel({<br>    required String id,<br>    required String name,<br>    required String symbol,<br>    required int rank,<br>    required bool isActive,<br>    required String type,<br>  }) = _CoinDomainModel;<br>}</pre><p>No @JsonKey, no fromJson — this is a <strong>pure domain object</strong>. It knows nothing about APIs or databases.</p><h3>2. Repository Interface</h3><pre>import &#39;../model/coin_domain_model.dart&#39;;</pre><pre>// Domain defines the CONTRACT<br>// Data layer provides the IMPLEMENTATION<br>// This is Dependency Inversion<br>abstract class CoinRepository {<br>  Future&lt;List&lt;CoinDomainModel&gt;&gt; getCoins();<br>}</pre><h3>3. Use Case</h3><pre>import &#39;package:injectable/injectable.dart&#39;;<br>import &#39;../model/coin_domain_model.dart&#39;;<br>import &#39;../repository/coin_repository.dart&#39;;</pre><pre>@injectable<br>class GetCoinsUseCase {<br>  final CoinRepository _repository;</pre><pre>  GetCoinsUseCase(this._repository);</pre><pre>  // callable like a function: getCoinsUseCase()<br>  Future&lt;List&lt;CoinDomainModel&gt;&gt; call() async {<br>    return await _repository.getCoins();<br>  }<br>}</pre><h3>Presentation Layer</h3><h3>Cubit vs Bloc — Understanding the Difference</h3><p>This is the key concept of the whole article.</p><p><strong>Cubit = MVVM</strong></p><p>The UI calls functions directly, just like calling viewModel.loadCoins() in Android.</p><pre>// UI calls function directly<br>context.read&lt;CoinCubit&gt;().fetchCoins();</pre><pre>// Android equivalent:<br>// viewModel.loadCoins()</pre><p><strong>Bloc = MVI</strong></p><p>The UI sends Events (Intents). The Bloc processes them. This is the unidirectional flow of MVI.</p><pre>// UI sends an Event<br>context.read&lt;CoinBloc&gt;().add(FetchCoins());</pre><pre>// Android equivalent:<br>// viewModel.onIntent(CoinIntent.FetchCoins)</pre><p>Cubit (MVVM)Bloc (MVI)UI triggersDirect function callSends an EventBoilerplateLessMoreTraceabilityModerateFull event logBest forSimple screensComplex interactions</p><h3>1. Cubit — MVVM Style</h3><p><strong>State:</strong></p><pre>import &#39;package:freezed_annotation/freezed_annotation.dart&#39;;<br>import &#39;../../domain/model/coin_domain_model.dart&#39;;</pre><pre>part &#39;coin_state.freezed.dart&#39;;</pre><pre>@freezed<br>abstract class CoinState with _$CoinState {<br>  const factory CoinState.initial() = CoinInitial;<br>  const factory CoinState.loading() = CoinLoading;<br>  const factory CoinState.loaded(List&lt;CoinDomainModel&gt; coins) = CoinLoaded;<br>  const factory CoinState.error(String message) = CoinError;<br>}</pre><p><strong>Cubit:</strong></p><pre>import &#39;package:flutter_bloc/flutter_bloc.dart&#39;;<br>import &#39;package:injectable/injectable.dart&#39;;<br>import &#39;../../domain/usecase/get_coins_usecase.dart&#39;;<br>import &#39;coin_state.dart&#39;;</pre><pre>@injectable<br>class CoinCubit extends Cubit&lt;CoinState&gt; {<br>  final GetCoinsUseCase _getCoinsUseCase;</pre><pre>  CoinCubit(this._getCoinsUseCase) : super(const CoinState.initial());</pre><pre>  // UI calls this directly — like viewModel.loadCoins()<br>  Future&lt;void&gt; fetchCoins() async {<br>    emit(const CoinState.loading());<br>    try {<br>      final coins = await _getCoinsUseCase();<br>      emit(CoinState.loaded(coins));<br>    } catch (e) {<br>      emit(CoinState.error(e.toString()));<br>    }<br>  }<br>}</pre><h3>2. Bloc — MVI Style</h3><p><strong>Events (= Intents in Android MVI):</strong></p><pre>import &#39;package:freezed_annotation/freezed_annotation.dart&#39;;</pre><pre>part &#39;coin_event.freezed.dart&#39;;</pre><pre>@freezed<br>abstract class CoinEvent with _$CoinEvent {<br>  // Android equivalent: CoinIntent.FetchCoins<br>  const factory CoinEvent.fetchCoins() = FetchCoins;<br>  const factory CoinEvent.refresh() = Refresh;<br>  const factory CoinEvent.search(String query) = Search;<br>}</pre><p><strong>Bloc:</strong></p><pre>import &#39;package:flutter_bloc/flutter_bloc.dart&#39;;<br>import &#39;package:injectable/injectable.dart&#39;;<br>import &#39;../../domain/usecase/get_coins_usecase.dart&#39;;<br>import &#39;coin_event.dart&#39;;<br>import &#39;coin_state.dart&#39;;</pre><pre>@injectable<br>class CoinBloc extends Bloc&lt;CoinEvent, CoinState&gt; {<br>  final GetCoinsUseCase _getCoinsUseCase;</pre><pre>  CoinBloc(this._getCoinsUseCase) : super(const CoinState.initial()) {<br>    on&lt;FetchCoins&gt;(_onFetchCoins);<br>    on&lt;Refresh&gt;(_onRefresh);<br>    on&lt;Search&gt;(_onSearch);<br>  }</pre><pre>  Future&lt;void&gt; _onFetchCoins(<br>    FetchCoins event,<br>    Emitter&lt;CoinState&gt; emit,<br>  ) async {<br>    emit(const CoinState.loading());<br>    try {<br>      final coins = await _getCoinsUseCase();<br>      emit(CoinState.loaded(coins));<br>    } catch (e) {<br>      emit(CoinState.error(e.toString()));<br>    }<br>  }</pre><pre>  Future&lt;void&gt; _onRefresh(Refresh event, Emitter&lt;CoinState&gt; emit) async {<br>    emit(const CoinState.loading());<br>    try {<br>      final coins = await _getCoinsUseCase();<br>      emit(CoinState.loaded(coins));<br>    } catch (e) {<br>      emit(CoinState.error(e.toString()));<br>    }<br>  }</pre><pre>  Future&lt;void&gt; _onSearch(Search event, Emitter&lt;CoinState&gt; emit) async {<br>    final currentState = state;<br>    if (currentState is CoinLoaded) {<br>      final filtered = currentState.coins<br>          .where((coin) =&gt;<br>              coin.name.toLowerCase().contains(event.query.toLowerCase()) ||<br>              coin.symbol.toLowerCase().contains(event.query.toLowerCase()))<br>          .toList();<br>      emit(CoinState.loaded(filtered));<br>    }<br>  }<br>}</pre><h3>Dependency Injection — get_it + injectable</h3><p>This replaces Hilt in Android. Same concept: annotate classes, generate wiring code.</p><pre>import &#39;package:dio/dio.dart&#39;;<br>import &#39;package:get_it/get_it.dart&#39;;<br>import &#39;package:injectable/injectable.dart&#39;;</pre><pre>part &#39;injection.config.dart&#39;;</pre><pre>final getIt = GetIt.instance;</pre><pre>@InjectableInit(<br>  initializerName: &#39;init&#39;,<br>  preferRelativeImports: true,<br>  asExtension: true,<br>)<br>Future&lt;void&gt; configureDependencies() async =&gt; getIt.init();</pre><pre>@module<br>abstract class NetworkModule {<br>  @lazySingleton<br>  Dio get dio =&gt; Dio(<br>        BaseOptions(<br>          baseUrl: &#39;https://api.coinpaprika.com/v1/&#39;,<br>          connectTimeout: const Duration(seconds: 30),<br>          receiveTimeout: const Duration(seconds: 30),<br>        ),<br>      )..interceptors.add(LogInterceptor(responseBody: true));<br>}</pre><p>build_runner generates injection.config.dart automatically — just like Hilt generates the @Component code in Android.</p><h3>UI — BlocBuilder</h3><pre>// MVVM — Cubit<br>BlocBuilder&lt;CoinCubit, CoinState&gt;(<br>  builder: (context, state) {<br>    return state.when(<br>      initial: () =&gt; const SizedBox(),<br>      loading: () =&gt; const CircularProgressIndicator(),<br>      loaded: (coins) =&gt; ListView.builder(<br>        itemCount: coins.length,<br>        itemBuilder: (_, i) =&gt; CoinCard(coin: coins[i]),<br>      ),<br>      error: (msg) =&gt; Text(msg),<br>    );<br>  },<br>)</pre><pre>// MVI — Bloc<br>BlocBuilder&lt;CoinBloc, CoinState&gt;(<br>  builder: (context, state) {<br>    return state.when(<br>      initial: () =&gt; const SizedBox(),<br>      loading: () =&gt; const CircularProgressIndicator(),<br>      loaded: (coins) =&gt; ListView.builder(<br>        itemCount: coins.length,<br>        itemBuilder: (_, i) =&gt; CoinCard(coin: coins[i]),<br>      ),<br>      error: (msg) =&gt; Text(msg),<br>    );<br>  },<br>)</pre><p>The .when() pattern is exactly like Kotlin&#39;s when(state) — exhaustive pattern matching over sealed states.</p><h3>Code Generation</h3><p>This is the equivalent of <strong>kapt/ksp</strong> in Android. Run whenever you add or change a Freezed class or injectable annotation:</p><pre># First time setup<br>flutter pub get<br>dart run build_runner build</pre><pre># After any model/annotation change<br>dart run build_runner clean<br>dart run build_runner build</pre><h3>Common Gotchas</h3><h3>1. Freezed 3.x requires abstract class</h3><pre>// ❌ Causes &quot;missing implementations&quot; error<br>@freezed<br>class CoinDomainModel with _$CoinDomainModel { ... }</pre><pre>// ✅ Correct for Freezed 3.x<br>@freezed<br>abstract class CoinDomainModel with _$CoinDomainModel { ... }</pre><h3>2. Part declaration vs import for injection.config.dart</h3><p>The generated injection.config.dart must use part &#39;injection.config.dart&#39; (not import) in your injection.dart. If it&#39;s missing the part ofdeclaration, run build_runner clean then build_runner build.</p><h3>3. SDK version in pubspec.yaml</h3><p>Make sure your SDK constraint matches your installed Dart version:</p><pre>environment:<br>  sdk: &#39;&gt;=3.12.0 &lt;4.0.0&#39;  # match your dart --version output</pre><h3>Data Flow Summary</h3><pre>User taps refresh<br>  ↓<br>context.read&lt;CoinBloc&gt;().add(FetchCoins())   [MVI]<br>  or<br>context.read&lt;CoinCubit&gt;().fetchCoins()        [MVVM]<br>  ↓<br>GetCoinsUseCase.call()<br>  ↓<br>CoinRepository.getCoins()                     [interface]<br>  ↓<br>CoinRepositoryImpl.getCoins()                 [implementation]<br>  ↓<br>CoinApi.getCoins()                            [Dio HTTP call]<br>  ↓<br>List&lt;CoinDto&gt;                                 [raw JSON]<br>  ↓<br>CoinMapper.toDomainList()                     [DTO → Domain]<br>  ↓<br>emit(CoinState.loaded(coins))<br>  ↓<br>BlocBuilder rebuilds UI</pre><h3>Final Thoughts</h3><p>Clean Architecture is language-agnostic. The patterns you know from Android — MVVM, MVI, UseCases, Repository pattern, DI — translate directly to Flutter. The tools change but the thinking stays the same.</p><p><strong>Key takeaways:</strong></p><ol><li>Domain layer is the heart — it knows nothing about the outside world</li><li>Cubit for simple screens (MVVM), Bloc for complex interactions (MVI)</li><li>Freezed 3.x requires abstract class — don&#39;t forget this</li><li>build_runner is your kapt/ksp equivalent — run it after every model change</li><li>get_it + injectable = Hilt, just with explicit annotations and code generation</li></ol><p><em>The full source code is available on GitHub: </em><a href="https://github.com/arindam9851/Flutter-CleanArchitecture-Bloc-Cubit"><em>Flutter-CleanArchitecture-with-MVI-MVVM</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49f1c7c21849" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Coroutine Cancellation in Kotlin — Complete Guide with Real Android Examples]]></title>
            <link>https://medium.com/@meaghosh/understanding-coroutine-cancellation-in-kotlin-complete-guide-with-real-android-examples-391a52ad8d8d?source=rss-40464c9971b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/391a52ad8d8d</guid>
            <category><![CDATA[cancel-coroutine]]></category>
            <category><![CDATA[supervisor-jobs]]></category>
            <category><![CDATA[kotlin-coroutines]]></category>
            <category><![CDATA[kotlin-beginners]]></category>
            <dc:creator><![CDATA[Arindam Ghosh]]></dc:creator>
            <pubDate>Fri, 29 May 2026 05:03:09 GMT</pubDate>
            <atom:updated>2026-05-29T05:03:09.518Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-gN3Afb--XKgNv_2GRm0sw.png" /></figure><p>When Android developers start using Kotlin Coroutines, most learn:</p><pre>viewModelScope.launch { }</pre><p>But very few truly understand how coroutine cancellation works internally.</p><p>And cancellation is one of the most important concepts in real-world Android apps.</p><p>Without proper cancellation handling:</p><ul><li>Multiple API calls run unnecessarily</li><li>Memory leaks happen</li><li>Old search results overwrite new ones</li><li>Background tasks continue after screen destruction</li><li>App performance suffers</li></ul><p>In this article, we’ll deeply understand:</p><ul><li>Job cancellation</li><li>Scope cancellation</li><li>Parent-child cancellation</li><li>coroutineScope</li><li>supervisorScope</li><li>Cooperative cancellation</li><li>CancellationException</li><li>Timeout cancellation</li><li>Real production use cases</li></ul><h3>What is Coroutine Cancellation?</h3><p>Coroutine cancellation means:</p><blockquote><em>Stopping a coroutine before it completes.</em></blockquote><p>Coroutines are designed to be lightweight and lifecycle-aware.</p><p>Unlike Threads, coroutines support structured concurrency and automatic cancellation propagation.</p><h3>1. Job Cancellation</h3><p>The simplest type of cancellation.</p><pre>private var loadJob: Job? = null<br><br>fun loadData(){<br>  loadJob?.cancel()<br><br>  loadJob = viewModelScope.launch{<br><br>  delay(500)<br><br>  println (&quot;API Completed&quot;)<br><br>  }<br>}</pre><h3>What happens here?</h3><p>When loadData() is called again:</p><ul><li>Previous coroutine gets cancelled</li><li>New coroutine starts</li></ul><h3>Real Android Use Case</h3><p>Perfect for:</p><ul><li>Search APIs</li><li>Retry button</li><li>Pagination</li><li>Debounce</li><li>Latest-request-only architecture</li></ul><h3>Example: Search API</h3><pre>private var searchJob: Job? = null<br><br>fun search(query: String) {<br>    searchJob?.cancel()<br><br>    searchJob = viewModelScope.launch {<br><br>        delay(500)<br><br>        repository.search(query)<br>    }<br>}</pre><h3>Why?</h3><p>If user types:</p><pre>a<br>an<br>and<br>andr<br>andro<br>android</pre><p>Without cancellation:</p><ul><li>6 API calls happen</li></ul><p>With cancellation:</p><ul><li>Only latest request executes</li></ul><p>This is a real production pattern.</p><h3>2. Scope Cancellation</h3><p>When a scope cancels:</p><ul><li>All child coroutines cancel automatically.</li></ul><p>Example:</p><pre>viewModelScope.launch {<br><br>launch {<br>        delay(5000)<br><br>        println(&quot;Task 1&quot;)<br>    }<br>    launch {<br>        delay(5000)<br><br>        println(&quot;Task 2&quot;)<br>    }<br>}</pre><p>If:</p><pre>viewModelScope.cancel()</pre><p>Both child coroutines cancel.</p><h3>Why This Matters</h3><p>This is called:</p><h3>Structured Concurrency</h3><p>Kotlin ensures:</p><ul><li>parent controls children</li><li>no orphan coroutines</li><li>safer concurrency</li></ul><h3>3. Parent-Child Cancellation</h3><p>By default:</p><p>If one child fails,<br>all siblings cancel.</p><p>Example:</p><pre>coroutineScope {<br><br>    launch {<br>        throw Exception(&quot;API Failed&quot;)<br>    }<br><br>    launch {<br>        delay(5000)<br><br>        println(&quot;Second API&quot;)<br>    }<br>}</pre><p>Result:</p><ul><li>Second coroutine also cancels</li></ul><h3>Why?</h3><p>Because coroutineScope follows structured concurrency strictly.</p><p>This prevents inconsistent state.</p><h3>4. supervisorScope</h3><p>One of the most important coroutine concepts.</p><p>Example:</p><pre>supervisorScope {<br><br>launch {<br>        throw Exception(&quot;API Failed&quot;)<br>    }<br>    launch {<br>        delay(5000)<br><br>        println(&quot;Second API Still Running&quot;)<br>    }<br>}</pre><p>Now:</p><ul><li>First coroutine fails</li><li>Second coroutine survives</li></ul><h3>Real Android Example</h3><p>Imagine:</p><ul><li>Coin API fails</li><li>Pokemon API succeeds</li></ul><p>You still want partial UI data.</p><p>Example:</p><pre>supervisorScope {<br>val coinDeferred = async {<br><br>        runCatching {<br>            useCase.getCoinList()<br>        }<br>    }<br><br>    val pokemonDeferred = async {<br><br>        runCatching {<br>            useCase.getPokemonList()<br>        }<br>    }<br><br>    val coinResult = coinDeferred.await()<br><br>    val pokemonResult = pokemonDeferred.await()<br>}</pre><p>This is a very common MVI production pattern.</p><h3>coroutineScope vs supervisorScope</h3><p>FeaturecoroutineScopesupervisorScopeOne child failsAll cancelOthers surviveStructured concurrencyStrictRelaxedBest forDependent tasksIndependent tasks</p><h3>5. Cooperative Cancellation</h3><p>Very important concept.</p><p>Coroutines do NOT stop immediately.</p><p>They stop only at:</p><ul><li>delay()</li><li>await()</li><li>yield()</li><li>suspension points</li></ul><p>Example:</p><pre>while(true) {}</pre><p>This NEVER cancels.</p><h3>Correct Way</h3><pre>while(isActive) {}</pre><p>Or:</p><pre>ensureActive()</pre><h3>Why?</h3><p>Coroutine cancellation is cooperative.</p><p>The coroutine must check whether it is cancelled.</p><h3>6. CancellationException</h3><p>Internally, cancellation works using:</p><pre>CancellationException</pre><p>And this is VERY important.</p><h3>Wrong Way</h3><pre>catch (e: Exception) {}</pre><p>This accidentally catches cancellation too.</p><p>Result:</p><ul><li>coroutine may not cancel properly</li></ul><h3>Correct Way</h3><pre>catch (e: CancellationException) {<br>    throw e<br>}<br>catch (e: Exception) {}</pre><h3>Why Re-throw?</h3><p>Because cancellation is NOT a failure.</p><p>It is a control signal.</p><h3>7. async Cancellation</h3><p>You can cancel individual async tasks.</p><pre>val deferred = async {<br><br>delay(5000)<br><br>    &quot;Result&quot;<br>}<br><br>deferred.cancel()</pre><p>Only this async block cancels.</p><h3>8. Timeout Cancellation</h3><p>Very useful for APIs.</p><pre>withTimeout(3000) {<br>  <br>  repository.getData()<br><br>}</pre><p>If API takes more than 3 seconds:</p><ul><li>coroutine automatically cancels</li></ul><h3>Safe Timeout Example</h3><pre>val result = withTimeoutOrNull(3000) {<br>  <br>  repository.getData()<br><br>}</pre><p>Returns:</p><ul><li>null instead of crash</li></ul><h3>9. Lifecycle-Aware Cancellation</h3><p>Android already provides automatic cancellation.</p><h3>viewModelScope</h3><p>Cancels when:</p><ul><li>ViewModel clears</li></ul><h3>lifecycleScope</h3><p>Cancels when:</p><ul><li>Lifecycle destroyed</li></ul><p>Example:</p><pre>viewModelScope.launch {}</pre><p>No need to manually cancel on screen destroy.</p><p>Kotlin handles it automatically.</p><h3>Production-Level Example</h3><pre>@HiltViewModel<br>class HomeViewModel @Inject constructor(<br>    private val repository: Repository<br>) : ViewModel() {<br><br>private var loadJob: Job? = null<br>    fun loadData() {<br>        <br>        loadJob?.cancel()<br>        <br>        loadJob = viewModelScope.launch {<br>            <br>              supervisorScope {<br>                <br>                val api1 = async {<br>                    repository.getCoins()<br>                }<br>                val api2 = async {<br>                    repository.getPokemon()<br>                }<br>                val coins = api1.await()<br>                val pokemon = api2.await()<br>            }<br>        }<br>    }<br>}</pre><h3>When Should You Use Cancellation?</h3><p>ScenarioUse Cancellation?Search APIYesRetry buttonYesPaginationYesFile UploadYesParallel APIsUsuallyOne-time splash APINot necessary</p><h3>Final Thoughts</h3><p>Coroutine cancellation is not just:</p><pre>job.cancel()</pre><p>It is deeply connected with:</p><ul><li>structured concurrency</li><li>lifecycle awareness</li><li>failure propagation</li><li>app performance</li><li>memory management</li></ul><p>Understanding cancellation properly will make your Android architecture significantly more production-ready.</p><p>Especially in:</p><ul><li>MVI</li><li>Clean Architecture</li><li>Compose apps</li><li>Parallel APIs</li><li>Real-time search systems</li></ul><p>Mastering cancellation is one of the biggest steps toward becoming an advanced Kotlin developer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=391a52ad8d8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RunCatching vs SupervisorScope vs SupervisorJob in Kotlin Coroutines — Explained Properly]]></title>
            <link>https://medium.com/@meaghosh/runcatching-vs-supervisorscope-vs-supervisorjob-in-kotlin-coroutines-explained-properly-c8c6fabf1933?source=rss-40464c9971b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8c6fabf1933</guid>
            <category><![CDATA[supervisorscope]]></category>
            <category><![CDATA[supervisor-jobs]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[mvvm]]></category>
            <dc:creator><![CDATA[Arindam Ghosh]]></dc:creator>
            <pubDate>Thu, 28 May 2026 15:14:40 GMT</pubDate>
            <atom:updated>2026-05-28T15:14:40.625Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dAlsrZwQXDJlW7pCC2KSeQ.png" /></figure><p>If you’ve worked with Kotlin Coroutines in Android, especially inside a ViewModel, you’ve probably seen developers combine:</p><ul><li>runCatching</li><li>supervisorScope</li><li>SupervisorJob</li></ul><p>…sometimes all together in the same code block.</p><p>The problem?</p><p>Most developers don’t fully understand:</p><ul><li>what each one actually does,</li><li>when it’s needed,</li><li>and when it becomes completely redundant.</li></ul><p>This article breaks everything down with <strong>real ViewModel examples</strong>, practical use cases, and clear rules you can actually apply in production apps.</p><h3>Understanding the Problem First</h3><p>Imagine you have two API calls running in parallel:</p><pre>val coinDeferred = async { useCase.getCoinList() }<br>val pokemonDeferred = async { useCase.getPokemonList() }</pre><p>Now suppose:</p><ul><li>getCoinList() fails</li><li>getPokemonList() succeeds</li></ul><p>What happens?</p><p>By default:</p><ul><li>the first failure cancels the parent coroutine,</li><li>which also cancels sibling coroutines.</li></ul><p>That means:</p><ul><li>one failed API can cancel the other successful request.</li></ul><p>This is where:</p><ul><li>runCatching</li><li>supervisorScope</li><li>SupervisorJob</li></ul><p>start becoming important.</p><p>But each solves a <strong>different layer</strong> of the problem.</p><h3>1. runCatching</h3><h3>What it actually does</h3><p>runCatching converts exceptions into a Result&lt;T&gt; object.</p><p>Instead of throwing exceptions, it safely wraps success or failure.</p><pre>val result = runCatching {<br>    someRiskyApiCall()<br>}</pre><p>This code:</p><ul><li>never throws,</li><li>always returns Result&lt;T&gt;.</li></ul><h3>The Result API</h3><pre>result.isSuccess<br>result.isFailure</pre><pre>result.getOrNull()<br>result.exceptionOrNull()</pre><pre>result.getOrDefault(emptyList())<br>result.getOrElse { emptyList() }</pre><pre>result.getOrThrow()</pre><h3>Without vs With runCatching</h3><h3>Without it</h3><pre>val coins = try {<br>    useCase.getCoinList()<br>} catch (e: Exception) {<br>    null<br>}</pre><h3>With it</h3><pre>val result = runCatching {<br>    useCase.getCoinList()<br>}</pre><pre>val coins = result.getOrNull()</pre><p>Cleaner.<br>More readable.<br>More composable.</p><h3>Why runCatching becomes powerful with async</h3><p>Consider this:</p><pre>val coinDeferred = async {<br>    runCatching {<br>        useCase.getCoinList()<br>    }<br>}</pre><pre>val pokemonDeferred = async {<br>    runCatching {<br>        useCase.getPokemonList()<br>    }<br>}</pre><p>Now something important changes.</p><p>Even if:</p><ul><li>getCoinList() fails,</li></ul><p>the coroutine itself does NOT fail.</p><p>Because the exception is absorbed into Result.</p><p>Meaning:</p><ul><li>both async blocks always complete,</li><li>sibling coroutines are never cancelled.</li></ul><p>This is one of the cleanest patterns for parallel API calls in Android.</p><h3>The Biggest Mistake Developers Make</h3><h3>Silent failure</h3><pre>coinList = coinResult.getOrNull() ?: emptyList()</pre><p>Looks harmless.</p><p>But if the API fails:</p><ul><li>the UI simply shows an empty list,</li><li>the user never knows something broke.</li></ul><p>This silently hides real production errors.</p><h3>Correct Approach</h3><p>Always surface the error too.</p><pre>coinList = coinResult.getOrNull() ?: emptyList(),<br>coinError = coinResult.exceptionOrNull()?.message</pre><p>Your UI should know:</p><ul><li>whether the list is empty,</li><li>OR the API actually failed.</li></ul><p>Huge difference.</p><h3>2. supervisorScope</h3><h3>What it actually does</h3><p>supervisorScope prevents one child coroutine failure from cancelling sibling coroutines.</p><pre>supervisorScope{    <br>val a = async {<br>        failingApiCall()<br>    }</pre><pre>    val b = async {<br>        successfulApiCall()<br>    }<br>}</pre><p>Without supervisorScope:</p><ul><li>failure in a</li><li>cancels b</li></ul><p>With supervisorScope:</p><ul><li>b continues running normally.</li></ul><h3>Important Difference from runCatching</h3><p>supervisorScope does NOT absorb exceptions.</p><p>It only changes cancellation behavior.</p><p>Exceptions still exist.</p><p>Meaning this can still throw:</p><pre>val result = deferred.await()</pre><p>So you still need:</p><ul><li>try/catch</li><li>OR runCatching</li></ul><p>somewhere.</p><h3>When Do You Actually Need supervisorScope?</h3><p>You need it when:</p><p>✅ your async blocks can throw<br>✅ you want sibling coroutines to survive failures</p><p>Example:</p><pre>supervisorScope{    <br>val coins = async {<br>        useCase.getCoinList()<br>    }</pre><pre>    val pokemon = async {<br>        useCase.getPokemonList()<br>    }</pre><pre>    val coinResult = runCatching { coins.await() }<br>    val pokemonResult = runCatching { pokemon.await() }<br>}</pre><p>Here:</p><ul><li>supervisorScope protects siblings,</li><li>runCatching handles exceptions individually.</li></ul><p>Both have separate responsibilities.</p><h3>When supervisorScope Becomes Redundant</h3><p>This is extremely common:</p><pre>supervisorScope{    <br>val coins = async {<br>        runCatching {<br>            useCase.getCoinList()<br>        }<br>    }</pre><pre>    val pokemon = async {<br>        runCatching {<br>            useCase.getPokemonList()<br>        }<br>    }<br>}</pre><p>This is unnecessary.</p><p>Why?</p><p>Because:</p><ul><li>runCatching already prevents coroutine failure,</li><li>so there’s nothing left for supervisorScope to protect.</li></ul><p>The exceptions never escape the child coroutine.</p><p>Meaning:</p><ul><li>sibling cancellation never happens anyway.</li></ul><p>So supervisorScope becomes dead code.</p><h3>3. SupervisorJob</h3><h3>What it actually does</h3><p>SupervisorJob creates a parent job where child failures don’t cancel siblings.</p><p>Example:</p><pre>CoroutineScope(SupervisorJob() + Dispatchers.IO)</pre><p>Without it:</p><pre>CoroutineScope(Dispatchers.IO)</pre><p>a single child failure can cancel the whole scope.</p><h3>The Most Important Android Fact</h3><h3>viewModelScope already uses SupervisorJob</h3><p>Internally:</p><pre>viewModelScope =<br>    CoroutineScope(<br>        SupervisorJob() + Dispatchers.Main<br>    )</pre><p>Meaning this is redundant:</p><pre>viewModelScope.launch(SupervisorJob()) {<br>}</pre><p>You already have one.</p><p>Adding another changes nothing.</p><h3>When Should You Use SupervisorJob Manually?</h3><p>Only when creating your own custom scope.</p><p>Example:</p><pre>class MyRepository{    <br>private val scope =<br>        CoroutineScope(<br>            SupervisorJob() + Dispatchers.IO<br>        )<br>}</pre><p>This is useful because:</p><ul><li>repository jobs become isolated,</li><li>one failure won’t cancel all background work.</li></ul><h3>The Production-Ready Pattern</h3><p>This is one of the cleanest approaches for ViewModels.</p><pre>viewModelScope.launch {    <br>val coinDeferred = async {<br>        runCatching {<br>            useCase.getCoinList()<br>        }<br>    }</pre><pre>    val pokemonDeferred = async {<br>        runCatching {<br>            useCase.getPokemonList()<br>        }<br>    }</pre><pre>    val coinResult = coinDeferred.await()<br>    val pokemonResult = pokemonDeferred.await()</pre><pre>    _state.value = _state.value.copy(<br>        coinList = coinResult.getOrNull() ?: emptyList(),<br>        pokemonList = pokemonResult.getOrNull() ?: emptyList(),</pre><pre>        coinError = coinResult.exceptionOrNull()?.message,<br>        pokemonError = pokemonResult.exceptionOrNull()?.message<br>    )<br>}</pre><p>Why this is excellent:</p><p>✅ parallel API calls<br>✅ independent failures<br>✅ no sibling cancellation<br>✅ no unnecessary supervisorScope<br>✅ no unnecessary try/catch<br>✅ UI receives proper error states</p><p>Simple.<br>Clean.<br>Production friendly.</p><h3>Combination Rules (Memorize These)</h3><p>CombinationNeeded?ReasonrunCatching inside async✅Prevents coroutine failuresupervisorScope alone. ✅Protects sibling coroutinesrunCatching + supervisorScope together. ❌ Usually redundantrunCatching + outer try/catch❌ RedundantManual SupervisorJob inside viewModelScope ❌ Already built inManual SupervisorJob in custom scope ✅ Correct usage</p><h3>Final Mental Model</h3><p>Think of them like this:</p><p>ToolResponsibilityrunCatchingConverts exceptions into datasupervisorScopePrevents sibling cancellationSupervisorJobPrevents parent scope cancellation</p><p>Each solves a different layer of coroutine failure handling.</p><p>The confusion happens when developers use all three together without understanding what problem each one solves.</p><h3>Key Takeaways</h3><h3>Use runCatching</h3><p>when you want:</p><ul><li>clean exception handling,</li><li>independent API results,</li><li>safer parallel calls.</li></ul><h3>Use supervisorScope</h3><p>when:</p><ul><li>child coroutines can still throw,</li><li>and siblings must survive.</li></ul><h3>Use SupervisorJob</h3><p>only for:</p><ul><li>custom scopes.</li></ul><p>Never manually inside:</p><ul><li>viewModelScope.</li></ul><h3>Conclusion</h3><p>Most coroutine code becomes overcomplicated because developers stack:</p><ul><li>try/catch</li><li>runCatching</li><li>supervisorScope</li><li>SupervisorJob</li></ul><p>…all together.</p><p>In reality:</p><ul><li>you usually need only one,</li><li>sometimes two,</li><li>rarely all three.</li></ul><p>Understanding how they interact is what separates:</p><ul><li>“coroutines that work”<br>from</li><li>“coroutines designed properly.”</li></ul><p>And in production Android apps, that difference matters a lot.</p><h3>Full Source Code</h3><p>The complete project with all files is available on GitHub:</p><p><a href="https://github.com/arindam9851/Clean-Architecture-with-parallel-api">https://github.com/arindam9851/Clean-Architecture-with-parallel-api</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8c6fabf1933" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Free Agentic AI Shopping Assistant for Android — From Zero to Production]]></title>
            <link>https://medium.com/@meaghosh/building-a-free-agentic-ai-shopping-assistant-for-android-from-zero-to-production-0df1fa0bc287?source=rss-40464c9971b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/0df1fa0bc287</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[mvi-architecture]]></category>
            <dc:creator><![CDATA[Arindam Ghosh]]></dc:creator>
            <pubDate>Thu, 19 Mar 2026 12:21:54 GMT</pubDate>
            <atom:updated>2026-03-19T12:21:54.365Z</atom:updated>
            <content:encoded><![CDATA[<p>How I built a fully working AI chat app with Kotlin, Jetpack Compose, Groq, Firebase, and Cloudinary — without spending a single dollar</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b0OzPG4M5z1xIhLB_KfAZQ.png" /></figure><h3>The Problem</h3><p>Most AI chatbot tutorials end the same way — a simple Q&amp;A bot that answers from its training data. But real apps need AI that can <strong>act</strong> — search your database, filter products, compare items, and respond intelligently based on <em>your</em> data.</p><p>That’s Agentic AI. And most developers assume it’s expensive or complex to build.</p><p>It’s not. I built a fully working Agentic AI Shopping Assistant for Android — 50 real products, images, natural language search, price filtering, stock checking — and the total cost was <strong>$0</strong>.</p><p>Here’s exactly how I did it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MMn0mocFjAXlF83qSxE_tg.png" /></figure><h3>What We’re Building</h3><p>A shopping assistant Android app where users chat naturally:</p><ul><li><em>“Show me electronics under 500 SEK”</em></li><li><em>“Give me all sold out products”</em></li><li><em>“What’s the best rated fitness gear?”</em></li><li><em>“Compare Yoga Mat and Dumbbell Set”</em></li></ul><p>The AI doesn’t just answer — it <strong>thinks</strong>, decides which database query to run, executes it against real Firestore data, and replies with matching products and images.</p><h3>Regular AI vs Agentic AI</h3><p>Before we dive in, let’s understand the key difference.</p><p><strong>Regular chatbot:</strong></p><pre>User asks → AI answers from memory</pre><p><strong>Agentic AI:</strong></p><pre>User asks → AI thinks → AI picks a tool → Tool queries real data → AI reads result → AI answers</pre><p>The magic is <strong>tool calling</strong> — giving the AI a set of functions it can invoke on its own. The AI decides which tool to call, with what parameters, based entirely on what the user asked.</p><h3>The Free Stack</h3><p>Here’s every service used and their cost:</p><p>ServicePurposeFree Limit<strong>Groq API</strong>AI brain (Llama 3.3 70B)14,400 requests/day<strong>Firebase Firestore</strong>Product database50,000 reads/day<strong>Firebase Remote Config</strong>Secure API key storageUnlimited<strong>Cloudinary</strong>Product image hosting25 GB/month<strong>Picsum Photos</strong>Auto image downloadUnlimited</p><p>Total monthly cost: <strong>$0</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b0KyvCx5yBs8AzERswqc-Q.png" /></figure><h3>Architecture — Clean Architecture + MVI</h3><p>The app follows Clean Architecture with MVI (Model-View-Intent) for the presentation layer.</p><pre>Presentation (MVI)<br>    ChatIntent → ChatViewModel → ChatState → ChatScreen</pre><pre>Domain (Pure Kotlin)<br>    AgenticAIUseCases → 8 use cases → Business logic</pre><pre>Data<br>    GroqAgentClient → Groq API → Agentic loop<br>    FirestoreProductSource → Firebase → Product data<br>    RemoteConfigSource → Firebase → API key</pre><h3>Why MVI?</h3><p>MVI gives us a single source of truth for UI state. Every user action is an Intent, every UI state is immutable, and side effects (like scrolling) are one-time Effects. This makes the code predictable and easy to debug.</p><p>kotlin</p><pre>// The entire MVI contract in one file<br>data class ChatState(<br>    val messages: List&lt;Message&gt; = emptyList(),<br>    val isLoading: Boolean = false,<br>    val isInitializing: Boolean = true,<br>    val inputText: String = &quot;&quot;,<br>    val error: String? = null,<br>    val products: List&lt;Product&gt; = emptyList()<br>)</pre><pre>sealed class ChatIntent {<br>    data class SendMessage(val text: String) : ChatIntent()<br>    data class UpdateInput(val text: String) : ChatIntent()<br>    object Retry : ChatIntent()<br>}</pre><pre>sealed class ChatEffect {<br>    object ScrollToBottom : ChatEffect()<br>    data class ShowError(val message: String) : ChatEffect()<br>}</pre><h3>Step 1 — Setting Up Firebase</h3><p>Firebase gives us two free services we need:</p><p><strong>Firestore</strong> — stores all product data (name, price, category, image URL, stock status, rating).</p><p><strong>Remote Config</strong> — stores the Groq API key securely. This means the key is never hardcoded in the APK. You can rotate or disable it anytime from the Firebase Console without pushing an app update.</p><blockquote><strong><em>Why not Firebase Storage for images?</em></strong><em> Firebase Storage requires the Blaze (paid) plan. We use Cloudinary instead — 25 GB free forever.</em></blockquote><h3>Step 2 — Getting the Groq API Key</h3><p>Groq is the secret weapon here. It runs the Llama 3.3 70B model on powerful servers — you just call their API. No downloading models, no GPU required.</p><ol><li>Sign up at <strong>console.groq.com</strong> — no credit card needed</li><li>Create an API key</li><li>Store it in Firebase Remote Config as groq_api_key</li></ol><p>Your Android app fetches this key at startup via Remote Config. The key never lives in your code.</p><h3>Step 3 — Uploading 50 Products Automatically</h3><p>Instead of manually entering products, I wrote a Python script that:</p><ol><li>Reads a CSV file with product data</li><li>Auto-downloads a free image for each product from Picsum Photos</li><li>Uploads the image to Cloudinary</li><li>Saves the product data + Cloudinary image URL to Firestore</li></ol><p>The CSV format is simple:</p><p>csv</p><pre>name,category,price,description,image_file<br>Samsung Galaxy Buds 2,electronics,449,Wireless earbuds with ANC,samsung_buds.jpg<br>Yoga Mat Premium,fitness,349,Non-slip 6mm thick mat,yoga_mat.jpg</pre><p>The key insight: <strong>Firestore stores text data (free), Cloudinary stores images (free)</strong>. Never use Firebase Storage unless you’re on the paid plan.</p><h3>Step 4 — The Domain Layer</h3><p>Each AI tool maps directly to a use case. All use cases are bundled into one data class for clean injection:</p><p>kotlin</p><pre>data class AgenticAIUseCases @Inject constructor(<br>    val getProducts: GetProductsUseCase,<br>    val searchProducts: SearchProductsUseCase,<br>    val filterByPrice: FilterByPriceUseCase,<br>    val filterByCategory: FilterByCategoryUseCase,<br>    val filterByStock: FilterByStockUseCase,<br>    val sortByRating: SortByRatingUseCase,<br>    val sortByPrice: SortByPriceUseCase,<br>    val compareProducts: CompareProductsUseCase,<br>    val getCategories: GetCategoriesUseCase<br>)</pre><p>This means GroqAgentClient gets one clean injection instead of 8 separate ones.</p><h3>Step 5 — The Heart of It: The Agentic Loop</h3><p>This is where the magic happens. The Groq API supports <strong>function calling</strong> — you define tools, and the AI decides which ones to call.</p><p>kotlin</p><pre>suspend fun chat(<br>    apiKey: String,<br>    history: List&lt;Message&gt;,<br>    products: List&lt;Product&gt;<br>): Pair&lt;String, List&lt;Product&gt;&gt; = withContext(Dispatchers.IO) {</pre><pre>    var currentMessages = buildInitialMessages(history)<br>    var finalProducts = emptyList&lt;Product&gt;()</pre><pre>    // Loop until AI stops calling tools<br>    for (i in 0 until 6) {<br>        val response = callGroqAPI(apiKey, currentMessages)</pre><pre>        when (response.finishReason) {</pre><pre>            &quot;stop&quot; -&gt; {<br>                // AI is done — return final text answer<br>                return@withContext Pair(response.text, finalProducts)<br>            }</pre><pre>            &quot;tool_calls&quot; -&gt; {<br>                // AI wants to call a tool<br>                for (toolCall in response.toolCalls) {<br>                    val result = executeTool(toolCall.name, toolCall.args, products)<br>                    finalProducts = result.products</pre><pre>                    // Feed tool result back to AI<br>                    currentMessages.add(toolResult(toolCall.id, result.text))<br>                }<br>                // Loop continues — AI reads result and decides next step<br>            }<br>        }<br>    }<br>}</pre><p>The loop continues until the AI says &quot;stop&quot; — meaning it has all the information it needs to answer. This is what makes it <strong>agentic</strong> — the AI drives the conversation, not your code.</p><h3>Step 6 — Defining Tools for the AI</h3><p>Tools are defined as JSON schemas. The AI reads these and decides which one matches the user’s intent:</p><p>kotlin</p><pre>// Example: filter_by_stock tool<br>{<br>  &quot;name&quot;: &quot;filter_by_stock&quot;,<br>  &quot;description&quot;: &quot;Filter products by availability. Use in_stock=false for sold out products&quot;,<br>  &quot;parameters&quot;: {<br>    &quot;in_stock&quot;: {<br>      &quot;type&quot;: &quot;boolean&quot;,<br>      &quot;description&quot;: &quot;true = in stock only, false = sold out only&quot;<br>    },<br>    &quot;category&quot;: {<br>      &quot;type&quot;: &quot;string&quot;,<br>      &quot;description&quot;: &quot;Optional category filter&quot;<br>    }<br>  }<br>}</pre><p>When a user says <em>“give me sold out electronics”</em>, the AI calls:</p><p>json</p><pre>filter_by_stock(in_stock=false, category=&quot;electronics&quot;)</pre><p>Your code executes this against Firestore data and returns the results.</p><h3>Step 7 — System Prompt Engineering</h3><p>The system prompt is critical. It tells the AI exactly when to use each tool:</p><p>kotlin</p><pre>val SYSTEM_PROMPT = &quot;&quot;&quot;<br>    You are a smart shopping assistant for a Swedish store.<br>    All prices are in SEK (Swedish Krona).<br>    Always use tools to get real product data before answering.</pre><pre>    Tool usage guide:<br>    - &quot;sold out&quot;, &quot;out of stock&quot;          → filter_by_stock(in_stock=false)<br>    - &quot;lowest rated&quot;, &quot;least ranking&quot;     → sort_by_rating(order=asc)<br>    - &quot;cheapest&quot;, &quot;budget&quot;                → sort_by_price(order=asc)<br>    - &quot;under X SEK&quot;                       → filter_by_price(max_price=X)<br>&quot;&quot;&quot;</pre><p>This guides the AI to pick the right tool even for unusual phrasings like <em>“least ranking product”</em> or <em>“give me only sold out ones”</em>.</p><h3>Step 8 — Showing Product Cards in Chat</h3><p>When the AI returns products, we show them as scrollable cards below the text bubble:</p><p>kotlin</p><pre>@Composable<br>fun ChatBubble(message: Message) {<br>    // Text response<br>    Surface(...) {<br>        Text(message.content)<br>    }</pre><pre>    // Product cards (if AI returned products)<br>    if (message.products.isNotEmpty()) {<br>        LazyRow {<br>            items(message.products) { product -&gt;<br>                ProductCard(product)<br>            }<br>        }<br>    }<br>}</pre><p>Each ProductCard loads the Cloudinary image URL using Coil:</p><p>kotlin</p><pre>AsyncImage(<br>    model = product.imageUrl,  // Cloudinary URL<br>    contentDescription = product.name,<br>    modifier = Modifier.size(80.dp).clip(RoundedCornerShape(8.dp)),<br>    contentScale = ContentScale.Crop<br>)</pre><h3>The Result</h3><p>Here’s what users can do with natural language:</p><p>User saysAI does<em>”Electronics under 500 SEK”</em>filter_by_price(500) + filter_by_category(&quot;electronics&quot;)<em>&quot;Sold out products&quot;</em>filter_by_stock(in_stock=false)<em>&quot;Worst rated items&quot;</em>sort_by_rating(order=asc)<em>&quot;Cheapest shoes&quot;</em>sort_by_price(order=asc) + filter_by_category(&quot;footwear&quot;)<em>&quot;Compare product A and B&quot;</em>compare_products(A, B)<em>&quot;Visa kategorier&quot;</em> (Swedish)get_categories() — replies in Swedish too!</p><h3>Key Lessons Learned</h3><p><strong>1. Firebase Storage needs the paid plan — use Cloudinary instead.</strong> This caught me off guard. Firebase Storage requires Blaze plan even for tiny usage. Cloudinary gives 25 GB free with zero setup friction.</p><h3>What’s Next</h3><p>This architecture scales easily:</p><ul><li><strong>Add to cart tool</strong> — write to Firestore directly from chat</li><li><strong>Order status tool</strong> — query order collection</li><li><strong>Admin agent</strong> — manage inventory via chat</li><li><strong>Multi-language</strong> — the AI already responds in Swedish if you write in Swedish</li><li><strong>Voice input</strong> — plug in Android SpeechRecognizer for hands-free shopping</li></ul><h3>Full Source Code</h3><p>The complete project with all files is available on GitHub:</p><p><a href="https://github.com/arindam9851/AgenticAI"><strong>github.com/arindam9851</strong></a></p><p>Includes:</p><ul><li>All Kotlin source files (Clean Architecture + MVI)</li><li>Python upload script</li><li>50-product CSV file</li><li>Complete README with setup instructions</li></ul><h3>Final Thoughts</h3><p>Agentic AI is not a future technology — it’s available today, for free, and surprisingly simple to implement. The key insight is separating the <strong>AI brain</strong> (Groq/Llama) from the <strong>tools</strong> (your Kotlin functions). The AI handles intent understanding. Your code handles execution. Together they create something that feels genuinely intelligent.</p><p>The entire stack costs nothing. The only investment is time — and now you have the blueprint.</p><p><em>If this helped you, follow me for more Android + AI content. Questions? Drop them in the comments.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0df1fa0bc287" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Static Code Analysis with SonarQube with Flutter]]></title>
            <link>https://medium.com/@meaghosh/static-code-analysis-with-sonarqube-with-flutter-11a74beb9950?source=rss-40464c9971b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/11a74beb9950</guid>
            <category><![CDATA[cicd-docker]]></category>
            <category><![CDATA[analysis]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[sonarqube]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Arindam Ghosh]]></dc:creator>
            <pubDate>Mon, 21 Aug 2023 08:39:03 GMT</pubDate>
            <atom:updated>2023-08-22T09:35:56.422Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*X4lXUlAfbcLPbOHB.png" /></figure><blockquote><strong>Introduction</strong></blockquote><p>SonarQube is a popular open-source platform for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells, and security vulnerabilities.</p><p>SonarQube’s official support for analyzing Flutter projects might have been limited or nonexistent since Flutter is based on the Dart programming language, which wasn’t one of the languages initially supported by SonarQube.</p><p>However, it’s possible that there have been developments or third-party integrations since then. Below are the general steps you would follow to set up <strong>SonarQube with a Flutter project in a Docker environment</strong>.</p><blockquote><strong>Step 1: Install Docker Desktop</strong></blockquote><p>Go to <a href="https://docs.docker.com/desktop/install/mac-install/"><strong>Docker Desktop</strong></a> link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8v6uaKOSqQUT_TWIyR47qg.png" /></figure><p>In my case, the downloaded version will be the Mac with an Apple chip. after downloading just move the docker app to the Applications folder like the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*53iY0HY_czjDFREMtGS84g.png" /></figure><p>When the installation process is done you have to open the docker application and probably should see something like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X9ETfLqScrY4cGHbSfufWQ.png" /></figure><blockquote><strong>Step 2: Download SonarQube</strong></blockquote><p>Go to <a href="https://www.sonarsource.com/products/sonarqube/downloads/"><strong>SonarQube</strong></a> link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MC1uH0E0j8JalJ10AWKRKQ.png" /></figure><p>Scroll down until you see the <strong>AVAILABLE FROM DOCKERHUB </strong>button.Click on that button then you see this page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zy_AC8BJxRBPwKd8o0O9YQ.png" /></figure><p>we will use the community edition. because this is open source and enough for this tutorial.</p><p>Open the terminal and paste this command:</p><blockquote><strong>docker pull sonarqube:10.1.0-community</strong></blockquote><p>With the image downloaded, we go back to Docker and in the Images option we can see that like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h_87n0t7ZSIDJa-6foFOpA.png" /></figure><p>You can also check this in the terminal using this command:</p><blockquote><strong>docker images</strong></blockquote><p>and this will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*om_2IBjNB229d-R2dupyJA.png" /></figure><p>you will notice that now we have a container created with the SonarQube image, now just run the container to start the software, for that, we can just click the start button in the container created or just type docker start sonarqubeapp in the terminal, where <strong>sonarquebeapp</strong> should be the name of the container.</p><p>While the container is opening you can open your browser and type http://localhost:9000/, after starting you will be able to see the login page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UaRiGoxMuExg6VM_2U1_zw.png" /></figure><p>By default to log in for the first time, just type <strong>admin</strong> in the login and password fields, you will be redirected to the home page and will see that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mNNaLAHBdMWY1-OepHYzLw.png" /></figure><p>Dart and Flutter are not supported officially by SonarQube yet, so for that reason, we need to download a plug-in that will do the work we need.</p><blockquote><strong>Step 3: Download SonarQube plugin</strong></blockquote><p>Open <a href="https://github.com/insideapp-oss/sonar-flutter"><strong>this repository</strong></a> and and go to releases page to download the last version.</p><p>after downloading the jar file , move the jar file to Docker container by using this command:</p><pre>docker cp sonar-flutter-plugin-0.4.0.jar sonarqubeapp:/opt/sonarqube/extensions/plugins</pre><p>now restart SonarQube,</p><p><strong>docker restart sonarqubeapp</strong> and wait for it.</p><p>Log in again and to check if the plug-in was correctly installed click on the administration tab, later click on the Marketplace tab inside the admin options, and finally in Plugins click on Installed to see the page like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PWagRrGgtS9dy34fHqAPkQ.png" /></figure><blockquote><strong>Step 4: Download Sonar Scanner</strong></blockquote><p>Go to the link and download <a href="https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarscanner/"><strong>Sonar Scanner</strong></a><strong>. </strong>to show report locally.</p><p><strong>I recommended to do that in your home folder.</strong></p><p><strong>Now you will have to add the path in your </strong><strong>.bash_profile or </strong><strong>.zshrc (or in environment variables in windows), it depends on what kind of terminal you use, type: </strong><strong>export PATH=&quot;$HOME/sonar-scanner-4.7.0.2747-macosx/bin:$PATH&quot;.</strong></p><blockquote><strong>Step 5: Create sonar-project.properties file in your root project</strong></blockquote><p>after cratering that file paste this line of code</p><pre># Project identification, either hardcode it or use Environment variables<br>sonar.projectKey=my project key<br>sonar.projectName=my project name<br>sonar.login=token<br><br># The host URL<br>sonar.host.url=http://localhost:9000<br><br># Source code location.<br># Path is relative to the sonar-project.properties file. Defaults to .<br># Use commas to specify more than one folder.<br>sonar.sources=lib<br>sonar.tests=test<br><br># Encoding of the source code. Default is default system encoding.<br>sonar.sourceEncoding=UTF-8<br><br># exclude generated files<br>sonar.exclusions=test/**/*_test.mocks.dart,lib/**/*.g.dart</pre><p>With this file created, go back to the SonarQube home page, and let’s create a project manually, to do that just click on the Button Add Project and then click the Manually option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*snsx01EqPa5SVGARDoM0lA.png" /></figure><p>Next, we give a project key and a display name to the project and click on the setup button, next page the Sonar will ask you to generate a token, so create a name for your token and click on generate, this will show you a token, you need to copy and go back to sonar-project.properties file and fill the project key, projectName and token with what was provided.</p><p><strong>Run this command in the project root directory’s terminal to generate the report.</strong></p><pre>flutter test --machine --coverage &gt; tests.output<br>sonar-scanner</pre><p>When finishing this, you can refresh your SonarQube page to see the app insights:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0oP7wWhNsJP1gNGwenpFUg.png" /></figure><p><strong>Done!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11a74beb9950" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter — Jenkins setup in mac Pipeline->Build->App Center]]></title>
            <link>https://medium.com/@meaghosh/flutter-jenkins-setup-in-mac-pipeline-build-app-center-90a25b700e89?source=rss-40464c9971b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/90a25b700e89</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[jenkins-pipeline]]></category>
            <dc:creator><![CDATA[Arindam Ghosh]]></dc:creator>
            <pubDate>Thu, 01 Jun 2023 21:53:53 GMT</pubDate>
            <atom:updated>2023-06-01T21:53:53.843Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter — Jenkins setup in mac Pipeline-&gt;Build-&gt;App Center</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ODZ8XDb9Lz4LdGg4QUEQow.png" /></figure><h4>Introduction:</h4><p>In today’s fast-paced software development landscape, continuous integration and deployment (CI/CD) has become crucial for efficient and reliable application development. Flutter, a popular cross-platform framework, enables developers to build high-quality apps for multiple platforms using a single codebase. Combining the power of Flutter with Jenkins, an open-source automation server, can greatly enhance the development process by automating build, test, and deployment tasks. In this article, we will explore how to leverage Jenkins to streamline Flutter app development.</p><h4>Step 1: Install Jenkins on Mac</h4><p>Hit this in your terminal</p><blockquote>brew install jenkins-lts<br>brew services start jenkins-lts</blockquote><p>By default, Jenkins runs on port 8080.</p><p>Check if the server was started properly by browsing to <a href="http://localhost:8080/">http://localhost:8080/.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*as2KCv68RRTEs_tuxfJUJg.png" /></figure><p>Open that path for the Initial password. and hit continue.</p><h4>Step 2: Configure Jenkins</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pdGUi-faieBR7OGVydtrww.png" /></figure><h4>Enter an item name and select Pipeline</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JbvCT7YmbHYMzSKgMHIv-g.png" /></figure><p>Paste this Script</p><pre>pipeline {<br>    agent any<br><br>    stages {<br>        stage(&#39;GIT PULL&#39;) {<br>            steps {<br>                git branch: BRANCH_NAME, credentialsId: &#39;XXXXXXXXXXXXXXXXXXXXXXX&#39;, url: &#39;https://github.com/XXXXXXX/XXXXX.git&#39;<br>            }<br>        }<br>        stage(&#39;FLUTTER CLEAN&#39;) {<br>            steps {<br>                sh &#39;flutter clean&#39;<br>            }<br>        }<br>        <br>        stage(&#39;BUILD ANDROID&#39;) {<br>            steps {<br>                sh &#39;flutter build apk --release --flavor ${ENV} --build-name=${BUILD_NAME} --build-number=${BUILD_NUM} lib/main/flavor/main_${ENV}.dart&#39;<br>            }<br>        }<br>        stage(&#39;BUILD IOS&#39;) {<br>            steps {<br>                sh &#39;flutter build ipa --release --flavor ${ENV} --build-name=${BUILD_NAME} --build-number=${BUILD_NUM} lib/main/flavor/main_${ENV}.dart --export-method development&#39;<br>            }<br>        }<br>        stage(&#39;DISTRIBUTE ANDROID&#39;) {<br>            steps {<br>                appCenter apiToken: &#39;XXXXXXXXXXXXXXXXX&#39;,<br>                appName: ANDROID_APP,<br>                branchName: &#39;&#39;,<br>                commitHash: &#39;&#39;,<br>                distributionGroups: &#39;Collaborators&#39;,<br>                mandatoryUpdate: false,<br>                notifyTesters: true,<br>                ownerName: &#39;XXXXXXXXXXX&#39;,<br>                pathToApp: &#39;build/app/outputs/flutter-apk/app-${ENV}-release.apk&#39;,<br>                pathToDebugSymbols: &#39;&#39;,<br>                pathToReleaseNotes: &#39;&#39;,<br>                releaseNotes: &#39;&#39;&#39;What’s new<br>1. Bug fixes<br>2. New feature<br>&#39;&#39;&#39;<br>            }<br>        }<br>        stage(&#39;DISTRIBUTE IOS&#39;) {<br>            steps {<br>                appCenter apiToken: &#39;XXXXXXXXXXXXXXXXXXX&#39;,<br>                appName: IOS_APP,<br>                branchName: &#39;&#39;,<br>                commitHash: &#39;&#39;,<br>                distributionGroups: &#39;Collaborators&#39;,<br>                mandatoryUpdate: false,<br>                notifyTesters: true,<br>                ownerName: &#39;XXXXXXXXXXXXX&#39;,<br>                pathToApp: &#39;build/ios/ipa/*.ipa&#39;,<br>                pathToDebugSymbols: &#39;&#39;,<br>                pathToReleaseNotes: &#39;&#39;,<br>                releaseNotes: &#39;&#39;&#39;What’s new<br>1. Bug fixes<br>2. New feature<br>&#39;&#39;&#39;<br>            }<br>        }<br>    }<br><br>    <br>}</pre><p>You can choose from different commands which I suppose is self-explanatory.</p><pre>ANDROID build command<br><br>flutter build apk --release --flavor uat lib/main/flavor/main_uat.dart<br>flutter build apk --release --flavor dev lib/main/flavor/main_dev.dart<br><br>flutter build apk --release --flavor prod lib/main/flavor/main_prod.dart<br><br>flutter build apk --release --flavor staging lib/main/flavor/main_staging.dart<br><br><br>IOS build commands<br><br>flutter build ipa --release --flavor dev lib/main/flavor/main_dev.dart --export-method development<br> <br>flutter build ipa --release --flavor staging lib/main/flavor/main_staging.dart --export-method ad-hoc<br> <br>flutter build ipa --release --flavor prod lib/main/flavor/main_prod.dart --export-method ad-hoc</pre><h4>Step 3: Set the Environment variable</h4><blockquote>Dashboard -&gt; Manage Jenkins -&gt; System Configuration -&gt; System -&gt; Scroll down to Global Properties. then add all Global variables that mention in Script. Like —</blockquote><blockquote>ANDROID_APP</blockquote><blockquote>BRANCH_NAME,</blockquote><blockquote>BUILD_NAME,</blockquote><blockquote>BUILD_NUM,</blockquote><blockquote>ENV,</blockquote><blockquote>IOS_APP,</blockquote><blockquote>PATH</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YLUTuWjuIu6AjbS9TK6eDw.png" /></figure><h4>Step 4: Set the path variable based on your SDK path</h4><pre>PATH = $PATH:/bin/sh:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/homebrew/bin:/Users/arindam9851/Developer/flutter/bin:/Users/arindam9851/Library/Android/sdk/platform-tools:/Applications/Android\ Studio.app/Contents/jbr/Contents/Home:/Users/arindam9851/Library/Android/sdk</pre><h4><strong>Step 5: Create an app centre token</strong></h4><p>Login to appcenter-&gt; profile -&gt; settings -&gt; Api Token -&gt; Create new api token</p><h4>Step 6: Create Git token</h4><p>Select your project in Jenkins. Pipeline syntax → select simple step -&gt; git -&gt; fill your detail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fqwjgsgUZVhSfmTPUbfjBQ.png" /></figure><h4>Click on +ADD button and fill Git detail</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aUD-wT9RhNL3iJGF8yl0Gg.png" /></figure><p>After that choose your credential from drop-down</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bqW-8i37m_mkXshCgkOSxw.png" /></figure><h3>Done. You can run your pipeline.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90a25b700e89" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>