Skip to content

Architecture Framework for Kotlin. Reuse every line of code. Handle all errors automatically. No boilerplate. Build features in minutes. Analytics, metrics, debugging in 3 lines of code. Make all code thread-safe. 50+ features.

License

Notifications You must be signed in to change notification settings

respawn-app/FlowMVI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlowMVI Framework Banner

CI License GitHub last commit Issues GitHub top language AndroidWeekly #563 Slack channel Ask DeepWiki

badge badge badge badge badge badge badge badge badge badge badge

FlowMVI is a Kotlin Multiplatform Architectural Framework.

It adds a plug-in system to your code that helps prevent crashes, handle errors, split responsibilities, reuse code, collect analytics, debug & log operations, monitor & improve performance, achieve thread-safety, save state, manage background jobs, and more.

⚡️ Quickstart:

  • Get Started in 10 mins: Quickstart
  • Latest version: Maven Central
  • API Docs: Javadoc
  • Sample App + Showcase (Web): Sample
  • Ask questions on Slack
Version catalogs
[versions]
flowmvi = "< Badge above 👆🏻 >"

[dependencies]
# Core KMP module
flowmvi-core = { module = "pro.respawn.flowmvi:core", version.ref = "flowmvi" }
# Test DSL
flowmvi-test = { module = "pro.respawn.flowmvi:test", version.ref = "flowmvi" }
# Compose multiplatform
flowmvi-compose = { module = "pro.respawn.flowmvi:compose", version.ref = "flowmvi" }
# Android (common + view-based)
flowmvi-android = { module = "pro.respawn.flowmvi:android", version.ref = "flowmvi" }
# Multiplatform state preservation
flowmvi-savedstate = { module = "pro.respawn.flowmvi:savedstate", version.ref = "flowmvi" }
# Performance metrics collection
flowmvi-metrics = { module = "pro.respawn.flowmvi:metrics", version.ref = "flowmvi" }
# Remote debugging client
flowmvi-debugger-client = { module = "pro.respawn.flowmvi:debugger-plugin", version.ref = "flowmvi" }
# Essenty (Decompose) integration
flowmvi-essenty = { module = "pro.respawn.flowmvi:essenty", version.ref = "flowmvi" }
flowmvi-essenty-compose = { module = "pro.respawn.flowmvi:essenty-compose", version.ref = "flowmvi" }
Gradle DSL
dependencies {
    val flowmvi = "< Badge above 👆🏻 >"
    // Core KMP module
    commonMainImplementation("pro.respawn.flowmvi:core:$flowmvi")
    // compose multiplatform
    commonMainImplementation("pro.respawn.flowmvi:compose:$flowmvi")
    // saving and restoring state
    commonMainImplementation("pro.respawn.flowmvi:savedstate:$flowmvi")
    // metrics collection & export
    commonMainImplementation("pro.respawn.flowmvi:metrics:$flowmvi")
    // essenty integration
    commonMainImplementation("pro.respawn.flowmvi:essenty:$flowmvi")
    commonMainImplementation("pro.respawn.flowmvi:essenty-compose:$flowmvi")
    // testing DSL
    commonTestImplementation("pro.respawn.flowmvi:test:$flowmvi")
    // android integration
    androidMainImplementation("pro.respawn.flowmvi:android:$flowmvi")
    // remote debugging client
    androidDebugImplementation("pro.respawn.flowmvi:debugger-plugin:$flowmvi")
}

🚀 Why FlowMVI?

Usually architecture frameworks mean boilerplate, restrictions, and support difficulty for marginal benefits of "clean code". FlowMVI does not dictate what your code should do or look like. Instead, this library focuses on building a supporting infrastructure to enable new possibilities for your app.

