How devapro/lanwalkietalkie works
1. What this repo is
- This is a multi-module Android app for local-network push-to-talk communication.
- It does not depend on a central backend: every app instance can both discover peers and communicate directly over Wi‑Fi LAN.
- The app uses Jetpack Compose for UI and an MVI-style state flow for screen logic.
2. Top-level module boundaries
- app is the Android application shell and entry point.
- core contains shared MVI infrastructure used by feature ViewModels.
- core-ui contains shared Compose theme/styling.
- service-network owns peer discovery and socket-based text/data transport.
- service-voice owns audio capture and playback.
- feature-ptt, feature-chat, and feature-settings are UI feature modules built on top of the shared core/services.
3. Application composition and startup
- PttApplication and MainActivity are the app entry points.
- appDi.kt wires the application graph.
- MainViewModel drives the main shell UI: it handles app initialization, permission checks, and active screen/tab selection.
- MainScreenInitStateFactory, MainTabsFactory, and the reducers under app/reducers define the shell state machine.
4. Shared architecture pattern
- The codebase is organized around MVI:
- Actions represent user intent or system requests.
- Reducers transform state in response to events.
- Action processors coordinate side effects and produce events.
- Init state factories build initial UI state.
- This pattern is implemented once in core/mvi and repeated in each feature module with feature-specific actions/events/state.
5. Core MVI layer
- MviViewModel, Reducer, ActionProcessor, InitStateFactory, and CoroutineContextProvider are the reusable framework pieces.
- Feature ViewModels inherit this infrastructure rather than duplicating coroutine/state handling.
- This is the main architectural boundary between UI intent and side effects.
6. Network subsystem: local discovery and message transport
- service-network is responsible for finding nearby devices and exchanging data over sockets.
- DiscoveryListener and RegistrationListener indicate the use of NsdManager for service discovery/registration on the local network.
- SocketServer and SocketClient represent the bidirectional transport layer.
- ChanelControllerImpl is the orchestration layer that likely coordinates channel lifecycle, peer connections, and routing.
- Repositories such as ConnectedDevicesRepository, DeviceInfoRepository, and TextMessagesRepository hold network-facing state/models.
- ClientInfoResolver and getDeviceID.kt support peer identity and device addressing.
7. Voice subsystem: recording and playback
- service-voice owns audio capture and audio output.
- VoiceRecorder uses recording APIs (MediaRecorder / AudioRecord per README intent) to capture push-to-talk audio.
- VoicePlayer uses AudioTrack-style playback to render incoming voice audio.
- VoiceDi.kt provides dependency wiring for the voice layer.
- This module is isolated so the PTT feature can depend on audio behavior without embedding low-level Android audio code.
8. Foreground/background service boundary
- WalkieService is the app’s runtime service boundary for long-lived communication.
- NotificationController manages the persistent foreground notification required for ongoing mic/network activity.
- This service layer is important because the app needs to keep audio and network operations alive while the UI is backgrounded.
9. PTT feature flow
- feature-ptt is the main push-to-talk screen.
- Its state is modeled by PttScreenState, with PttAction and PttEvent driving changes.
- Reducers such as StartRecordingReducer, StopRecordingReducer, and VoiceDataReceivedReducer connect user interaction and incoming network/audio events.
- ConnectedDevicesUpdatedReducer keeps the UI in sync with the current peer list.
- UI files like PTTContent, PTTContentPortrait, PTTContentLandscape, PTTButton, DeviceItem, and WaveCanvas suggest a responsive screen that adapts to orientation and shows live audio/device feedback.
10. Chat feature flow
- feature-chat is the text-message companion to PTT.
- It has its own MVI slice: ChatScreenState, ChatAction, ChatEvent, and ChatViewModel.
- Reducers cover initialization, loading history, sending, receiving, marking read, and device list updates.
- MessageModelMapper converts between network message models and UI models.
- ChatContent, ChatTab, InputSection, and MessageItem form the Compose UI for message history and input.
11. Main shell UI and navigation
- RootContent and OffContent in the app module are the top-level Compose containers.
- BottomTabs, RailTabs, TabsContent, and RequiredPermissionsNotification are shared shell UI elements.
- MainTab and MainTabItem model the app’s tab/navigation structure across PTT, chat, and settings.
- The UI is responsive: it switches between bottom navigation and rail navigation depending on layout/size.
12. Permissions and app readiness
- PermissionState and the permission-related reducers in the app module indicate that the app gates functionality on runtime permissions.
- Required permissions are part of the main shell state, not buried in each feature, so the app can globally block or warn before activating network/audio features.
- This is especially important because audio capture, foreground service behavior, and local discovery all depend on Android runtime permissions.
13. Settings feature
- feature-settings is lightweight and currently mostly a Compose content module.
- Architecturally it fits the same feature-module pattern, but it is less stateful than PTT/chat.
14. Shared UI/theme and platform config
- core-ui provides the app theme (Color.kt, Theme.kt, Type.kt) used by all Compose screens.
- The app module contains drawables, strings, themes, backup rules, and manifest configuration, while each feature module keeps its own manifest and resources.
- The repository also includes Android test and unit test scaffolding per module, plus a GitHub Actions workflow for APK build automation.
15. End-to-end data flow
- User interacts with a feature screen in Compose.
- UI emits an action into the feature ViewModel.
- The MVI processor/reducers update screen state and trigger side effects.
- Side effects call into service-network and/or service-voice.
- Network/audio services communicate with peer devices and feed events back into feature reducers.
- The updated state is rendered back through Compose, while the app shell keeps permissions, tabs, and service status coherent.
Main entry points: serivce-network service-network · mvi core/mvi · service-voice service-voice · MainViewModel.kt MainViewModel
Components 34
App Shell
Application entry point, shell UI, permissions, and service boundary.
- app · Android application shell and entry module.
app - PttApplication · Application class that boots the app graph.
app/src/main/java/pro/devapp/walkietalkiek/PttApplication.kt - MainActivity · Primary activity hosting the Compose shell.
app/src/main/java/pro/devapp/walkietalkiek/MainActivity.kt - MainViewModel · Drives initialization, permissions, and active tab selection.
app/src/main/java/pro/devapp/walkietalkiek/MainViewModel.kt - Main state · Main screen action, event, and state model.
app/src/main/java/pro/devapp/walkietalkiek/model - Shell factories · Initial state and tab construction for the shell.
app/src/main/java/pro/devapp/walkietalkiek/factory - Shell reducers · App startup, permission checks, and screen switching reducers.
app/src/main/java/pro/devapp/walkietalkiek/reducers - RootContent · Top-level Compose container for the app shell.
app/src/main/java/pro/devapp/walkietalkiek/ui/RootContent.kt - Shell UI · Bottom tabs, rail tabs, tab content, and permission notice.
app/src/main/java/pro/devapp/walkietalkiek/ui/components - WalkieService · Long-lived service boundary for network and audio activity.
app/src/main/java/pro/devapp/walkietalkiek/service/WalkieService.kt - NotificationController · Manages the persistent foreground notification.
app/src/main/java/pro/devapp/walkietalkiek/service/NotificationController.kt
Shared Core
Reusable MVI infrastructure and shared Compose theme.
- core/mvi · Reusable ViewModel, reducer, processor, and init-state abstractions.
core/src/main/java/pro/devapp/walkietalkiek/core/mvi - MviViewModel · Shared MVI ViewModel base used by features.
core/src/main/java/pro/devapp/walkietalkiek/core/mvi/MviViewModel.kt - Reducer · Reducer contract for state transitions.
core/src/main/java/pro/devapp/walkietalkiek/core/mvi/Reducer.kt - ActionProcessor · Coordinates actions, side effects, and emitted events.
core/src/main/java/pro/devapp/walkietalkiek/core/mvi/ActionProcessor.kt - InitStateFactory · Creates initial UI state for screens.
core/src/main/java/pro/devapp/walkietalkiek/core/mvi/InitStateFactory.kt - core-ui theme · Shared color, typography, and theme definitions.
core-ui/src/main/java/pro/devapp/walkietalkiek/core/theme
Network Service
Local discovery, sockets, and network-facing state.
- service-network · Peer discovery and socket transport for local LAN communication.
serivce-network - Channel controller · Coordinates channel lifecycle and peer routing.
serivce-network/src/main/java/pro/devapp/walkietalkiek/serivce/network/ChanelControllerImpl.kt - NSD listeners · Service discovery and registration listeners.
serivce-network/src/main/java/pro/devapp/walkietalkiek/serivce/network - Socket transport · Client and server socket endpoints for bidirectional exchange.
serivce-network/src/main/java/pro/devapp/walkietalkiek/serivce/network/SocketClient.kt - Network state · Connected devices, device info, and message repositories.
serivce-network/src/main/java/pro/devapp/walkietalkiek/serivce/network/data - Device identity · Device ID and client info resolution helpers.
serivce-network/src/main/java/pro/devapp/walkietalkiek/serivce/network/getDeviceID.kt
Voice Service
Audio capture and playback for push-to-talk.
- service-voice · Audio recording and playback layer for PTT.
service-voice - VoiceRecorder · Captures microphone input for push-to-talk.
service-voice/src/main/java/pro/devapp/walkietalkiek/service/voice/VoiceRecorder.kt - VoicePlayer · Plays received voice audio to the speaker.
service-voice/src/main/java/pro/devapp/walkietalkiek/service/voice/VoicePlayer.kt - VoiceDi · Dependency wiring for the voice layer.
service-voice/src/main/java/pro/devapp/walkietalkiek/service/voice/di/VoiceDi.kt
PTT Feature
Main push-to-talk screen and voice interaction flow.
- feature-ptt · Primary push-to-talk UI and interaction state machine.
feature-ptt - PttViewModel · Feature ViewModel for push-to-talk state.
feature-ptt/src/main/java/pro/devapp/walkietalkiek/feature/ptt/PttViewModel.kt - PttActionProcessor · Coordinates PTT actions and side effects.
feature-ptt/src/main/java/pro/devapp/walkietalkiek/feature/ptt/PttActionProcessor.kt - PTT state · PTT actions, events, and screen state.
feature-ptt/src/main/java/pro/devapp/walkietalkiek/feature/ptt/model - PTT reducers · Recording, voice reception, and device list reducers.
feature-ptt/src/main/java/pro/devapp/walkietalkiek/feature/ptt/reducer - PTT UI · Responsive PTT layout, button, device list, and wave visualizer.
feature-ptt/src/main/java/pro/devapp/walkietalkiek/feature/ptt/ui
Chat Feature
Text messaging companion screen and message flow.
- feature-chat · Text chat companion UI and message flow.
feature-chat
Connections 39
- app → PttApplication: starts · Android runtime creates the application instance.
- app → MainActivity: hosts · Application module provides the main activity.
- MainActivity → RootContent: renders · Activity hosts the top-level Compose shell.
- PttApplication → MainViewModel: injects · Application wiring provides the shell ViewModel dependencies.
- MainViewModel → Main state: manages · ViewModel owns shell state and events.
- MainViewModel → Shell factories: initializes · Builds initial screen state and tabs.
- MainViewModel → Shell reducers: delegates · Uses reducers for startup and permission transitions.
- MainViewModel → core/mvi: extends · Shell ViewModel relies on shared MVI infrastructure.
- Shell reducers → WalkieService: controls · Reducers trigger service startup and readiness changes.
- RootContent → Shell UI: composes · Root content assembles shell navigation and notices.
- Shell UI → feature-ptt: switches to · Shell routes to the PTT feature tab.
- Shell UI → feature-chat: switches to · Shell routes to the chat feature tab.
- Shell UI → core-ui theme: styles with · Shared shell UI uses common theme definitions.
- WalkieService → NotificationController: uses · Foreground service relies on persistent notification management.
- WalkieService → service-network: coordinates · Service boundary keeps LAN transport alive.
- WalkieService → service-voice: coordinates · Service boundary keeps audio capture/playback alive.
- core/mvi → MviViewModel: provides · Reusable base ViewModel implementation.
- core/mvi → Reducer: provides · Shared reducer contract.
- core/mvi → ActionProcessor: provides · Shared action processor contract.
- core/mvi → InitStateFactory: provides · Shared initial state factory contract.
- service-network → Channel controller: orchestrates · Controller coordinates discovery and peer routing.
- service-network → NSD listeners: discovers · Uses NSD listeners for local service discovery.
- service-network → Socket transport: transports · Uses socket client/server for data exchange.
- service-network → Network state: stores · Repositories hold connected device and message state.
- service-network → Device identity: identifies · Helpers resolve peer and device identity.
- service-voice → VoiceRecorder: captures · Records microphone audio.
- service-voice → VoicePlayer: plays · Renders incoming audio.
- service-voice → VoiceDi: wires · Dependency graph for audio services.
- feature-ptt → PttViewModel: contains · Feature module exposes its ViewModel.
- PttViewModel → PttActionProcessor: uses · Feature ViewModel delegates side effects.
- PttViewModel → PTT state: owns · ViewModel manages PTT actions, events, and state.
- PttViewModel → core/mvi: extends · PTT ViewModel uses shared MVI base classes.
- PttActionProcessor → service-voice: calls · Action processing starts and stops audio capture.
- PttActionProcessor → service-network: calls · Action processing sends and receives LAN voice data.
- PttActionProcessor → PTT reducers: emits · Side effects feed reducers with events.
- PTT reducers → service-voice: consumes · Reducers react to recorded and received voice data.
- PTT reducers → service-network: consumes · Reducers react to connected device updates.
- PTT UI → PttViewModel: binds to · Compose UI observes PTT ViewModel state.
- PTT UI → core-ui theme: styles with · PTT screen uses shared theme.