---
title: "Architecture & Best Practices"
canonical_url: "https://apidocs.sportradar.com/resources/epsilon-sdk/docs/architecture"
markdown_url: "https://apidocs.sportradar.com/resources/epsilon-sdk/docs/architecture.md"
last_updated: "2026-06-15T10:09:12Z"
---

# Architecture & Best Practices

Epsilon SDK follows modern Android and Kotlin Multiplatform development patterns. While it is designed to be flexible, adhering to these patterns ensures better integration and maintainability.

> **Note**
>
> This page focuses on recommended integration patterns for projects that adopt Epsilon SDK modules.

## MVVM Pattern

The SDK promotes the **Model-View-ViewModel (MVVM)** architecture.

### ViewModel handling

ViewModels should be handled in a platform-agnostic way.

- In your KMP modules, you should extend the official `androidx.lifecycle.ViewModel`.

### State Management

States should be immutable data classes. Use `StateFlow` to expose state from ViewModels to the UI.

**Example state setup**

```kotlin
data class MyState(
    val isLoading: Boolean = false,
    val data: List<String> = emptyList(),
    val error: String? = null
)

class MyViewModel : ViewModel() {
    private val _state = MutableStateFlow(MyState())
    val state: StateFlow<MyState> = _state.asStateFlow()

    fun loadData() {
        viewModelScope.launch {
            _state.update { it.copy(isLoading = true) }
            // ... load data
            _state.update { it.copy(isLoading = false, data = result) }
        }
    }
}
```

## Networking Guidelines

When using `epsilon-networking`, follow these best practices:

1. **Structured Responses**: Always use `NetworkResponse<T>` to wrap your API calls. It handles success and failure cases gracefully.
2. **Error Resolution**: Use the `NetworkErrorResolver` to map HTTP errors to domain-specific error models.
3. **Dispatchers**: Use `Dispatchers.IO` for network operations to ensure optimal performance across platforms. The default implementation in Epsilon uses `Dispatchers.IO` for all targets except JavaScript, which uses `Dispatchers.Default`.

## UI & Resources

- **Jetpack Compose**: All UI components (if provided by a KMP SDK) are built with Compose Multiplatform.
- **Moko Resources**: Use the `epsilon-string` module to manage localized strings and colors. This allows you to share resources between Android and iOS.
- **Naming Conventions**: Use descriptive names for states and events (e.g., `onBackClick`, `isSubmitting`).

## Dependency Injection

The Epsilon SDK is designed to be DI-agnostic. While Sportradar projects often use **Koin**, the SDK itself does not enforce any specific DI framework, allowing it to be used in any project environment.

> **Tip**
>
> For project setup details, continue with the [Integration Guide](https://apidocs.sportradar.com/resources/epsilon-sdk/docs/integration_guide.md).