Here's what you get:

  • Powerful plug-in system to reuse any business logic you desire. Write your auth, error handling, analytics, logging, configuration, and any other code once and forget about it, focusing on more important things instead.

  • Automatically recover from exceptions, prevent crashes, and report them to analytics.

  • Automatically collect and view logs: forget about Log.e("asdf") sprinkling.

  • Collect 50+ performance metrics with Prometheus, Grafana, OpenTelemetry export and 5 lines of setup.

  • Manage concurrent, long-running background jobs with complete thread-safety.

  • Debounce, retry, batch, throttle, conflate, intercept any operations automatically

  • Compress, persist, and restore state automatically on any platform

  • Create compile-time safe state machines with a readable DSL. Forget about casts, inconsistent states, and nulls

  • Share, distribute, disable, intercept, safely manage side-effects

  • Build fully async, reactive and parallel apps - with no manual thread synchronization required!

  • Write simple, familiar MVVM+ code or follow MVI/Redux - no limits or requirements

  • Build restartable, reusable business logic components with no external dependencies or dedicated lifecycles

  • No base classes, complicated abstractions, or factories of factories - write simple, declarative logic using a DSL

  • Automatic multiplatform system lifecycle handling

  • First class, one-liner Compose Multiplatform support with Previews and UI tests.

  • Integrates with Decompose, Koin, Kodein, androidx.navigation, Nav3, and more

  • Dedicated IDE Plugin for debugging and codegen and app for Windows, Linux, macOS

  • The core library has no dependencies - just coroutines

  • Extensively covered by 350+ tests

  • Minimal performance overhead, equal to using a simple Channel, with regular benchmarking

  • Test any business logic using clean, declarative DSL

  • Learn more by exploring the sample app in your browser

  • 10 minutes to try by following the Quickstart Guide.

đź‘€ Show me the code!

Here is an example of your new workflow:

1. Define a Contract:

sealed interface State : MVIState {

    data object Loading : State
    data class Error(val e: Exception) : State
    data class Content(val user: User?) : State
}

sealed interface Intent : MVIIntent {
    data object ClickedSignOut : Intent
}

sealed interface Action : MVIAction { // optional side-effect
    data class ShowMessage(val message: String) : Action
}

2. Declare your business logic:

val authStore = store(initial = State.Loading, coroutineScope) {
    recover { e: Exception -> // handle errors
        updateState { State.Error(e) }
        null
    }
    init { // load data
        updateState {
            State.Content(user = repository.loadUser())
        }
    }
    reduce { intent: Intent -> // respond to events
        when (intent) {
            is ClickedSignOut -> updateState<State.Content, _> {
                
                action(ShowMessage("Bye!"))
                copy(user = null)
            }
        }
    }
}

FlowMVI lets you scale your app in a way that does not increase complexity. Adding a new feature is as simple as calling a function.

Extend your logic with Plugins

Powerful DSL allows you to hook into various events and amend any part of your logic:

fun analyticsPlugin(analytics: Analytics) = plugin<MVIState, MVIIntent, MVIAction> {
    onStart {
        analytics.logScreenView(config.name) // name of the screen
    }
    onIntent { intent ->
        analytics.logUserAction(intent.name)
    }
    onException { e ->
        analytics.logError(e)
    }
    onSubscribe {
        analytics.logEngagementStart(config.name)
    }
    onUnsubscribe {
        analytics.logEngagementEnd(config.name)
    }
    onStop {
        analytics.logScreenLeave(config.name)
    }
}

Never write analytics, debugging, logging, or state persistence code again.

Compose Multiplatform

Using FlowMVI with Compose is a matter of one line of code:

@Composable
fun AuthScreen() {
    // subscribe based on system lifecycle - on any platform
    val state by authStore.subscribe

    when (state) {
        is Content -> {
            Button(onClick = { store.intent(ClickedSignOut) }) {
                Text("Sign Out")
            }
        }
    }
}

Enjoy testable UI and free @Previews.

Testing DSL

Bundled Test Harness with minimal verbosity:

Test Stores

authStore.subscribeAndTest {
    // turbine + kotest example
    
    intent(ClickedSignOut)
    
    states.test {
        awaitItem() shouldBe Content(user = null)
    }
    actions.test {
        awaitItem() shouldBe ShowMessage("Bye!")
    }
}

Test plugins

val timer = Timer()
timerPlugin(timer).test(Loading) {

    onStart()

    // time travel keeps track of all plugin operations for you
    assert(timeTravel.starts == 1)
    assert(state is DisplayingCounter)
    assert(timer.isStarted)

    onStop(null)

    assert(!timer.isStarted)
}

Finally stop writing UI tests and replace them with unit tests.

Debugger IDE Plugin + App

IDE plugin generates code and lets you debug and control your app remotely: Plugin

Debugger.mp4

People love the library:

Star History Chart

Ready to try?

Begin by reading the Quickstart Guide.


License

   Copyright 2022-2026 Respawn Team and contributors

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       https://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

About

Architecture Framework for Kotlin. Reuse every line of code. Handle all errors automatically. No boilerplate. Build features in minutes. Analytics, metrics, debugging in 3 lines of code. Make all code thread-safe. 50+ features.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Languages