# yulianmartinez/movienik architecture

> Architecture diagram of the GitHub repository yulianmartinez/movienik, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yulianmartinez/movienik
- Repository: https://github.com/yulianmartinez/movienik

## Overview

1. **Overall structure**
   - This is a **multi-module Android app** in Kotlin, organized around **Clean Architecture + MVVM**.
   - The modules are:
     - **app**: presentation/UI layer
     - **domain**: business rules and contracts
     - **infrastructure**: API access, data mapping, and repository implementations
   - Dependency direction is intended to flow inward: **presentation → domain ← infrastructure**.

2. **Primary business purpose**
   - The app is a **TV series search client** for the **TVMaze public API**.
   - Users can:
     - search for shows,
     - open show details,
     - browse episodes.
   - The architecture is centered on these three use cases, which are reflected in the domain and infrastructure packages.

3. **Presentation layer (`app`)**
   - The presentation module contains the Android UI surface:
     - `activity`: `SplashActivity`, `HomeActivity`, `DetailActivity`
     - `fragment`: `HomeFragment`
     - `widget`: custom search UI (`SearchMovienik`)
     - `adapter`: RecyclerView adapters/view holders for shows and episodes
     - `viewmodel`: `SearchViewModel`, `DetailViewModel`, `EpisodeViewModel`
   - This layer owns user interaction, rendering, and navigation, but should not contain API logic.

4. **Navigation and screen flow**
   - The likely user flow is:
     - **SplashActivity** opens the app,
     - **HomeActivity / HomeFragment** presents search and results,
     - selecting a show navigates to **DetailActivity**,
     - episodes are fetched/displayed from the detail path.
   - A `router/HomeRouting.kt` file suggests a centralized navigation helper rather than scattered intent handling.

5. **ViewModel boundary**
   - The ViewModels are the bridge between UI and domain services.
   - They likely orchestrate:
     - search queries,
     - show detail loading,
     - episode loading,
     - state presentation to adapters/views.
   - The presence of extension files like `CoroutineExtension`, `ViewModelExtension`, and `MessageExtension` suggests common UI state/error handling patterns are standardized here.

6. **Domain layer (`domain`)**
   - The domain module defines the core contracts and models:
     - `model`: `Show`, `Episode`, `Image`
     - `dto`: `SearchResultDto`
     - `repository`: `SearchRepository`, `DetailRepository`, `EpisodeRepository`
     - `service`: `SearchService`, `DetailService`, `EpisodeService`
     - `exception`: domain-specific exceptions for each flow
   - This module contains the business-facing API of the app and is intentionally independent of Android and network libraries.

7. **Infrastructure layer (`infrastructure`)**
   - This module implements the domain repository contracts and handles all back-end communication.
   - Key responsibilities:
     - HTTP/API access through `rest/endpoint` and `rest/manager`
     - request customization in `rest/interceptor/RequestInterceptor`
     - mapping from network/entity objects into domain models via `mapper`
     - repository implementations in `repository`
   - This is the only layer that should know the details of the TVMaze API.

8. **Data model translation**
   - Infrastructure uses its own transport/storage shapes:
     - `ShowEntity`, `EpisodeEntity`, `ImageEntity`, `SearchResultEntity`
   - Mappers such as `ShowTranslate`, `EpisodeTranslate`, `ImageTranslate`, and `SearchResultTranslate` convert between infrastructure entities and domain models.
   - This mapping boundary is important: it isolates the rest of the app from API shape changes.

9. **Networking and API composition**
   - The REST stack is split into:
     - `endpoint`: API interface definitions for search, detail, and episodes
     - `manager`: API manager wrappers for those endpoints
     - `interceptor`: shared request behavior
   - The DI modules (`HttpClientModule`, `DispatcherModule`, and feature modules under `di/search`, `di/detail`, `di/episode`) wire these pieces together.
   - This suggests the app uses dependency injection to assemble networking, threading, and repositories per feature.

