Skip to content

Android App

The Antimatter Android app is a native companion application built with Kotlin and Jetpack Compose. It connects to the antimatter-core Gateway over an encrypted WebSocket tunnel, and provides a full-featured interface to monitor, control, and interact with your AI agent remotely.

  • Source: android/
  • Package: dev.saifmukhtar.antimatter
  • Min SDK: Android 8.0 (API 26)
  • Target SDK: Android 15 (API 35)
  • Architecture: Multi-module Gradle, MVVM + Hilt DI

Module Graph

:app # MainActivity, Hilt Application, NavHost
โ”œโ”€โ”€ :core:network # WebSocket client, BridgeService, protocol types
โ”œโ”€โ”€ :core:data # Room DB, DAOs, Entities, DataStore preferences
โ”œโ”€โ”€ :core:ui # Material 3 theme, Markdown renderer, shared composables
โ”œโ”€โ”€ :feature:connect # QR scanner, pairing flow, connection state
โ”œโ”€โ”€ :feature:chat # Trajectory/chat UI, prompting, artifact viewer
โ”œโ”€โ”€ :feature:files # Workspace file browser, file viewer
โ”œโ”€โ”€ :feature:terminal # Native PTY terminal (Termux-based)
โ”œโ”€โ”€ :terminal-emulator # JNI NDK terminal emulator (Termux fork)
โ””โ”€โ”€ :terminal-view # TerminalView composable bridge

Core Modules

:core:network

The networking heart of the app.

FileResponsibility
BridgeWebSocket.ktOkHttp WebSocket client โ€” connects to Gateway, performs AUTH_CHALLENGE/AUTH_RESPONSE Ed25519 handshake, decrypts E2EE payloads, emits Flow<InboundMessage>
BridgeService.ktForeground Service that keeps the WebSocket alive when the app is backgrounded; surfaces push notifications for agent events
OutboundMessage.ktSealed Kotlin class hierarchy for all outbound message types (SendMessage, PtyStart, PtyInput, PtyResize, GetFiles, etc.)
InboundMessage.ktSealed class hierarchy for all inbound messages from the Gateway

:core:data

Offline persistence layer.

ComponentTechnologyPurpose
Room DatabaseAppDatabase.ktSQLite persistence for conversations, steps, artifacts
FTS TableRoom FTS4 extensionFull-text search across all trajectory data
DataStoreJetpack DataStoreUser settings, selected adapter, connection preferences
StepDaoRoom DAOCRUD + FTS queries for agent trajectory steps
ArtifactDaoRoom DAOCRUD for file artifacts created by the agent

:core:ui

Shared design system and UI utilities.

ComponentPurpose
AntimatterThemeMaterial 3 MaterialTheme wrapper with dynamic color support (Android 12+)
MarkdownTextCustom Composable that renders Markdown with syntax highlighting
Color.ktBrand color tokens (AntiPrimary, TermuxBlack, AntiBackground, etc.)
Typography.ktInter + JetBrains Mono type scale

Feature Modules

:feature:connect โ€” Pairing & Connection

Handles the full QR pairing and connection flow.

ScreenViewModelPurpose
ConnectScreenConnectionViewModelConnection dashboard โ€” status, adapter selection, disconnect
QRScannerScreenConnectionViewModelCamera QR scanner with CameraX

Connection flow:

  1. User scans QR code โ†’ URL, token, and Ed25519 public key extracted.
  2. BridgeWebSocket opens connection with Authorization: Bearer <token>.
  3. AUTH_CHALLENGE nonce received โ†’ Gateway signs with Ed25519 private key.
  4. App verifies signature against paired public key.
  5. Sends GET_AVAILABLE_AGENTS โ†’ user selects adapter.

:feature:chat โ€” AI Chat Interface

The primary interaction screen.

ComponentPurpose
ChatScreenMain chat UI โ€” message list, input, agent status
ChatViewModelBusiness logic โ€” sends prompts, processes streaming trajectory, manages Room inserts
ThinkingBubbleAnimated indicator when agent is generating
ToolCallCardExpandable card rendering tool calls (bash, file edit, search, etc.)
ArtifactCardRenders file artifacts with diff preview
MessageInputMulti-line input with image attachment support

Streaming: Messages are received as STEP events from the Gateway. Each step is a trajectory entry (thinking, tool_call, tool_result, text) rendered live as it arrives.

:feature:files โ€” Workspace Browser

| Screen | ViewModel | Purpose | |---|---| | FilesScreen | FilesViewModel | Tree view of workspace files | | FileViewScreen | FilesViewModel | File content viewer with syntax highlighting |

Sends GET_FILES and READ_FILE WebSocket messages to the Gateway, which forwards them to the active adapter.

:feature:terminal โ€” Native PTY Terminal

The most advanced feature โ€” a full interactive terminal shell connected to the host machine via the encrypted WebSocket tunnel.

ComponentPurpose
TerminalScreenFull-screen Compose UI embedding TerminalView
TerminalViewModelManages PTY session lifecycle โ€” PtyStart, PtyInput, PtyResize, PtyOutput
TerminalViewNative Android View from the terminal-view module (Termux-based)
:terminal-emulatorJNI NDK library โ€” actual VT100/xterm terminal emulation in native code

How it works:

  1. TerminalViewModel sends PTY_START to the Gateway.
  2. Gateway spawns a PTY process on the host (/bin/bash).
  3. All keystrokes from TerminalView โ†’ PTY_INPUT โ†’ Gateway โ†’ PTY stdin.
  4. PTY stdout โ†’ Gateway โ†’ PTY_OUTPUT โ†’ TerminalView renders output.
  5. Pinch-to-zoom adjusts font size via TerminalViewClient.onScale().
  6. Extra keys bar provides Termux-style utility keys (ESC, TAB, CTRL, ALT, arrows, /, -).

Security: Biometric Authentication

Before the app establishes any WebSocket connection, it requires local biometric authentication:

Biometric auth flow (simplified)
val promptInfo = BiometricPrompt.PromptInfo.Builder()
.setTitle("Unlock Antimatter")
.setSubtitle("Verify your identity to connect to your agent")
.setAllowedAuthenticators(
BiometricManager.Authenticators.BIOMETRIC_STRONG
or BiometricManager.Authenticators.DEVICE_CREDENTIAL
)
.build()
biometricPrompt.authenticate(promptInfo)

Supported: Fingerprint, Face Unlock, PIN/Pattern fallback.


Building the App

  1. Open the android/ directory in Android Studio Koala or newer.
  2. Let Gradle sync and download dependencies.
  3. Select the app run configuration.
  4. Run on a connected device or emulator (API 26+).

Gradle Tasks Reference

TaskCommand
Lint./gradlew lintDebug
Unit tests./gradlew testDebugUnitTest
Build debug APK./gradlew assembleDebug
Install debug./gradlew installDebug
Build release APK./gradlew assembleRelease

Tech Stack Summary

CategoryLibrary / ToolVersion
LanguageKotlin2.0+
UIJetpack Compose + Material 3Latest
DIHilt2.51+
NetworkingOkHttp4.x
PersistenceRoom + DataStoreLatest
TerminalTermux terminal-emulator (NDK)Fork
CameraCameraXLatest
BiometricsAndroidX BiometricLatest
BuildGradle (Kotlin DSL)8.x

Saif Mukhtar

Saif Mukhtar

Creator & Lead Developer of Antimatter ยท Android, iOS & Python engineer