How lamlai/sync-chative works
Main Components
• WordPress Plugin Environment: This hosts the entire plugin and ties into the WordPress lifecycle.
• Admin Interface: Represented by the settings page (settings-page.php), logs viewer (logs-page.php), and ancillary admin styles (admin-styles.php) within the “templates” folder.
• Synchronization Logic:
• API Integration: The component responsible for fetching contacts from Chative’s API.
• Sync Manager: The module handling the syncing process (including duplicate checks, sync interval handling, manual trigger logic, and CS validation) likely defined in functions.php.
• Background Processing: The WordPress cron-based scheduling mechanism that automatically triggers synchronization every 5 minutes.
• Logging System: The component dedicated to recording sync attempts, including success/failure status, history, and log cleanup.
Relationships and Interactions
• How the WordPress Environment triggers the Plugin’s activation and initializes the sync components.
• Logging System with the Sync Manager, showing that all sync attempts and outcomes are recorded.
Important Architectural Patterns and Design Principles
• Separation of Concerns: Clearly separate UI, background processing, API integration, and logging.
• Modular Design: Each component (e.g., admin interface, sync management, logging) can be represented as discrete modules or blocks.
• Integration Layer: Mark the external integrations (Chative API and FluentCRM) as separate entities to emphasize external dependencies.
• Event-driven Triggers: Emphasize using WordPress cron for auto-triggered events versus manual triggers from the admin UI.
Incorporate Relevant Technologies and Libraries
• External APIs: Clearly denote the Chative API and the FluentCRM system.
• UI Components: Represent that the admin interface is built using PHP templates (files in the “templates” folder) and potentially some CSS/JS (as hinted by admin-styles.php).