# pgreze/android-reactions architecture

> Architecture diagram of the GitHub repository pgreze/android-reactions, 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/pgreze/android-reactions
- Repository: https://github.com/pgreze/android-reactions

## Overview

##### Project Type and Purpose
- This is an open-source Android library that implements a fully customizable version of Facebook’s reaction pattern.
- It provides both a library module (with reaction components, DSL configurations, and UI elements) and a sample Android app demonstrating its use.
- The README clarifies installation via Maven Central and usage examples in both Kotlin and Java, so the project is intended to be integrated into other Android applications.

##### Analyzing the File Structure
- Top-Level Modules: Notice two primary modules:
– The “library” directory holds the core source code including Java/Kotlin files for ReactionPopup, ReactionView, models, and DSL helpers.
– The “sample” directory contains an Android sample app demonstrating how to use the library.
- Build Configuration: Files like build.gradle.kts, settings.gradle.kts, and the buildSrc folder (which holds shared Gradle scripts and configurations in Kotlin) indicate a Gradle-based build system. This differentiation also shows a separation between build logic and source code.
- CI/CD: The “.github/workflows” directory (with “build.yml” and “deploy.yml”) shows that GitHub Actions are used to automate building and deployment.
- Resources: The presence of Android resource files such as AndroidManifest.xml, layouts, drawables, and values catalogs demonstrate that the library is a UI component for Android.

##### Main Components
- Library Module:
- Core Reaction Components: Includes classes like ReactionPopup, ReactionView, ReactionViewGroup, RoundedView, and DSL configuration functions (found in the library/src/main/java/com/github/pgreze/reactions).
- Android Resources: Contains XML layouts, drawable assets, and style definitions that drive the reactions UI.
- Sample Module:
- Demonstration App: A sample Android application that serves to illustrate the integration and use of the library.
- Build Infrastructure:
- Gradle Build Scripts and buildSrc: Custom Gradle logic (Config.kt, Utils.kt) and build configuration files handle building, testing, and packaging.
- CI/CD Pipelines: GitHub Actions workflows for build and deploy.
- External Artifacts:
- Maven Central: The project publishes its artifacts to Maven Central, indicated in the README installation instructions.
- External Dependencies: The project makes use of standard Android libraries, Gradle, and potentially other libraries (e.g., for handling image scaling and view events).

##### Relationships and Interactions
- The sample module directly depends on the library module, using its APIs (like ReactionPopup, reactions DSL configuration) to show how a consumer would integrate the library.
- The build system (Gradle) orchestrates the compilation and packaging of both the library and sample modules, while buildSrc provides common build logic across the project.
- CI/CD pipelines (via GitHub Actions) start the build and testing processes and eventually deploy the resulting library artifacts to Maven Central.
- The library interacts with Android framework components (views, resources, layouts) to provide the reaction UI components.

##### Architectural Patterns and Design Principles
- Modularity: Clear separation between the core library and its sample application promotes reusability and ease of integration.
- DSL (Domain Specific Language): The Kotlin DSL inside the library allows for an intuitive configuration of the reaction popups.
- Layered Structure: The design separates UI component logic from configuration/build logic, with dedicated directories for source code, resources, and build configuration.
- CI/CD Integration: Automated workflows ensure builds and deployments follow continuous integration practices.

## Diagram (Mermaid)

```mermaid
graph TD
    A("Android Reactions Project"):::external

    %% Modules Group
    subgraph "Modules"
        L("Library Module"):::source
        S("Sample Module"):::source
    end

    %% Library Module Details
    subgraph "Library Module Details"
        L1("Core Reaction Components"):::source
        L2("Android Resources"):::source
    end

    %% Build & Deployment Group
    subgraph "Build & Deployment"
        B("Gradle Build Scripts"):::build
        BS("buildSrc"):::build
        CI("CI/CD Pipelines"):::build
    end

    %% External Dependencies Group
    subgraph "External Dependencies"
        Maven("Maven Central"):::external
        Android("Android Framework"):::external
    end

    %% High-level Connections
    A --> L
    A --> S

    %% Library Module internal connections
    L --> L1
    L --> L2
    S --> L1
    S --> L

    %% Build infrastructure connections
    B --> L
    B --> S
    BS --> B
    CI --> B
    CI --> BS
    CI --> Maven

    %% External dependencies interactions
    L2 -->|"renders_with"| Android
    S -->|"runs_on"| Android

    %% Click Events
    click L1 "https://github.com/pgreze/android-reactions/tree/master/library/src/main/java/com/github/pgreze/reactions"
    click L2 "https://github.com/pgreze/android-reactions/tree/master/library/src/main/res"
    click S "https://github.com/pgreze/android-reactions/tree/master/sample"
    click B "https://github.com/pgreze/android-reactions/blob/master/build.gradle.kts"
    click BS "https://github.com/pgreze/android-reactions/tree/master/buildSrc"
    click CI "https://github.com/pgreze/android-reactions/tree/master/.github/workflows"

    %% Style Definitions
    classDef source fill:#CEF6CE,stroke:#2E8B57,stroke-width:2px;
    classDef build fill:#FFD700,stroke:#B8860B,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px;
```
