# qingyang-520/qingyangai-agent architecture

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

- Interactive diagram: https://gitdiagram.com/qingyang-520/qingyangai-agent
- Repository: https://github.com/qingyang-520/qingyangai-agent

## Overview

QingYangAI-Agent is a native MAUI AI companion, centered on a user chat with an OpenAI-compatible model and optional client-side actions. Its principal workflow combines model replies with perception, tools, and locally stored conversation state; separate branches provide image generation and scheduled proactive care. The graph preserves documented capabilities even where implementation files were not sampled. Some UI-to-service wiring and unsampled subsystems are therefore omitted rather than inferred.

Main entry points: [`AgentActionExecutor.cs`](https://github.com/qingyang-520/qingyangai-agent/blob/main/AgentActionExecutor.cs) (Action executor), [`DeviceContextService.cs`](https://github.com/qingyang-520/qingyangai-agent/blob/main/DeviceContextService.cs) (Device context), [`Platforms/Android/CareReceiver.cs`](https://github.com/qingyang-520/qingyangai-agent/blob/main/Platforms/Android/CareReceiver.cs) (Care scheduler), [`ChatPage.xaml.cs`](https://github.com/qingyang-520/qingyangai-agent/blob/main/ChatPage.xaml.cs) (Chat interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversation["Chat and agent"]
  node_chat["Chat interface<br/>[ChatPage.xaml.cs]"]
  node_agent["Agent loop"]
  node_parser["Instruction parser"]
  node_executor["Action executor"]
end

subgraph group_perception["Device perception"]
  node_registry["Perception API registry<br/>[ApiRegistry.cs]"]
  node_device["Device context"]
  node_usage["Usage stats"]
  node_notifications["Notification capture"]
  node_accessibility["Accessibility capture"]
  node_calendar["Calendar access<br/>[CalendarHelper.cs]"]
end

subgraph group_care["Proactive companion"]
  node_carewatch["Background observation<br/>[CareWatch.cs]"]
  node_caretimer["Care scheduler<br/>[CareReceiver.cs]"]
  node_innerlife["Inner life and heartbeat"]
  node_caremessage["Care notification"]
end

subgraph group_tools["Actions and media"]
  node_fileguard["File access controls<br/>[FileGuard.cs]"]
  node_filetool["File operations<br/>[FileTool.cs]"]
  node_browser["Browser and web<br/>[BrowserTool.cs]"]
  node_shizuku["Command execution<br/>[ShizukuRunner.cs]"]
  node_images["Image generation<br/>[ImageGenService.cs]"]
end

subgraph group_state["Local state"]
  node_settings["App settings<br/>[AppSettings.cs]"]
  node_store[("Chat and domain store<br/>[ChatStore.cs]")]
end

node_user(("User"))
node_model{{"Configured model API"}}

node_user -->|"chats with"| node_chat
node_agent -->|"requests completion"| node_model
node_executor -->|"uses"| node_filetool
node_executor -->|"runs commands"| node_shizuku
node_executor -->|"executes perception"| node_registry
node_executor -->|"uses"| node_browser
node_executor -.->|"checks access"| node_fileguard
node_agent -->|"parses actions"| node_parser
node_registry -->|"dispatches"| node_device
node_device -->|"reads usage"| node_usage
node_device -->|"reads notices"| node_notifications
node_device -->|"checks service"| node_accessibility
node_device -->|"reads calendar"| node_calendar
node_caretimer -->|"observes periodically"| node_carewatch
node_caretimer -->|"requests heartbeat"| node_innerlife
node_caretimer -->|"reads and writes"| node_store
node_caretimer -->|"shows message"| node_caremessage
node_innerlife -->|"executes APIs"| node_registry
node_innerlife -->|"reads conversation"| node_store
node_carewatch -->|"uses perception"| node_registry
node_settings -.->|"configures persistence"| node_store
node_images -->|"generates images"| node_model
node_chat -.->|"starts agent mode"| node_agent
node_chat -.->|"persists conversation"| node_store
node_chat -.->|"requests generation"| node_images

click node_chat "https://github.com/qingyang-520/qingyangai-agent/blob/main/ChatPage.xaml.cs"
click node_agent "https://github.com/qingyang-520/qingyangai-agent/blob/main/AgentLoopService.cs"
click node_parser "https://github.com/qingyang-520/qingyangai-agent/blob/main/InstructionParser.cs"
click node_executor "https://github.com/qingyang-520/qingyangai-agent/blob/main/AgentActionExecutor.cs"
click node_registry "https://github.com/qingyang-520/qingyangai-agent/blob/main/ApiRegistry.cs"
click node_device "https://github.com/qingyang-520/qingyangai-agent/blob/main/DeviceContextService.cs"
click node_usage "https://github.com/qingyang-520/qingyangai-agent/blob/main/Platforms/Android/UsageStatsHelper.cs"
click node_notifications "https://github.com/qingyang-520/qingyangai-agent/blob/main/Platforms/Android/CareNotificationListener.cs"
click node_accessibility "https://github.com/qingyang-520/qingyangai-agent/blob/main/Platforms/Android/QyAccessibilityService.cs"
click node_calendar "https://github.com/qingyang-520/qingyangai-agent/blob/main/Platforms/Android/CalendarHelper.cs"
click node_carewatch "https://github.com/qingyang-520/qingyangai-agent/blob/main/CareWatch.cs"
click node_caretimer "https://github.com/qingyang-520/qingyangai-agent/blob/main/Platforms/Android/CareReceiver.cs"
click node_innerlife "https://github.com/qingyang-520/qingyangai-agent/blob/main/InnerLifeService.cs"
click node_caremessage "https://github.com/qingyang-520/qingyangai-agent/blob/main/Platforms/Android/CareNotification.cs"
click node_fileguard "https://github.com/qingyang-520/qingyangai-agent/blob/main/FileGuard.cs"
click node_filetool "https://github.com/qingyang-520/qingyangai-agent/blob/main/FileTool.cs"
click node_browser "https://github.com/qingyang-520/qingyangai-agent/blob/main/BrowserTool.cs"
click node_shizuku "https://github.com/qingyang-520/qingyangai-agent/blob/main/ShizukuRunner.cs"
click node_images "https://github.com/qingyang-520/qingyangai-agent/blob/main/ImageGenService.cs"
click node_settings "https://github.com/qingyang-520/qingyangai-agent/blob/main/AppSettings.cs"
click node_store "https://github.com/qingyang-520/qingyangai-agent/blob/main/ChatStore.cs"

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_chat,node_agent,node_parser,node_executor,node_user toneBlue
class node_registry,node_device,node_usage,node_notifications,node_accessibility,node_calendar toneAmber
class node_carewatch,node_caretimer,node_innerlife,node_caremessage,node_model toneMint
class node_fileguard,node_filetool,node_browser,node_shizuku,node_images toneRose
class node_settings,node_store toneIndigo
```

## Components

### Chat and agent

- [Chat interface](https://github.com/qingyang-520/qingyangai-agent/blob/main/ChatPage.xaml.cs): `ChatPage.xaml.cs`
- [Agent loop](https://github.com/qingyang-520/qingyangai-agent/blob/main/AgentLoopService.cs): `AgentLoopService.cs`
- [Instruction parser](https://github.com/qingyang-520/qingyangai-agent/blob/main/InstructionParser.cs): `InstructionParser.cs`
- [Action executor](https://github.com/qingyang-520/qingyangai-agent/blob/main/AgentActionExecutor.cs): `AgentActionExecutor.cs`

### Device perception

- [Perception API registry](https://github.com/qingyang-520/qingyangai-agent/blob/main/ApiRegistry.cs): `ApiRegistry.cs`
- [Device context](https://github.com/qingyang-520/qingyangai-agent/blob/main/DeviceContextService.cs): `DeviceContextService.cs`
- [Usage stats](https://github.com/qingyang-520/qingyangai-agent/blob/main/Platforms/Android/UsageStatsHelper.cs): `Platforms/Android/UsageStatsHelper.cs`
- [Notification capture](https://github.com/qingyang-520/qingyangai-agent/blob/main/Platforms/Android/CareNotificationListener.cs): `Platforms/Android/CareNotificationListener.cs`
- [Accessibility capture](https://github.com/qingyang-520/qingyangai-agent/blob/main/Platforms/Android/QyAccessibilityService.cs): `Platforms/Android/QyAccessibilityService.cs`
- [Calendar access](https://github.com/qingyang-520/qingyangai-agent/blob/main/Platforms/Android/CalendarHelper.cs): `Platforms/Android/CalendarHelper.cs`

### Proactive companion

- [Background observation](https://github.com/qingyang-520/qingyangai-agent/blob/main/CareWatch.cs): `CareWatch.cs`
- [Care scheduler](https://github.com/qingyang-520/qingyangai-agent/blob/main/Platforms/Android/CareReceiver.cs): `Platforms/Android/CareReceiver.cs`
- [Inner life and heartbeat](https://github.com/qingyang-520/qingyangai-agent/blob/main/InnerLifeService.cs): `InnerLifeService.cs`
- [Care notification](https://github.com/qingyang-520/qingyangai-agent/blob/main/Platforms/Android/CareNotification.cs): `Platforms/Android/CareNotification.cs`

### Actions and media

- [File access controls](https://github.com/qingyang-520/qingyangai-agent/blob/main/FileGuard.cs): `FileGuard.cs`
- [File operations](https://github.com/qingyang-520/qingyangai-agent/blob/main/FileTool.cs): `FileTool.cs`
- [Browser and web](https://github.com/qingyang-520/qingyangai-agent/blob/main/BrowserTool.cs): `BrowserTool.cs`
- [Command execution](https://github.com/qingyang-520/qingyangai-agent/blob/main/ShizukuRunner.cs): `ShizukuRunner.cs`
- [Image generation](https://github.com/qingyang-520/qingyangai-agent/blob/main/ImageGenService.cs): `ImageGenService.cs`

### Local state

- [App settings](https://github.com/qingyang-520/qingyangai-agent/blob/main/AppSettings.cs): `AppSettings.cs`
- [Chat and domain store](https://github.com/qingyang-520/qingyangai-agent/blob/main/ChatStore.cs): `ChatStore.cs`

### Other components

- **User**
- **Configured model API**

## Connections

- User → Chat interface: chats with
- Agent loop → Configured model API: requests completion (evidence: `AgentLoopService.cs`)
- Action executor → File operations: uses (evidence: `AgentActionExecutor.cs`)
- Action executor → Command execution: runs commands (evidence: `AgentActionExecutor.cs`)
- Action executor → Perception API registry: executes perception (evidence: `AgentActionExecutor.cs`)
- Action executor → Browser and web: uses (evidence: `AgentActionExecutor.cs`)
- Action executor → File access controls: checks access
- Agent loop → Instruction parser: parses actions (evidence: `AgentLoopService.cs`)
- Perception API registry → Device context: dispatches (evidence: `ApiRegistry.cs`)
- Device context → Usage stats: reads usage (evidence: `DeviceContextService.cs`)
- Device context → Notification capture: reads notices (evidence: `DeviceContextService.cs`)
- Device context → Accessibility capture: checks service (evidence: `DeviceContextService.cs`)
- Device context → Calendar access: reads calendar (evidence: `DeviceContextService.cs`)
- Care scheduler → Background observation: observes periodically (evidence: `Platforms/Android/CareReceiver.cs`)
- Care scheduler → Inner life and heartbeat: requests heartbeat (evidence: `Platforms/Android/CareReceiver.cs`)
- Care scheduler → Chat and domain store: reads and writes (evidence: `Platforms/Android/CareReceiver.cs`)
- Care scheduler → Care notification: shows message (evidence: `Platforms/Android/CareReceiver.cs`)
- Inner life and heartbeat → Perception API registry: executes APIs (evidence: `InnerLifeService.cs`)
- Inner life and heartbeat → Chat and domain store: reads conversation (evidence: `InnerLifeService.cs`)
- Background observation → Perception API registry: uses perception (evidence: `CareWatch.cs`)
- App settings → Chat and domain store: configures persistence
- Image generation → Configured model API: generates images
- Chat interface → Agent loop: starts agent mode
- Chat interface → Chat and domain store: persists conversation
- Chat interface → Image generation: requests generation