10. **Feature-specific flows**
   - There are three clear vertical slices:
     - **Search**: query TVMaze, receive a list of shows, render in the home screen
     - **Detail**: fetch one show’s detail payload
     - **Episode**: fetch episodes for a selected show
   - Each slice has its own repository/service/endpoint/DI wiring, which keeps feature responsibilities separated.

11. **UI rendering primitives**
   - Result lists are rendered through `ShowAdapter`/`ShowViewHolder` and `EpisodeAdapter`/`EpisodeViewHolder`.
   - Selection callbacks are abstracted via `OnShowSelectedListener` and `OnEpisodeSelectedListener`.
   - This keeps the adapters generic and lets the fragment/activity own navigation or detail actions.

12. **Shared presentation utilities**
   - The `extension` package contains reusable UI helpers:
     - image loading
     - logging
     - navigation
     - click safety
     - visibility helpers
     - edit text validation
   - These are cross-cutting presentation concerns and reduce boilerplate across activities, fragments, and ViewModels.

13. **Android-specific resource layer**
   - The app includes standard Android resources for layouts, drawables, themes, and raw assets.
   - Notable raw assets like `empty_effect.json` and `nothing_here.json` indicate the app uses visual empty-state animations/effects in the UI.

14. **Testing boundaries**
   - The repository includes:
     - unit tests in `app/src/test`
     - instrumentation tests in `app/src/androidTest`
     - infrastructure unit tests
   - The README indicates tests exist for:
     - ViewModels in presentation
     - services in domain
     - mappers in infrastructure
   - That matches the layered architecture: each layer is tested at its own boundary.

15. **Architecture summary for diagramming**
   - If you draw this repo, model it as:
     - **UI layer** at the top, handling screens, adapters, and ViewModels
     - **Domain layer** in the middle, exposing services, repository interfaces, models, and exceptions
     - **Infrastructure layer** at the bottom, implementing repositories and calling the TVMaze API
   - The key data flow is:
     - **user input → ViewModel → domain service → repository interface → infrastructure implementation → TVMaze API → mapper → domain model → UI state/rendering**

