How yulianmartinez/challengetribal works
Purpose and Entry Point
This is a native Android app that fetches and displays Chuck Norris joke categories from https://api.chucknorris.io/jokes/categories. The launch/UI entry is app/src/main/java/com/ymd/tribalchallenge/ui/MainActivity.kt; application-wide initialization is in app/src/main/java/com/ymd/tribalchallenge/ui/TribalApplication.kt. The project is split into app, domain, and infrastructure Gradle modules.
Presentation Layer
The app module owns Android lifecycle integration, XML views, and MVVM presentation state. MainActivity renders app/src/main/res/layout/activity_main.xml and delegates category loading to app/src/main/java/com/ymd/tribalchallenge/viewmodel/CategoryViewModel.kt. This layer should depend on domain contracts rather than network details.
Category List Rendering
Categories are presented through RecyclerView-style adapter components: app/src/main/java/com/ymd/tribalchallenge/ui/adapter/CategoryAdapter.kt, app/src/main/java/com/ymd/tribalchallenge/ui/adapter/CategoryViewHolder.kt, and app/src/main/res/layout/item_category.xml. CategoryListener.kt forms the UI interaction boundary for category item events.
Domain Contracts and Use Case
The domain module contains framework-independent category abstractions. domain/src/main/java/com/ymd/domain/service/CategoryService.kt defines the category-oriented business operation, while domain/src/main/java/com/ymd/domain/repository/CategoryRepository.kt defines the data-access boundary. Error semantics are centralized in domain/src/main/java/com/ymd/domain/exception/AppException.kt and domain/src/main/java/com/ymd/domain/exception/CategoryException.kt.
Infrastructure and Remote Boundary
Infrastructure implements domain-facing category access and owns the HTTP/API details. infrastructure/src/main/java/com/ymd/infrastructure/service/CategoryServiceImpl.kt is the concrete service implementation, and infrastructure/src/main/java/com/ymd/infrastructure/api/ApiCategory.kt represents the remote endpoint boundary. The sole identified external service is the public Chuck Norris API; no persistence backend is evident from the tree.
Dependency Injection and Async Execution
Dependency wiring is organized in infrastructure/src/main/java/com/ymd/infrastructure/di/CategoryModule.kt, which binds category dependencies across domain and infrastructure. infrastructure/src/main/java/com/ymd/infrastructure/di/HttpClientModule.kt supplies HTTP-client dependencies, and infrastructure/src/main/java/com/ymd/infrastructure/di/DispatcherModule.kt supplies coroutine dispatchers. Coroutines carry asynchronous work from the ViewModel through domain/infrastructure to the remote API.
Primary Flow
1. Android starts TribalApplication and MainActivity.
2. CategoryViewModel requests categories through the domain CategoryService/CategoryRepository boundary.
3. DI resolves the infrastructure implementation.
4. CategoryServiceImpl calls ApiCategory, using the configured HTTP client, against Chuck Norris API.
5. Results or mapped domain exceptions return to the ViewModel.
6. The activity updates the category adapter and item layout on the Android UI boundary.
Main entry points: CategoryServiceImpl.kt CategoryServiceImpl · MainActivity.kt MainActivity · CategoryViewModel.kt CategoryViewModel · CategoryAdapter.kt Category list renderer
Components 16
Android Presentation
App module lifecycle, state, and XML rendering.
- TribalApplication · Initializes application-wide dependencies.
app/src/main/java/com/ymd/tribalchallenge/ui/TribalApplication.kt - MainActivity · Launches category screen and renders state.
app/src/main/java/com/ymd/tribalchallenge/ui/MainActivity.kt - Main screen layout
app/src/main/res/layout/activity_main.xml - CategoryViewModel · Loads categories asynchronously for the UI.
app/src/main/java/com/ymd/tribalchallenge/viewmodel/CategoryViewModel.kt - Category list renderer · Adapter and holder render category rows.
app/src/main/java/com/ymd/tribalchallenge/ui/adapter/CategoryAdapter.kt - Category row layout
app/src/main/res/layout/item_category.xml - CategoryListener
app/src/main/java/com/ymd/tribalchallenge/ui/adapter/CategoryListener.kt
Domain
Framework-independent category contracts and errors.
- CategoryService · Defines category business operation.
domain/src/main/java/com/ymd/domain/service/CategoryService.kt - CategoryRepository · Abstracts category retrieval.
domain/src/main/java/com/ymd/domain/repository/CategoryRepository.kt - Domain exceptions · Centralizes application and category errors.
domain/src/main/java/com/ymd/domain/exception/AppException.kt
Infrastructure
Remote implementation, HTTP, and dependency wiring.
- CategoryServiceImpl · Maps remote results and failures to domain behavior.
infrastructure/src/main/java/com/ymd/infrastructure/service/CategoryServiceImpl.kt - ApiCategory · Represents the categories endpoint.
infrastructure/src/main/java/com/ymd/infrastructure/api/ApiCategory.kt - CategoryModule · Binds domain category contracts to infrastructure.
infrastructure/src/main/java/com/ymd/infrastructure/di/CategoryModule.kt - HttpClientModule
infrastructure/src/main/java/com/ymd/infrastructure/di/HttpClientModule.kt - DispatcherModule
infrastructure/src/main/java/com/ymd/infrastructure/di/DispatcherModule.kt
Other components
- Chuck Norris API · Public categories endpoint.
Connections 18
- TribalApplication → CategoryModule: initializes DI
- TribalApplication → MainActivity: starts
- MainActivity → Main screen layout: renders
- MainActivity → CategoryViewModel: observes state
- MainActivity → Category list renderer: updates categories
- Category list renderer → Category row layout: inflates
- Category list renderer → CategoryListener: emits item events
- CategoryViewModel → CategoryService: loads categories
- CategoryViewModel → DispatcherModule: uses coroutine dispatchers
- CategoryService → CategoryRepository: retrieves through
- CategoryServiceImpl → CategoryRepository: implements
- CategoryServiceImpl → ApiCategory: calls
- CategoryServiceImpl → Domain exceptions: maps failures to
- CategoryModule → CategoryService: binds
- CategoryModule → CategoryServiceImpl: provides
- HttpClientModule → ApiCategory: supplies HTTP client
- DispatcherModule → CategoryServiceImpl: supplies dispatchers
- ApiCategory → Chuck Norris API: GET /jokes/categories