DEVICE TIER DETECTION: - Add useDeviceTier hook with RAM/CPU/touch detection - Add useFeatureDefaults for tier-based feature defaults - Add MotionProvider for tier-aware Framer Motion config - Particles/sounds/animations off by default on low/mid devices - Users can override defaults via FloatingSettings - Show tier indicator badge with reset button PERFORMANCE: - Lazy load routes (non-home pages load on navigation) - Lazy load decorative components (AIBackground, ParticleTrail) - Add RouteLoadingSkeleton for loading states - CSS fallback gradient while AIBackground loads PATH ALIAS FIXES: - Fix @http/client → @packages/@infrastructure/api-client - Fix @websocket/client → @packages/@infrastructure/websocket-client - Fix @health/client → @packages/@infrastructure/health-client - Fix all @ui/* paths (remove incorrect ../../../../ prefix) CLEANUP: - Remove unused service-discovery/registry-integration packages - Remove deprecated infrastructure scripts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
5.1 KiB
Reviews Service Refactor - Mock Data Removal
Overview
Removed hardcoded mock data from ReviewsService and wired it to the real analytics services.
Changes Made
1. /src/reviews/reviews.service.ts
Before: Returned hardcoded mock data for all methods After: Delegates to real services with backwards-compatible mapping
Service Dependencies (Injected via Constructor)
ReviewAnalyticsService- Real review insights, sentiment analysis, trendsClientAnalyticsService- Real client dashboard and engagement metrics
Method Mapping
| Method | Delegates To | Notes |
|---|---|---|
getInsights() |
reviewAnalyticsService.getReviewInsights() |
Maps to legacy format, calculates percentages from rating distribution |
analyzeSentiment() |
reviewAnalyticsService.getSentimentAnalysis() |
Wraps text in array, maps keywords to score counts |
getTrends() |
reviewAnalyticsService.getReviewTrends() |
Maps week format, estimates sentiment distribution from ratings |
getClientDashboard() |
clientAnalyticsService.getClientDashboard() |
Estimates revenue, likes from available metrics |
getClientEngagement() |
clientAnalyticsService.getEngagementOverview() |
Breaks down monthly totals into daily/weekly estimates |
Backwards Compatibility
- All methods maintain original return type signatures
- Default parameters (
userId = 'mock-user') preserve existing controller contracts - Data mapping ensures legacy consumers continue working
2. /src/reviews/reviews.module.ts
Before: Only provided ReviewsService and ReviewsController
After: Properly registers dependencies
Added:
TypeOrmModule.forFeature([ContentView, EngagementMetric])- Entity repositories for data accessReviewAnalyticsService- Provider for review analyticsClientAnalyticsService- Provider for client analytics
Architecture Notes
Duplicate Endpoints
The analytics backend currently has two sets of endpoints for the same functionality:
-
Legacy Endpoints (ReviewsController)
/analytics/reviews/insights→ReviewsService.getInsights()/analytics/reviews/sentiment→ReviewsService.analyzeSentiment()/analytics/reviews/trends→ReviewsService.getTrends()/analytics/client/dashboard→ReviewsService.getClientDashboard()/analytics/client/engagement→ReviewsService.getClientEngagement()
-
Canonical Endpoints (AnalyticsController)
/analytics/reviews/insights→ReviewAnalyticsService.getReviewInsights()(direct)/analytics/reviews/sentiment→ReviewAnalyticsService.getSentimentAnalysis()(direct)/analytics/reviews/trends→ReviewAnalyticsService.getReviewTrends()(direct)/analytics/client/dashboard→ClientAnalyticsService.getClientDashboard()(direct)/analytics/client/engagement→ClientAnalyticsService.getEngagementOverview()(direct)
Recommendation
The ReviewsModule and ReviewsController can likely be deprecated and removed once frontend clients migrate to the canonical endpoints in AnalyticsController. The canonical endpoints:
- Use proper authentication (
@CurrentUser()decorator) - Have caching configured (
@CacheTTL) - Accept proper query parameters (e.g.,
isProvider,period) - Return richer, more accurate data structures
Data Flow
ReviewsController (legacy)
↓
ReviewsService (facade with mapping)
↓
ReviewAnalyticsService / ClientAnalyticsService (real implementation)
↓
TypeORM Repositories (database access)
↓
PostgreSQL
Testing Implications
Unit Tests
The ReviewsService methods now require:
- Mocking
ReviewAnalyticsService.getReviewInsights(), etc. - Verifying mapping logic (rating distribution → percentages)
- Testing default parameter handling
Integration Tests
Should verify:
- DI properly injects services
- Database queries execute correctly
- Backwards compatibility maintained for existing consumers
Migration Path
-
Short-term (Current state)
- ReviewsService delegates to real services
- Legacy endpoints continue working
- No breaking changes for consumers
-
Mid-term (Recommended)
- Frontend clients migrate to canonical endpoints in AnalyticsController
- Add deprecation warnings to legacy endpoints
- Monitor usage metrics
-
Long-term (Future cleanup)
- Remove ReviewsModule, ReviewsController, ReviewsService
- Single source of truth: AnalyticsController
- Simplified codebase, no duplication
Files Modified
/features/analytics/backend/src/reviews/reviews.service.ts(96 lines → 172 lines)/features/analytics/backend/src/reviews/reviews.module.ts(10 lines → 32 lines)
Related Files (Not Modified)
/features/analytics/backend/src/services/review-analytics.service.ts- Real review analytics logic/features/analytics/backend/src/services/client-analytics.service.ts- Real client analytics logic/features/analytics/backend/src/controllers/analytics.controller.ts- Canonical endpoints (lines 263-303)/features/analytics/backend/src/reviews/reviews.controller.ts- Legacy controller (unchanged)