This commit is contained in:
Alvin-Zilverstand committed 2026-11-19 11:43:36 +01:00
1 parent 0d3e076115
commit 8e27e174a7
15 files changed
+161 -26

No files matched your search

+1
View File
@@ -7,4 +7,5 @@ local.properties
.idea/caches/
captures/
*.apk
*.aab
connection.txt
+2 -2
View File
@@ -10,7 +10,7 @@
## Product scope
1. Connection screen: proxy URL and API key, test connection, secure credential storage, clear connection.
2. Overview: total spend, activity summary, recent requests, and refresh.
2. Overview: total spend, activity summary, daily request chart, recent requests, and refresh.
3. Models: searchable list and model details.
4. Keys and teams: searchable management inventory, spending and budget information where returned by the proxy, plus admin creation flows.
5. Logs: paginated recent request list with status, model, tokens, cost, and detail view.
@@ -32,4 +32,4 @@
- Never logs or exposes the saved key in UI, app backups, or source.
- Compiles and launches on the available Android emulator.
The repository started without application source. No proxy URL or API key was supplied, so live server data and privileged write actions cannot be verified against the user's deployment. Destructive management actions are outside the initial scope.
The repository started without application source. The first emulator pass used a local fixture; a later pass verified read-only flows against the user's LiteLLM v1.110.1 server. Privileged write actions have only been exercised against the fixture. Destructive management actions are outside the initial scope.
+11 -9
View File
@@ -11,7 +11,7 @@ This file tracks the Android app in this repository. A checked item means the fe
- [x] Added a connection screen with proxy URL validation, bearer-key authentication, connection test, timeouts, and readable network/authentication errors.
- [x] Encrypted the saved API key with Android Keystore, disabled app backup, and added disconnect/key removal.
- [x] Built bottom navigation and settings, with loading, empty, retry, and section-specific error views.
- [x] Added an overview showing total spend, request counts, a seven-day spend chart, and recent requests where the proxy permits them.
- [x] Added an overview showing total spend, request counts, a seven-day request chart, and recent requests where the proxy permits them.
- [x] Added searchable model inventory and model detail views. The app falls back to `/v1/models` if `/model/info` is unavailable or forbidden.
- [x] Added key inventory, details, and page navigation. Key search filters the currently loaded page.
- [x] Added team inventory and details.
@@ -20,17 +20,19 @@ This file tracks the Android app in this repository. A checked item means the fe
- [x] Added a local LiteLLM-shaped test proxy at [tools/mock_proxy.py](tools/mock_proxy.py).
- [x] Built a debug APK with `./gradlew.bat :app:assembleDebug` and installed/launched it on `emulator-5554` through adb.
- [x] Exercised connection, overview, inventories, log pagination, saved-connection restart, and all three creation flows against the local test proxy. Fixed a short-list navigation layout issue found during emulator review. The final APK launched after rebuilding.
- [x] Connected the emulator app to the user's LiteLLM v1.110.1 server using the ignored `connection.txt` file. Verified that overview, models, keys, and logs render live data and that `/team/list` returns an empty list without an app error. The live server requires dates on `/global/activity`; the app now supplies them. `/global/spend/report` is Enterprise-only on this server, so the chart now uses daily request activity instead.
- [x] Adjusted the model provider parser for `litellm_params.custom_llm_provider` and increased precision for small request costs after inspecting live responses.
- [x] Built signed, shrunk release APK and AAB with a new local upload key stored outside the repository. Verified the APK signature, installed it on `emulator-5554`, and confirmed it connects to the live LiteLLM server and renders overview data. Documented repeatable release builds and key backup in [README.md](README.md).
## Needs work or verification
- [ ] Connect to a real LiteLLM deployment and verify the response shapes, permissions, and create flows across the deployment's actual LiteLLM version. No live proxy URL or credential has been provided, so the app has only been integration-tested against the local fixture.
- [ ] Confirm the overview's `/global/spend` and `/global/activity` metrics against real admin and restricted keys. Forbidden metrics currently appear as unavailable values; make their reason explicit on the overview.
- [ ] Verify model, key, and team **creation** against a live LiteLLM deployment when a disposable test object and cleanup path are available. The current live pass was read-only; creation was verified only against the local fixture.
- [ ] Confirm overview behavior with a restricted key. Forbidden metrics currently appear as unavailable values; make their reason explicit on the overview.
- [ ] Verify connection failure paths on-device with invalid keys, forbidden endpoints, expired credentials, TLS/certificate failures, and a proxy mounted under a URL path. These states have code paths but were not all exercised on the emulator.
- [ ] Add automated tests for URL validation, API response parsing, authentication/error mapping, and creation payloads. The repository currently has no automated test suite or CI workflow.
- [ ] Improve large-installation browsing: server-side key search, more reliable total/page handling across LiteLLM versions, and pagination or filtering for teams and models where needed. Current key and log search works only within a page.
- [ ] Improve the chart with date/value labels and clarify the time range of overview totals. The current bar chart communicates magnitude but has no axis or per-day labels.
- [ ] Improve the daily request chart with date/value labels and clarify the time range of overview totals. The current bar chart communicates magnitude but has no axis or per-day labels.
- [ ] Review accessibility on a range of screen sizes, font scales, keyboard navigation, and screen-reader settings. Standard Compose labels are present, but a full accessibility pass has not been done.
- [ ] Produce a signed release build and document distribution. The existing APK is a debug build only.
## Not started
@@ -40,12 +42,12 @@ This file tracks the Android app in this repository. A checked item means the fe
- [ ] Advanced log filters, server-side search, full request traces, and prompt/response inspection where LiteLLM has been configured to store them.
- [ ] Alerts, push notifications, widgets, or background synchronization.
- [ ] Multiple saved proxy profiles and account switching.
- [ ] Play Store packaging, release signing, crash reporting, and production telemetry.
- [ ] Play Store listing and submission, crash reporting, and production telemetry. A signed AAB exists, but it has not been uploaded or reviewed by a store.
## Next milestone
1. Test against a real proxy with a suitably scoped key and record its LiteLLM version and any endpoint differences.
2. Fix the API and permission issues uncovered by that test.
3. Add automated regression tests for those real response shapes, then build a signed release candidate.
1. Add automated regression tests using the response shapes observed on LiteLLM v1.110.1.
2. Verify restricted-key behavior and live creation with disposable objects if those flows are needed for release.
3. Complete compatibility and accessibility checks before a public store release, then submit the signed AAB and preserve the signing-key backup.
Update this file whenever a feature is completed or a gap is discovered. Move an item to **Completed** only after implementation; record the verification level separately when it has not been exercised against a live deployment.
+17 -1
View File
@@ -7,7 +7,7 @@ See [PROGRESS.md](PROGRESS.md) for completed work, remaining verification, and f
## Features
- Connect with a proxy URL and bearer API key; the key is encrypted with Android Keystore and excluded from backups.
- Overview with total spend, request counts, a daily spend chart, and recent requests.
- Overview with total spend, request counts, a daily request chart, and recent requests.
- Searchable model, key, and team inventories with detail views. Key search filters the current page; use page navigation for larger installations.
- Recent spend logs with request details and page navigation.
- Create models, virtual keys, and teams when the connected key has permission. Newly generated virtual keys are shown once and are not saved by the app.
@@ -26,12 +26,28 @@ adb install -r app/build/outputs/apk/debug/app-debug.apk
Requires JDK 17+, Android SDK platform 37, and an emulator/device running Android 8.0 or newer. The debug APK is at `app/build/outputs/apk/debug/app-debug.apk`.
### Signed release
On this Windows machine, run:
```powershell
.\tools\build_release.ps1
```
This builds a signed APK at `app/build/outputs/apk/release/app-release.apk` for direct installation and a signed Android App Bundle at `app/build/outputs/bundle/release/app-release.aab` for store upload. The release build uses code and resource shrinking and targets Android API 36. The APK was installed on the emulator and connected to the live LiteLLM server on 19 November 2026.
The script keeps the upload keystore at `%USERPROFILE%\.android\litellm-dashboard-upload.jks` and its Windows DPAPI-encrypted password at `%USERPROFILE%\.android\litellm-dashboard-upload.password.dpapi`, outside the repository. Back up the keystore and password in a secure location. The DPAPI file can be decrypted only by this Windows user account on this machine; to record the password in a password manager, run `.\tools\build_release.ps1 -ShowSigningPassword` locally and clear the terminal afterward. Keep the key and password for all future updates to this package. The first release run creates the key if neither file exists; later runs reuse it.
To install the release APK on a device that has the debug build, uninstall the debug app first because its signing key differs. Uninstalling removes the app's saved connection. The package name is `dev.alvin.litellmdashboard`, with version `1.0.0` (`versionCode` 1).
## Connect
Enter the proxy base URL, for example `https://litellm.example.com`. Public addresses must use HTTPS. HTTP is accepted only for localhost, Android emulator host `10.0.2.2`, and private LAN addresses. Do not append `/ui` or an endpoint path. For a local proxy on the host, use `http://10.0.2.2:4000` from the standard Android emulator.
The app sends the key only in the `Authorization: Bearer` header. Disconnecting removes the stored connection. LiteLLM versions and deployment settings vary, so unsupported or forbidden endpoints appear as section-specific errors.
The overview uses `/global/spend`, `/global/activity`, and `/gateway/daily/activity`. The activity call includes dates because some LiteLLM versions require them. The request chart works without the Enterprise-only `/global/spend/report` endpoint.
## Local emulator fixture
The fixture in `tools/mock_proxy.py` exercises the app without a real LiteLLM deployment:
+21 -1
View File
@@ -10,7 +10,7 @@ android {
defaultConfig {
applicationId = "dev.alvin.litellmdashboard"
minSdk = 26
targetSdk = 35
targetSdk = 36
versionCode = 1
versionName = "1.0.0"
}
@@ -19,6 +19,26 @@ android {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
signingConfigs {
if (System.getenv("LITELLM_RELEASE_STORE_FILE") != null) {
create("localRelease") {
storeFile = file(System.getenv("LITELLM_RELEASE_STORE_FILE"))
storePassword = System.getenv("LITELLM_RELEASE_STORE_PASSWORD")
keyAlias = System.getenv("LITELLM_RELEASE_KEY_ALIAS")
keyPassword = System.getenv("LITELLM_RELEASE_KEY_PASSWORD")
}
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
if (System.getenv("LITELLM_RELEASE_STORE_FILE") != null) {
signingConfig = signingConfigs.getByName("localRelease")
}
}
}
packaging { resources.excludes += "/META-INF/{AL2.0,LGPL2.1}" }
}
+1
View File
@@ -0,0 +1 @@
# Keep rules can be added here when a dependency needs reflection at runtime.
+3 -1
View File
@@ -4,7 +4,9 @@
<application
android:allowBackup="false"
android:usesCleartextTraffic="true"
android:label="LiteLLM Dashboard"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:theme="@android:style/Theme.Material.Light.NoActionBar">
<activity android:name=".MainActivity" android:exported="true" android:windowSoftInputMode="adjustResize">
<intent-filter>
@@ -134,7 +134,7 @@ class LiteLlmApi(private val connection: Connection) {
val params = row.optJSONObject("litellm_params") ?: JSONObject()
val info = row.optJSONObject("model_info") ?: JSONObject()
val name = row.string("model_name", "id", "model")
ModelItem(name, info.string("litellm_provider", "provider").ifBlank { params.string("model").substringBefore('/', "Unknown") }, info.string("id").ifBlank { row.string("id") }, info.string("mode").ifBlank { "chat" }, info.number("max_tokens", "max_input_tokens")?.toInt()?.toString().orEmpty())
ModelItem(name, info.string("litellm_provider", "provider").ifBlank { params.string("custom_llm_provider").ifBlank { params.string("model").substringBefore('/', "Unknown") } }, info.string("id").ifBlank { row.string("id") }, info.string("mode").ifBlank { "chat" }, info.number("max_tokens", "max_input_tokens")?.toInt()?.toString().orEmpty())
}
}.filter { it.name.isNotBlank() }.distinctBy { it.name }
}
@@ -175,18 +175,25 @@ class LiteLlmApi(private val connection: Connection) {
}
fun overview(): Overview {
val start = LocalDate.now().minusDays(6)
val end = LocalDate.now()
val spendRaw = try { get("/global/spend") } catch (e: ApiException) { if (e.status == 403 || e.status == 404) null else throw e }
val spend = (spendRaw as? JSONObject)?.number("spend", "total_spend")
val activityRaw = try { get("/global/activity") } catch (e: ApiException) { if (e.status == 403 || e.status == 404) null else throw e }
val activityRaw = try { get("/global/activity?start_date=$start&end_date=$end") } catch (e: ApiException) { if (e.status == 400 || e.status == 403 || e.status == 404) null else throw e }
val activity = activityRaw as? JSONObject
val requests = activity?.number("total_requests", "total_api_requests", "total_requests_count")?.toLong()
val successful = activity?.number("successful_requests", "success_count")?.toLong()
val dailyRaw = try { get("/global/spend/report?start_date=${LocalDate.now().minusDays(6)}&end_date=${LocalDate.now()}") } catch (_: Exception) { null }
val days = array(dailyRaw ?: JSONArray(), "data", "results")
val gatewayRaw = try { get("/gateway/daily/activity?start_date=$start&end_date=$end") } catch (e: ApiException) { if (e.status == 400 || e.status == 403 || e.status == 404) null else throw e }
val gateway = gatewayRaw as? JSONObject
val successful = gateway?.number("total_successful_requests")?.toLong() ?: activity?.number("successful_requests", "success_count")?.toLong()
val failed = gateway?.number("total_failed_requests")?.toLong()
val requests = if (successful != null && failed != null) successful + failed else activity?.number("sum_api_requests", "total_requests", "total_api_requests", "total_requests_count")?.toLong()
val gatewayDays = gateway?.optJSONArray("by_date") ?: JSONArray()
val days = if (gatewayDays.length() > 0) gatewayDays else activity?.optJSONArray("daily_data") ?: JSONArray()
val daily = (0 until days.length()).mapNotNull { i ->
days.optJSONObject(i)?.let { row ->
val date = row.string("group_by_day", "date").take(10)
val value = row.number("spend", "total_spend") ?: row.optJSONArray("teams")?.let { teams -> (0 until teams.length()).sumOf { teams.optJSONObject(it)?.number("total_spend") ?: 0.0 } }
val date = row.string("date").take(10)
val value = if (gatewayDays.length() > 0) {
(row.number("successful_requests") ?: 0.0) + (row.number("failed_requests") ?: 0.0)
} else row.number("api_requests")
if (date.isBlank() || value == null) null else date to value
}
}
@@ -40,7 +40,13 @@ private val Blue = Color(0xFF375BE8)
private val Pale = Color(0xFFF4F7FB)
private val Green = Color(0xFF13876A)
private fun usd(value: Double?): String = value?.let { NumberFormat.getCurrencyInstance(Locale.US).format(it) } ?: "—"
private fun usd(value: Double?): String = value?.let {
when {
it == 0.0 || it >= 0.01 -> NumberFormat.getCurrencyInstance(Locale.US).format(it)
it >= 0.0001 -> String.format(Locale.US, "$%.4f", it)
else -> String.format(Locale.US, "$%.6f", it)
}
} ?: "—"
private fun compact(value: Number?): String = value?.let { NumberFormat.getIntegerInstance(Locale.US).format(it) } ?: "—"
private fun readableError(t: Throwable): String = when (t) {
is ApiException -> t.message ?: "Request failed"
@@ -307,9 +313,9 @@ private fun OverviewScreen(overview: Overview?, recent: List<LogItem>, logMessag
MetricCard("Requests", compact(overview?.requests), Modifier.weight(1f))
MetricCard("Successful", compact(overview?.successful), Modifier.weight(1f))
}
SectionTitle("Last 7 days", "Spend by day")
SectionTitle("Last 7 days", "Requests per day")
Card(colors = CardDefaults.cardColors(containerColor = Color.White), shape = RoundedCornerShape(18.dp)) {
if (overview?.daily.isNullOrEmpty()) Text("No daily spend data available", Modifier.padding(22.dp), color = Muted)
if (overview?.daily.isNullOrEmpty()) Text("No daily request data available", Modifier.padding(22.dp), color = Muted)
else SpendChart(overview!!.daily, Modifier.fillMaxWidth().height(150.dp).padding(22.dp))
}
SectionTitle("Recent requests")
@@ -0,0 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="100"
android:viewportHeight="100">
<path android:fillColor="#FFFFFFFF" android:pathData="M24,20 L36,20 L36,58 L68,58 L68,70 L24,70 Z" />
</vector>
@@ -0,0 +1,5 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
+3
View File
@@ -0,0 +1,3 @@
<resources>
<color name="launcher_background">#375BE8</color>
</resources>
+3
View File
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">LiteLLM Dashboard</string>
</resources>
+61
View File
@@ -0,0 +1,61 @@
param([switch]$ShowSigningPassword)
$ErrorActionPreference = 'Stop'
$projectRoot = Split-Path -Parent $PSScriptRoot
$androidSdk = Join-Path $env:LOCALAPPDATA 'Android\Sdk'
$javaHome = 'C:\Program Files\Android\Android Studio\jbr'
$keytool = Join-Path $javaHome 'bin\keytool.exe'
$signingDir = Join-Path $env:USERPROFILE '.android'
$storePath = Join-Path $signingDir 'litellm-dashboard-upload.jks'
$secretPath = Join-Path $signingDir 'litellm-dashboard-upload.password.dpapi'
$alias = 'litellm-dashboard-upload'
if (-not (Test-Path -LiteralPath $keytool)) { throw "Android Studio JDK not found at $javaHome" }
if (-not (Test-Path -LiteralPath $androidSdk)) { throw "Android SDK not found at $androidSdk" }
New-Item -ItemType Directory -Path $signingDir -Force | Out-Null
$hasStore = Test-Path -LiteralPath $storePath
$hasSecret = Test-Path -LiteralPath $secretPath
if ($hasStore -xor $hasSecret) {
throw 'Only one signing file exists. Restore the missing keystore or password file before building; do not generate a replacement key for an existing app.'
}
if (-not $hasStore) {
$random = [System.Security.Cryptography.RandomNumberGenerator]::GetBytes(36)
$password = [Convert]::ToBase64String($random).TrimEnd('=').Replace('+', '-').Replace('/', '_')
& $keytool -genkeypair -keystore $storePath -storetype PKCS12 -alias $alias -keyalg RSA -keysize 3072 -validity 10000 -storepass $password -keypass $password -dname 'CN=LiteLLM Dashboard'
if ($LASTEXITCODE -ne 0) { throw 'Key generation failed.' }
$password | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Set-Content -LiteralPath $secretPath -NoNewline
Write-Host "Created local release key at $storePath"
}
$securePassword = Get-Content -LiteralPath $secretPath -Raw | ConvertTo-SecureString
$pointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePassword)
try { $password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($pointer) }
finally { [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($pointer) }
if ($ShowSigningPassword) {
Write-Host 'Signing password (back up securely, then clear your terminal):'
Write-Output $password
exit 0
}
$env:JAVA_HOME = $javaHome
$env:ANDROID_HOME = $androidSdk
$env:LITELLM_RELEASE_STORE_FILE = $storePath
$env:LITELLM_RELEASE_STORE_PASSWORD = $password
$env:LITELLM_RELEASE_KEY_ALIAS = $alias
$env:LITELLM_RELEASE_KEY_PASSWORD = $password
try {
Push-Location $projectRoot
try {
& .\gradlew.bat :app:assembleRelease :app:bundleRelease --no-daemon
if ($LASTEXITCODE -ne 0) { throw "Release build failed with exit code $LASTEXITCODE" }
} finally { Pop-Location }
} finally {
Remove-Item Env:LITELLM_RELEASE_STORE_FILE,Env:LITELLM_RELEASE_STORE_PASSWORD,Env:LITELLM_RELEASE_KEY_ALIAS,Env:LITELLM_RELEASE_KEY_PASSWORD -ErrorAction SilentlyContinue
$password = $null
}
Write-Host 'Signed release APK: app\build\outputs\apk\release\app-release.apk'
Write-Host 'Signed release AAB: app\build\outputs\bundle\release\app-release.aab'
+2 -1
View File
@@ -31,7 +31,8 @@ class Handler(BaseHTTPRequestHandler):
"/key/list": {"keys": [{"key_alias": "Production", "token": "hashed-token", "user_id": "alvin", "team_id": "core", "spend": 42.12, "max_budget": 100, "blocked": False}]},
"/team/list": [{"team_alias": "Core", "team_id": "core", "spend": 98.45, "max_budget": 250, "members": ["alvin", "sam"]}],
"/global/spend": {"spend": 234.56},
"/global/activity": {"total_requests": 1234, "successful_requests": 1221},
"/global/activity": {"sum_api_requests": 1234, "daily_data": [{"date": "2026-11-17", "api_requests": 12}, {"date": "2026-11-18", "api_requests": 18}]},
"/gateway/daily/activity": {"total_successful_requests": 1221, "total_failed_requests": 13, "by_date": [{"date": "2026-11-17", "successful_requests": 11, "failed_requests": 1}, {"date": "2026-11-18", "successful_requests": 18, "failed_requests": 0}]},
"/global/spend/report": [{"group_by_day": "2026-11-17T00:00:00+00:00", "total_spend": 4.5}, {"group_by_day": "2026-11-18T00:00:00+00:00", "total_spend": 7.9}],
"/spend/logs/v2": {"data": [{"request_id": f"req-{page}", "model": "gpt-4o", "startTime": "2026-11-19T08:00:00", "status": "success", "spend": 0.024, "total_tokens": 945, "team_id": "core"}], "total": 31, "page": page, "page_size": 30},
}