How asiercamara/alpr-vue works
1. Overall shape
This is a single-page browser application built with Vue 3 + TypeScript. It has no backend service dependency for runtime recognition: the detection and OCR pipeline runs locally in the browser, with heavy inference offloaded to Web Workers. The root app is organized around camera input, upload input, and a detection/history UI.
2. Primary runtime boundary
The app is split into a main UI thread and a worker-based inference layer. Vue components, Pinia stores, theming, localization, and user interaction live on the main thread. ONNX model loading and frame processing live in src/workers/, which keeps video scanning responsive while AI runs.
3. Core user flow
Input enters the system from two paths: a live webcam via useCamera or uploaded/local media via useStaticMedia and MediaUploader. Both feed frames into the same detection pipeline. The worker returns plate boxes and OCR text, which are validated, grouped, and displayed in the UI.
4. Inference pipeline
The worker side is a two-stage ALPR flow: YOLOv9 plate detection first, then OCR on cropped plate regions. Model assets are shipped in public/models/ as ONNX files, and modelsLoader.js warms them up before use. Detection logic includes image preprocessing, box filtering/NMS, cropping, OCR postprocessing, and text cleanup.
5. State management boundaries
The app state is centralized in three Pinia stores:
- appStore: operational state such as camera status, loading, and errors
- plateStore: detection results, grouping/confirmation, editing, clearing, ordering
- settingsStore: persistent user preferences saved to localStorage
This separation keeps UI state, recognition results, and preferences distinct.
6. Detection result handling
useDetection bridges the worker output into application state. It validates plate quality using utility rules, then sends accepted detections into plateStore. plateStore performs Levenshtein-based grouping and confirmation timing so repeated detections merge into stable plate records rather than noisy duplicates.
7. UI composition
App.vue acts as the shell and composes the main subsystems: camera preview, uploader, plate list, modals, settings, help, and toast notifications. CameraPreview is the live scanning surface with a <video> element plus canvas overlay for boxes. PlateList and PlateModal are the primary result surfaces for browsing, editing, copying, and exporting detections.
8. Configuration and personalization
User preferences are implemented as first-class architecture, not incidental UI state. useTheme controls light/dark/system mode by toggling the document root class. useLocale syncs language to vue-i18n. Settings cover recognition behavior, feedback, theme, and language, and are exposed through a dedicated bottom-sheet panel.
9. Internationalization and accessibility-oriented UI
The app includes localized strings for English and Spanish under src/i18n/, with automatic browser-language detection plus manual override. The UI uses bottom sheets, toast feedback, icon-only controls, and responsive layouts optimized for mobile and camera use, which affects component structure and interaction design.
10. Utility layer
Several small utilities support the main flow without owning state: export.ts generates CSV output, feedback.ts handles audio/vibration confirmation feedback, and validation.ts contains plate quality rules and similarity helpers. These are invoked from stores/composables rather than directly from UI components, keeping logic centralized.
11. Assets and offline behavior
The app ships its own models, sample media, PWA manifest, and static assets inside the repo. Because the recognition stack runs client-side and uses browser APIs like camera access, WebAssembly, and OffscreenCanvas, the deployment model is static hosting rather than server rendering or API-backed execution.
12. Tooling and quality gates
The repo is built with Vite, type-checked with vue-tsc, tested with Vitest, linted with ESLint, and formatted with Prettier. Component and composable test files are colocated with implementation, which suggests a design focused on behavior-level verification around the stores, worker bridge, and UI states.
Main entry points: App.vue App shell · plateStore.ts plateStore · useDetection.ts useDetection · mainWorker.js main worker
Components 26
Main thread
Vue UI, state, localization, and user interaction run in the browser UI thread.
- main.ts · Creates the Vue application and registers global plugins/runtime setup.
src/main.ts - App shell · Top-level composition of camera, upload, results, settings, help, and notifications.
src/App.vue - Camera preview · Live video scanning surface with overlay feedback for detection results.
src/components/ui/CameraPreview.vue - Media uploader · Upload and local media entry point for static image/video scanning.
src/components/ui/MediaUploader.vue - Plate list · Primary browsing surface for detected plates, ordering, and actions.
src/components/ui/PlateList.vue - Plate modal · Expanded record view for editing, copying, and exporting a detection.
src/components/ui/PlateModal.vue - Settings sheet · Bottom-sheet controls for recognition behavior, theme, language, and feedback.
src/components/ui/SettingsSheet.vue - Help sheet · Guidance and usage help for the camera-first scanning workflow.
src/components/ui/HelpSheet.vue - useCamera · Manages webcam access, camera state, and live capture orchestration.
src/composables/useCamera.ts - useStaticMedia · Handles uploaded or local media playback and frame extraction.
src/composables/useStaticMedia.ts - useDetection · Bridges worker output into application state and applies detection validation.
src/composables/useDetection.ts - appStore · Operational state for camera status, loading, and errors.
src/stores/appStore.ts - plateStore · Central store for recognition results, grouping, confirmation, editing, and clearing.
src/stores/plateStore.ts - settingsStore · Persistent user preferences saved to local storage.
src/stores/settingsStore.ts - useTheme · Switches light, dark, and system theme modes by updating the document root.
src/composables/useTheme.ts - useLocale · Synchronizes language selection with vue-i18n and browser defaults.
src/composables/useLocale.ts - i18n · Localization bootstrap and runtime translation registry.
src/i18n/index.ts - validation · Plate quality rules and similarity helpers used before accepting detections.
src/utils/validation.ts - feedback · Audio and vibration confirmation feedback triggered on successful recognition.
src/utils/feedback.ts - export · CSV export generation for plate records.
src/utils/export.ts
Inference layer
Web Worker-based detection and OCR pipeline that keeps processing off the UI thread.
- main worker · Browser worker entry that coordinates model loading and inference messages.
src/workers/mainWorker.js - models loader · Loads and warms ONNX models before inference starts.
src/workers/modelsLoader.js - detector pipeline · YOLO-based plate detection with preprocessing, filtering, cropping, and box handling.
src/workers/detector/detector/detectionProcessor.js - ocr pipeline · OCR processing for cropped plates plus text cleanup and postprocessing.
src/workers/ocr/ocr/ocrProcessor.js
Assets
Bundled models, sample media, and static app assets shipped with the client app.
- model assets · Packaged ONNX models and config files used entirely client-side.
public/models - sample media · Bundled videos used for local testing and demo playback.
public/test
Connections 28
- main.ts → App shell: mounts · Bootstraps the Vue application shell.
- App shell → Camera preview: composes · Places the live camera scanning surface in the shell.
- App shell → Media uploader: composes · Provides upload and static-media entry points.
- App shell → Plate list: composes · Renders the main result browsing surface.
- App shell → Plate modal: composes · Opens detailed record editing and export flows.
- App shell → Settings sheet: composes · Exposes user preferences and recognition settings.
- App shell → Help sheet: composes · Provides workflow help and usage guidance.
- App shell → useCamera: uses · Connects live camera input into the app.
- App shell → useStaticMedia: uses · Connects uploads and local media into the app.
- App shell → useDetection: uses · Routes frames into the recognition bridge.
- useDetection → main worker: posts frames · Sends frames to worker-based inference and receives detections back.
- main worker → models loader: initializes · Loads and warms the model runtime before processing.
- main worker → detector pipeline: runs · Executes plate detection on incoming frames.
- detector pipeline → ocr pipeline: crops to OCR · Passes detected plate regions to OCR for text extraction.
- main worker → model assets: loads assets · Reads packaged ONNX models from the static asset bundle.
- useDetection → validation: validates · Filters accepted detections using plate quality rules.
- useDetection → plateStore: commits · Stores accepted plates and updates grouping state.
- plateStore → export: exports · Produces CSV output from stored plate records.
- plateStore → feedback: triggers · Emits recognition feedback when detections stabilize.
- settingsStore → useTheme: drives · Feeds theme preference into the theme controller.
- settingsStore → useLocale: drives · Feeds language preference into the locale controller.
- useLocale → i18n: syncs · Keeps the UI language aligned with the translation runtime.
- Plate list → plateStore: reads · Displays grouped detection history from state.
- Plate modal → plateStore: edits · Updates and confirms individual plate records.
- Settings sheet → settingsStore: edits · Persists recognition and UI preferences.
- Camera preview → useCamera: binds · Uses the live camera stream and capture controls.
- Media uploader → useStaticMedia: binds · Feeds uploaded media into frame extraction.
- useCamera → sample media: demo input · Shares the same media pipeline with bundled sample clips.