How trosydman/justposts works
Main Components
• UI Layer:
• MainActivity.kt as the single-activity host.
• Two main Fragments: PostsFragment.kt (displays a paginated list of posts) and PostDetailsFragment.kt (displays details for a selected post).
• Associated ViewModels: PostsViewModel.kt and PostDetailsViewModel.kt.
• Domain Layer:
• Data models representing the domain (Post and User).
• Mappers (PostsResponseDTOMapper.kt and Data1DTOMapper.kt) to convert data from API responses into UI/domain models.
• Data Layer:
• Repository: PostRepository.kt, which encapsulates logic for data retrieval.
• Data Sources:
▫ Remote: GraphQLRemoteDataSource (and GraphQLZeroClient with its interface IGraphQLZeroClient for GraphQL communication).
• GraphQL schema and query files (Posts.graphql, schema.json) located under the graphql directory.
• Dependency Injection and Configuration:
• DI modules (ClientModule.kt, NetworkModule.kt, RemoteModule.kt, RepositoryModule.kt) that define how dependencies are provided.
• Build scripts and Gradle configuration files.
Relationships and Interactions
• The UI layer (Activity/Fragments) observes data via their respective ViewModels.
• ViewModels interact with the PostRepository to retrieve and update data.
• The Repository uses the GraphQLRemoteDataSource, which in turn uses the Apollo Client (configured and provided via DI) to fetch data from the GraphQLZero API.
• Mappers convert raw API responses into clean domain models that the UI can use.
• Dependency Injection (using Hilt) ties together these objects to ensure proper lifecycle and instance management.
Architectural Patterns and Principles
• MVVM (Model-View-ViewModel): Separates UI (Activities/Fragments) from business logic (ViewModels) and data handling.
• Clean Architecture/Repository Pattern: The repository abstracts data operations, and mappers decouple the DTOs (from Apollo) from domain models.
• Dependency Injection (Hilt): Simplifies the construction and management of dependency graphs.
Relevant Technologies and Frameworks
• Kotlin as the programming language.
• Android Jetpack components (ViewModel, LiveData, Navigation, Paging 3).
• Apollo Client for GraphQL.
• Hilt for dependency injection.
• Material Design for consistent user experience.