How uphyca/stetho-realm works
Purpose and Integration Entry Point
Stetho-Realm is an Android library that replaces Stetho’s SQLite-backed database inspection with Realm database inspection. Host apps initialize Realm, then install the library’s InspectorModulesProvider into Stetho’s WebKit inspector pipeline. Primary public integration surface: stetho_realm/src/main/java/com/uphyca/stetho_realm/RealmInspectorModulesProvider.java.
Runtime and Dependencies
The library runs inside an Android application process and is packaged as an AAR. Its material external boundaries are:
• Realm: embedded object database; Realm files and schema/data are read by the adapter.
• Facebook Stetho: Chrome DevTools/WebKit inspection transport and database-domain APIs.
• Android filesystem/context: used to locate Realm database files, including an optional caller-supplied folder.
Build/publishing are Gradle-based: build.gradle, stetho_realm/build.gradle, and deploy.gradle.
Inspector Module Composition
RealmInspectorModulesProvider is the composition root. Its builder accepts inspection policies—base Stetho provider, Realm file folder/name pattern, encryption keys, metadata-table visibility, record limit, and sort direction—then appends the Realm inspector module to the selected base provider. This is the key boundary that lets applications preserve or customize other Stetho modules.
Paths:
• stetho_realm/src/main/java/com/uphyca/stetho_realm/RealmInspectorModulesProvider.java
• stetho_realm/src/main/AndroidManifest.xml
Realm File Discovery
RealmFilesProvider abstracts discovery of inspectable Realm files. It mediates filesystem selection before database inspection, applying the configured folder and filename pattern rather than exposing arbitrary application files. The discovered file set feeds peer/database construction.
Paths:
• stetho_realm/src/main/java/com/uphyca/stetho_realm/RealmFilesProvider.java
• stetho_realm/src/main/java/com/uphyca/stetho_realm/RealmInspectorModulesProvider.java
Stetho Database-Domain Bridge
RealmPeerManager is the Stetho-facing control layer: it participates in DevTools peer/session lifecycle and exposes the Realm-backed database domain to connected inspector clients. It coordinates available databases and routes schema/data inspection requests into the Realm adapter instead of SQLite handling.
Paths:
• stetho_realm/src/main/java/com/uphyca/stetho_realm/RealmPeerManager.java
• stetho_realm/src/main/java/com/uphyca/stetho_realm/Database.java
Realm-to-Inspector Data Adaptation
The top-level Database represents a Realm database in the inspector-facing model; the delegate implementation encapsulates Realm-specific schema/table/record access and conversion. This separation isolates Stetho protocol abstractions from Realm APIs and supports configured encryption, metadata inclusion, ordering, and limits. The README indicates inspection is read-oriented; update/delete are explicitly not implemented.
Paths:
• stetho_realm/src/main/java/com/uphyca/stetho_realm/Database.java
• stetho_realm/src/main/java/com/uphyca/stetho_realm/delegate/Database.java
Delivery Model
The repository includes a checked-in Maven-style artifact repository with released AARs and POMs, intended for consumption from GitHub-hosted maven-repo. Publication emits the Android library to that directory.
Paths:
• maven-repo/com/uphyca/stetho_realm/maven-metadata.xml
• maven-repo/com/uphyca/stetho_realm/2.1.0/stetho_realm-2.1.0.aar
• deploy.gradle
Main entry points: RealmInspectorModulesProvider.java RealmInspectorModulesProvider · RealmPeerManager.java RealmPeerManager · RealmFilesProvider.java RealmFilesProvider · Database.java Inspector Database
Components 14
Host Runtime
- Android host app · Initializes Realm and installs the provider.
- Realm · Provides Realm files, schema, and records.
- Facebook Stetho · Supplies WebKit inspector modules and database APIs.
- Android filesystem · Hosts inspectable Realm files.
Stetho-Realm Library
- RealmInspectorModulesProvider · Builds policies and appends Realm inspection to a base Stetho provider.
stetho_realm/src/main/java/com/uphyca/stetho_realm/RealmInspectorModulesProvider.java - Android manifest
stetho_realm/src/main/AndroidManifest.xml - RealmFilesProvider · Selects Realm files by configured folder and name pattern.
stetho_realm/src/main/java/com/uphyca/stetho_realm/RealmFilesProvider.java - RealmPeerManager · Manages DevTools peers and routes database inspection requests.
stetho_realm/src/main/java/com/uphyca/stetho_realm/RealmPeerManager.java - Inspector Database · Represents a Realm database in Stetho's inspector-facing model.
stetho_realm/src/main/java/com/uphyca/stetho_realm/Database.java - Realm database delegate · Reads schema and records with encryption, metadata, sort, and limit policies.
stetho_realm/src/main/java/com/uphyca/stetho_realm/delegate/Database.java
Build & Delivery
- Gradle Android build · Packages the library as an AAR.
stetho_realm/build.gradle - Publication script · Publishes the Android library into the checked-in Maven repository.
deploy.gradle - Checked-in Maven repo · Contains released AARs, POMs, and Maven metadata.
maven-repo/com/uphyca/stetho_realm/maven-metadata.xml - Released AAR 2.1.0
maven-repo/com/uphyca/stetho_realm/2.1.0/stetho_realm-2.1.0.aar
Connections 16
- Android host app → Realm: initializes
- Android host app → RealmInspectorModulesProvider: installs
- RealmInspectorModulesProvider → Facebook Stetho: extends base modules
- RealmInspectorModulesProvider → RealmFilesProvider: configures discovery
- RealmInspectorModulesProvider → RealmPeerManager: adds Realm module
- Android manifest → RealmInspectorModulesProvider: packages
- RealmFilesProvider → Android filesystem: locates selected files
- RealmFilesProvider → RealmPeerManager: supplies databases
- Facebook Stetho → RealmPeerManager: peer and request lifecycle
- RealmPeerManager → Inspector Database: exposes
- Inspector Database → Realm database delegate: delegates reads
- Realm database delegate → Realm: reads schema and records
- Gradle Android build → Publication script: produces library for publishing
- Publication script → Checked-in Maven repo: publishes
- Checked-in Maven repo → Released AAR 2.1.0: contains
- Released AAR 2.1.0 → Android host app: consumed as dependency