# mo7amd89/nowinandroid architecture

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

- Interactive diagram: https://gitdiagram.com/mo7amd89/nowinandroid
- Repository: https://github.com/mo7amd89/nowinandroid

## Overview

##### Project’s High-Level Structure
- The primary product is a modern Android app with multiple build flavors (demo versus prod) for either static data or live content.
- It is modularized into many separate components. There are “feature” modules (bookmarks, for you, interests, search, settings, topic) that handle specific user-facing screens and functionalities.
- There are “core” modules that encapsulate shared functionality across the app. These include analytics, common utilities, data, database, datastore, design system, domain (business logic), model, network, notifications, testing utilities, and UI.
- In addition, there are supporting modules like benchmarks, build-logic for custom Gradle plugins, lint rules, and sync.

##### Main Components and Their Responsibilities
- App Module: This is the actual runnable Android application. It integrates the feature modules and configures the product flavors (demo/prod) as well as build variants (debug, release, benchmark).
- Feature Modules: Each “feature” (bookmarks, for you, interests, etc.) encapsulates its own screens (built with Compose), ViewModels, and navigation logic. They are designed to be independently testable and replaceable.
- Presentation/UI Layer: Built with Jetpack Compose following Material 3 guidelines. UI components are defined in both the app module and the shared “core/designsystem” module.
- Domain Layer: Contains business logic and use cases (for example, fetching followable topics or recent searches) defined in the core/domain module.
- Data Layer & Repository: The core/data module (with repositories, network and local database integrations) is responsible for fetching data either from local storage (via core/database) or via network calls (in core/network) and mapping the results to domain models (in core/model).
- Infrastructure & Services: Modules like core/network, core/notifications, and core/datastore-proto provide network data sources, push notification support, and data persistence using DataStore.
- Dependency Injection: Hilt is used across the project to bind interfaces to implementations. This is critical because it makes it possible to substitute concrete implementations with test doubles (as seen in the testing modules).
- Testing and Benchmarking: Dedicated modules (like benchmarks, core/testing, ui-test-hilt-manifest) exist for unit tests, instrumentation tests, screenshot tests, and performance benchmarking. They hook into the DI and repository design to enable robust validation without heavy mocking.

##### Interactions and Data Flow
- The presentation layer (Compose screens within feature modules) communicates with ViewModels.
- ViewModels use use cases defined in the Domain layer to process user actions.
- Use cases interact with repositories from the Data layer which decide whether to fetch fresh data from the Network module (core/network) or cached data from the Database (core/database) or DataStore (core/datastore).
- Shared components such as the design system and analytics are injected into relevant parts of the app via Hilt.
- There is a parallel build/process environment shown by different build flavors (demo for static data and prod for live network data) and variants (debug, release, benchmark).

