Folder structure for Android MVVM pattern

Hi, Can you please suggest android folder structure pattern?
Till now I came to these structures:

  1. Now I am using
  • data
  • di
  • features
    • login
      -LoginViewModel
      -LoginRepository
      -LoginViewActivity
    • dashboard
      -DashBoardViewModel
      -DashBoardRepository
      -DashBoardViewActivity
  • utillity
  • customviews

or

  • data

  • di

  • activites
    -LoginViewActivity
    -DashBoardViewActivity

  • ViewModel
    -LoginViewModel
    -DashBoardViewModel

  • repository
    -LoginRepository
    -DashBoardRepository

  • utility

  • customeview

I’ve found much more success with the first pattern. In fact, I prefer to keep everything related to a feature in its own gradle module including its models, DI and views. That way you can keep them as a single compilation unit and have nice isolation if you ever rewrite a feature or want to remove one.

1 Like

Yes follow a domain driven pattern for your folder structure for sure. It’s much easier to understand what is going on in the project, for other developers to muck or for you to return to the project later and remember what it was all about.