How qyzhg/prism works
1. Overall shape
- This is a desktop AI translation app built with Tauri: a Vue 3 + Vite frontend for the UI and a Rust backend for OS integration, network calls, OCR, and persistence.
- The app is cross-platform, with explicit backend modules for Windows and macOS, plus an unsupported fallback path.
2. User interface layer
- The main UI lives under src/ and is centered on App.vue, main.js, and a set of reusable components.
- UI pieces are split into functional panels and modals: language selection, model selection, settings, history, hotkey recording, translation results, toolbar, and title bar.
- This layer is responsible for collecting user input, showing translation/OCR results, and triggering backend actions through Tauri commands.
3. Secondary overlay / capture UI
- area-selector.html, src/AreaSelector.vue, and src/area-selector.js indicate a separate screen-region selection interface.
- That suggests a screenshot/OCR flow where the app can ask the user to choose an area of the screen before sending the image into the OCR pipeline.
4. Tauri bridge and application boundary
- The backend is under src-tauri/src/, which is the main boundary between the desktop shell and Rust logic.
- commands.rs is the likely command surface exposed to the frontend.
- app_state.rs suggests shared runtime state that coordinates settings, API configuration, database access, and task execution across commands.
5. Translation pipeline
- translation.rs and http_client.rs indicate the app sends text to an external AI model API, then returns translated text to the frontend.
- The README says the app targets OpenAI-compatible APIs and mentions Tencent Hunyuan-MT-7B as the default translation model.
- This is an online service boundary: translation depends on configured base URL and API key.
6. OCR pipeline
- ocr.rs and ocr_tasks.rs represent the screenshot-to-text path.
- The README identifies Qwen3-VL-8B-Instruct as the OCR/vision model, so OCR is not local image parsing but an API-backed vision-language call.
- Typical flow is: capture or select screen region → process image → extract text → optionally translate → display result and store history.
7. Local persistence
- database.rs plus the included SQLite artifacts show that the app keeps local history/state in SQLite.
- The README explicitly says translation history is stored locally and not uploaded.
- This persistence layer is the main local data boundary: user history, cached records, and possibly configuration metadata.
8. Runtime coordination and limits
- token_limits.rs indicates the app tracks prompt/output size constraints for model calls.
- app_state.rs and task modules imply the backend coordinates async work, API requests, and UI-triggered operations without blocking the desktop UI.
- The project uses Tokio in the Rust runtime for concurrency.
9. System integration
- shortcuts.rs and system_tray.rs show two key OS-facing subsystems: global hotkeys and a tray menu / background presence.
- These are important entry points besides the main window: users can trigger actions from the tray or keyboard shortcuts without interacting with the full UI.
- Platform-specific code under src-tauri/src/platform/ handles OS differences and keeps those integrations isolated.
10. Build, packaging, and release
- Frontend build is handled by Vite; backend build and desktop packaging are handled by Cargo + Tauri.
- tauri.conf.json and tauri.macos.conf.json define desktop app packaging behavior, icons, and platform-specific settings.
- .github/workflows/release.yml indicates automated release packaging/distribution.
11. External service dependencies
- The app is designed around remote model providers rather than an embedded ML runtime.
- The main external dependency is an AI model API endpoint; the README specifically references SiliconFlow as a provider and notes compatibility with other OpenAI-style services.
- That means the architecture has a hard network boundary: UI and local state stay on-device, but translation/OCR requests go out to the configured API.
12. Key architecture summary
- Frontend: Vue desktop UI + capture overlay.
- Backend: Rust/Tauri command layer.
- Services: translation and OCR over HTTP to external model APIs.
- Local storage: SQLite for history.
- OS integration: tray, shortcuts, and platform-specific support.
- This makes the app a local desktop orchestrator around cloud AI services, with all sensitive history retained locally.
Main entry points: commands.rs Commands · app_state.rs App state · ocr.rs OCR · App.vue App shell
Components 17
Frontend
Vue desktop UI and capture overlay
- App shell · Main desktop application shell and composition root
src/App.vue - Main UI · Bootstraps the Vue app and mounts the desktop interface
src/main.js - Panels · Core interaction surfaces for input, settings, history, and results
src/components - Area selector · Separate screen-region selection interface for OCR capture
area-selector.html - Selector logic · Overlay-specific frontend logic for region picking
src/area-selector.js
Backend
Tauri command surface, services, and OS integration
- Commands · Backend command surface invoked by the frontend
src-tauri/src/commands.rs - App state · Shared backend state for settings, API config, and coordination
src-tauri/src/app_state.rs - Translation · Text translation pipeline and request orchestration
src-tauri/src/translation.rs - OCR · Screenshot-to-text pipeline backed by model API calls
src-tauri/src/ocr.rs - OCR tasks · Background OCR job execution and coordination
src-tauri/src/ocr_tasks.rs - HTTP client · Shared outbound client for OpenAI-compatible model endpoints
src-tauri/src/http_client.rs - Tray & hotkeys · Background presence and global keyboard entry points
src-tauri/src/system_tray.rs - Platform layer · Windows, macOS, and unsupported platform-specific behavior
src-tauri/src/platform/mod.rs - Token limits · Prompt and output size management for model calls
src-tauri/src/token_limits.rs
External services
Remote model APIs and local persistence boundary
- SQLite store · Local history and app data storage
src-tauri/src/database.rs - Model API · External translation and vision-model endpoint
Build & release
Frontend, desktop packaging, and release automation
- Build & release · Vite frontend build, Tauri packaging, and release automation
Connections 20
- Main UI → App shell: mounts · Vue entry renders the application shell
- App shell → Panels: uses · Shell composes the main UI panels and modals
- App shell → Area selector: opens · Shell can launch the region-selection overlay
- Area selector → Selector logic: drives · Overlay HTML is powered by dedicated frontend logic
- Panels → Commands: invokes · UI actions call backend commands through Tauri
- Selector logic → Commands: invokes · Overlay sends capture actions to backend commands
- Commands → App state: reads/writes · Commands coordinate through shared runtime state
- App state → Translation: orchestrates · State drives translation requests and configuration
- App state → OCR: orchestrates · State drives OCR capture and processing
- OCR → OCR tasks: queues · OCR work is executed asynchronously in background tasks
- Translation → HTTP client: uses · Translation sends outbound API requests through the shared client
- OCR → HTTP client: uses · OCR vision calls use the shared HTTP client
- HTTP client → Model API: calls · Outbound requests go to the configured model provider
- Translation → SQLite store: stores · Translated history is persisted locally
- OCR → SQLite store: stores · OCR/translation results can be persisted locally
- Commands → Tray & hotkeys: exposes · Backend command surface is reachable from tray and hotkeys
- Tray & hotkeys → Platform layer: adapts · OS integrations are specialized per platform
- App state → Token limits: checks · Request sizing is constrained before model calls
- Build & release → Main UI: builds · Frontend is built with Vite before packaging
- Build & release → Commands: packages · Rust/Tauri backend is packaged into the desktop app