How dotanuki-labs/norris works
Main Components
• Application Module (app):
– This is the primary Android module which contains the main AndroidManifest, application class (NorrisApplication), and core Activities (e.g., SplashActivity).
– It handles launching and serves as the entry point to the app.
• Feature Modules (features/facts and features/search):
– These encapsulate distinct use cases: one for displaying Chuck Norris facts and another for search functionality, each following patterns such as MVVM.
– Within each feature, include separate areas for presentation (UI Activities like FactsActivity, SearchActivity), domain (models such as ChuckNorrisFact, SearchOptions), data (data sources for facts and searches), and DI components (factories and context providers).
• Platform Modules (platform):
▪ Core-assets – manages images, layouts, and other Android resources.
▪ Core-navigator – provides navigation abstractions (e.g., Navigator, Screen, and mapping provider).
▪ Core-persistence – handles local storage and persistence, with DI elements for storage setup.
▪ Testing modules – separate modules (e.g., testing-application, testing-helpers-espresso, testing-persistence, testing-screenshots) for various testing frameworks.
– Under platform/jvm you also have core-rest that encapsulates networking functionality and REST client logic (e.g., RestClient, ApiUrlFactory) with its own testing support.
• Build & Tooling Infrastructure:
– Gradle Scripts: multiple build.gradle.kts files, settings.gradle.kts, and a custom gradle/plugins folder housing custom Gradle plugins for enforcing module conventions, feature toggles, and build configuration (e.g., AndroidApplicationConventions, AutoModulePlugin).
– CI/CD Configuration: GitHub Actions workflows (.github/workflows/main.yml) and other automation files (.mergify.yml, renovate.json).
– Scripts: Utility scripts are provided (e.g., aggregate-test-reports.sh, code-style-kotlin.sh) to aid in maintenance and consistency.
• External Services and Tools:
– External REST API (api.chucknorris.io) serves as the primary remote data source.
– Tools for E2E testing (Maestro Cloud), device farm (Emulator.wtf), security checks (AppSweep), and PR automation (Mergify) are mentioned; these should be included as external integrations insofar as they influence build or test flows.
Relationships and Data Flow
• Within each feature module, present a layered structure:
• UI (presentation layer) interacts with ViewModels (also represented in DI subcomponents), which in turn interact with the domain layer (models and use case implementations).
• The domain layer communicates with the data layer to retrieve or persist data either via REST (using platform/jvm/core-rest) or local persistence (using platform/android/core-persistence).
• DI components (NorrisAppComponentFactory, Fact and Search factories, etc.) as facilitating dependency injection across these layers.
Architectural Patterns & Design Principles
• Modularity: The project is clearly broken into modules (app, features, platform, gradle plugins) to isolate concerns.
• Layered/MVVM Approach: Feature modules follow MVVM or similar patterns with clear separation between UI, domain logic, and data handling.
• Dependency Injection: Widespread use of DI (visible in ‘di’ directories for both the app and feature modules) to decouple implementation details.
• Reusability: Platform modules (such as core-assets, core-navigator, core-persistence, core-rest) encapsulate functionality that can be shared across the app and testing scenarios.
• Testing Infrastructure: A strong focus on testing is evidenced by dedicated modules for Android UI testing (Espresso), screenshot testing, and even specialized Gradle plugins for managing feature modules.