# bifangknt/mtga architecture

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

- Interactive diagram: https://gitdiagram.com/bifangknt/mtga
- Repository: https://github.com/bifangknt/mtga

## Overview

MTGA is a Windows/macOS desktop app that exposes a local OpenAI Chat Completions-compatible proxy for IDEs and forwards requests to configured model providers. The main workflow is IDE request → local proxy → provider-specific execution → response; users configure targets and start the services in the GUI. The README documents the UI/actions/services/domain layering and startup certificate and hosts operations. Several backend subsystems are represented from documented capabilities and indexed modules; their internal call wiring was not sampled, so uncertain links are omitted.

Main entry points: [`python-src/mtga_app/commands`](https://github.com/bifangknt/mtga/tree/tauri/python-src/mtga_app/commands) (Application commands), [`python-src/modules/services/proxy_orchestration.py`](https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/services/proxy_orchestration.py) (Proxy orchestration), [`python-src/modules/actions`](https://github.com/bifangknt/mtga/tree/tauri/python-src/modules/actions) (Action handlers), [`app/components`](https://github.com/bifangknt/mtga/tree/tauri/app/components) (GUI panels)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Desktop interface"]
  node_ui["GUI panels"]
  node_store["Frontend state<br/>[useMtgaStore.ts]"]
  node_api["Tauri API bridge<br/>[useMtgaApi.ts]"]
end

subgraph group_bridge["Command orchestration"]
  node_commands["Application commands"]
  node_actions["Action handlers"]
end

subgraph group_proxy["Model proxy"]
  node_config["Configuration<br/>[config_service.py]"]
  node_proxy_orch["Proxy orchestration"]
  node_proxy_server["Proxy server<br/>[proxy_server.py]"]
  node_routing["Model routing<br/>[model_routing.py]"]
  node_upstream["Upstream adapter"]
  node_mlitellm["Provider execution"]
end

subgraph group_system["Local services"]
  node_cert["Certificate management"]
  node_hosts["Hosts management<br/>[hosts_manager.py]"]
  node_system_prompt["System prompts"]
  node_updates["Update checks<br/>[update_service.py]"]
end

subgraph group_runtime["Runtime foundations"]
  node_resources[("User data and resources")]
  node_platform["Platform privileges<br/>[privileges.py]"]
end

node_user(("MTGA user"))
node_ide(("Trae IDE"))
node_provider(("Model provider"))

node_user -->|"configures and starts"| node_ui
node_ui -.->|"uses state"| node_store
node_store -->|"invokes commands"| node_api
node_api -.->|"dispatches commands"| node_commands
node_commands -.->|"routes operations"| node_actions
node_actions -->|"uses services"| node_config
node_actions -->|"uses services"| node_proxy_orch
node_commands -->|"starts proxy"| node_proxy_orch
node_ide -->|"sends API requests"| node_proxy_server
node_proxy_server -.->|"routes requests"| node_routing
node_routing -.->|"selects upstream"| node_upstream
node_upstream -->|"executes provider call"| node_mlitellm
node_mlitellm -->|"forwards request"| node_provider
node_proxy_orch -->|"prepares certificate"| node_cert
node_proxy_orch -->|"updates hosts"| node_hosts
node_commands -.->|"manages prompts"| node_system_prompt
node_commands -.->|"checks updates"| node_updates
node_cert -->|"uses resource paths"| node_resources
node_hosts -->|"uses privileges"| node_platform

click node_ui "https://github.com/bifangknt/mtga/tree/tauri/app/components"
click node_store "https://github.com/bifangknt/mtga/blob/tauri/app/composables/useMtgaStore.ts"
click node_api "https://github.com/bifangknt/mtga/blob/tauri/app/composables/useMtgaApi.ts"
click node_commands "https://github.com/bifangknt/mtga/tree/tauri/python-src/mtga_app/commands"
click node_actions "https://github.com/bifangknt/mtga/tree/tauri/python-src/modules/actions"
click node_config "https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/services/config_service.py"
click node_proxy_orch "https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/services/proxy_orchestration.py"
click node_proxy_server "https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/proxy/proxy_server.py"
click node_routing "https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/proxy/model_routing.py"
click node_upstream "https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/proxy/upstream_adapter.py"
click node_mlitellm "https://github.com/bifangknt/mtga/tree/tauri/python-src/modules/mlitellm"
click node_cert "https://github.com/bifangknt/mtga/tree/tauri/python-src/modules/cert"
click node_hosts "https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/hosts/hosts_manager.py"
click node_system_prompt "https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/services/system_prompt_service.py"
click node_updates "https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/services/update_service.py"
click node_resources "https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/runtime/resource_manager.py"
click node_platform "https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/platform/privileges.py"

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_ui,node_store,node_api,node_user toneBlue
class node_commands,node_actions toneAmber
class node_config,node_proxy_orch,node_proxy_server,node_routing,node_upstream,node_mlitellm toneMint
class node_cert,node_hosts,node_system_prompt,node_updates toneRose
class node_resources,node_platform,node_ide,node_provider toneIndigo
```

## Components

### Desktop interface

- [GUI panels](https://github.com/bifangknt/mtga/tree/tauri/app/components): `app/components`
- [Frontend state](https://github.com/bifangknt/mtga/blob/tauri/app/composables/useMtgaStore.ts): `app/composables/useMtgaStore.ts`
- [Tauri API bridge](https://github.com/bifangknt/mtga/blob/tauri/app/composables/useMtgaApi.ts): `app/composables/useMtgaApi.ts`

### Command orchestration

- [Application commands](https://github.com/bifangknt/mtga/tree/tauri/python-src/mtga_app/commands): `python-src/mtga_app/commands`
- [Action handlers](https://github.com/bifangknt/mtga/tree/tauri/python-src/modules/actions): `python-src/modules/actions`

### Model proxy

- [Configuration](https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/services/config_service.py): `python-src/modules/services/config_service.py`
- [Proxy orchestration](https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/services/proxy_orchestration.py): `python-src/modules/services/proxy_orchestration.py`
- [Proxy server](https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/proxy/proxy_server.py): `python-src/modules/proxy/proxy_server.py`
- [Model routing](https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/proxy/model_routing.py): `python-src/modules/proxy/model_routing.py`
- [Upstream adapter](https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/proxy/upstream_adapter.py): `python-src/modules/proxy/upstream_adapter.py`
- [Provider execution](https://github.com/bifangknt/mtga/tree/tauri/python-src/modules/mlitellm): `python-src/modules/mlitellm`

### Local services

- [Certificate management](https://github.com/bifangknt/mtga/tree/tauri/python-src/modules/cert): `python-src/modules/cert`
- [Hosts management](https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/hosts/hosts_manager.py): `python-src/modules/hosts/hosts_manager.py`
- [System prompts](https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/services/system_prompt_service.py): `python-src/modules/services/system_prompt_service.py`
- [Update checks](https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/services/update_service.py): `python-src/modules/services/update_service.py`

### Runtime foundations

- [User data and resources](https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/runtime/resource_manager.py): `python-src/modules/runtime/resource_manager.py`
- [Platform privileges](https://github.com/bifangknt/mtga/blob/tauri/python-src/modules/platform/privileges.py): `python-src/modules/platform/privileges.py`

### Other components

- **MTGA user**
- **Trae IDE**
- **Model provider**

## Connections

- MTGA user → GUI panels: configures and starts (evidence: `README.md`)
- GUI panels → Frontend state: uses state
- Frontend state → Tauri API bridge: invokes commands (evidence: `app/composables/useMtgaStore.ts`)
- Tauri API bridge → Application commands: dispatches commands
- Application commands → Action handlers: routes operations (evidence: `python-src/mtga_app/commands/model_tests.py`)
- Action handlers → Configuration: uses services (evidence: `README.md`)
- Action handlers → Proxy orchestration: uses services (evidence: `README.md`)
- Application commands → Proxy orchestration: starts proxy (evidence: `python-src/mtga_app/commands/proxy.py`)
- Trae IDE → Proxy server: sends API requests (evidence: `README.md`)
- Proxy server → Model routing: routes requests
- Model routing → Upstream adapter: selects upstream
- Upstream adapter → Provider execution: executes provider call (evidence: `README.md`)
- Provider execution → Model provider: forwards request (evidence: `README.md`)
- Proxy orchestration → Certificate management: prepares certificate (evidence: `README.md`)
- Proxy orchestration → Hosts management: updates hosts (evidence: `README.md`)
- Application commands → System prompts: manages prompts
- Application commands → Update checks: checks updates
- Certificate management → User data and resources: uses resource paths (evidence: `python-src/modules/cert/ca_metadata.py`)
- Hosts management → Platform privileges: uses privileges (evidence: `python-src/modules/hosts/hosts_manager.py`)
