How trosydman/realstation works
Project Type & Purpose
• The RealStation project is an Android mobile app built using 100% Kotlin and Jetpack Compose.
• Its purpose is to display a list of real estate items fetched from a remote endpoint. When a user selects an item, the app navigates to a details screen showing more information.
• The architecture is based on the MVI (Model-View-Intent) pattern combined with UDF (Unidirectional Data Flow) and follows additional principles like CLEAN, SOLID, and the Repository pattern.
Analyzing the File Structure
• The project is structured into several layers:
• The “ui” package contains all the presentation components (composables, screens, view models for list and details, navigation, theme).
• The “domain” package includes interfaces (such as the repository abstraction) and domain models, plus mapping utilities under “utils.”
• The “data” package implements data retrieval through RealStateRepositoryImpl, defines remote models in “remote/model,” and manages dependency injection (DI) through DataModule.
• Additional directories such as “extensions” and “utils” provide utility functions and coroutine dispatchers.
• Dependency management is handled using Gradle with a TOML file for version catalogs, while Hilt is used for Dependency Injection.
Main Components to be Represented
a. Presentation/UI Layer:
• MainActivity: The single-activity entry point.
• RealStateListScreen: Displays the list of real estate listings.
• RealStateDetailsScreen: Shows detailed information when an item is selected.
• ViewModels: RealStateListViewModel and RealStateDetailsViewModel that manage UI state (RealStateListUIState and RealStateDetailsUIState) through MVI + UDF.
• Composable components and Material Design theming (with separate design for light and dark themes).
b. Domain Layer:
• RealStateRepository interface: Defines the contract for data operations.
• Domain models (e.g., RealState) and mappers that convert between data and UI models (via DomainMapper and UIMapper).
c. Data Layer:
• RealStateRepositoryImpl: Implements data retrieval logic.
• Remote layers include:
• AvivAPI: Retrofit interface to consume the external JSON endpoint.
• NetworkConnectionInterceptor: Handles network call changes.
• DTOs and corresponding mappers (RealStateDTO, RealStateDTOMapper, RealStateListDTO, RealStateListDTOMapper) that convert network responses to usable data models.
d. Dependency Injection (DI):
• Modules in “data/di” (DataModule) and “ui/di” (UIModule) to inject required dependencies (repository, API client, coroutine dispatchers, etc.).
e. Utility Components:
• Extensions (e.g., BigDecimalX) and additional modules within “utils” for resources and coroutine dispatchers.
Relationships and Interactions
• UI components (screens and view models) retrieve data by calling methods on the domain layer through the injected RealStateRepository.
• The domain layer abstracts the underlying implementation which, in the data layer, calls the AvivAPI with Retrofit.
• Dependency injection modules supply the concrete implementations for the repository, network clients, and coroutine dispatchers to both the UI and data layers.
Architectural Patterns & Design Principles
• The use of MVI alongside UDF for managing UI state and events.
• Repository pattern that abstracts data fetching.
• Single-Activity pattern with composable screens.
• Clean architecture separation between UI, Domain, and Data layers.
• SOLID principles ensuring each component has a distinct responsibility.