##### Architectural Patterns & Tools
- Use of Dependency Injection (Hilt) to decouple modules.
- Use the Model-View-ViewModel (MVVM) pattern as the primary design pattern for the UI layer.
- Repository Pattern in the Data layer where concrete implementations abstract network or database logic.
- Interactions between feature modules and core libraries where common business logic, UI components, and networking facilities are reused.
- The build infrastructure (Gradle, GitHub Actions workflows) can be represented as peripheral “DevOps” components that automate testing, building, and benchmarking.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% App Layer
    A("Now in Android App Module"):::app

    %% Feature Modules
    subgraph "Feature Modules"
        F1("Feature: Bookmarks"):::feature
        F2("Feature: For You"):::feature
        F3("Feature: Interests"):::feature
        F4("Feature: Search"):::feature
        F5("Feature: Settings"):::feature
        F6("Feature: Topic"):::feature
    end

    %% ViewModel Layer (aggregating UI logic)
    V("ViewModels"):::view

    %% Core Modules
    subgraph "Core Modules"
        subgraph "Services"
            S1("Analytics"):::service
            S2("Common Utilities"):::service
        end
        subgraph "Domain & Model"
            D1("Domain (Use Cases)"):::domain
            D2("Model"):::domain
        end
        subgraph "Data"
            DA("Data & Repository"):::data
            N("Network"):::data
            DB("Database"):::data
            DS("Datastore"):::data
            NO("Notifications"):::data
        end
        subgraph "UI Layer"
            U1("Design System"):::ui
            U2("UI Components"):::ui
        end
        subgraph "Testing"
            T1("Testing Utilities"):::testing
        end
    end

    %% Supporting Modules
    subgraph "Supporting"
        SP1("Benchmarking"):::support
        SP2("Build Logic"):::support
        SP3("Lint Rules"):::support
        SP4("Sync"):::support
        SP5("UI Test Hilt Manifest"):::support
    end

    %% Connections from App to Features
    A -->|"contains"| F1
    A -->|"contains"| F2
    A -->|"contains"| F3
    A -->|"contains"| F4
    A -->|"contains"| F5
    A -->|"contains"| F6

    %% Features forward interactions to ViewModels
    F1 -->|"triggers"| V
    F2 -->|"triggers"| V
    F3 -->|"triggers"| V
    F4 -->|"triggers"| V
    F5 -->|"triggers"| V
    F6 -->|"triggers"| V

    %% ViewModels invoke Domain layer
    V -->|"invokes"| D1

    %% Domain calls Repository in Data layer
    D1 -->|"calls"| DA

    %% Repository data sources
    DA -->|"fetches"| N
    DA -->|"caches"| DB
    DA -->|"persists"| DS
    DA -->|"notifies"| NO

    %% Dependency Injection (Hilt) connections from App Module
    A -->|"HiltDI"| D1
    A -->|"HiltDI"| DA
    A -->|"HiltDI"| U1

    %% Services and UI Layer integration
    A -->|"integrates"| S1
    A -->|"integrates"| S2
    A -->|"applies"| U2

    %% Supporting and Testing modules linked for build/validation
    T1 -.-> A
    SP1 -.-> A
    SP2 -.-> A
    SP3 -.-> A
    SP4 -.-> A
    SP5 -.-> A

    %% Click Events
    click A "https://github.com/mo7amd89/nowinandroid/tree/main/app/src/main/kotlin/com/google/samples/apps/nowinandroid"
    click F1 "https://github.com/mo7amd89/nowinandroid/tree/main/feature/bookmarks"
    click F2 "https://github.com/mo7amd89/nowinandroid/tree/main/feature/foryou"
    click F3 "https://github.com/mo7amd89/nowinandroid/tree/main/feature/interests"
    click F4 "https://github.com/mo7amd89/nowinandroid/tree/main/feature/search"
    click F5 "https://github.com/mo7amd89/nowinandroid/tree/main/feature/settings"
    click F6 "https://github.com/mo7amd89/nowinandroid/tree/main/feature/topic"
    click S1 "https://github.com/mo7amd89/nowinandroid/tree/main/core/analytics"
    click S2 "https://github.com/mo7amd89/nowinandroid/tree/main/core/common"
    click DA "https://github.com/mo7amd89/nowinandroid/tree/main/core/data"
    click DB "https://github.com/mo7amd89/nowinandroid/tree/main/core/database"
    click DS "https://github.com/mo7amd89/nowinandroid/tree/main/core/datastore-proto"
    click D1 "https://github.com/mo7amd89/nowinandroid/tree/main/core/domain"
    click D2 "https://github.com/mo7amd89/nowinandroid/tree/main/core/model"
    click N "https://github.com/mo7amd89/nowinandroid/tree/main/core/network"
    click NO "https://github.com/mo7amd89/nowinandroid/tree/main/core/notifications"
    click U1 "https://github.com/mo7amd89/nowinandroid/tree/main/core/designsystem"
    click U2 "https://github.com/mo7amd89/nowinandroid/tree/main/core/ui"
    click T1 "https://github.com/mo7amd89/nowinandroid/tree/main/core/testing"
    click SP1 "https://github.com/mo7amd89/nowinandroid/tree/main/benchmarks"
    click SP2 "https://github.com/mo7amd89/nowinandroid/tree/main/build-logic"
    click SP3 "https://github.com/mo7amd89/nowinandroid/tree/main/lint"
    click SP4 "https://github.com/mo7amd89/nowinandroid/tree/main/sync"
    click SP5 "https://github.com/mo7amd89/nowinandroid/tree/main/ui-test-hilt-manifest"

    %% Styles
    classDef app fill:#f4a261,stroke:#000,stroke-width:2px;
    classDef feature fill:#e9c46a,stroke:#000,stroke-width:2px;
    classDef view fill:#a2d2ff,stroke:#000,stroke-width:2px;
    classDef domain fill:#2a9d8f,stroke:#000,stroke-width:2px,color:#fff;
    classDef data fill:#e76f51,stroke:#000,stroke-width:2px,color:#fff;
    classDef ui fill:#457b9d,stroke:#000,stroke-width:2px,color:#fff;
    classDef service fill:#a8dadc,stroke:#000,stroke-width:2px;
    classDef testing fill:#9b2226,stroke:#000,stroke-width:2px,color:#fff;
    classDef support fill:#264653,stroke:#000,stroke-width:2px,color:#fff;

    class A app;
    class F1,F2,F3,F4,F5,F6 feature;
    class V view;
    class D1,D2 domain;
    class DA,N,DB,DS,NO data;
    class S1,S2 service;
    class U1,U2 ui;
    class T1 testing;
    class SP1,SP2,SP3,SP4,SP5 support;
```
