Skip to content

feat(admin): Implement Data Sync and Relationship Matching System#26

Merged
TKanX merged 18 commits intomainfrom
feature/25-implement-publication-data-sync-relationship-matching-system
Feb 7, 2026
Merged

feat(admin): Implement Data Sync and Relationship Matching System#26
TKanX merged 18 commits intomainfrom
feature/25-implement-publication-data-sync-relationship-matching-system

Conversation

@TKanX
Copy link
Copy Markdown
Member

@TKanX TKanX commented Feb 7, 2026

Summary:

Implemented a sophisticated data synchronization system for the admin panel that automates the enrichment of publication metadata and rebuilds relational links between content. This feature integrates OpenAlex and CrossRef APIs to fetch citation counts and keywords, and employs a multi-signal matching engine to automatically link publications to members and research areas based on ORCID, name matching, and keyword analysis.

Changes:

  • Implemented Sync Dashboard (src/app/admin/(authenticated)/sync/):

    • Created a real-time dashboard with SyncStatsCards showing current data health (synced vs. unsynced items).
    • Developed SyncControls to trigger different sync modes: Metadata-only, Relationships-only, or Full Sync.
    • Built SyncProgressPanel using Server-Sent Events (SSE) to display live progress logs, phase updates, and error reporting.
  • Developed Matching Engine (src/lib/publications/matching.ts):

    • Member Matching: Links publications to members using a tiered strategy: ORCID (highest priority) -> Exact Name -> Aliases -> Last Name + Initial.
    • Research Area Matching: Classifies publications into research areas by analyzing keyword intersections between OpenAlex topics and area definitions.
    • Relationship Inference: Automatically derives Member ↔ Research Area links based on the publications they share.
  • Built Sync Logic (src/lib/publications/sync.ts):

    • Metadata Phase: Iterates through publications with DOIs, fetching updated citation counts and keywords from external APIs (OpenAlex/CrossRef) with rate limiting (polite-pool).
    • Relationship Phase: Loads all entities into memory and rebuilds the entire relationship graph (Publication↔Member, Publication↔Area, Member↔Area) in a single atomic transaction.
  • Created API Infrastructure:

    • Added POST /api/admin/sync endpoint that streams SSE events for long-running sync processes.
    • Implemented a global lock to prevent concurrent sync operations.
    • Expanded OpenAlex client (src/lib/publications/openalex.ts) to fetch rich metadata including author ORCIDs and topic keywords.
  • Database Updates:

    • Added getSyncStats Server Action to power the dashboard metrics.
    • Optimized schema seeding to create robust test data for verifying matching logic.
  • UI Components:

    • Added visual indicators for sync status (loading spinners, success checks).
    • Implemented useSync hook to manage SSE connection lifecycle and state.

TKanX added 18 commits February 6, 2026 23:35
Copilot AI review requested due to automatic review settings February 7, 2026 09:16
@TKanX TKanX linked an issue Feb 7, 2026 that may be closed by this pull request
9 tasks
@TKanX TKanX self-assigned this Feb 7, 2026
@TKanX TKanX added the enhancement ✨ New feature or request label Feb 7, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an admin-facing publication sync system that updates external metadata (citations/keywords/authors) and rebuilds Publication↔Member↔ResearchArea relationships, with a new Sync UI and an SSE-backed API for live progress.

Changes:

  • Introduces a publication sync engine (runSync) with metadata and relationship rebuild phases, plus a matching engine for Member/Area linkage.
  • Expands OpenAlex/Crossref clients and adds a unified DOI sync service for “OpenAlex-first, Crossref-fallback”.
  • Adds an Admin “Data Sync” page with stats, controls, and live progress via an SSE API route.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/lib/publications/sync.ts New orchestration for metadata sync + relationship rebuild with SSE events and a process-local lock/cache
src/lib/publications/matching.ts New multi-signal matching logic for Publication↔Member and Publication↔Area
src/lib/publications/openalex.ts Adds sync-focused OpenAlex fetch/parse including citations, keywords, and ORCID author info
src/lib/publications/crossref.ts Adds citation-only fetch helper and refactors fetching into a shared helper
src/lib/publications/doi-sync.ts New unified DOI sync service (OpenAlex → Crossref fallback)
src/lib/publications/shared.ts Adds sync-related types/constants (AuthorInfo/SyncMetadata/SYNC_DELAY/MIN_KEYWORD_SCORE)
src/lib/publications/index.ts Re-exports new sync services and types
src/lib/admin/actions/sync.ts Adds getSyncStats server action for the admin sync dashboard
src/lib/admin/actions/index.ts Re-exports sync action/types
src/app/api/admin/sync/route.ts New SSE endpoint to run sync and stream progress events
src/components/admin/layout/sidebar-nav.tsx Adds “Tools → Data Sync” nav entry
src/app/admin/(authenticated)/sync/page.tsx New admin sync page wired to getSyncStats
src/app/admin/(authenticated)/sync/loading.tsx Loading skeleton for sync page
src/app/admin/(authenticated)/sync/_components/* Client UI for stats, controls, SSE state handling, and progress rendering

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/app/api/admin/sync/route.ts
Comment thread src/app/api/admin/sync/route.ts
Comment thread src/lib/publications/sync.ts
Comment thread src/lib/publications/matching.ts
Comment thread src/lib/publications/shared.ts
Comment thread src/lib/publications/sync.ts
Comment thread src/lib/publications/sync.ts
Comment thread src/lib/publications/sync.ts
Comment thread src/lib/admin/actions/sync.ts
@TKanX TKanX merged commit 75e5530 into main Feb 7, 2026
8 checks passed
@TKanX TKanX deleted the feature/25-implement-publication-data-sync-relationship-matching-system branch February 7, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Publication Data Sync & Relationship Matching System

2 participants