# onlyinamerica/glancereader architecture

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

- Interactive diagram: https://gitdiagram.com/onlyinamerica/glancereader
- Repository: https://github.com/onlyinamerica/glancereader

## Overview

##### Main Components
- Android Device / User Interface – This element includes all user-facing parts of the application.
- App Module – This is the core component and includes:
- Android Manifest and Gradle build files.
- UI components: Activities (MainActivity, CommunityActivity, PreferencesActivity), Fragments (FeedFragment, SpritzFragment, PreferencesFragment, etc.), and Adapters.
- Business logic classes for reading formats (like Epub, HtmlPage, UnsupportedFormatException) and utilities (FileUtils, GlancePrefsManager).
- Integration with in-app billing (billing package with IabHelper, Purchase, Security, etc.).
- Event handling components (classes under the events package for various UI and logic events).
- HTTP and networking support (TrustManager and related classes).
- Lib Module – This secondary module encapsulates a reusable library (for Spritzer functionality) with its own set of activities/test cases, shared UI components, event classes, and utility functions.
- External Libraries – JAR files such as Parse-1.5.1.jar and epublib-core-latest.jar that provide additional functionality (e.g., parsing feeds, epub handling).

##### Relationships and Interactions
- The UI layer (Activities/Fragments) in the “app” module interacts with business logic classes and util classes to control and update the display.
- Adapters in the “app” module manage the data presentation for lists or structured views.
- The billing component interfaces with Google’s in-app billing services via AIDL (see IInAppBillingService.aidl) and the helper classes in the billing package.
- Communication between different parts of the app is facilitated through event classes (e.g., ChapterSelectRequested, NextChapterEvent, etc.), establishing an event-driven architecture.
- The lib module provides reusable Spritzer functionality which is incorporated into the main app, suggesting a clear dependency from the UI to this library for text rendering and animation.
- External libraries (Parse, epublib) serve as stand-alone modules that the business logic uses for retrieving feeds or processing EPUB files.

##### Architectural Patterns and Design Principles
- Modular Design: Separation between the “app” and “lib” modules helps in maintaining a clean separation of concerns.
- Event-driven Architecture: Use of event classes indicates a design that leverages event posting and handling for inter-component communication.
- Utilization of Android native components: Activities, Fragments, Adapters ensure adherence to standard Android paradigms.
- Use of Gradle for build management, demonstrating a modern Android project structure.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Android Device"
        subgraph "Glance Application"
            subgraph "App Module"
                subgraph "User Interface"
                    MainAct["MainActivity"]:::ui
                    CommAct["CommunityActivity"]:::ui
                    PrefAct["PreferencesActivity"]:::ui
                    Frags["Fragments (FeedFragment, SpritzFragment, PreferencesFragment, TocDialogFragment, WpmDialogFragment)"]:::ui
                    Adapt["Adapters (AdapterUtils, ArticleAdapter, ReaderSectionAdapter, TocReferenceAdapter)"]:::ui
                end
                subgraph "Business Logic & Utilities"
                    Formats["Formats (Epub, HtmlPage, SpritzerMedia, UnsupportedFormatException)"]:::logic
                    FileUtils["FileUtils"]:::logic
                    GlancePrefs["GlancePrefsManager"]:::logic
                    Billing["Billing Integration"]:::logic
                    AIDL["AIDL Billing Interface"]:::logic
                    Events["Events (ChapterSelectRequested, ChapterSelectedEvent, HttpUrlParsedEvent, NextChapterEvent, WpmSelectedEvent)"]:::logic
                    Trust["TrustManager"]:::logic
                end
            end
            subgraph "Lib Module"
                Spritzer["Spritzer Library (Spritzer, SpritzerTextView, TextUtil)"]:::lib
                LibEvents["Lib Events (SpritzFinishedEvent, SpritzProgressEvent)"]:::lib
            end
            subgraph "External Libraries"
                ParseLib["Parse Library"]:::external
                Epublib["Epublib"]:::external
            end
        end
    end

    %% UI to Business Logic interactions
    MainAct -->|"triggersEvent"| Events
    CommAct -->|"triggersEvent"| Events
    PrefAct -->|"opensPrefs"| GlancePrefs
    Frags -->|"initiatesFormat"| Formats
    Adapt -->|"rendersData"| Events

    %% UI to Lib Module interaction
    Frags -->|"invokesSpritzer"| Spritzer

    %% Business Logic internal connections
    FileUtils -->|"assists"| Formats
    Billing -->|"callsBillingService"| AIDL
    Events -->|"updatesUI"| MainAct
    Trust -->|"securesHTTP"| Events

    %% Business Logic to External Libraries
    Formats -->|"parsesEPUB"| Epublib
    Formats -->|"retrievesFeed"| ParseLib

    %% Lib Module internal connection
    LibEvents -->|"spritzUpdate"| Spritzer

    %% Styles
    classDef ui fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef logic fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef lib fill:#D1E8FF,stroke:#333,stroke-width:2px;
    classDef external fill:#FFB347,stroke:#333,stroke-width:2px;

click MainAct "https://github.com/onlyinamerica/glancereader/blob/master/app/src/main/java/pro/dbro/glance/activities/MainActivity.java"
click CommAct "https://github.com/onlyinamerica/glancereader/blob/master/app/src/main/java/pro/dbro/glance/activities/CommunityActivity.java"
click PrefAct "https://github.com/onlyinamerica/glancereader/blob/master/app/src/main/java/pro/dbro/glance/activities/PreferencesActivity.java"
click Frags "https://github.com/onlyinamerica/glancereader/tree/master/app/src/main/java/pro/dbro/glance/fragments"
click Adapt "https://github.com/onlyinamerica/glancereader/tree/master/app/src/main/java/pro/dbro/glance/adapters"
click Formats "https://github.com/onlyinamerica/glancereader/tree/master/app/src/main/java/pro/dbro/glance/formats"
click FileUtils "https://github.com/onlyinamerica/glancereader/blob/master/app/src/main/java/pro/dbro/glance/FileUtils.java"
click GlancePrefs "https://github.com/onlyinamerica/glancereader/blob/master/app/src/main/java/pro/dbro/glance/GlancePrefsManager.java"
click Billing "https://github.com/onlyinamerica/glancereader/tree/master/app/src/main/java/pro/dbro/glance/billing"
click AIDL "https://github.com/onlyinamerica/glancereader/blob/master/app/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl"
click Events "https://github.com/onlyinamerica/glancereader/tree/master/app/src/main/java/pro/dbro/glance/events"
click Trust "https://github.com/onlyinamerica/glancereader/blob/master/app/src/main/java/pro/dbro/glance/http/TrustManager.java"
click Spritzer "https://github.com/onlyinamerica/glancereader/tree/master/lib/src/main/java/pro/dbro/glance/lib"
click LibEvents "https://github.com/onlyinamerica/glancereader/tree/master/lib/src/main/java/pro/dbro/glance/lib/events"
click ParseLib "https://github.com/onlyinamerica/glancereader/blob/master/app/libs/Parse-1.5.1.jar"
click Epublib "https://github.com/onlyinamerica/glancereader/blob/master/app/libs/epublib-core-latest.jar"
```
