Skip to main content
The domain layer is the innermost ring of the architecture. It contains no framework imports and no knowledge of how data is fetched or displayed. Everything else depends on it.

Structure

The Movie entity

Movie is the canonical representation of a film throughout the application. It is a plain Dart class with no serialization logic or external dependencies.

Field reference

posterPath and backdropPath on the domain entity are already full URLs. The infrastructure mapper is responsible for constructing them — the domain entity never knows about the image CDN.

Abstract datasource

MoviesDatasource is an abstract class that declares what operations any data source must support. The domain defines the contract; the infrastructure fulfills it.
All methods accept a page parameter that defaults to 1, enabling pagination without forcing callers to supply it.

Abstract repository

MoviesRepository mirrors the datasource contract. The extra abstraction layer allows the application to swap datasources or add caching inside a repository implementation without changing the presentation layer.
The repository and datasource abstractions look identical here, but they serve different purposes. The datasource is about raw data access; the repository is where business logic (caching, merging sources, error handling) would live as the app grows.