Battle.net Character Sync - Feature Complete ✅
Completed: February 2, 2026
Summary
Implemented a full-featured Battle.net character synchronization system with real-time WebSocket progress tracking, background job processing, and comprehensive error handling.
What Was Built
Backend
-
SyncCharactersFromBattleNetUseCase
- Fetches user's WoW characters from Battle.net API
- Creates/updates characters in database
- Deduplicates by
(battleNetId, realm) - Queues background enrichment jobs
- Returns sync session ID for tracking
-
CharacterEnrichmentProcessor
- Background Bull queue processor
- Fetches character avatars and profile data
- Emits real-time WebSocket progress updates
- Handles failures gracefully with retries
- Character-by-character status tracking
-
CharacterSyncGateway
- WebSocket gateway for real-time updates
- Events:
sync-progress,sync-complete,sync-error - Room-based subscriptions per session
- Sends current character being processed
-
CharacterSyncSession Model
- Tracks sync progress in database
- Fields: status, totalCharacters, processedCharacters, failedCharacters
- User-specific sessions
- Used for resume/recovery
Frontend
-
useCharacterSync Hook
- WebSocket client integration
- Auto-connects on active sync detection
- Methods:
startSync(),joinSession(),reset() - Returns: progress, error, isConnected, isSyncing, isComplete
-
CharacterSyncProgress Component
- Real-time progress bar with percentage
- Current character display with animated status icons
- Processing: spinning arrow (blue)
- Completed: check circle (green)
- Failed: X circle (red)
- Smooth fade-in animations
-
RTK Query Integration
syncCharactersmutationenrichCharactermutation (single character)getActiveSyncquery- Automatic cache invalidation on completion
API Endpoints
POST /api/v1/characters/sync- Batch sync all charactersPOST /api/v1/characters/:id/enrich- Enrich single characterGET /api/v1/characters/sync/active- Get active sync sessionGET /api/v1/characters/sync/:sessionId- Get session detailsPATCH /api/v1/characters/sync/:sessionId/complete- Manual completion
Features
- ✅ Real-time character-by-character progress tracking
- ✅ WebSocket-based updates (no polling)
- ✅ Background avatar fetching
- ✅ Single character enrichment
- ✅ Batch character sync
- ✅ Multi-game version support (retail, classic, SoD, etc.)
- ✅ Character deduplication
- ✅ Reactivation of archived characters
- ✅ Encrypted Battle.net token handling
- ✅ Retry logic with exponential backoff
- ✅ Full i18n support
- ✅ Consistent UX between batch and single sync
Technical Highlights
External API Integration Pattern
Created reusable BaseApiAdapter pattern for external APIs:
BattleNetAdapter- Battle.net API ACLRaiderIOAdapter- Raider.IO API ACL (future)- Standardized error handling
- Token management
- Rate limiting support
Real-Time Architecture
flowchart TD
A[User] --> B[API]
B --> C[UseCase]
C --> D[Create Session]
C --> E[Queue Jobs]
E --> F[Processor]
F --> G[WebSocket]
G --> H[Frontend]
F --> I[Update Session]
Performance
- Lightweight initial sync (basic data only)
- Background enrichment (avatars/profile)
- Bulk job queuing
- Parallel processing via Bull
- Database session tracking
Files Modified/Created
Backend
apps/api/src/domains/character/application/use-cases/sync-characters-from-battlenet.use-case.tsapps/api/src/jobs/character-enrichment.processor.tsapps/api/src/domains/character/gateways/character-sync.gateway.tsapps/api/src/domains/character/character.controller.tsapps/api/src/common/external-api/base-api-adapter.tsapps/api/src/common/external-api/battle-net-adapter.tsapps/api/prisma/schema.prisma(CharacterSyncSession model)
Frontend
apps/web/src/hooks/useCharacterSync.tsapps/web/src/hooks/useWebSocket.tsapps/web/src/components/CharacterSyncProgress.tsxapps/web/src/store/api/charactersApi.tsapps/web/src/routes/characters/index.tsxapps/web/src/routes/characters/-CharacterCard.tsxapps/web/src/locales/en/character.jsonapps/web/src/locales/en/common.json
Documentation
docs/docs/systems/character-sync.mddocs/sidebars.ts
Commits
Total: ~30 commits Key milestones:
- External API adapter pattern
- Battle.net character sync use case
- WebSocket gateway and progress tracking
- Frontend hooks and components
- Single-character enrichment
- Bug fixes (deduplication, template enum, inactive characters)
- i18n translations
- Documentation
Testing Notes
- Tested with 6-character Battle.net account
- Tested Classic Season of Discovery (classic_sod)
- Verified WebSocket real-time updates
- Confirmed avatar fetching from Battle.net
- Tested single-character enrichment
- Verified deduplication logic
- Confirmed inactive character handling
Manual Notion Update Required
Action needed: Update the following task(s) in Notion to "Done" status:
- Battle.net Character Sync implementation
- Real-time progress tracking with WebSockets
- Character enrichment background jobs
Next Steps
See remaining TODOs:
- Remove duplicate updateRole endpoint from Guild controller (1 pt)
- Migrate findOne to DDD - GetGuildDetailUseCase (1 pt)
Notes
This feature serves as a template for future external API integrations:
- Use the
BaseApiAdapterpattern - Follow the sync session + background job pattern
- Use WebSocket for real-time progress
- Keep frontend and backend sync consistent