Skip to content

Latest commit

 

History

History
62 lines (45 loc) · 2.44 KB

File metadata and controls

62 lines (45 loc) · 2.44 KB

ully# Issue #373: Offline Capabilities - Microservices Architecture

Overview

Successfully implemented Microservices-aware Offline Capabilities for the TeachLink frontend. This feature improves the user experience by caching mutations (POST, PUT, DELETE) locally when the network drops and intelligently routing them to the correct backend microservice (Auth, Courses, Groups, etc.) when connectivity is restored.

Implementation Details

New Files Created

  1. src/lib/offline/OfflineSyncManager.ts

    • Core queue management implementation.
    • Network event listeners (online/offline).
    • Configuration for microservice gateways/URLs.
    • Sequential queue processing to ensure data consistency.
  2. src/lib/offline/__tests__/OfflineSyncManager.test.ts

    • Unit tests covering offline enqueueing behavior.
    • Tests for proper endpoint routing to distributed microservices.
    • 100% pass rate.

Features Implemented

  • Microservice Routing: Extensible MicroserviceTarget configuration routes requests to specific domain APIs (Auth, Courses, Groups).
  • Durable Queue: LocalStorage-backed request queuing ensures data survives browser refreshes.
  • Chronological Processing: Requests are processed in the order they were generated when connectivity returns.
  • Graceful Degradation: If a specific microservice is down upon reconnection, the queue pauses to prevent data loss.

Integration Guide

To integrate this into an existing component (like useStudyGroups), instantiate the manager and push mutations to it:

import { OfflineSyncManager } from '@/lib/offline/OfflineSyncManager';

const syncManager = new OfflineSyncManager({
  apiGatewayUrl: 'https://api.teachlink.com/v1',
  serviceUrls: {
    groups: 'https://groups.teachlink.com/v1', // Direct microservice routing
  },
});

// When adding a new resource, enqueue it
syncManager.enqueueRequest({
  targetService: 'groups',
  endpoint: `/groups/${groupId}/resources`,
  method: 'POST',
  body: newResource,
});

Acceptance Criteria Status

  • ✅ Offline Capabilities properly implements Microservices Architecture concepts on the client side.
  • ✅ All related tests pass.
  • ✅ No regression in existing functionality.
  • ✅ Code follows project coding standards (TypeScript, modularized).
  • ✅ Performance impact is minimal (Queue processing happens in the background).

Status: ✅ Complete
Environment: Ready for Staging testing