Модулна структура
Клиентът е организиран в 14 модула (поддиректории и отделни файлове в client/src/). Тази страница описва всеки от тях и зависимостите помежду им.
Карта на модулите
| Модул | Директория / файл | Описание |
|---|---|---|
| audio | src/audio/ | Захващане на звук от микрофона (WASAPI), звукови нотификации, системен mute/unmute |
| auth | src/auth/ | OAuth автентикация, JWT управление, keyring storage |
| autostart | src/autostart.rs | Автоматично стартиране с Windows (Registry Run key) или macOS (LaunchAgent plist) |
| cli | src/cli/ | CLI подкоманди: transcribe, login, status, WAV валидация |
| config | src/config.rs | JSON конфигурация -- зареждане, запазване, стойности по подразбиране |
| hotkeys | src/hotkeys/ | Глобални горещи клавиши чрез GetAsyncKeyState polling, hotkey recorder |
| injection | src/injection/ | Инжектиране на текст в активното приложение (SendInput, clipboard paste) |
| llm | src/llm/ | LLM пост-обработка -- OpenAI-compatible chat completions, system prompts |
| machine_id | src/machine_id.rs | Хардуерно-базиран идентификатор на машината (SHA-256 hash) |
| server_health | src/server_health.rs | Периодична проверка на здравето на licensing сървъра |
| server_secrets | src/server_secrets.rs | XOR-обфускирани сървърни URL-та и API ключове |
| transcription | src/transcription/ | WebSocket комуникация с ASR сървъра, WAV кодиране, филтриране на халюцинации |
| ui | src/ui/ | egui интерфейс: app state machine, overlay, settings panel, tray icon, branding, i18n |
| updater | src/updater/ | Автоматично обновяване от GitHub Releases с SHA256 верификация и rollback |
| usage | src/usage/ | Квота и отчитане на използването, offline кеш |
Файлова структура
client/src/
├── main.rs # Entry point: CLI dispatch или GUI стартиране
├── lib.rs # Thin library target (expose icon/branding за build tools)
├── config.rs # Config struct + load/save
├── machine_id.rs # Hardware-based machine ID
├── server_health.rs # ServerHealth polling
├── server_secrets.rs # XOR-obfuscated server constants
├── autostart.rs # Auto-start registry/plist
│
├── audio/
│ ├── mod.rs # pub mod declarations
│ ├── capture.rs # AudioCapture struct, WASAPI capture loop
│ ├── sound.rs # Звукови нотификации (sine beep generation)
│ └── volume.rs # System speaker mute/unmute (COM IAudioEndpointVolume)
│
├── auth/
│ ├── mod.rs # AuthManager state machine
│ ├── browser_auth.rs # Browser redirect flow (axum localhost server)
│ ├── token.rs # JWT store/get/validate via keyring
│ └── types.rs # AuthState enum, AccountInfo, Claims
│
├── cli/
│ ├── mod.rs # Cli struct (clap), Command enum, run()
│ ├── transcribe.rs # `dictaro transcribe` subcommand
│ ├── login.rs # `dictaro login` subcommand
│ ├── status.rs # `dictaro status` subcommand
│ └── validate.rs # WAV file validation pipeline
│
├── hotkeys/
│ ├── mod.rs # pub mod declarations
│ ├── listener.rs # GetAsyncKeyState polling thread
│ ├── types.rs # HotkeyEvent, HotkeyConfig, HotkeyRecorder, parse/format
│ └── vk_map.rs # Virtual key code <-> string mapping
│
├── injection/
│ ├── mod.rs # inject_text(), replace_text()
│ ├── sendinput.rs # Win32 SendInput (KEYEVENTF_UNICODE)
│ └── clipboard.rs # Clipboard paste (save -> set -> Ctrl+V -> restore)
│
├── llm/
│ ├── mod.rs # LlmProcessor, API key storage, output validation
│ ├── client.rs # HTTP chat completions client (reqwest async)
│ └── prompts.rs # System prompt builder (cleanup, professional, custom)
│
├── transcription/
│ ├── mod.rs # pub mod declarations
│ ├── client.rs # WebSocket transcription client + background thread
│ └── hallucination.rs # Филтър за ASR халюцинации (YouTube phrases, repeats)
│
├── ui/
│ ├── mod.rs # pub mod declarations
│ ├── app.rs # App struct (54KB) -- main egui state machine
│ ├── overlay.rs # Recording overlay bar (gradient, animation)
│ ├── settings.rs # Settings panel (47KB) -- all config UI
│ ├── tray.rs # System tray icon и контекстно меню
│ ├── icon.rs # Programmatic app icon rendering
│ ├── branding.rs # Centralized brand constants (name, colors, fonts)
│ └── i18n.rs # Locale init, language list, OS detection
│
├── updater/
│ ├── mod.rs # check_for_update(), MSIX detection
│ ├── github.rs # GitHub Releases API client
│ ├── download.rs # Download + SHA256 verification
│ └── swap.rs # Self-replace + rollback safety
│
└── usage/
├── mod.rs # UsageManager (record, fetch, sync)
├── types.rs # QuotaStatus, PendingRecord
└── cache.rs # Offline usage cache (JSON file)
Граф на зависимостите между модулите
Платформена абстракция
Повечето модули използват #[cfg(windows)] и #[cfg(target_os = "macos")] за платформено-специфичен код. Текущото състояние:
| Модул | Windows | macOS | Linux |
|---|---|---|---|
| audio/capture | WASAPI | stub (TODO: cpal) | не се поддържа |
| audio/sound | Win32 PlaySoundW | no-op | no-op |
| audio/volume | COM IAudioEndpointVolume | no-op | no-op |
| hotkeys/listener | GetAsyncKeyState | stub (TODO: rdev) | не се поддържа |
| injection/sendinput | Win32 SendInput | не се поддържа | не се поддържа |
| injection/clipboard | Win32 Clipboard API | arboard (partial) | arboard |
| autostart | Registry Run key | LaunchAgent plist | не се поддържа |
| auth/token (keyring) | Windows Credential Manager | Apple Keychain | Secret Service |
| machine_id | Registry + PowerShell | IOPlatformUUID | hostname fallback |