A sophisticated Android application built with strict modular architecture to demonstrate clean separation of concerns, scalability, and maintainability.
DesktopBot is an intelligent Android application that integrates multiple technologies:
- π· Camera - Real-time frame capture
- π€ Machine Learning - Face detection and head movement tracking
- π§ Large Language Model - Decision-making and command generation
- π‘ Bluetooth - BLE communication with external devices
- π Facial Expressions - Emotion display based on AI decisions
- π¨ User Interface - Interactive controls and status updates
This project follows a strictly enforced modular architecture where:
- Each module has a single, well-defined responsibility
- All inter-module communication flows through the AppCoordinator
- Direct module-to-module access is prohibited
- Each module owns its hardware, permissions, and domain logic
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β APP MODULE β
β (AppCoordinator) β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Data Flows β β
β β β β
β β Camera β ML β LLM β Face β β
β β Bluetooth β LLM β β
β β UI β All Modules β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Module | Responsibility |
|---|---|
| app | Entry point, coordination, module initialization |
| bluetooth | BLE operations, scanning, pairing, data transfer |
| camera | Camera access, frame capture, camera permissions |
| ml | ML models, face detection, head movement analysis |
| llm | LLM processing, decision logic, command generation |
| face | Facial expression display, emotion rendering |
| ui | User interface, user interactions, status display |
- Android Studio: Arctic Fox or newer
- Minimum SDK: 28 (Android 9.0)
- Target SDK: 36
- Kotlin: 2.0.21
- Gradle: 8.13.2+
git clone https://github.com/yourusername/desktopbot.git
cd desktopbot- Open Android Studio
- Select "Open an Existing Project"
- Navigate to the
desktopbotfolder - Wait for Gradle sync to complete
./gradlew buildOr use Android Studio's build menu.
- Connect an Android device or start an emulator
- Click the "Run" button in Android Studio
- Grant necessary permissions when prompted
The app requires the following permissions:
- Camera - For real-time frame capture
- Bluetooth - For BLE device communication
- Location (Android < 12) - Required for BLE scanning
Permissions are handled within their respective modules:
- Camera permissions β
cameramodule - Bluetooth permissions β
bluetoothmodule
- ARCHITECTURE.md - Complete architecture documentation
- QUICK_REFERENCE.md - Quick reference guide for developers
- NO direct module-to-module communication
- ALL communication goes through AppCoordinator
- Each module owns its hardware/permissions
- No architecture breaks without approval
Camera β ML β LLM β Face
Bluetooth β LLM
UI β AppCoordinator β All Modules
desktopbot/
βββ app/ # Main entry module
β βββ src/main/java/com/ad/desktopbot/
β βββ MainActivity.kt # Entry point
β βββ core/
β βββ ModuleInterfaces.kt # All interfaces & data models
β βββ AppCoordinator.kt # Central orchestrator
β
βββ bluetooth/ # Bluetooth module
β βββ src/main/java/com/ad/bluetooth/
β βββ BluetoothRepository.kt
β βββ BluetoothControllerImpl.kt
β
βββ camera/ # Camera module
β βββ src/main/java/com/ad/camera/
β βββ CameraRepository.kt
β βββ CameraControllerImpl.kt
β
βββ ml/ # ML module
β βββ src/main/java/com/ad/ml/
β βββ MLRepository.kt
β βββ MLControllerImpl.kt
β
βββ llm/ # LLM module
β βββ src/main/java/com/ad/llm/
β βββ LLMRepository.kt
β βββ LLMControllerImpl.kt
β
βββ face/ # Face expression module
β βββ src/main/java/com/ad/face/
β βββ FaceRepository.kt
β βββ FaceControllerImpl.kt
β
βββ ui/ # UI module
βββ src/main/java/com/ad/ui/
βββ UIRepository.kt
βββ UIControllerImpl.kt
- Contains the AppCoordinator - the only component that orchestrates module communication
- Defines all module interfaces and data models
- Initializes all modules in
MainActivity
- Manages BLE scanning, connection, and data transfer
- Receives data from Bluetooth devices β sends to LLM
- Receives JSON commands from LLM β transmits to devices
- Handles all Bluetooth permissions
- Manages camera lifecycle and frame capture
- Uses CameraX for modern camera API
- Sends frames to ML module for processing
- Handles camera permissions
- Loads and runs ML models
- Performs face detection and head movement analysis
- Sends results to LLM module
- TODO: Integrate actual ML models (TensorFlow Lite, ML Kit)
- Acts as the "brain" of the application
- Processes data from ML and Bluetooth modules
- Generates JSON commands for Bluetooth devices
- Generates emotion data for Face module
- TODO: Integrate actual LLM model
- Displays facial expressions based on LLM emotion data
- TODO: Implement actual emotion rendering (UI animations, physical servos)
- Manages all user interface elements
- Displays status updates and results
- Forwards user actions to other modules via AppCoordinator
- Identify the owning module - Which module should handle this?
- Update the interface - Add method to the controller interface in
ModuleInterfaces.kt - Implement in repository - Add implementation in the module's repository
- Update controller - Update the controller implementation
- Update AppCoordinator - If data flow changes are needed
If a new feature doesn't fit the existing architecture:
-
Create a proposal with:
- Reason for breaking existing architecture
- Proposed module name and responsibilities
- Communication requirements
- Why existing modules can't handle it
-
Get approval before implementing
Each module can be tested independently:
./gradlew test./gradlew connectedAndroidTest- Unit test each module's repository independently
- Mock callbacks for testing
- Integration test data flows through AppCoordinator
- UI test user interactions
- Look at AppCoordinator callbacks
- Verify module controller implementations
- Check callback setup in
setupDataFlows() - Check logcat with module TAGs:
AppCoordinatorBluetoothRepositoryCameraRepositoryMLRepositoryLLMRepositoryFaceRepositoryUIRepository
- AndroidX Core KTX
- AndroidX AppCompat
- Material Design Components
- AndroidX Activity
- AndroidX ConstraintLayout
- Camera: CameraX (Core, Camera2, Lifecycle, View)
- ML: TODO - TensorFlow Lite or ML Kit
- LLM: TODO - LLM integration
- Integrate actual ML models (TensorFlow Lite)
- Integrate actual LLM model
- Implement physical facial expression rendering
- Add voice recognition (new
audiomodule) - Add cloud synchronization
- Add comprehensive unit tests
- Add UI tests
- Add performance monitoring
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Follow the architecture rules
- Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Note: All contributions must follow the modular architecture. Any architecture-breaking changes require approval.
This project is licensed under the MIT License - see the LICENSE file for details.
- Your Name - Initial work
- Android Architecture Components
- CameraX
- Kotlin Coroutines
- Material Design
For questions or issues:
- Open an issue on GitHub
- Check the ARCHITECTURE.md documentation
- Refer to QUICK_REFERENCE.md
Remember: This architecture exists to keep the codebase clean, maintainable, and scalable. Follow the rules! π