# mega7306626007/mwesh architecture

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

- Interactive diagram: https://gitdiagram.com/mega7306626007/mwesh
- Repository: https://github.com/mega7306626007/mwesh

## Overview

Mweshimiwa is an offline-first Android conversational assistant with voice input, a deterministic command capability, and an on-device generative model. The principal workflow is user/voice input → conversation handling and context assembly → model generation → displayed response. Other documented branches include personality, memory, conversation search, command handlers, settings, and developer diagnostics. Source excerpts establish the conversation and inference flow; several UI, command, and persistence connections are supported only by imports or README descriptions, so uncertain links are dashed or omitted.

Main entry points: [`app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt`](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt) (App navigation), [`app/src/main/java/com/mweshimiwa/assistant/ui/conversation/ConversationViewModel.kt`](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ui/conversation/ConversationViewModel.kt) (Conversation ViewModel), [`app/src/main/java/com/mweshimiwa/assistant/conversation/chat/ConversationManager.kt`](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/conversation/chat/ConversationManager.kt) (Conversation manager), [`app/src/main/java/com/mweshimiwa/assistant/data/database/MweshimiwaDatabase.kt`](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/data/database/MweshimiwaDatabase.kt) (Room database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Android app"]
  node_main["App navigation<br/>[MainActivity.kt]"]
  node_conversation_ui["Conversation UI"]
  node_viewmodel["Conversation ViewModel"]
  node_voice_in["Speech recognition"]
  node_voice_out["Text to speech<br/>[MweshimiwaTts.kt]"]
  node_developer["Developer diagnostics<br/>[DeveloperScreen.kt]"]
  node_settings["Settings<br/>[SettingsScreen.kt]"]
end

subgraph group_conversation["Conversation"]
  node_manager["Conversation manager"]
  node_search["Conversation search"]
end

subgraph group_intelligence["Assistant intelligence"]
  node_context["Context manager<br/>[ContextManager.kt]"]
  node_personality["Personality"]
  node_memory["Memory retrieval<br/>[MemoryRetriever.kt]"]
  node_inference["Inference engine"]
  node_onnx["ONNX backend<br/>[OnnxBackend.kt]"]
  node_request["Generation request"]
end

subgraph group_commands["Commands"]
  node_commands_executor["Command executor<br/>[CommandExecutor.kt]"]
  node_router["Command router<br/>[CommandRouter.kt]"]
  node_command_handlers["Command handlers"]
end

subgraph group_state["Local state"]
  node_database[("Room database")]
  node_conversation_repo["Conversation repository"]
  node_memory_repo["Memory repository"]
  node_preferences["Preferences"]
end

node_user(("User"))

node_user -->|"uses app"| node_main
node_main -->|"routes to"| node_conversation_ui
node_main -->|"routes to"| node_settings
node_main -->|"routes to"| node_developer
node_main -->|"creates"| node_viewmodel
node_main -->|"starts listening"| node_voice_in
node_main -->|"initializes"| node_voice_out
node_main -->|"observes theme"| node_preferences
node_conversation_ui -.->|"presents state"| node_viewmodel
node_viewmodel -.->|"delegates chat"| node_manager
node_viewmodel -->|"dispatches commands"| node_commands_executor
node_voice_in -->|"returns transcript"| node_viewmodel
node_manager -->|"builds context"| node_context
node_context -->|"builds prompt"| node_personality
node_manager -.->|"submits request"| node_request
node_manager -.->|"generates response"| node_inference
node_inference -.->|"delegates inference"| node_onnx
node_onnx -.->|"runs offline"| node_user
node_manager -.->|"uses retrieved context"| node_memory
node_commands_executor -.->|"routes intent"| node_router
node_router -.->|"dispatches command"| node_command_handlers
node_conversation_repo -->|"accesses records"| node_database
node_memory_repo -->|"accesses records"| node_database
node_search -.->|"searches messages"| node_database
node_memory -.->|"retrieves memories"| node_memory_repo
node_developer -->|"shows model status"| node_viewmodel

click node_main "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt"
click node_conversation_ui "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ui/conversation/ConversationScreen.kt"
click node_viewmodel "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ui/conversation/ConversationViewModel.kt"
click node_voice_in "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/voice/speech/SpeechRecognizer.kt"
click node_voice_out "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/voice/tts/MweshimiwaTts.kt"
click node_manager "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/conversation/chat/ConversationManager.kt"
click node_search "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/conversation/chat/ConversationSearchEngine.kt"
click node_context "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ai/context/ContextManager.kt"
click node_personality "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/conversation/personality/MweshimiwaPersonality.kt"
click node_memory "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ai/context/MemoryRetriever.kt"
click node_inference "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ai/inference/ModelInferenceEngine.kt"
click node_onnx "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ai/backend/OnnxBackend.kt"
click node_request "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ai/model/ConversationRequest.kt"
click node_commands_executor "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/commands/executor/CommandExecutor.kt"
click node_router "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/commands/router/CommandRouter.kt"
click node_command_handlers "https://github.com/mega7306626007/mwesh/tree/main/app/src/main/java/com/mweshimiwa/assistant/commands/handlers"
click node_database "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/data/database/MweshimiwaDatabase.kt"
click node_conversation_repo "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/data/repositories/ConversationRepository.kt"
click node_memory_repo "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/data/repositories/MemoryRepository.kt"
click node_preferences "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/data/preferences/MweshimiwaPreferences.kt"
click node_developer "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ui/developer/DeveloperScreen.kt"
click node_settings "https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ui/settings/SettingsScreen.kt"

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_main,node_conversation_ui,node_viewmodel,node_voice_in,node_voice_out,node_developer,node_settings,node_user toneBlue
class node_manager,node_search toneAmber
class node_context,node_personality,node_memory,node_inference,node_onnx,node_request toneMint
class node_commands_executor,node_router,node_command_handlers toneRose
class node_database,node_conversation_repo,node_memory_repo,node_preferences toneIndigo
```

## Components

### Android app

- [App navigation](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt): `app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt`
- [Conversation UI](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ui/conversation/ConversationScreen.kt): `app/src/main/java/com/mweshimiwa/assistant/ui/conversation/ConversationScreen.kt`
- [Conversation ViewModel](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ui/conversation/ConversationViewModel.kt): `app/src/main/java/com/mweshimiwa/assistant/ui/conversation/ConversationViewModel.kt`
- [Speech recognition](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/voice/speech/SpeechRecognizer.kt): `app/src/main/java/com/mweshimiwa/assistant/voice/speech/SpeechRecognizer.kt`
- [Text to speech](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/voice/tts/MweshimiwaTts.kt): `app/src/main/java/com/mweshimiwa/assistant/voice/tts/MweshimiwaTts.kt`
- [Developer diagnostics](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ui/developer/DeveloperScreen.kt): `app/src/main/java/com/mweshimiwa/assistant/ui/developer/DeveloperScreen.kt`
- [Settings](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ui/settings/SettingsScreen.kt): `app/src/main/java/com/mweshimiwa/assistant/ui/settings/SettingsScreen.kt`

### Conversation

- [Conversation manager](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/conversation/chat/ConversationManager.kt): `app/src/main/java/com/mweshimiwa/assistant/conversation/chat/ConversationManager.kt`
- [Conversation search](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/conversation/chat/ConversationSearchEngine.kt): `app/src/main/java/com/mweshimiwa/assistant/conversation/chat/ConversationSearchEngine.kt`

### Assistant intelligence

- [Context manager](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ai/context/ContextManager.kt): `app/src/main/java/com/mweshimiwa/assistant/ai/context/ContextManager.kt`
- [Personality](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/conversation/personality/MweshimiwaPersonality.kt): `app/src/main/java/com/mweshimiwa/assistant/conversation/personality/MweshimiwaPersonality.kt`
- [Memory retrieval](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ai/context/MemoryRetriever.kt): `app/src/main/java/com/mweshimiwa/assistant/ai/context/MemoryRetriever.kt`
- [Inference engine](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ai/inference/ModelInferenceEngine.kt): `app/src/main/java/com/mweshimiwa/assistant/ai/inference/ModelInferenceEngine.kt`
- [ONNX backend](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ai/backend/OnnxBackend.kt): `app/src/main/java/com/mweshimiwa/assistant/ai/backend/OnnxBackend.kt`
- [Generation request](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/ai/model/ConversationRequest.kt): `app/src/main/java/com/mweshimiwa/assistant/ai/model/ConversationRequest.kt`

### Commands

- [Command executor](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/commands/executor/CommandExecutor.kt): `app/src/main/java/com/mweshimiwa/assistant/commands/executor/CommandExecutor.kt`
- [Command router](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/commands/router/CommandRouter.kt): `app/src/main/java/com/mweshimiwa/assistant/commands/router/CommandRouter.kt`
- [Command handlers](https://github.com/mega7306626007/mwesh/tree/main/app/src/main/java/com/mweshimiwa/assistant/commands/handlers): `app/src/main/java/com/mweshimiwa/assistant/commands/handlers`

### Local state

- [Room database](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/data/database/MweshimiwaDatabase.kt): `app/src/main/java/com/mweshimiwa/assistant/data/database/MweshimiwaDatabase.kt`
- [Conversation repository](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/data/repositories/ConversationRepository.kt): `app/src/main/java/com/mweshimiwa/assistant/data/repositories/ConversationRepository.kt`
- [Memory repository](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/data/repositories/MemoryRepository.kt): `app/src/main/java/com/mweshimiwa/assistant/data/repositories/MemoryRepository.kt`
- [Preferences](https://github.com/mega7306626007/mwesh/blob/main/app/src/main/java/com/mweshimiwa/assistant/data/preferences/MweshimiwaPreferences.kt): `app/src/main/java/com/mweshimiwa/assistant/data/preferences/MweshimiwaPreferences.kt`

### Other components

- **User**

## Connections

- User → App navigation: uses app (evidence: `app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt`)
- App navigation → Conversation UI: routes to (evidence: `app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt`)
- App navigation → Settings: routes to (evidence: `app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt`)
- App navigation → Developer diagnostics: routes to (evidence: `app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt`)
- App navigation → Conversation ViewModel: creates (evidence: `app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt`)
- App navigation → Speech recognition: starts listening (evidence: `app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt`)
- App navigation → Text to speech: initializes (evidence: `app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt`)
- App navigation → Preferences: observes theme (evidence: `app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt`)
- Conversation UI → Conversation ViewModel: presents state (evidence: `app/src/main/java/com/mweshimiwa/assistant/ui/conversation/ConversationScreen.kt`)
- Conversation ViewModel → Conversation manager: delegates chat
- Conversation ViewModel → Command executor: dispatches commands
- Speech recognition → Conversation ViewModel: returns transcript (evidence: `app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt`)
- Conversation manager → Context manager: builds context (evidence: `app/src/main/java/com/mweshimiwa/assistant/conversation/chat/ConversationManager.kt`)
- Context manager → Personality: builds prompt (evidence: `app/src/main/java/com/mweshimiwa/assistant/ai/context/ContextManager.kt`)
- Conversation manager → Generation request: submits request
- Conversation manager → Inference engine: generates response
- Inference engine → ONNX backend: delegates inference
- ONNX backend → User: runs offline (evidence: `README.md`)
- Conversation manager → Memory retrieval: uses retrieved context
- Command executor → Command router: routes intent
- Command router → Command handlers: dispatches command
- Conversation repository → Room database: accesses records (evidence: `app/src/main/java/com/mweshimiwa/assistant/data/repositories/ConversationRepository.kt`)
- Memory repository → Room database: accesses records (evidence: `app/src/main/java/com/mweshimiwa/assistant/data/repositories/MemoryRepository.kt`)
- Conversation search → Room database: searches messages
- Memory retrieval → Memory repository: retrieves memories
- Developer diagnostics → Conversation ViewModel: shows model status (evidence: `app/src/main/java/com/mweshimiwa/assistant/MainActivity.kt`)
