refactor(apps): 重构数据层目录结构并新增启动预热编排器

This commit is contained in:
zl-q
2026-03-29 20:26:30 +08:00
parent 33340de8f9
commit 4db9a13bfe
108 changed files with 1653 additions and 1320 deletions
@@ -0,0 +1,73 @@
# Frontend Cache + SWR + Boot Prewarm Implementation Plan (Updated)
> This document replaces the previous version and removes outdated path references.
## Current Architecture Baseline
- Shared infrastructure is under `apps/lib/data/` only:
- cache: `apps/lib/data/cache/`
- network: `apps/lib/data/network/`
- storage: `apps/lib/data/storage/`
- Feature business repositories/models live under each feature:
- calendar: `apps/lib/features/calendar/data/repositories/`, `apps/lib/features/calendar/data/models/`
- messages: `apps/lib/features/messages/data/repositories/`, `apps/lib/features/messages/data/models/`
- contacts: `apps/lib/features/contacts/data/repositories/`, `apps/lib/features/contacts/data/models/`
- chat history cache repo: `apps/lib/features/chat/data/repositories/chat_history_repository.dart`
## Scope
1. Keep cache infra generic and reusable.
2. Keep TTL policy defined per feature repository (not centralized in shared cache).
3. Keep boot prewarm bounded by timeout with cache-first UX.
## Tasks
### Task A: Cache Infra Stability
**Files:**
- `apps/lib/data/cache/cache_store.dart`
- `apps/lib/data/cache/cache_policy.dart`
- `apps/lib/data/cache/cached_repository.dart`
**Checks:**
- `flutter test apps/test/data/cache/cached_repository_test.dart`
- `flutter test apps/test/data/cache/hybrid_cache_store_test.dart`
- `flutter test apps/test/data/cache/shared_prefs_cache_store_test.dart`
### Task B: Feature Repositories Use Local TTL Policies
**Files:**
- `apps/lib/features/todo/data/repositories/todo_repository.dart`
- `apps/lib/features/messages/data/repositories/inbox_repository.dart`
- `apps/lib/features/contacts/data/repositories/friend_repository.dart`
- `apps/lib/features/settings/data/repositories/user_profile_cache_repository.dart`
- `apps/lib/features/chat/data/repositories/chat_history_repository.dart`
- `apps/lib/features/calendar/data/repositories/calendar_repository.dart`
**Checks:**
- `flutter test apps/test/data/repositories/shared_repositories_test.dart`
- `flutter test apps/test/features/chat/data/repositories/chat_history_repository_test.dart`
- `flutter test apps/test/features/settings/data/repositories/user_profile_cache_repository_test.dart`
### Task C: Auth Boot Prewarm Gate
**Files:**
- `apps/lib/app/services/app_prewarm_orchestrator.dart`
- `apps/lib/app/router/app_router.dart`
- `apps/lib/features/auth/presentation/screens/auth_boot_screen.dart`
- `apps/lib/app/di/injection.dart`
**Checks:**
- `flutter test apps/test/app/services/app_prewarm_orchestrator_test.dart`
- `flutter test apps/test/app/router/app_router_redirect_test.dart`
### Task D: Regression Safety
**Checks:**
- `flutter analyze`
- Run all tests from Tasks A/B/C together before finalizing.
## Notes
- Any old path references from previous plan versions are obsolete.
- Notification/reminder data-interaction services are intentionally removed for separate rewrite.