Description
As an Android Client Developer, I want to call existing Master Data Sync and Pre-registration Sync APIs separately when operators click "Synchronise Data" and "Download Pre-Registration Data" buttons, So that I can provide segregated sync functionality without requiring any backend changes - just using existing APIs in a new way based on which button is clicked.
Purpose
To provide operators with granular control over sync operations through clear and descriptive button names that explain the purpose of each sync, along with visibility into sync progress and specific error messages for each sync type. This enhancement also addresses the differing sync frequencies, where master data sync occurs infrequently, while pre-registration data is expected to be synced and updated on a daily basis.
Pre-requisites
- Master Data Sync API endpoint already exists: v1/syncdata/v2/clientsettings
- Pre-registration Sync API endpoint already exists: /preregistration/v1/sync
- Existing SyncService or similar service available
- Network/HTTP client infrastructure available
- Database access for storing timestamps
Basic Flow
Existing APIs Being Used:
1. Master Data Sync (Already Exists)
Endpoint: /v1/syncdata/v2/clientsettings
Purpose: Syncs master configuration, templates, devices
Called by: "Synchronise Data" button
2. Pre-registration Sync (Already Exists)
Endpoint: /preregistration/v1/sync
Purpose: Syncs pre-registered applicant data
Called by: "Download Pre-Registration Data" button
Step 1: When Operator Clicks "Synchronise Data" Button
-
Android UI calls: respective method
-
SyncService makes request to existing API: /v1/syncdata/v2/clientsettings
-
Backend API processes ONLY master data:
- Downloads document templates
- Downloads device configuration
- Downloads machine settings
- Download all master data required for registration
- Returns ONLY master data (no pre-registration data)
-
Response received (same as before):
{
"success": true,
"masterData": {
"documentTypes": [...],
"devices": [...],
"configuration": {...}
},
"status": "COMPLETED",
"timestamp": "2024-05-13T14:45:00Z"
}
-
Android UI:
- Stores response as master data
- Updates last sync timestamp for "Synchronise Data"
- Displays: "✓ Synchronise Data completed successfully"
- Button becomes enabled again
Step 2: When Operator Clicks "Download Pre-Registration Data" Button
- Android UI calls the respective method
- SyncService makes request to existing API: /preregistration/v1/sync
- Backend API processes ONLY pre-registration data:
- Downloads applicant records
- Downloads biometric data
- Returns ONLY pre-registration data (no master data)
- Response received (same as before):
- Android UI:
- Stores response as pre-registration data
- Updates last sync timestamp for "Download Pre-Registration Data"
- Displays: "✓ Download Pre-Registration Data completed successfully"
- Button becomes enabled again
Step 3: Error Handling Using Existing API Responses
"Synchronise Data" fails:
-
API returns error (same as existing behavior):
{
"success": false,
"errorCode": "NETWORK_TIMEOUT",
"errorMessage": "Request timeout after 30s",
"status": "FAILED"
}
-
Android UI:
- Parses the error response
- Shows specific error: "Synchronise Data failed: Network timeout"
- Logs with
syncType = "SYNCHRONISE_DATA"
- Offers [RETRY] button
"Download Pre-Registration Data" fails:
-
API returns error (same as existing behavior):
{
"success": false,
"errorCode": "SERVER_ERROR",
"errorMessage": "Internal server error",
"status": "FAILED"
}
-
Android UI:
- Parses the error response
- Shows specific error: "Download Pre-Registration Data failed: Server error"
- Logs with
syncType = "DOWNLOAD_PRE_REG"
- Offers [RETRY] button
Step 4: Store Last Sync Timestamps Separately
In local database (GLOBAL_PARAM table):
After "Synchronise Data" completes:
- Key: "last_synchronise_data_timestamp"
- Value: "2024-05-13 14:45:00"
After "Download Pre-Registration Data" completes:
- Key: "last_download_pre_reg_data_timestamp"
- Value: "2024-05-13 14:50:00"
Display on dashboard:
Synchronise Data
Last synced: 2:30 PM
Download Pre-Registration Data
Last synced: 2:45 PM
Step 5: Retry Logic Using Same Existing APIs
When user clicks [RETRY] after failure:
-
Android calls same API endpoint again:
POST /registration/v1/config/mastersync (for "Synchronise Data")
OR
POST /registration/v1/preregistration/sync (for "Download Pre-Registration Data")
-
Backend API handles retry (same logic as original call)
-
No special retry parameter needed
-
Backend returns fresh response
Alternate Flows
Alternate Flow A1: Network Loss During Sync
- API call is in progress
- Network connection drops
- Android detects timeout/network error
- Shows message: "Network connection lost"
- User clicks [RETRY]
- Android calls same API endpoint again
- Network restored; API succeeds
Alternate Flow A2: No New Data to Sync
- "Download Pre-Registration Data" API called
- API returns:
{"success": true, "preRegistrations": []}
- Android UI shows: "Download Pre-Registration Data completed. No new data found."
- Timestamp still updated
- Button enabled again
Alternate Flow A3: Authentication Error (401)
- API returns:
{"success": false, "status": 401}
- Android redirects to login screen
- After login, user can retry sync
- Same API called again
Alternate Flow A4: Multiple Retries Fail
- First retry fails
- Second retry fails
- After 3 failures, show: "Multiple attempts failed"
- Offer [TRY LATER] or [CONTACT SUPPORT]
- Stop retrying automatically
Alternate Flow A5: App Backgrounded During Sync
- API call made
- Operator switches to another app
- Sync request continues in background
- When app returns to foreground:
- If still syncing: Progress restored
- If completed: Success/error shown
Scenarios
| Scenario |
Action |
API Called |
Expected Result |
| S1 |
Click "Synchronise Data" |
POST /registration/v1/config/mastersync |
Only master data synced |
| S2 |
Click "Download Pre-Registration Data" |
POST /registration/v1/preregistration/sync |
Only pre-reg data downloaded |
| S3 |
Network timeout |
Retry same API |
Eventually succeeds |
| S4 |
No new pre-reg data |
GET /registration/v1/preregistration/sync |
Success; "No data" message |
| S5 |
Server returns 500 |
Retry available |
User can retry |
| S6 |
3 failed retries |
- |
Stop retrying; show error |
Data Fields
No response
Business Rules (With Audit)
No response
Acceptance Criteria
| Criteria |
Verification Method |
| "Synchronise Data" API called when button clicked |
Check network logs; verify /config/mastersync endpoint hit |
| "Download Pre-Registration Data" API called when button clicked |
Check network logs; verify /preregistration/sync endpoint hit |
| Master data response processed as master only |
Verify only master data stored in database |
| Pre-reg response processed as pre-reg only |
Verify only pre-reg data stored in database |
| Error messages specific to each sync type |
Error shows correct button name in message |
| Timestamps stored separately |
Query database; verify different timestamps |
Exceptions
| Exception |
Handling |
| Network error during call |
Show error; allow retry of same API |
| API returns error response |
Parse error; show specific message |
| Timeout during API call |
Treat as network error; allow retry |
| User navigates away during sync |
Continue request in background |
| App crashes during sync |
User can retry manually |
Documentation
No response
Reference UX
No response
Compatibility
No response
Implementation Details
Important Notes
NO BACKEND CHANGES REQUIRED:
✅ Use existing Master Data Sync API as-is
✅ Use existing Pre-registration Sync API as-is
✅ Use existing Combined Sync API for backward compatibility
✅ Just call them separately based on button click
✅ All logic for queue/progress/error handled at Android level
What Changes:
- ❌ NOT the backend APIs (they stay the same)
- ✅ The SyncService methods (separate them)
- ✅ The Android UI (two buttons with correct labels)
- ✅ The state management (track which sync running)
- ✅ The queue logic (local memory, not backend)
Non-Functional Requirements
| Requirement |
Specification |
| API Calls |
Use existing endpoints (no changes) |
| Response Parsing |
Handle responses same as before |
| Error Handling |
Same error handling as existing code |
| Performance |
No performance impact (same APIs) |
| Data Integrity |
No data mixing (master vs pre-reg) |
Description
As an Android Client Developer, I want to call existing Master Data Sync and Pre-registration Sync APIs separately when operators click "Synchronise Data" and "Download Pre-Registration Data" buttons, So that I can provide segregated sync functionality without requiring any backend changes - just using existing APIs in a new way based on which button is clicked.
Purpose
To provide operators with granular control over sync operations through clear and descriptive button names that explain the purpose of each sync, along with visibility into sync progress and specific error messages for each sync type. This enhancement also addresses the differing sync frequencies, where master data sync occurs infrequently, while pre-registration data is expected to be synced and updated on a daily basis.
Pre-requisites
Basic Flow
Existing APIs Being Used:
Step 1: When Operator Clicks "Synchronise Data" Button
Android UI calls: respective method
SyncService makes request to existing API: /v1/syncdata/v2/clientsettings
Backend API processes ONLY master data:
Response received (same as before):
{ "success": true, "masterData": { "documentTypes": [...], "devices": [...], "configuration": {...} }, "status": "COMPLETED", "timestamp": "2024-05-13T14:45:00Z" }Android UI:
Step 2: When Operator Clicks "Download Pre-Registration Data" Button
Step 3: Error Handling Using Existing API Responses
"Synchronise Data" fails:
API returns error (same as existing behavior):
{ "success": false, "errorCode": "NETWORK_TIMEOUT", "errorMessage": "Request timeout after 30s", "status": "FAILED" }Android UI:
syncType = "SYNCHRONISE_DATA""Download Pre-Registration Data" fails:
API returns error (same as existing behavior):
{ "success": false, "errorCode": "SERVER_ERROR", "errorMessage": "Internal server error", "status": "FAILED" }Android UI:
syncType = "DOWNLOAD_PRE_REG"Step 4: Store Last Sync Timestamps Separately
In local database (GLOBAL_PARAM table):
Display on dashboard:
Step 5: Retry Logic Using Same Existing APIs
When user clicks [RETRY] after failure:
Android calls same API endpoint again:
Backend API handles retry (same logic as original call)
No special retry parameter needed
Backend returns fresh response
Alternate Flows
Alternate Flow A1: Network Loss During Sync
Alternate Flow A2: No New Data to Sync
{"success": true, "preRegistrations": []}Alternate Flow A3: Authentication Error (401)
{"success": false, "status": 401}Alternate Flow A4: Multiple Retries Fail
Alternate Flow A5: App Backgrounded During Sync
Scenarios
Data Fields
No response
Business Rules (With Audit)
No response
Acceptance Criteria
Exceptions
Documentation
No response
Reference UX
No response
Compatibility
No response
Implementation Details
Important Notes
NO BACKEND CHANGES REQUIRED:
✅ Use existing Master Data Sync API as-is
✅ Use existing Pre-registration Sync API as-is
✅ Use existing Combined Sync API for backward compatibility
✅ Just call them separately based on button click
✅ All logic for queue/progress/error handled at Android level
What Changes:
Non-Functional Requirements