# silentcoderhere/aihub architecture

> Architecture diagram of the GitHub repository silentcoderhere/aihub, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/silentcoderhere/aihub
- Repository: https://github.com/silentcoderhere/aihub

## Overview

#### Purpose and principal workflow

AI Hub is an Android app that brings multiple AI websites into a customizable, tabbed WebView experience; the README describes persistent sessions and privacy protections. The initiating actor is the **app user**: after onboarding, `MainActivity` loads local service/domain data and displays the app UI. The user can select an AI service to browse its website inside the app. The code sample establishes the activity’s data loading and UI construction, but omits the screen implementation that wires service selection to WebView creation.

#### Components

##### App shell and service catalogue
- **Main activity** — `app/src/main/java/com/foss/aihub/MainActivity.kt`: Android activity entry point; checks onboarding state, loads service/domain data, and constructs `AiHubApp`.
- **AI Hub workspace** — `app/src/main/java/com/foss/aihub/ui/screens/AiHubScreen.kt`: workspace screen, documented by its presence in the tree; its implementation was not sampled, so its internal navigation and session wiring are uncertain.
- **Service catalogue model and loader** — `app/src/main/java/com/foss/aihub/models/AiService.kt`: decodes categorized services from the app-private `ais.json` file into `AiService` records.
- **Service management UI** — `app/src/main/java/com/foss/aihub/ui/screens/ManageAiServicesScreen.kt`: supports searching/filtering and reordering services; the excerpt shows order changes saved through `SettingsManager`.

##### Embedded browsing and downloads
- **WebView navigation and security** — `app/src/main/java/com/foss/aihub/ui/webview/WebViewClient.kt`: handles page loading/errors, gates URL connectivity through `WebViewSecurity`, and injects blob/share interceptors and user CSS/JS after page load.
- **WebView browser interactions** — `app/src/main/java/com/foss/aihub/ui/webview/WebChromeClient.kt`: routes file selection and permission requests to `MainActivity`, handles JavaScript dialogs, and supports popup windows.
- **Download handling** — `app/src/main/java/com/foss/aihub/ui/webview/DownloadHandler.kt`: streams downloaded content to Android Downloads/MediaStore; the excerpt also shows a separate blob-URL handling branch.

##### Configuration, preferences, and remote data
- **Persistent settings** — `app/src/main/java/com/foss/aihub/utils/SettingManager.kt`: reads and writes app preferences, including filters, service defaults/order, onboarding status, and remote-data ETags; exposes settings updates through a flow.
- **Remote configuration updater** — `app/src/main/java/com/foss/aihub/utils/CloudDataHandler.kt`: uses Ktor with the OkHttp engine to check ETags and download service/domain data into app-private files.
- **Configuration state models** — `app/src/main/java/com/foss/aihub/models/AppSettings.kt`: settings data type, documented by the settings manager’s import and use; its fields were not sampled.
- **Service chooser UI** — `app/src/main/java/com/foss/aihub/ui/components/NavigationDrawerContent.kt`: displays/filter-selects services and persists selected filters; its callbacks support selecting or reloading a service.
- **Settings and customization UI** — `app/src/main/java/com/foss/aihub/ui/screens/SettingsScreen.kt`: settings screen exists in the tree; its implementation was not sampled.
- **Onboarding UI** — `app/src/main/java/com/foss/aihub/ui/screens/OnboardingScreens.kt`: onboarding screens exist in the tree; the activity invokes onboarding and marks it complete on callback.

##### External participants
- **App user** — `null`: initiates onboarding and interacts with service selection, settings, and browsing.
- **AI service websites** — `null`: external websites loaded by the embedded browser; individual providers and exact navigation wiring are not established by the excerpts.
- **AI Hub configuration host** — `null`: external HTTP host serving service/domain configuration; the concrete base URL is defined outside the sampled excerpt.

#### Relationships

