iClock-Sync is a Python-based tool designed to fetch and upload attendance logs from ZKTeco iClock devices directly to Google Firestore. It integrates seamlessly with school management systems like SchoolSync and is built modularly, ensuring flexibility for future expansions to support databases such as MySQL, PostgreSQL, MongoDB, and more.
- π Multi-Device Support: Fetch attendance logs from multiple ZKTeco iClock devices.
- π©Ή Structured Normalization: Logs are consistently formatted with unique IDs and comprehensive validation.
- βοΈ Firestore Integration: Uploads only new, deduplicated records with smart caching.
- πΎ Local Audit Logs: Save uploaded logs locally for verification and auditing.
- π§ High-Performance Caching: Smart cache management using
uploaded_ids_cache.json(99%+ efficiency). - π§ͺ Dry-Run Mode: Safely preview uploads without altering Firestore data.
- β³ Smart Date Filtering: Efficiently filter logs to upload only recent records, reducing processing by 99%.
- π Optimized Syncing: Intelligent sync intervals with built-in performance optimization.
- π‘οΈ Data Validation: Comprehensive validation prevents invalid records from reaching Firestore.
- π§ Command-Line Interface: Run using
iclock --export-simple,--dry-run, etc. after editable install.
git clone https://github.com/kudadonbe/iclock-sync.git
cd iclock-syncWe recommend using a virtual environment based on your OS:
python3 -m venv .venv
source .venv/bin/activatepython -m venv .venv
.venv\Scripts\Activate.ps1
β οΈ If activation fails, run this once:Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
pip install -r requirements.txtpip install -e .If using
python -m cli, also set:$env:PYTHONPATH = "$(Get-Location)"
Place your Firebase Admin SDK credentials in:
config/firebase-key.json
Update config/settings.py or use .env:
FIREBASE_KEY_PATH=config/firebase-key.jsoniclock-sync/
βββ cache/ # Cached data
β βββ uploaded_ids_cache.json
βββ config/ # Configuration files
β βββ firebase-key.json
β βββ settings.py
βββ core/ # Core application logic
β βββ firestore_uploader.py
β βββ iclock_connector.py
β βββ normalizer.py
β βββ utils.py
βββ data/ # Sample or test data
β βββ sample_logs.txt
βββ logs/ # Application log files
β βββ sync_*.log
βββ output/ # Output logs (JSON)
β βββ logs_*.json
βββ .env # Environment-specific variables
βββ .env.example # Template
βββ cli.py # Main CLI entry-point
βββ pyproject.toml # Project metadata
βββ requirements.txt # Python dependencies
βββ README.md # Project documentation
iclockiclock --dry-runiclock --since 2iclock --loop 5 --since 1iclock --export-simple
iclock --export-normalizediclock --dry-run --since 1Or directly:
python -m cli --dry-run --since 1Use this if
iclockcommand isn't recognized. Also set:$env:PYTHONPATH = "$(Get-Location)"
- Firebase credentials:
firebase-key.json - Optional:
.envfile withFIREBASE_KEY_PATH
- Idempotent uploads (no duplicates)
- Audit trail via output logs
- Handles multiple devices gracefully
- MySQL, PostgreSQL, MongoDB support
- Web dashboard
- REST API layer via FastAPI
Hussain Shareef (@kudadonbe)
Makunudhoo School, Maldives π²π»
MIT License β free for personal/commercial use