<?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 Ravish Rajput on Medium]]></title>
        <description><![CDATA[Stories by Ravish Rajput on Medium]]></description>
        <link>https://medium.com/@ravish.rajput22?source=rss-7f77cdc6e969------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*L4XazgRoW_WvCI8S</url>
            <title>Stories by Ravish Rajput on Medium</title>
            <link>https://medium.com/@ravish.rajput22?source=rss-7f77cdc6e969------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:46:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ravish.rajput22/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[Scaling Android Apps with Feature‑Based Modularization]]></title>
            <link>https://medium.com/@ravish.rajput22/scaling-android-apps-with-feature-based-modularization-f18696c5537b?source=rss-7f77cdc6e969------2</link>
            <guid isPermaLink="false">https://medium.com/p/f18696c5537b</guid>
            <category><![CDATA[modules]]></category>
            <category><![CDATA[android-project-structure]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[modularization]]></category>
            <dc:creator><![CDATA[Ravish Rajput]]></dc:creator>
            <pubDate>Wed, 03 Dec 2025 15:33:23 GMT</pubDate>
            <atom:updated>2025-12-03T15:33:23.306Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UcovOcrni_PX0byx-wdbpw.jpeg" /></figure><p>Most Android projects start small and simple: a couple of activities, a ui package, maybe a data package, and that’s it. It works… until it doesn’t.</p><p>As the app grows, the classic layer‑based structure (ui, domain, data, utils) starts to break down:</p><ul><li>It’s hard to see which code belongs to which part of the product.</li><li>Merge conflicts become frequent because many teams touch the same modules.</li><li>Features are tightly coupled, so shipping or refactoring one screen often breaks another.</li></ul><p>A feature‑based project structure flips this around. Instead of organizing files by technical layers, you organize them by business features: feature-auth, feature-payments, feature-profile, etc. This is especially powerful for medium‑to‑large apps with multiple developers or teams.</p><p>In this article, we’ll walk through:</p><ul><li>What feature‑based structuring is and why it matters</li><li>How to organize modules and packages</li><li>A concrete example project structure</li><li>Best practices and common pitfalls</li><li>A simple migration strategy from a legacy layer‑based project</li></ul><h3>Layer‑Based vs Feature‑Based: What’s the Difference?</h3><h3>Traditional Layer‑Based Structure</h3><p>In many legacy apps, the tree looks like this:</p><p>app/<br> └── src/main/java/com/example/app/<br> ├── ui/<br> ├── data/<br> ├── domain/<br> ├── network/<br> └── util/</p><p>Pros:</p><ul><li>Intuitive for beginners.</li><li>Technical concerns (network, database, UI) are grouped together.</li></ul><p>Cons:</p><ul><li>Poor feature isolation: logic for a single feature is scattered across multiple packages.</li><li>Hard to onboard: “Where is the payments refund logic?” — answer: everywhere.</li><li>Scaling issues: adding new features often touches shared ui, data, or util code.</li></ul><h3>Feature‑Based Structure</h3><p>Feature‑based structure groups everything related to a business capability in one place:</p><p>app/<br> └── src/main/java/com/example/app/<br> ├── feature_auth/<br> ├── feature_home/<br> ├── feature_profile/<br> ├── feature_payments/<br> └── core/</p><p>Each feature contains its own UI, domain, and data layers (internally), but externally you think and work in terms of features, not layers.</p><p>Benefits:</p><ul><li>High cohesion: all code for a feature lives together.</li><li>Lower coupling: features depend only on shared core modules, not on each other.</li><li>Team autonomy: different teams own different feature modules.</li><li>Easier navigation: “Forgot Password?” → go to feature_auth.</li></ul><h3>Modules vs Packages: How Far Should You Go?</h3><p>Feature‑based structuring can be applied at two levels:</p><ul><li>Module level: separate Gradle modules per feature</li><li>Package level: one module (app), but packages structured by feature</li></ul><p>For small projects, package‑level is often enough. For larger projects or multi‑team setups, multi‑module is ideal.</p><h3>Example: Multi‑Module Feature Structure</h3><p>At the Gradle module level:</p><p>:app // entry point (navigation, DI setup)<br>:core:ui // shared UI components, theme<br>:core:domain // common domain models &amp; use cases<br>:core:data // networking, database, common repos<br>:feature:auth<br>:feature:home<br>:feature:profile<br>:feature:payments</p><p>Inside :feature:auth:</p><p>feature/auth/src/main/java/com/example/feature/auth/<br> ├── ui/<br> │ ├── login/<br> │ │ ├── LoginFragment.kt<br> │ │ └── LoginViewModel.kt<br> │ ├── register/<br> │ └── forgotpassword/<br> ├── domain/<br> │ ├── usecase/<br> │ │ └── LoginUseCase.kt<br> │ └── model/<br> └── data/<br> ├── AuthRepositoryImpl.kt<br> └── remote/</p><p>Key point: from the outside, auth is just feature_auth. The internal structure can still follow clean architecture or MVVM.</p><h3>Core Modules: What Belongs Where?</h3><p>To avoid duplicating logic and to keep features decoupled, it helps to have a core layer.</p><p>Some typical core modules:</p><p>core:ui:</p><ul><li>Design system, themes, typography</li><li>Common UI components (buttons, toolbars, dialogs)</li><li>Base fragments/activities (if you use them)</li></ul><p>core:domain:</p><ul><li>Global domain models (e.g., User, Session)</li><li>Cross‑cutting use cases (e.g., GetCurrentUser, ObserveSession)</li></ul><p>core:data:</p><ul><li>Network configuration (Retrofit, Ktor, etc.)</li><li>Database configuration (Room)</li><li>Common repositories or data sources used by multiple features</li></ul><p>You can also introduce core:common or core:util for utilities that truly are shared, but be careful: a bloated util module is how monoliths sneak back in.</p><h3>Example: A Feature‑Based Project Tree</h3><p>Here’s a more complete sample structure for a moderately complex app:</p><p>app/<br> ├── src/main/java/com/example/app/<br> │ ├── navigation/<br> │ └── App.kt<br> └── build.gradle.kts</p><p>core/<br> ├── ui/<br> │ └── src/main/java/com/example/core/ui/<br> ├── domain/<br> │ └── src/main/java/com/example/core/domain/<br> ├── data/<br> │ └── src/main/java/com/example/core/data/<br> └── common/<br> └── src/main/java/com/example/core/common/</p><p>feature/<br> ├── auth/<br> │ └── src/main/java/com/example/feature/auth/<br> ├── home/<br> │ └── src/main/java/com/example/feature/home/<br> ├── profile/<br> │ └── src/main/java/com/example/feature/profile/<br> └── payments/<br> └── src/main/java/com/example/feature/payments/</p><p>Each feature can be a dynamic feature module (for Play Feature Delivery) or a standard Android library module, depending on your needs.</p><h3>Navigation in a Feature‑Based World</h3><p>One common question is: <em>“If features are isolated, how do they talk to each other?”</em></p><p>Typical patterns:</p><ul><li>Centralized navigation graph:</li></ul><p>The app module owns the navigation graph; features expose destinations (fragments/composables) and routes, but not direct dependencies between features.</p><ul><li>Navigator interfaces:</li></ul><p>Each feature defines a simple navigation interface in a shared module (e.g. core:navigation). Implementations live in app, so feature_auth doesn’t directly depend on feature_home.</p><ul><li>Deep links / routing:</li></ul><p>Features can be addressed by route strings or deep links, further decoupling them.</p><p>The goal is to avoid feature_auth importing classes directly from feature_profile whenever possible.</p><h3>Best Practices for Feature‑Based Structuring</h3><ul><li>Start with clear boundaries:</li></ul><p>Name features based on business language, not technical concepts: auth, profile, search, orders, cart, etc.</p><ul><li>Keep dependencies one‑way:</li></ul><p>Features can depend on core modules, but avoid features depending on other features unless absolutely necessary.</p><ul><li>Enforce boundaries with Gradle:</li></ul><p>Use Gradle’s dependency graph and visibility to prevent accidental cross‑feature imports.</p><ul><li>Be strict about “shared” code:</li></ul><p>Only move something into core if at least two features actually need it. Don’t pre‑optimize by putting everything shared “just in case”.</p><ul><li>Align teams to features:</li></ul><p>If you have multiple teams, assign each one ownership of a set of feature modules. Ownership encourages cleaner boundaries.</p><h3>Migrating from Layer‑Based to Feature‑Based</h3><p>You don’t have to rewrite everything. A gradual migration works well:</p><h3>1. Introduce core Modules</h3><p>Extract truly shared logic from the existing app module:</p><ul><li>Move design system and shared views into core:ui.</li><li>Move global repositories and data sources into core:data.</li><li>Move reusable domain models/use cases into core:domain.</li></ul><h3>2. Create New Features as Modules</h3><p>For any new, major feature, create a dedicated feature_x module from day one. This prevents further growth of the monolith.</p><h3>3. Incrementally Carve Out Existing Features</h3><p>Pick a high‑value, relatively isolated feature (e.g., auth):</p><ul><li>Create :feature:auth.</li><li>Move relevant screens, view models, use cases, and repositories into it.</li><li>Wire up dependencies from app and core.</li></ul><p>Repeat this for other features over time. The core idea: don’t freeze development just to restructure.</p><h3>4. Clean Up Old Layers</h3><p>As features are migrated, gradually shrink the old ui, data, domain packages in the app module until they’re gone or reduced to thin wrappers.</p><h3>Common Pitfalls and How to Avoid Them</h3><ul><li>Pitfall: Giant “core” module becomes a new monolith</li><li>Fix: Split core into targeted modules (core:ui, core:data, core:domain, core:common) and review what goes in there.</li><li>Pitfall: Feature depends on too many other features</li><li>Fix: Move shared logic into core where appropriate, or introduce explicit interfaces (ProfileProvider, AuthSessionProvider, etc.) in a shared module.</li><li>Pitfall: Over‑engineering for small apps</li><li>Fix: For very small apps, keep everything in one module but still structure packages by feature. You can split into modules when the app grows.</li></ul><h3>When Feature‑Based Structure Makes the Most Sense</h3><p>You’ll see the biggest value if:</p><ul><li>Your app has more than a few major features.</li><li>Multiple developers or teams work on the same codebase.</li><li>You plan to use dynamic feature modules or demand‑based downloads.</li><li>You want to support independent release cycles or refactors per feature.</li></ul><p>For a side project or a simple app with one or two screens, feature‑based structure might be overkill — but thinking in terms of features can still make your code easier to evolve later.</p><h3>Conclusion</h3><p>Feature‑based structuring is about aligning your code with your product, not your framework. By organizing your Android project around business capabilities — auth, profile, payments, search — you get:</p><ul><li>Cleaner boundaries and higher cohesion</li><li>Less coupling between teams and features</li><li>A project structure that scales with your app and your organization</li></ul><p>If you’re starting a new app, consider going feature‑first from day one. If you’re working on a legacy codebase, start small: carve out one feature, introduce core modules, and let the new structure grow organically.</p><p>If you tell me your target audience (junior vs mid/senior Android devs) and preferred length, I can help you tighten this into a shorter piece or expand specific sections (e.g., with Gradle snippets, Compose examples, or diagrams).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f18696c5537b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>