- **App user -> Main activity**: launches the Android app; `MainActivity` is the activity entry point.
- **Main activity -> Onboarding UI**: displays onboarding when completion is absent; invokes the completion callback to persist completion.
- **Main activity -> AI Hub workspace**: constructs `AiHubApp` after data is ready; the exact composition and screen wiring are not sampled.
- **Main activity -> Service catalogue model and loader**: loads service data during startup; the excerpt shows `loadAllData`, while the loader reads app-private `ais.json`.
- **Main activity -> Remote configuration updater**: startup reads local service/domain files, but the sampled code does not establish when remote updates are invoked.
- **Remote configuration updater -> AI Hub configuration host**: sends HEAD/GET requests to check ETags and fetch changed files.
- **Remote configuration updater -> Persistent settings**: reads stored ETags and saves returned ETags after updates.
- **Remote configuration updater -> app-private configuration files**: writes downloaded response bodies; service loading reads `ais.json` from the same private-files area.
- **AI Hub workspace -> Service chooser UI**: ownership only; the screen composition was not sampled, so direct runtime wiring is unconfirmed.
- **Service chooser UI -> Persistent settings**: writes filter changes; selection/reload behavior is exposed through callbacks.
- **Service management UI -> Persistent settings**: writes the reordered service-name list through `updateSettings`.
- **Service chooser UI -> AI service websites**: selection callbacks indicate service selection, but the sampled code does not establish the navigation call.
- **AI service websites -> WebView navigation and security**: the browser client handles page loads and checks requested URLs; the exact WebView construction site was not sampled.
- **WebView navigation and security -> Persistent settings**: reads custom CSS/JS from the settings flow before injecting them.
- **WebView browser interactions -> Main activity**: delegates file chooser and permission requests to activity methods.
- **WebView navigation and security -> Download handling**: blob interception is installed after page load, but the sampled excerpts do not establish the precise download dispatch path.
- **Download handling -> Android Downloads/MediaStore**: writes downloaded data through the content resolver or legacy Downloads directory.

#### Coverage limits

The source sample omits `AiHubScreen` and the main WebView setup, so tab/session persistence, precise service-selection navigation, and the call site for remote updates cannot be verified. The README documents tracker blocking and persistent conversations, but the sampled excerpts do not establish their implementation or backing storage.

