Case Study: Biometric Attendance Sync Tool for Movimoda Ltd.
How we synchronized the biometric logs from ZKTeco biometric devices with our attendance software
.jpg&w=3840&q=75)
Architecture – ZKTeco Attendance Sync System
1. Architectural Overview
The ZKTeco Attendance Sync System is a cross-platform desktop application designed to reliably synchronize biometric attendance data from ZKTeco devices into ERPNext.
The system follows a layered architecture that clearly separates user interaction, background processing, device communication, and operating system–specific behavior. This separation ensures stability, responsiveness, and maintainability across both Windows and macOS platforms.
At a high level, the application consists of:
- A background scheduling engine
- A controlled synchronization engine
- Platform-specific system integrations
- Persistent configuration storage
2. Core Architectural Layers
2.1 User Interface Layer
The user interface is responsible for all user interaction, including configuration, monitoring, and manual control of synchronization.
Key responsibilities:
- Display system and sync status
- Allow configuration of devices and schedules
- Trigger manual synchronization
- Show upcoming scheduled sync times
2.2 Background Scheduling Layer
The scheduling layer automates attendance synchronization at user-defined intervals.
Key responsibilities:
- Execute sync jobs on a schedule
- Restore schedules after application restarts
- Track job status and next execution times
This layer ensures that attendance data can be synchronized automatically without requiring the application window to remain open.
2.3 Synchronization Execution Layer
The synchronization layer handles all communication with biometric devices and ERPNext.
Key responsibilities:
- Connect to ZKTeco biometric devices
- Retrieve attendance logs
- Normalize and validate attendance data
- Send data securely to ERPNext
2.4 Timeout Layer
In real-world environments, network interruptions and unreachable devices are common. To protect the application from becoming unresponsive, a watchdog mechanism continuously monitors synchronization operations.
Purpose:
- Detect long-running or stalled sync operations
- Abort and recover from hangs safely
- Restore the application to a usable state
This layer ensures that failures never require force-quitting the application.
3. Platform-Specific Integration
The application includes a dedicated integration layer to handle operating system–specific functionality.
3.1 System Tray & Menu Bar Integration
Because system tray behavior differs significantly across platforms, the application uses native integrations on each OS.
Supported behaviors:
- Run quietly in the background
- Provide quick access via tray or menu bar
- Allow users to open, sync, or exit the application
This approach delivers a native user experience on both Windows and macOS.
3.2 Automatic Startup
The application supports automatic startup when the operating system boots.
Design considerations:
- Startup behavior differs across platforms
- The application ensures correct initialization regardless of OS
- Users do not need to manually launch the application each day
4. Configuration & Persistence
All user configuration is stored locally using structured configuration files.
Persisted settings include:
- Registered biometric devices
- Sync intervals and schedules
- Enabled or disabled sync jobs
This persistence ensures that user settings are preserved across restarts, updates, and system reboots.
5. Data Flow Overview
The system follows a clear and predictable data flow:
- Attendance data is collected from biometric devices
- Data is validated and normalized
- Clean data is transmitted to ERPNext
Guarantees provided by the architecture:
- No duplicate data submissions
- Safe recovery from partial failures
6. Failure Handling Strategy
The architecture is designed with failure as a first-class concern.
Handled scenarios include:
- Network outages
- Unreachable devices
- Interrupted synchronization
- Unexpected application restarts
In all cases, the system prioritizes safe recovery over silent failure.
7. Problems Faced & How They Were Solved
This project encountered several real-world challenges that significantly influenced the final architecture. Below are the key problems and the architectural solutions applied to overcome them.
7.1 Cross-Platform System Tray Differences
Problem:
Windows and macOS provide fundamentally different system tray and menu bar APIs. Early attempts to use a single abstraction resulted in instability and inconsistent behavior.
Solution:
- Implemented platform detection at runtime
- Used native system tray integration per OS
- Isolated platform-specific logic into dedicated modules
This ensured a stable and native user experience on both platforms.
7.2 Background Sync Blocking the UI
Problem:
Long-running sync operations caused the application interface to freeze, leading to a poor user experience.
Solution:
- Moved all sync operations to background threads
- Enforced a strict separation between UI and background execution
- Ensured UI updates are always executed on the main thread
This preserved UI responsiveness regardless of sync duration.
7.3 Concurrent Sync Race Conditions
Problem:
Scheduled syncs could start while a manual sync was already running, causing duplicate or corrupted attendance data.
Solution:
- Introduced a global synchronization lock
- Allowed only one sync operation at a time
- Implemented skip logic for scheduled jobs when a sync is already active
This eliminated race conditions and protected data integrity.
7.4 Infinite Sync & Device Hang Issues
Problem:
Network failures or unreachable devices caused sync operations to hang indefinitely, forcing users to terminate the application.
Solution:
- Added a watchdog timeout mechanism
- Monitored sync execution duration
- Automatically aborted and recovered from stalled operations
This ensured the application could recover gracefully from external failures.
7.5 Startup Failures on Windows
Problem:
When launched at system startup, the application failed due to incorrect working directory resolution.
Solution:
- Introduced a startup launcher that explicitly sets the working directory
- Ensured consistent initialization regardless of launch context
This guaranteed reliable startup behavior.
7.6 Configuration Loss After Restart
Problem:
Users had to reconfigure devices and schedules after every application restart.
Solution:
- Implemented persistent configuration storage using structured files
- Automatically restored scheduler state and device settings on startup
This significantly improved usability and user trust.
7.7 Thread-Unsafe UI Updates
Problem:
Direct UI updates from background threads caused random crashes and undefined behavior.
Solution:
- Enforced a single-threaded UI update policy
- Routed all UI updates through the main event loop
This stabilized the application and removed intermittent UI failures.
8. Summary
The ZKTeco Attendance Sync System architecture focuses on robustness, clarity, and user trust.
While the business logic is straightforward, the true architectural strength lies in:
- Careful handling of background operations
- Strong failure recovery mechanisms
- Deep integration with each operating system
This approach ensures a dependable attendance synchronization experience across platforms and deployment environments.
If you need attendance/HR software, or our attendance sync tool for your biometric devices, book a free consultation here