Lightweight Android library for seamless inter-module communication using a unified event and message system.
- π Overview
- πΎ Features
- π Core Concepts
- π Getting Started
- π Project Roadmap
- π° Contributing
- π License
- π Acknowledgments
Modules-Door-Lib is a lightweight Android library designed for multi-module projects, enabling seamless communication between modules.
At the core is the abstract class DoorEntry, the single entry point of each module.
All transactions (commands and events) flow through this class, keeping your architecture decoupled and scalable.
Developers only need to register:
messageListβ Defines which messages a module can send or receive.eventListβ Defines which events a module can publish or subscribe to.
π Initialization, event publishing, and subscription handling are fully managed by the kernel, so you donβt need to write any boilerplate.
| Feature | Summary | |
|---|---|---|
| π | Communication |
|
| π§© | Decoupling |
|
| π | Scalability |
|
| βοΈ | Simplicity |
|
- Door Entry
- The entry point of a module. Extend
DoorEntryonce per module.
- Door Command
- Object passed between modules. Fields:
messageNameβ identifierpayloadβ optional Json datadoorNameβ target module
- MessageType
SendType: Outgoing commandReceiveType: Incoming command
- EventType
PublishType: Publish a flow eventSubscribeType: Subscribe to a flow
- Door (Initializer Class)
- Responsible for initializing internal processes with all DoorEntry classes.
- Should be initialized once inside your Application class.
- Accepts a list of all DoorEntry implementations across modules.
- Kernel (Internal Engine)
- Handles:
- Event publishing & subscribing
- Message passing between modules
- Transparent to developers (no manual setup required).
- Plug & Play: Just register DoorEntry classes with all messages and events
- Kernel-managed communication (publish/subscribe handled internally)
- Error reduction: Only need to declare events & messages correctly
- Scalable: Works seamlessly as modules grow
- Language: Kotlin
- Build Tool: Gradle
Build from source:
β― git clone https://github.com/shubham-gadekar-alpha/Modules-Door-Lib/
β― cd Modules-Door-Lib
β― gradle build@Singleton
class DataDoor @Inject internal constructor(
private val bookRepository: BookRepository,
) : DoorEntry() {
override val eventList: List<EventType>
get() = listOf(
EventType.PublishType("SubscribeBookById", this),
EventType.PublishType("SubscribeReadingList", this),
)
override val messageList: List<MessageType>
get() = listOf(
MessageType.ReceiveType("GetBookById", this),
MessageType.SendType("ReceivedBookByIdResponse", this),
)
override fun init() { /* Custom init if needed */ }
override fun onReceive(message: DoorCommand) {
// Handle incoming message here
}
override fun publish(message: DoorCommand): SharedFlow<DoorCommand> =
throw NotImplementedError("Handled internally by kernel")
override fun subscribe(subscription: SharedFlow<DoorCommand>, featureCommand: DoorCommand) =
throw NotImplementedError("Handled internally by kernel")
}Finally, you need to collect all your doors in the Application class and initialize the Door kernel.
@HiltAndroidApp
class BooksExplorerApplication : Application() {
@Inject
lateinit var door: Door
@Inject
lateinit var door1: DoorEntry1
@Inject
lateinit var door2: DoorEntry2
private val doorList: List<DoorEntry>
get() = listOf(
door1,
door2
)
override fun onCreate() {
super.onCreate()
door.init(doorList) // Initializes all registered doors
}
}
Add the following dependency to your module-level build.gradle file:
implementation("com.github.shubham-gadekar-alpha:Modules-Door-Lib:v1.0.1")Also make sure you have JitPack added to your project-level settings.gradle (or build.gradle if using older Gradle):
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
- Support command-based messaging
- Support flow-based event streaming
- Add support for Jetpack Compose UI sharing
- Advanced debugging & logging tools
- π Report Issues: Submit bugs found or log feature requests for the
Modules-Door-Libproject. - π‘ Submit Pull Requests: Review open PRs, and submit your own PRs.
Contributing Guidelines
- Fork the Repository: Start by forking the project repository to your github account.
- Clone Locally: Clone the forked repository to your local machine using a git client.
git clone https://github.com/shubham-gadekar-alpha/Modules-Door-Lib/
- Create a New Branch: Always work on a new branch, giving it a descriptive name.
git checkout -b new-feature-x
- Make Your Changes: Develop and test your changes locally.
- Commit Your Changes: Commit with a clear message describing your updates.
git commit -m 'Implemented new feature x.' - Push to github: Push the changes to your forked repository.
git push origin new-feature-x
- Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
- Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
- List any resources, contributors, inspiration, etc. here.
- Inspired by the need for clean multi-module Android architecture.