Main entry points: [`infrastructure`](https://github.com/yulianmartinez/movienik/tree/master/infrastructure) (infrastructure), [`app`](https://github.com/yulianmartinez/movienik/tree/master/app) (app), [`app/src/main/java/com/ymd/movienik/ui`](https://github.com/yulianmartinez/movienik/tree/master/app/src/main/java/com/ymd/movienik/ui) (Screens), [`domain/src/main/java/com/ymd/domain/service`](https://github.com/yulianmartinez/movienik/tree/master/domain/src/main/java/com/ymd/domain/service) (Services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_app_module["app<br/>android-ui module"]
  node_app_ui["Screens<br/>activities/fragments"]
  node_app_vm["ViewModels<br/>ui state"]
  node_app_list["Adapters<br/>list rendering"]
  node_app_nav["Router<br/>navigation helper"]
end

subgraph group_domain["Domain"]
  node_domain_module["domain<br/>core module"]
  node_domain_services["Services"]
  node_domain_repos["Repos<br/>contracts"]
  node_domain_models["Models<br/>domain data"]
end

subgraph group_infrastructure["Infrastructure"]
  node_infra_module["infrastructure<br/>data module"]
  node_infra_di["DI<br/>dependency wiring"]
  node_infra_repos["Repo impls<br/>repository adapters"]
  node_infra_rest["REST stack<br/>api access"]
  node_infra_map["Mappers<br/>translation layer"]
  node_infra_entities["Entities<br/>transport models"]
end

node_app_module -->|"contains"| node_app_ui
node_app_module -->|"contains"| node_app_vm
node_app_module -->|"contains"| node_app_list
node_app_module -->|"contains"| node_app_nav
node_app_ui -->|"binds to"| node_app_vm
node_app_list -->|"renders in"| node_app_ui
node_app_ui -->|"requests"| node_domain_services
node_app_vm -->|"orchestrates"| node_domain_services
node_domain_module -->|"contains"| node_domain_services
node_domain_module -->|"contains"| node_domain_repos
node_domain_module -->|"contains"| node_domain_models
node_domain_services -->|"depends on"| node_domain_repos
node_infra_module -->|"contains"| node_infra_di
node_infra_module -->|"contains"| node_infra_repos
node_infra_module -->|"contains"| node_infra_rest
node_infra_module -->|"contains"| node_infra_map
node_infra_module -->|"contains"| node_infra_entities
node_infra_repos -->|"implements"| node_domain_repos
node_infra_repos -->|"fetches from"| node_infra_rest
node_infra_rest -->|"returns"| node_infra_entities
node_infra_map -->|"maps to"| node_domain_models
node_infra_entities -->|"translated by"| node_infra_map

click node_app_module "https://github.com/yulianmartinez/movienik/tree/master/app"
click node_app_ui "https://github.com/yulianmartinez/movienik/tree/master/app/src/main/java/com/ymd/movienik/ui"
click node_app_vm "https://github.com/yulianmartinez/movienik/tree/master/app/src/main/java/com/ymd/movienik/viewmodel"
click node_app_list "https://github.com/yulianmartinez/movienik/tree/master/app/src/main/java/com/ymd/movienik/adapter"
click node_app_nav "https://github.com/yulianmartinez/movienik/tree/master/app/src/main/java/com/ymd/movienik/router"
click node_domain_module "https://github.com/yulianmartinez/movienik/tree/master/domain"
click node_domain_services "https://github.com/yulianmartinez/movienik/tree/master/domain/src/main/java/com/ymd/domain/service"
click node_domain_repos "https://github.com/yulianmartinez/movienik/tree/master/domain/src/main/java/com/ymd/domain/repository"
click node_domain_models "https://github.com/yulianmartinez/movienik/tree/master/domain/src/main/java/com/ymd/domain/model"
click node_infra_module "https://github.com/yulianmartinez/movienik/tree/master/infrastructure"
click node_infra_di "https://github.com/yulianmartinez/movienik/tree/master/infrastructure/src/main/java/com/ymd/infrastructure/di"
click node_infra_repos "https://github.com/yulianmartinez/movienik/tree/master/infrastructure/src/main/java/com/ymd/infrastructure/repository"
click node_infra_rest "https://github.com/yulianmartinez/movienik/tree/master/infrastructure/src/main/java/com/ymd/infrastructure/rest"
click node_infra_map "https://github.com/yulianmartinez/movienik/tree/master/infrastructure/src/main/java/com/ymd/infrastructure/mapper"
click node_infra_entities "https://github.com/yulianmartinez/movienik/tree/master/infrastructure/src/main/java/com/ymd/infrastructure/entity"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_module,node_app_ui,node_app_vm,node_app_list,node_app_nav toneBlue
class node_domain_module,node_domain_services,node_domain_repos,node_domain_models toneAmber
class node_infra_module,node_infra_di,node_infra_repos,node_infra_rest,node_infra_map,node_infra_entities toneMint
```

## Components

### Presentation

Android UI, navigation, and ViewModels

- [app](https://github.com/yulianmartinez/movienik/tree/master/app): android-ui module · Presentation module with activities, fragments, adapters, and ViewModels · `app`
- [Screens](https://github.com/yulianmartinez/movienik/tree/master/app/src/main/java/com/ymd/movienik/ui): activities/fragments · Splash, home, and detail screens plus the main fragment and custom widget · `app/src/main/java/com/ymd/movienik/ui`
- [ViewModels](https://github.com/yulianmartinez/movienik/tree/master/app/src/main/java/com/ymd/movienik/viewmodel): ui state · Search, detail, and episode state orchestration for the UI · `app/src/main/java/com/ymd/movienik/viewmodel`
- [Adapters](https://github.com/yulianmartinez/movienik/tree/master/app/src/main/java/com/ymd/movienik/adapter): list rendering · RecyclerView adapters and holders for shows and episodes · `app/src/main/java/com/ymd/movienik/adapter`
- [Router](https://github.com/yulianmartinez/movienik/tree/master/app/src/main/java/com/ymd/movienik/router): navigation helper · Centralized navigation and cross-cutting presentation helpers · `app/src/main/java/com/ymd/movienik/router`

### Domain

Business rules, models, services, and repository contracts

- [domain](https://github.com/yulianmartinez/movienik/tree/master/domain): core module · Pure business layer with models, services, and contracts · `domain`
- [Services](https://github.com/yulianmartinez/movienik/tree/master/domain/src/main/java/com/ymd/domain/service): use-case services · Search, detail, and episode business operations · `domain/src/main/java/com/ymd/domain/service`
- [Repos](https://github.com/yulianmartinez/movienik/tree/master/domain/src/main/java/com/ymd/domain/repository): contracts · Repository interfaces consumed by the services · `domain/src/main/java/com/ymd/domain/repository`
- [Models](https://github.com/yulianmartinez/movienik/tree/master/domain/src/main/java/com/ymd/domain/model): domain data · Show, episode, image, and search result types plus exceptions · `domain/src/main/java/com/ymd/domain/model`

### Infrastructure

API access, mapping, repository implementations, and DI

- [infrastructure](https://github.com/yulianmartinez/movienik/tree/master/infrastructure): data module · TVMaze API integration, translation, and repository implementations · `infrastructure`
- [DI](https://github.com/yulianmartinez/movienik/tree/master/infrastructure/src/main/java/com/ymd/infrastructure/di): dependency wiring · Modules that assemble HTTP clients, dispatchers, and feature bindings · `infrastructure/src/main/java/com/ymd/infrastructure/di`
- [Repo impls](https://github.com/yulianmartinez/movienik/tree/master/infrastructure/src/main/java/com/ymd/infrastructure/repository): repository adapters · Concrete implementations of the domain repositories · `infrastructure/src/main/java/com/ymd/infrastructure/repository`
- [REST stack](https://github.com/yulianmartinez/movienik/tree/master/infrastructure/src/main/java/com/ymd/infrastructure/rest): api access · Endpoints, API managers, and request interception for TVMaze · `infrastructure/src/main/java/com/ymd/infrastructure/rest`
- [Mappers](https://github.com/yulianmartinez/movienik/tree/master/infrastructure/src/main/java/com/ymd/infrastructure/mapper): translation layer · Converts API entities into domain models · `infrastructure/src/main/java/com/ymd/infrastructure/mapper`
- [Entities](https://github.com/yulianmartinez/movienik/tree/master/infrastructure/src/main/java/com/ymd/infrastructure/entity): transport models · Network-facing data shapes for shows, episodes, images, and search results · `infrastructure/src/main/java/com/ymd/infrastructure/entity`

## Connections

- app → Screens: contains · Android presentation surface
- app → ViewModels: contains · ViewModels live in the app module
- app → Adapters: contains · List adapters and view holders
- app → Router: contains · Navigation and shared UI helpers
- Screens → ViewModels: binds to · Screens observe and drive ViewModels
- Adapters → Screens: renders in · Adapters are hosted by screens
- Screens → Services: requests · User actions trigger domain use cases through ViewModels
- ViewModels → Services: orchestrates · ViewModels coordinate search/detail/episode flows
- domain → Services: contains · Core use-case services
- domain → Repos: contains · Repository contracts
- domain → Models: contains · Core data and exceptions
- Services → Repos: depends on · Services call repository interfaces
- infrastructure → DI: contains · Dependency wiring
- infrastructure → Repo impls: contains · Repository implementations
- infrastructure → REST stack: contains · HTTP and API composition
- infrastructure → Mappers: contains · Domain translation boundary
- infrastructure → Entities: contains · API transport shapes
- Repo impls → Repos: implements · Concrete data access behind contracts
- Repo impls → REST stack: fetches from · Repositories call API managers
- REST stack → Entities: returns · API responses are shaped as entities
- Mappers → Models: maps to · Transforms transport data into business models
- Entities → Mappers: translated by · Entities feed the mapping layer
