# aritraroy/flashbar architecture

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

- Interactive diagram: https://gitdiagram.com/aritraroy/flashbar
- Repository: https://github.com/aritraroy/flashbar

## Overview

##### Main Components
- Flashbar Library Module: This contains the core functionality including:
- The Flashbar builder and its related API (Flashbar.kt, FlashbarContainerView.kt, FlashbarView.kt).
- Utility classes (under flashbar/util) and custom view elements (under flashbar/view) like FbButton, FbProgress, and ShadowView.
- Sample Application Module ("app"): This is a demo project that uses the Flashbar library to show sample alerts in Java and Kotlin. It demonstrates how to integrate and use the library.
- Android Framework Components: Since Flashbar integrates into an Activity by attaching views to the decor view, include this aspect, as well as resource management (layouts, drawables, values).

##### Relationships and Interactions
- The Sample Application calls the Flashbar API through a fluent Builder pattern to configure and display alerts.
- The Flashbar library internally uses container and view classes to attach overlay components to the Activity’s window.
- The Animations and utility submodules support the customization and dynamic behavior of the Flashbar before it displays or dismisses.
- Communication with the Android runtime is implied (via Activity, AndroidManifest, Gradle config for resource handling).

##### Architectural Patterns and Design Principles
- Modular Separation: The library code (flashbar) is kept separate from the sample app, emphasizing reusability.
- Builder Pattern: The Flashbar.Builder abstracts the configuration of the alert bar allowing chaining and flexible customization.
- Separation of Concerns: Different packages handle animations, views, utilities, and event listeners, each responsible for their domain.

##### Technologies and Tools
- Programming Languages: Primarily Kotlin (with Java samples).
- Build System: Gradle (files like build.gradle, settings.gradle).
- Android Nine-patch or vector drawable resources for UI components.
- Animation and event handling frameworks provided by Android and custom-built classes in flashbar/anim.

##### Elements
- Another for the sample app,
- Another for Android platform components.
- Configuration options (such as animations, swipe-to-dismiss, and event listener callbacks) as additional annotations near the related components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Flashbar Library Module"
        subgraph "API Layer"
            API["Flashbar Builder"]:::library
        end
        subgraph "Rendering Components"
            Container["FlashbarContainerView"]:::library
            View["FlashbarView"]:::library
        end
        subgraph "Animation Module"
            Anim["Animation Components"]:::library
        end
        subgraph "Utility & Custom Views"
            Util["Utility Classes"]:::library
            CustomViews["Custom View Elements"]:::library
        end
    end

    subgraph "Sample Application Module"
        SampleApp["Sample App (Demo)"]:::sample
    end

    subgraph "Android Framework Components"
        AndroidCore["Android Activity & Resources (Library)"]:::android
        AndroidApp["Android Activity & Resources (Sample App)"]:::android
    end

    SampleApp -->|"calls"| API
    API -->|"builds"| Container
    API -->|"builds"| View
    API -->|"triggers"| Anim
    API -->|"utilizes"| Util
    API -->|"integrates"| CustomViews
    Container -->|"attaches to"| AndroidCore
    View -->|"attaches to"| AndroidCore
    Anim -->|"animates"| Container
    Anim -->|"animates"| View
    SampleApp -->|"uses"| AndroidApp

    click API "https://github.com/aritraroy/flashbar/blob/develop/flashbar/src/main/java/com/andrognito/flashbar/Flashbar.kt"
    click Container "https://github.com/aritraroy/flashbar/blob/develop/flashbar/src/main/java/com/andrognito/flashbar/FlashbarContainerView.kt"
    click View "https://github.com/aritraroy/flashbar/blob/develop/flashbar/src/main/java/com/andrognito/flashbar/FlashbarView.kt"
    click Anim "https://github.com/aritraroy/flashbar/tree/develop/flashbar/src/main/java/com/andrognito/flashbar/anim"
    click Util "https://github.com/aritraroy/flashbar/blob/develop/flashbar/src/main/java/com/andrognito/flashbar/util/CommonUtils.kt"
    click CustomViews "https://github.com/aritraroy/flashbar/tree/develop/flashbar/src/main/java/com/andrognito/flashbar/view"
    click SampleApp "https://github.com/aritraroy/flashbar/tree/develop/app/"
    click AndroidCore "https://github.com/aritraroy/flashbar/blob/develop/flashbar/src/main/AndroidManifest.xml"
    click AndroidApp "https://github.com/aritraroy/flashbar/blob/develop/app/src/main/AndroidManifest.xml"

    classDef library fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef sample fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef android fill:#F4A460,stroke:#000,stroke-width:2px;
```
