# flycom-e/clearbox architecture

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

- Interactive diagram: https://gitdiagram.com/flycom-e/clearbox
- Repository: https://github.com/flycom-e/clearbox

## Overview

ClearBox combines an Android app driven by configurable KrScript pages and actions with a native, root-oriented cleaning and storage toolkit that also exposes a terminal UI. The app workflow is startup and permission/root checks, page loading, action selection, then script execution. The README documents cleanup, file organization, automation, storage analysis, and update/install blocking; native implementation details are only partly sampled, so links to specific native operations are marked unverified where necessary.

Main entry points: [`AppSource/krscript/src/main/java/wipe/cache/krscript/ui/ActionListFragment.kt`](https://github.com/flycom-e/clearbox/blob/main/AppSource/krscript/src/main/java/wipe/cache/krscript/ui/ActionListFragment.kt) (Action lists), [`AppSource/clearbox/src/main/java/wipe/cache/main/MainActivity.kt`](https://github.com/flycom-e/clearbox/blob/main/AppSource/clearbox/src/main/java/wipe/cache/main/MainActivity.kt) (Main UI), [`AppSource/krscript/src/main/java/wipe/cache/krscript/executor/ScriptEnvironment.kt`](https://github.com/flycom-e/clearbox/blob/main/AppSource/krscript/src/main/java/wipe/cache/krscript/executor/ScriptEnvironment.kt) (Script environment), [`AppSource/clearbox/src/main/java/wipe/cache/main/SplashActivity.kt`](https://github.com/flycom-e/clearbox/blob/main/AppSource/clearbox/src/main/java/wipe/cache/main/SplashActivity.kt) (Startup checks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_android["Android app"]
  node_splash["Startup checks<br/>[SplashActivity.kt]"]
  node_mainui["Main UI<br/>[MainActivity.kt]"]
end

subgraph group_script["KrScript runtime"]
  node_pageconfig["Page configuration"]
  node_actionui["Action lists"]
  node_actionmodel["Action models<br/>[RunnableNode.kt]"]
  node_scriptenv["Script environment"]
  node_scriptlog["Execution logs"]
end

subgraph group_native["Native toolkit"]
  node_nativecli["Terminal interface<br/>[main.c]"]
  node_clean["Cache and junk cleanup<br/>[storage_clean.c]"]
  node_appclean["App cache cleanup<br/>[app_cache_clean.c]"]
  node_rules["Custom rule cleanup<br/>[cust_rule_clean.c]"]
  node_filemanager["File management<br/>[file_manager.c]"]
  node_analysis["Storage analysis<br/>[ncdu.c]"]
  node_diskgc["Disk garbage collection<br/>[disk_gc.c]"]
  node_timed["Timed automation<br/>[time_daemon.c]"]
  node_blocking["Cache/update blocking"]
end

subgraph group_shared["System access"]
  node_shell["Root shell<br/>[KeepShellPublic.kt]"]
  node_storage["Shared file access"]
  node_rootfs[("Android filesystem")]
end

node_user(("User"))
node_terminal(("Terminal user"))

node_user -->|"opens app"| node_splash
node_splash -->|"opens home"| node_mainui
node_mainui -->|"loads pages"| node_pageconfig
node_mainui -->|"shows actions"| node_actionui
node_actionui -->|"handles actions"| node_actionmodel
node_actionui -->|"executes scripts"| node_scriptenv
node_scriptenv -.->|"runs commands"| node_shell
node_scriptenv -.->|"uses files"| node_storage
node_actionui -.->|"shows logs"| node_scriptlog
node_terminal -->|"runs ClearBox"| node_nativecli
node_user -.->|"requests cleanup"| node_clean
node_user -.->|"requests app cleanup"| node_appclean
node_user -->|"configures rules"| node_rules
node_user -->|"organizes files"| node_filemanager
node_user -->|"analyzes storage"| node_analysis
node_user -->|"runs optimization"| node_diskgc
node_user -->|"sets automation"| node_timed
node_user -->|"blocks updates"| node_blocking
node_clean -.->|"cleans files"| node_rootfs
node_appclean -.->|"cleans caches"| node_rootfs
node_rules -.->|"applies rules"| node_rootfs
node_filemanager -.->|"manages files"| node_rootfs
node_analysis -.->|"reads usage"| node_rootfs
node_diskgc -.->|"reclaims space"| node_rootfs
node_blocking -.->|"protects paths"| node_rootfs

click node_splash "https://github.com/flycom-e/clearbox/blob/main/AppSource/clearbox/src/main/java/wipe/cache/main/SplashActivity.kt"
click node_mainui "https://github.com/flycom-e/clearbox/blob/main/AppSource/clearbox/src/main/java/wipe/cache/main/MainActivity.kt"
click node_pageconfig "https://github.com/flycom-e/clearbox/blob/main/AppSource/krscript/src/main/java/wipe/cache/krscript/config/PageConfigReader.kt"
click node_actionui "https://github.com/flycom-e/clearbox/blob/main/AppSource/krscript/src/main/java/wipe/cache/krscript/ui/ActionListFragment.kt"
click node_actionmodel "https://github.com/flycom-e/clearbox/blob/main/AppSource/krscript/src/main/java/wipe/cache/krscript/model/RunnableNode.kt"
click node_scriptenv "https://github.com/flycom-e/clearbox/blob/main/AppSource/krscript/src/main/java/wipe/cache/krscript/executor/ScriptEnvironment.kt"
click node_scriptlog "https://github.com/flycom-e/clearbox/blob/main/AppSource/krscript/src/main/java/wipe/cache/krscript/ui/DialogLogFragment.kt"
click node_shell "https://github.com/flycom-e/clearbox/blob/main/AppSource/common/src/main/java/wipe/cache/common/shell/KeepShellPublic.kt"
click node_storage "https://github.com/flycom-e/clearbox/blob/main/AppSource/common/src/main/java/wipe/cache/common/shared/FilePathResolver.kt"
click node_nativecli "https://github.com/flycom-e/clearbox/blob/main/src/main.c"
click node_clean "https://github.com/flycom-e/clearbox/blob/main/src/storage_clean.c"
click node_appclean "https://github.com/flycom-e/clearbox/blob/main/src/app_cache_clean.c"
click node_rules "https://github.com/flycom-e/clearbox/blob/main/src/cust_rule_clean.c"
click node_filemanager "https://github.com/flycom-e/clearbox/blob/main/src/file_manager.c"
click node_analysis "https://github.com/flycom-e/clearbox/blob/main/src/ncdu.c"
click node_diskgc "https://github.com/flycom-e/clearbox/blob/main/src/Daemon/disk_gc.c"
click node_timed "https://github.com/flycom-e/clearbox/blob/main/src/Daemon/time_daemon.c"
click node_blocking "https://github.com/flycom-e/clearbox/blob/main/src/Daemon/stop_cache_daemon.c"

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_splash,node_mainui,node_user,node_terminal toneBlue
class node_pageconfig,node_actionui,node_actionmodel,node_scriptenv,node_scriptlog toneAmber
class node_nativecli,node_clean,node_appclean,node_rules,node_filemanager,node_analysis,node_diskgc,node_timed,node_blocking toneMint
class node_shell,node_storage,node_rootfs toneRose
```

## Components

### Android app

- [Startup checks](https://github.com/flycom-e/clearbox/blob/main/AppSource/clearbox/src/main/java/wipe/cache/main/SplashActivity.kt): `AppSource/clearbox/src/main/java/wipe/cache/main/SplashActivity.kt`
- [Main UI](https://github.com/flycom-e/clearbox/blob/main/AppSource/clearbox/src/main/java/wipe/cache/main/MainActivity.kt): `AppSource/clearbox/src/main/java/wipe/cache/main/MainActivity.kt`

### KrScript runtime

- [Page configuration](https://github.com/flycom-e/clearbox/blob/main/AppSource/krscript/src/main/java/wipe/cache/krscript/config/PageConfigReader.kt): `AppSource/krscript/src/main/java/wipe/cache/krscript/config/PageConfigReader.kt`
- [Action lists](https://github.com/flycom-e/clearbox/blob/main/AppSource/krscript/src/main/java/wipe/cache/krscript/ui/ActionListFragment.kt): `AppSource/krscript/src/main/java/wipe/cache/krscript/ui/ActionListFragment.kt`
- [Action models](https://github.com/flycom-e/clearbox/blob/main/AppSource/krscript/src/main/java/wipe/cache/krscript/model/RunnableNode.kt): `AppSource/krscript/src/main/java/wipe/cache/krscript/model/RunnableNode.kt`
- [Script environment](https://github.com/flycom-e/clearbox/blob/main/AppSource/krscript/src/main/java/wipe/cache/krscript/executor/ScriptEnvironment.kt): `AppSource/krscript/src/main/java/wipe/cache/krscript/executor/ScriptEnvironment.kt`
- [Execution logs](https://github.com/flycom-e/clearbox/blob/main/AppSource/krscript/src/main/java/wipe/cache/krscript/ui/DialogLogFragment.kt): `AppSource/krscript/src/main/java/wipe/cache/krscript/ui/DialogLogFragment.kt`

### Native toolkit

- [Terminal interface](https://github.com/flycom-e/clearbox/blob/main/src/main.c): `src/main.c`
- [Cache and junk cleanup](https://github.com/flycom-e/clearbox/blob/main/src/storage_clean.c): `src/storage_clean.c`
- [App cache cleanup](https://github.com/flycom-e/clearbox/blob/main/src/app_cache_clean.c): `src/app_cache_clean.c`
- [Custom rule cleanup](https://github.com/flycom-e/clearbox/blob/main/src/cust_rule_clean.c): `src/cust_rule_clean.c`
- [File management](https://github.com/flycom-e/clearbox/blob/main/src/file_manager.c): `src/file_manager.c`
- [Storage analysis](https://github.com/flycom-e/clearbox/blob/main/src/ncdu.c): `src/ncdu.c`
- [Disk garbage collection](https://github.com/flycom-e/clearbox/blob/main/src/Daemon/disk_gc.c): `src/Daemon/disk_gc.c`
- [Timed automation](https://github.com/flycom-e/clearbox/blob/main/src/Daemon/time_daemon.c): `src/Daemon/time_daemon.c`
- [Cache/update blocking](https://github.com/flycom-e/clearbox/blob/main/src/Daemon/stop_cache_daemon.c): `src/Daemon/stop_cache_daemon.c`

### System access

- [Root shell](https://github.com/flycom-e/clearbox/blob/main/AppSource/common/src/main/java/wipe/cache/common/shell/KeepShellPublic.kt): `AppSource/common/src/main/java/wipe/cache/common/shell/KeepShellPublic.kt`
- [Shared file access](https://github.com/flycom-e/clearbox/blob/main/AppSource/common/src/main/java/wipe/cache/common/shared/FilePathResolver.kt): `AppSource/common/src/main/java/wipe/cache/common/shared/FilePathResolver.kt`
- **Android filesystem**

### Other components

- **User**
- **Terminal user**

## Connections

- User → Startup checks: opens app (evidence: `AppSource/clearbox/src/main/java/wipe/cache/main/SplashActivity.kt`)
- Startup checks → Main UI: opens home (evidence: `AppSource/clearbox/src/main/java/wipe/cache/main/SplashActivity.kt`)
- Main UI → Page configuration: loads pages (evidence: `AppSource/clearbox/src/main/java/wipe/cache/main/MainActivity.kt`)
- Main UI → Action lists: shows actions (evidence: `AppSource/clearbox/src/main/java/wipe/cache/main/MainActivity.kt`)
- Action lists → Action models: handles actions (evidence: `AppSource/krscript/src/main/java/wipe/cache/krscript/ui/ActionListFragment.kt`)
- Action lists → Script environment: executes scripts (evidence: `AppSource/krscript/src/main/java/wipe/cache/krscript/ui/ActionListFragment.kt`)
- Script environment → Root shell: runs commands (evidence: `AppSource/krscript/src/main/java/wipe/cache/krscript/executor/ScriptEnvironment.kt`)
- Script environment → Shared file access: uses files
- Action lists → Execution logs: shows logs (evidence: `AppSource/krscript/src/main/java/wipe/cache/krscript/ui/ActionListFragment.kt`)
- Terminal user → Terminal interface: runs ClearBox
- User → Cache and junk cleanup: requests cleanup
- User → App cache cleanup: requests app cleanup
- User → Custom rule cleanup: configures rules
- User → File management: organizes files
- User → Storage analysis: analyzes storage
- User → Disk garbage collection: runs optimization
- User → Timed automation: sets automation
- User → Cache/update blocking: blocks updates
- Cache and junk cleanup → Android filesystem: cleans files
- App cache cleanup → Android filesystem: cleans caches
- Custom rule cleanup → Android filesystem: applies rules
- File management → Android filesystem: manages files
- Storage analysis → Android filesystem: reads usage
- Disk garbage collection → Android filesystem: reclaims space
- Cache/update blocking → Android filesystem: protects paths
