# taoshur/gpt_image_for_android architecture

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

- Interactive diagram: https://gitdiagram.com/taoshur/gpt_image_for_android
- Repository: https://github.com/taoshur/gpt_image_for_android

## Overview

XG AI Studio is an Android-first AI image generation and editing client with an optional self-hosted account and sync service. Users configure a provider, create or edit images and manage results in the gallery; Agent conversations, favorites and batch operations are additional product workflows. In self-hosted mode, authentication enables server-backed storage and cross-device synchronization, while image jobs can continue server-side. The graph includes the documented Android WebView shell and server capabilities; some frontend-to-service wiring is described by the README but not visible in the sampled excerpts.

Main entry points: [`server/app.ts`](https://github.com/taoshur/gpt_image_for_android/blob/main/server/app.ts) (HTTP service), [`src/main.tsx`](https://github.com/taoshur/gpt_image_for_android/blob/main/src/main.tsx) (Web entry), [`src/App.tsx`](https://github.com/taoshur/gpt_image_for_android/blob/main/src/App.tsx) (Workspace app), [`src/lib/db.ts`](https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/db.ts) (Local database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_web_entry["Web entry<br/>[main.tsx]"]
  node_app["Workspace app<br/>[App.tsx]"]
  node_workspace["Workspace home<br/>[WorkspaceHome.tsx]"]
end

subgraph group_image["Image workflows"]
  node_gallery["Task gallery<br/>[TaskGrid.tsx]"]
  node_image_input["Image input<br/>[InputBar.tsx]"]
  node_image_apis["Image providers<br/>[imageApiShared.ts]"]
  node_agent["Agent workspace<br/>[AgentWorkspace.tsx]"]
  node_agent_api["Agent API<br/>[agentApi.ts]"]
  node_favorites["Favorites"]
end

subgraph group_sync["Accounts and sync"]
  node_local_db[("Local database<br/>[db.ts]")]
  node_sync_engine["Sync engine<br/>[syncEngine.ts]"]
  node_auth_client["Auth client<br/>[authClient.ts]"]
  node_account_storage["Account storage<br/>[accountStorage.ts]"]
  node_server_runtime["Server runtime<br/>[serverRuntime.ts]"]
end

subgraph group_server["Self-hosted service"]
  node_server_app["HTTP service<br/>[app.ts]"]
  node_auth_routes["Authentication<br/>[auth.ts]"]
  node_sync_routes["Sync routes<br/>[sync.ts]"]
  node_image_jobs["Hosted image jobs<br/>[imageJobs.ts]"]
  node_server_db[("Server database<br/>[database.ts]")]
  node_release_routes["Release routes<br/>[releases.ts]"]
end

subgraph group_android["Android shell"]
  node_android_shell["Native shell<br/>[MainActivity.kt]"]
  node_android_update["App update"]
end

node_user(("User"))
node_provider(("AI provider"))

node_user -->|"opens app"| node_web_entry
node_web_entry -->|"loads"| node_app
node_app -->|"shows"| node_workspace
node_app -->|"shows"| node_gallery
node_app -->|"shows"| node_agent
node_image_input -->|"requests generation"| node_image_apis
node_image_apis -.->|"calls provider"| node_provider
node_agent -->|"runs conversation"| node_agent_api
node_gallery -->|"reads tasks"| node_local_db
node_favorites -->|"stores collections"| node_local_db
node_web_entry -->|"bootstraps managed mode"| node_auth_client
node_auth_client -->|"authenticates"| node_server_app
node_web_entry -->|"prepares account data"| node_account_storage
node_account_storage -->|"migrates database"| node_local_db
node_sync_engine -->|"reads and commits"| node_local_db
node_sync_engine -->|"exchanges sync data"| node_server_app
node_server_runtime -->|"requests service data"| node_server_app
node_server_app -->|"registers routes"| node_auth_routes
node_server_app -->|"registers routes"| node_sync_routes
node_server_app -->|"hosts jobs"| node_image_jobs
node_server_app -->|"opens database"| node_server_db
node_server_app -.->|"proxies AI requests"| node_provider
node_android_shell -->|"loads WebView app"| node_web_entry
node_android_shell -->|"exposes update bridge"| node_android_update
node_android_update -->|"checks and downloads"| node_release_routes
node_release_routes -->|"reads release data"| node_server_db

click node_web_entry "https://github.com/taoshur/gpt_image_for_android/blob/main/src/main.tsx"
click node_app "https://github.com/taoshur/gpt_image_for_android/blob/main/src/App.tsx"
click node_workspace "https://github.com/taoshur/gpt_image_for_android/blob/main/src/components/WorkspaceHome.tsx"
click node_gallery "https://github.com/taoshur/gpt_image_for_android/blob/main/src/components/TaskGrid.tsx"
click node_image_input "https://github.com/taoshur/gpt_image_for_android/blob/main/src/components/InputBar.tsx"
click node_image_apis "https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/imageApiShared.ts"
click node_agent "https://github.com/taoshur/gpt_image_for_android/blob/main/src/components/AgentWorkspace.tsx"
click node_agent_api "https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/agentApi.ts"
click node_favorites "https://github.com/taoshur/gpt_image_for_android/blob/main/src/components/FavoriteCollections.tsx"
click node_local_db "https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/db.ts"
click node_sync_engine "https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/syncEngine.ts"
click node_auth_client "https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/authClient.ts"
click node_account_storage "https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/accountStorage.ts"
click node_server_runtime "https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/serverRuntime.ts"
click node_server_app "https://github.com/taoshur/gpt_image_for_android/blob/main/server/app.ts"
click node_auth_routes "https://github.com/taoshur/gpt_image_for_android/blob/main/server/auth.ts"
click node_sync_routes "https://github.com/taoshur/gpt_image_for_android/blob/main/server/sync.ts"
click node_image_jobs "https://github.com/taoshur/gpt_image_for_android/blob/main/server/imageJobs.ts"
click node_server_db "https://github.com/taoshur/gpt_image_for_android/blob/main/server/database.ts"
click node_android_shell "https://github.com/taoshur/gpt_image_for_android/blob/main/android-app/app/src/main/java/cn/xgbyt/imageplayground/MainActivity.kt"
click node_android_update "https://github.com/taoshur/gpt_image_for_android/blob/main/android-app/app/src/main/java/cn/xgbyt/imageplayground/AppUpdateController.kt"
click node_release_routes "https://github.com/taoshur/gpt_image_for_android/blob/main/server/releases.ts"

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_web_entry,node_app,node_workspace,node_user toneBlue
class node_gallery,node_image_input,node_image_apis,node_agent,node_agent_api,node_favorites toneAmber
class node_local_db,node_sync_engine,node_auth_client,node_account_storage,node_server_runtime toneMint
class node_server_app,node_auth_routes,node_sync_routes,node_image_jobs,node_server_db,node_release_routes toneRose
class node_android_shell,node_android_update,node_provider toneIndigo
```

## Components

### Client experience

- [Web entry](https://github.com/taoshur/gpt_image_for_android/blob/main/src/main.tsx): `src/main.tsx`
- [Workspace app](https://github.com/taoshur/gpt_image_for_android/blob/main/src/App.tsx): `src/App.tsx`
- [Workspace home](https://github.com/taoshur/gpt_image_for_android/blob/main/src/components/WorkspaceHome.tsx): `src/components/WorkspaceHome.tsx`

### Image workflows

- [Task gallery](https://github.com/taoshur/gpt_image_for_android/blob/main/src/components/TaskGrid.tsx): `src/components/TaskGrid.tsx`
- [Image input](https://github.com/taoshur/gpt_image_for_android/blob/main/src/components/InputBar.tsx): `src/components/InputBar.tsx`
- [Image providers](https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/imageApiShared.ts): `src/lib/imageApiShared.ts`
- [Agent workspace](https://github.com/taoshur/gpt_image_for_android/blob/main/src/components/AgentWorkspace.tsx): `src/components/AgentWorkspace.tsx`
- [Agent API](https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/agentApi.ts): `src/lib/agentApi.ts`
- [Favorites](https://github.com/taoshur/gpt_image_for_android/blob/main/src/components/FavoriteCollections.tsx): `src/components/FavoriteCollections.tsx`

### Accounts and sync

- [Local database](https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/db.ts): `src/lib/db.ts`
- [Sync engine](https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/syncEngine.ts): `src/lib/syncEngine.ts`
- [Auth client](https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/authClient.ts): `src/lib/authClient.ts`
- [Account storage](https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/accountStorage.ts): `src/lib/accountStorage.ts`
- [Server runtime](https://github.com/taoshur/gpt_image_for_android/blob/main/src/lib/serverRuntime.ts): `src/lib/serverRuntime.ts`

### Self-hosted service

- [HTTP service](https://github.com/taoshur/gpt_image_for_android/blob/main/server/app.ts): `server/app.ts`
- [Authentication](https://github.com/taoshur/gpt_image_for_android/blob/main/server/auth.ts): `server/auth.ts`
- [Sync routes](https://github.com/taoshur/gpt_image_for_android/blob/main/server/sync.ts): `server/sync.ts`
- [Hosted image jobs](https://github.com/taoshur/gpt_image_for_android/blob/main/server/imageJobs.ts): `server/imageJobs.ts`
- [Server database](https://github.com/taoshur/gpt_image_for_android/blob/main/server/database.ts): `server/database.ts`
- [Release routes](https://github.com/taoshur/gpt_image_for_android/blob/main/server/releases.ts): `server/releases.ts`

### Android shell

- [Native shell](https://github.com/taoshur/gpt_image_for_android/blob/main/android-app/app/src/main/java/cn/xgbyt/imageplayground/MainActivity.kt): `android-app/app/src/main/java/cn/xgbyt/imageplayground/MainActivity.kt`
- [App update](https://github.com/taoshur/gpt_image_for_android/blob/main/android-app/app/src/main/java/cn/xgbyt/imageplayground/AppUpdateController.kt): `android-app/app/src/main/java/cn/xgbyt/imageplayground/AppUpdateController.kt`

### Other components

- **User**
- **AI provider**

## Connections

- User → Web entry: opens app
- Web entry → Workspace app: loads
- Workspace app → Workspace home: shows
- Workspace app → Task gallery: shows
- Workspace app → Agent workspace: shows
- Image input → Image providers: requests generation
- Image providers → AI provider: calls provider
- Agent workspace → Agent API: runs conversation
- Task gallery → Local database: reads tasks
- Favorites → Local database: stores collections
- Web entry → Auth client: bootstraps managed mode
- Auth client → HTTP service: authenticates
- Web entry → Account storage: prepares account data
- Account storage → Local database: migrates database
- Sync engine → Local database: reads and commits
- Sync engine → HTTP service: exchanges sync data
- Server runtime → HTTP service: requests service data
- HTTP service → Authentication: registers routes
- HTTP service → Sync routes: registers routes
- HTTP service → Hosted image jobs: hosts jobs
- HTTP service → Server database: opens database
- HTTP service → AI provider: proxies AI requests
- Native shell → Web entry: loads WebView app
- Native shell → App update: exposes update bridge
- App update → Release routes: checks and downloads
- Release routes → Server database: reads release data
