5.5 KiB
5.5 KiB
JW Library Sync System: Architecture & Roadmap
Date: 2026-03-31 Core Stack: Android (Tablet/Phone), Tasker, AutoInput, GitSync, Gitea, n8n, jwlFusion.
## SYSTEM OVERVIEW
1. Local Backup (Tablet & Phone)
- Trigger: Time-based (04:30 AM Tablet / 04:35 AM Phone).
- Action: Tasker copies the
.jwlibraryexport from the app's export location to the localvaultdirectory. - Sync: Tasker uses AutoInput to:
- Launch GitSync.
- Click the "Sync" or "Push" button for the
vaultrepository. - Wait for the notification/UI change indicating success.
2. Central Merge (The "Global Truth")
- Trigger: Tablet at 04:45 AM.
- Action: Tasker sends an HTTP POST to the n8n webhook (
bunny-wyvern.ts.net). - n8n Logic: 1. SSH into the server.
2. Pull all branch updates from Gitea.
3. Run
jwlFusionto merge device backups intomaster.jwlibrary. 4. Commit and Push the merged file back to Gitea. 5. Return a200 OK"Sync successful" message to Tasker.
3. Restoration (Sync Back)
- Action: Upon receiving the
200 OK, Tasker triggers theRestoreFromMastertask. - Logic: GitSync pulls the latest
master.jwlibrary, and Tasker (via AutoInput or intent) imports it back into the JW Library app.
## CURRENT CONFIGURATION (POST-INTENT DEPRECATION)
- GitSync: Bypassing Intent issues by using AutoInput to physically click the sync buttons.
- Storage: Vault is located at
/storage/emulated/0/vault(Shared Storage). - Git Settings: "Safe Directory" and "Credential Store" have been configured in the environment to prevent ownership/password prompts.
## TO-DO LIST (FOR TOMORROW)
- AutoInput Optimization: Refine the "Click" sequence in Tasker to ensure it handles the screen being off (using
Turn OnandDismiss Keyguardactions). - Validation Check: Run a manual end-to-end test:
- Manually trigger Tablet Sync.
- Manually trigger Phone Sync.
- Manually trigger n8n Webhook via Tasker.
- Error Handling: Add a Tasker "Else" condition for the HTTP Request—if n8n returns an error, send a Join/Gotify notification so you know the merge failed.
- Gitea Cleanup: Verify the
.gitignorein thevaultfolder is correctly ignoring temporary.tmpfiles created during the export process. - Staggering Review: Confirm if 5 minutes is enough buffer for the Phone to finish its push before the Tablet initiates the Merge Script.
## FINAL SYSTEM LOGIC (4:30 AM SEQUENCE)
- 04:30 (Tablet): Tasker -> AutoInput (GitSync Push).
- 04:35 (Phone): Tasker -> AutoInput (GitSync Push).
- 04:45 (Tablet): Tasker -> HTTP Request (n8n Webhook).
- On Success: Tasker -> Perform Task (RestoreFromMaster).
DETAILS
PROJECT: Automated JW Library Multi-Device Sync (via Gitea/n8n)
Status: In Progress (Active Debugging Phase) User Persona: INTJ (Prefers logic-first, no-fluff, technical precision)
1. THE ARCHITECTURE
The goal is to sync JW Library backups (.jwlibrary) across multiple Android devices using a central "Master" merge script.
- Source Devices: Android Tablet & Phone.
- Storage: Local Git "Vault" folder at
/storage/emulated/0/vault. - Git Client: GitSync (Android App).
- Remote: Self-hosted Gitea instance.
- Orchestration: n8n (running on
bunny-wyvern.ts.net). - Merge Logic:
jwlFusionscript on the server.
2. TECHNICAL HURDLES & CURRENT FIXES
- Termux Plugin Failure: The
Termux:Taskerplugin failed with "Missing/Disabled Receiver" errors (likely due to Android 14 security or Play Store/F-Droid version mismatch). We abandoned Termux scripts for now. - GitSync Intent Failure: Attempted to trigger GitSync via
com.viscouspot.gitsync.action.SYNCintents, but the app did not respond to background broadcasts. - Current Solution: Using Tasker + AutoInput. Tasker wakes the device, opens the GitSync UI, and AutoInput physically clicks "Sync" to ensure the push/pull happens.
3. THE DAILY TIMELINE (SCHEDULED)
- 04:30 AM (Tablet): Tasker triggers. AutoInput clicks through GitSync to push the latest local backup to its own branch on Gitea.
- 04:35 AM (Phone): Same process. Pushes its unique backup to its own branch.
- 04:45 AM (Tablet - Master Trigger):
- Tasker sends an HTTP POST to the n8n Webhook.
- n8n Workflow: * SSH into the server.
- Pull all device branches.
- Run
jwlFusionto merge everything intomaster.jwlibrary. - Push
master.jwlibraryto themasterbranch.
- Restoration: Once n8n returns
200 OK, the Tablet (and later the Phone) triggers a "Restore" task to pull the newmasterand import it into JW Library.
4. AGENT "TO-DO" LIST (FOR NEXT SESSION)
- Refine AutoInput: Ensure the "Sync" clicks are robust (handling screen-off states or unexpected popups).
- n8n Webhook Verification: Confirm the n8n SSH node is correctly executing the
jwlFusioncommand and handling Git conflicts. - Restore Logic: Finalize the Tasker task that takes the pulled
master.jwlibraryand automates the "Import" into the JW Library app. - Race Condition Check: Verify the 5-minute stagger between devices is sufficient for GitSync to finish its network operations.
5. REFERENCE DATA
- Vault Path:
/storage/emulated/0/vault - n8n Webhook:
http://n8n.bunny-wyvern.ts.net:5678/webhook/sync-jw-backup - Personality Context: User is an INTJ. Provide direct, technical solutions. No fluff.