# dotanuki-labs/norris architecture

> Architecture diagram of the GitHub repository dotanuki-labs/norris, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dotanuki-labs/norris
- Repository: https://github.com/dotanuki-labs/norris

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Layer
    subgraph "Application Layer"
        App["App Module"]:::app
    end

    %% Feature Modules
    subgraph "Feature Modules"
        %% Facts Feature
        subgraph "Facts Feature"
            FactsUI["UI: FactsActivity"]:::feature
            FactsVM["ViewModel: FactsViewModel"]:::feature
            FactsDomain["Domain: ChuckNorrisFact"]:::feature
            FactsData["Data: FactsDataSource"]:::feature
            FactsDI["DI: Facts Component"]:::di
            FactsUI -->|"triggers"| FactsVM
            FactsVM -->|"calls"| FactsDomain
            FactsDomain -->|"fetchesData"| FactsData
            FactsDI --- FactsUI
            FactsDI --- FactsVM
        end

        %% Search Feature
        subgraph "Search Feature"
            SearchUI["UI: SearchActivity"]:::feature
            SearchVM["ViewModel: SearchViewModel"]:::feature
            SearchDomain["Domain: SearchOptions"]:::feature
            SearchData["Data: SearchesDataSource"]:::feature
            SearchDI["DI: Search Component"]:::di
            SearchUI -->|"triggers"| SearchVM
            SearchVM -->|"calls"| SearchDomain
            SearchDomain -->|"fetchesData"| SearchData
            SearchDI --- SearchUI
            SearchDI --- SearchVM
        end
    end

    %% Platform Modules
    subgraph "Platform Modules"
        %% Android Platform
        subgraph "Android Platform"
            Assets["Core-assets"]:::android
            Navigator["Core-navigator"]:::android
            Persistence["Core-persistence"]:::android
            subgraph "Android Testing"
                AndroidTesting1["Testing Application"]:::testing
                AndroidTesting2["Testing Helpers Espresso"]:::testing
                AndroidTesting3["Testing Persistence"]:::testing
                AndroidTesting4["Testing Screenshots"]:::testing
            end
        end
        %% JVM Platform
        subgraph "JVM Platform"
            Rest["Core-rest"]:::jvm
            subgraph "JVM Testing"
                JVMTst1["Testing Helpers"]:::testing
                JVMTst2["Testing Mockserver"]:::testing
                JVMTst3["Testing REST"]:::testing
            end
        end
    end

    %% Build & Tooling Infrastructure
    subgraph "Build & Tooling"
        Build["Build Scripts & Gradle Plugins"]:::build
        CI["CI/CD Configuration"]:::build
        Scripts["Utility Scripts"]:::build
    end

    %% External Services & Tools
    subgraph "External Services"
        ExternalAPI["REST API: api.chucknorris.io"]:::external
        Maestro["Maestro Cloud"]:::external
        Emulator["Emulator.wtf"]:::external
        AppSweep["AppSweep"]:::external
        Mergify["Mergify"]:::external
    end

    %% Relationships between Layers
    App -->|"launches"| FactsUI
    App -->|"launches"| SearchUI
    FactsUI -->|"navigatesVia"| Navigator
    SearchUI -->|"navigatesVia"| Navigator

    FactsData -->|"fetchesFrom"| Rest
    FactsData -->|"cachesTo"| Persistence
    SearchData -->|"fetchesFrom"| Rest
    SearchData -->|"cachesTo"| Persistence

    Build -->|"configures"| App
    CI -->|"triggers"| Build
    Scripts -->|"assists"| Build

    Rest -->|"calls"| ExternalAPI

    CI -->|"integratesWith"| Maestro
    CI -->|"integratesWith"| Emulator
    CI -->|"integratesWith"| AppSweep
    CI -->|"integratesWith"| Mergify

    %% Click Events
    click App "https://github.com/dotanuki-labs/norris/tree/master/app/src/main/java/io/dotanuki/app"
    click FactsUI "https://github.com/dotanuki-labs/norris/tree/master/features/facts"
    click SearchUI "https://github.com/dotanuki-labs/norris/tree/master/features/search"
    click Assets "https://github.com/dotanuki-labs/norris/tree/master/platform/android/core-assets"
    click Navigator "https://github.com/dotanuki-labs/norris/tree/master/platform/android/core-navigator"
    click Persistence "https://github.com/dotanuki-labs/norris/tree/master/platform/android/core-persistence"
    click AndroidTesting1 "https://github.com/dotanuki-labs/norris/tree/master/platform/android/testing-application"
    click AndroidTesting2 "https://github.com/dotanuki-labs/norris/tree/master/platform/android/testing-helpers-espresso"
    click AndroidTesting3 "https://github.com/dotanuki-labs/norris/tree/master/platform/android/testing-persistence"
    click AndroidTesting4 "https://github.com/dotanuki-labs/norris/tree/master/platform/android/testing-screenshots"
    click Rest "https://github.com/dotanuki-labs/norris/tree/master/platform/jvm/core-rest"
    click JVMTst1 "https://github.com/dotanuki-labs/norris/tree/master/platform/jvm/testing-helpers"
    click JVMTst2 "https://github.com/dotanuki-labs/norris/tree/master/platform/jvm/testing-mockserver"
    click JVMTst3 "https://github.com/dotanuki-labs/norris/tree/master/platform/jvm/testing-rest"
    click Build "https://github.com/dotanuki-labs/norris/tree/master/gradle/"
    click CI "https://github.com/dotanuki-labs/norris/blob/master/.github/workflows/main.yml"
    click Scripts "https://github.com/dotanuki-labs/norris/tree/master/scripts"

    %% Styles
    classDef app fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef feature fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef di fill:#dda0dd,stroke:#000,stroke-width:1px;
    classDef android fill:#f4d03f,stroke:#000,stroke-width:1px;
    classDef jvm fill:#F0A500,stroke:#000,stroke-width:1px;
    classDef testing fill:#aed6f1,stroke:#000,stroke-width:1px;
    classDef build fill:#ffcccb,stroke:#000,stroke-width:1px;
    classDef external fill:#d3d3d3,stroke:#000,stroke-width:1px;
```