Main entry points: [`app/src/main/java/com/foss/aihub/MainActivity.kt`](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/MainActivity.kt) (Main activity), [`app/src/main/java/com/foss/aihub/utils/SettingManager.kt`](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/utils/SettingManager.kt) (Persistent settings), [`app/src/main/java/com/foss/aihub/utils/CloudDataHandler.kt`](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/utils/CloudDataHandler.kt) (Remote configuration updater), [`app/src/main/java/com/foss/aihub/ui/components/NavigationDrawerContent.kt`](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/components/NavigationDrawerContent.kt) (Service chooser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App shell and catalogue"]
  node_main["Main activity<br/>Android activity"]
  node_workspace["AI Hub workspace<br/>Workspace screen"]
  node_catalogue["Service catalogue loader<br/>Service data loader"]
  node_chooser["Service chooser<br/>UI component"]
  node_service_management["Service management<br/>UI screen"]
  node_onboarding["Onboarding screens<br/>UI screens"]
end

subgraph group_browser["Embedded browsing"]
  node_webview_client["WebView navigation<br/>WebView client"]
  node_chrome_client["WebView interactions<br/>WebChromeClient"]
  node_download["Download handler<br/>[DownloadHandler.kt]"]
end

subgraph group_config["Configuration and preferences"]
  node_settings["Persistent settings<br/>Preferences manager"]
  node_updater["Remote configuration updater"]
  node_config_files["Private configuration files<br/>App-private files"]
end

subgraph group_external["External participants"]
  node_user(("App user"))
  node_websites(("AI service websites<br/>External websites"))
  node_config_host(("AI Hub configuration host<br/>HTTP host"))
  node_downloads["Android Downloads and MediaStore<br/>Android storage"]
end

node_user -->|"launches"| node_main
node_main -->|"displays"| node_onboarding
node_main -->|"constructs"| node_workspace
node_main -->|"loads data"| node_catalogue
node_catalogue -->|"reads"| node_config_files
node_workspace -.->|"owns"| node_chooser
node_chooser -->|"updates filters"| node_settings
node_service_management -->|"saves order"| node_settings
node_chooser -.->|"selects service"| node_websites
node_updater -->|"checks and fetches"| node_config_host
node_updater -->|"reads and saves ETags"| node_settings
node_updater -->|"writes updates"| node_config_files
node_websites -->|"loads pages"| node_webview_client
node_webview_client -->|"reads custom CSS and JS"| node_settings
node_chrome_client -->|"delegates requests"| node_main
node_webview_client -.->|"intercepts blobs"| node_download
node_download -->|"writes downloads"| node_downloads

click node_main "https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/MainActivity.kt"
click node_workspace "https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/screens/AiHubScreen.kt"
click node_catalogue "https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/models/AiService.kt"
click node_chooser "https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/components/NavigationDrawerContent.kt"
click node_service_management "https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/screens/ManageAiServicesScreen.kt"
click node_onboarding "https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/screens/OnboardingScreens.kt"
click node_webview_client "https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/webview/WebViewClient.kt"
click node_chrome_client "https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/webview/WebChromeClient.kt"
click node_download "https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/webview/DownloadHandler.kt"
click node_settings "https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/utils/SettingManager.kt"
click node_updater "https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/utils/CloudDataHandler.kt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_workspace,node_catalogue,node_chooser,node_service_management,node_onboarding toneBlue
class node_webview_client,node_chrome_client,node_download toneAmber
class node_settings,node_updater,node_config_files toneMint
class node_user,node_websites,node_config_host,node_downloads toneRose
```

## Components

### App shell and catalogue

- [Main activity](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/MainActivity.kt): Android activity · `app/src/main/java/com/foss/aihub/MainActivity.kt`
- [AI Hub workspace](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/screens/AiHubScreen.kt): Workspace screen · `app/src/main/java/com/foss/aihub/ui/screens/AiHubScreen.kt`
- [Service catalogue loader](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/models/AiService.kt): Service data loader · `app/src/main/java/com/foss/aihub/models/AiService.kt`
- [Service chooser](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/components/NavigationDrawerContent.kt): UI component · `app/src/main/java/com/foss/aihub/ui/components/NavigationDrawerContent.kt`
- [Service management](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/screens/ManageAiServicesScreen.kt): UI screen · `app/src/main/java/com/foss/aihub/ui/screens/ManageAiServicesScreen.kt`
- [Onboarding screens](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/screens/OnboardingScreens.kt): UI screens · `app/src/main/java/com/foss/aihub/ui/screens/OnboardingScreens.kt`

### Embedded browsing

- [WebView navigation](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/webview/WebViewClient.kt): WebView client · `app/src/main/java/com/foss/aihub/ui/webview/WebViewClient.kt`
- [WebView interactions](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/webview/WebChromeClient.kt): WebChromeClient · `app/src/main/java/com/foss/aihub/ui/webview/WebChromeClient.kt`
- [Download handler](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/ui/webview/DownloadHandler.kt): Download handler · `app/src/main/java/com/foss/aihub/ui/webview/DownloadHandler.kt`

### Configuration and preferences

- [Persistent settings](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/utils/SettingManager.kt): Preferences manager · `app/src/main/java/com/foss/aihub/utils/SettingManager.kt`
- [Remote configuration updater](https://github.com/silentcoderhere/aihub/blob/main/app/src/main/java/com/foss/aihub/utils/CloudDataHandler.kt): Configuration updater · `app/src/main/java/com/foss/aihub/utils/CloudDataHandler.kt`
- **Private configuration files**: App-private files

### External participants

- **App user**: User
- **AI service websites**: External websites
- **AI Hub configuration host**: HTTP host
- **Android Downloads and MediaStore**: Android storage

## Connections

- App user → Main activity: launches
- Main activity → Onboarding screens: displays
- Main activity → AI Hub workspace: constructs · Creates AiHubApp; exact screen composition is not sampled.
- Main activity → Service catalogue loader: loads data
- Service catalogue loader → Private configuration files: reads · Reads ais.json from app-private files.
- AI Hub workspace → Service chooser: owns · Screen composition and direct runtime wiring are unconfirmed.
- Service chooser → Persistent settings: updates filters
- Service management → Persistent settings: saves order
- Service chooser → AI service websites: selects service · Selection callbacks exist, but navigation wiring is not established.
- Remote configuration updater → AI Hub configuration host: checks and fetches
- Remote configuration updater → Persistent settings: reads and saves ETags
- Remote configuration updater → Private configuration files: writes updates
- AI service websites → WebView navigation: loads pages
- WebView navigation → Persistent settings: reads custom CSS and JS
- WebView interactions → Main activity: delegates requests · Routes file chooser and permission requests to activity methods.
- WebView navigation → Download handler: intercepts blobs · Blob interception is installed after page load; dispatch details are not established.
- Download handler → Android Downloads and MediaStore: writes downloads
