π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
WrappedEngine structure
laurenspriem2bbd8388b24b
diff --git a/mobile/apps/photos/.docs/ente_wrapped_2025_engineering_plan.md b/mobile/apps/photos/.docs/ente_wrapped_2025_engineering_plan.mdindex 3911e5b159..659623c54a 100644--- a/mobile/apps/photos/.docs/ente_wrapped_2025_engineering_plan.md+++ b/mobile/apps/photos/.docs/ente_wrapped_2025_engineering_plan.md@@ -328,8 +328,15 @@ Open Decisions- Use `FullScreenMemory` vs custom viewer β create separate custom viewer for control, borrowing many elements from `FullScreenMemory` as a starting point.Milestones & Checklist-- [ ] Create `lib/services/wrapped/wrapped_engine.dart` with isolate compute stub-- [ ] Implement candidate builders (stats, people, places, aesthetics, curation, narrative)+- [x] Create `lib/services/wrapped/wrapped_engine.dart` with isolate compute stub+- [x] Implement candidate builders (stats, people, places, aesthetics, curation, narrative)+- [ ] Flesh out candidate builder implementations+ - [ ] StatsCandidateBuilder+ - [ ] PeopleCandidateBuilder+ - [ ] PlacesCandidateBuilder+ - [ ] AestheticsCandidateBuilder+ - [ ] CurationCandidateBuilder+ - [ ] NarrativeCandidateBuilder- [ ] Add selection/diversity + badge logic- [ ] Add `WrappedCacheService` (file-based JSON) + invalidation hooks- [ ] Add LocalSettings extension for resume/completediff --git a/mobile/apps/photos/lib/services/wrapped/candidate_builders.dart b/mobile/apps/photos/lib/services/wrapped/candidate_builders.dartnew file mode 100644index 0000000000..216d57d6c6--- /dev/null+++ b/mobile/apps/photos/lib/services/wrapped/candidate_builders.dart@@ -0,0 +1,107 @@+import "package:flutter/foundation.dart" show immutable;++import "models.dart";++/// Provides basic context details for candidate builders.+@immutable+class WrappedEngineContext {+ const WrappedEngineContext({+ required this.year,+ required this.now,+ });++ final int year;+ final DateTime now;+}++/// Contract for producing Wrapped candidate cards for a specific domain.+abstract class WrappedCandidateBuilder {+ const WrappedCandidateBuilder();++ String get debugLabel;++ Future<List<WrappedCard>> build(WrappedEngineContext context);+}++class StatsCandidateBuilder extends WrappedCandidateBuilder {+ const StatsCandidateBuilder();++ @override+ String get debugLabel => "stats";++ @override+ Future<List<WrappedCard>> build(WrappedEngineContext context) async {+ return <WrappedCard>[];+ }+}++class PeopleCandidateBuilder extends WrappedCandidateBuilder {+ const PeopleCandidateBuilder();++ @override+ String get debugLabel => "people";++ @override+ Future<List<WrappedCard>> build(WrappedEngineContext context) async {+ return <WrappedCard>[];+ }+}++class PlacesCandidateBuilder extends WrappedCandidateBuilder {+ const PlacesCandidateBuilder();++ @override+ String get debugLabel => "places";++ @override+ Future<List<WrappedCard>> build(WrappedEngineContext context) async {+ return <WrappedCard>[];+ }+}++class AestheticsCandidateBuilder extends WrappedCandidateBuilder {+ const AestheticsCandidateBuilder();++ @override+ String get debugLabel => "aesthetics";++ @override+ Future<List<WrappedCard>> build(WrappedEngineContext context) async {+ return <WrappedCard>[];+ }+}++class CurationCandidateBuilder extends WrappedCandidateBuilder {+ const CurationCandidateBuilder();++ @override+ String get debugLabel => "curation";++ @override+ Future<List<WrappedCard>> build(WrappedEngineContext context) async {+ return <WrappedCard>[];+ }+}++class NarrativeCandidateBuilder extends WrappedCandidateBuilder {+ const NarrativeCandidateBuilder();++ @override+ String get debugLabel => "narrative";++ @override+ Future<List<WrappedCard>> build(WrappedEngineContext context) async {+ return <WrappedCard>[];+ }+}++/// Registry of all candidate builders invoked by the engine.+const List<WrappedCandidateBuilder> wrappedCandidateBuilders =+ <WrappedCandidateBuilder>[+ StatsCandidateBuilder(),+ PeopleCandidateBuilder(),+ PlacesCandidateBuilder(),+ AestheticsCandidateBuilder(),+ CurationCandidateBuilder(),+ NarrativeCandidateBuilder(),+];diff --git a/mobile/apps/photos/lib/services/wrapped/models.dart b/mobile/apps/photos/lib/services/wrapped/models.dartnew file mode 100644index 0000000000..db5ce087f7--- /dev/null+++ b/mobile/apps/photos/lib/services/wrapped/models.dart@@ -0,0 +1,65 @@+import "package:flutter/foundation.dart" show immutable;++@immutable+class WrappedResult {+ WrappedResult({+ required List<WrappedCard> cards,+ required this.year,+ this.badgeKey,+ }) : cards = List<WrappedCard>.unmodifiable(cards);++ final List<WrappedCard> cards;+ final int year;+ final String? badgeKey;+}++@immutable+class WrappedCard {+ WrappedCard({+ required this.type,+ required this.title,+ this.subtitle,+ List<MediaRef> media = const <MediaRef>[],+ Map<String, Object?> meta = const <String, Object?>{},+ }) : media = List<MediaRef>.unmodifiable(media),+ meta = Map<String, Object?>.unmodifiable(meta);++ final WrappedCardType type;+ final String title;+ final String? subtitle;+ final List<MediaRef> media;+ final Map<String, Object?> meta;+}++@immutable+class MediaRef {+ const MediaRef(this.uploadedFileID);++ final int uploadedFileID;+}++enum WrappedCardType {+ statsTotals,+ statsVelocity,+ busiestDay,+ longestStreak,+ longestGap,+ topPerson,+ topThreePeople,+ groupVsSolo,+ newFaces,+ newPlaces,+ topCities,+ mostVisitedSpot,+ thenAndNow,+ yearInColor,+ monochrome,+ panoramas,+ biggestShot,+ top9Wow,+ favorites,+ albums,+ topEvents,+ bestOf25,+ badge,+}diff --git a/mobile/apps/photos/lib/services/wrapped/wrapped_engine.dart b/mobile/apps/photos/lib/services/wrapped/wrapped_engine.dartnew file mode 100644index 0000000000..288baf5f1c--- /dev/null+++ b/mobile/apps/photos/lib/services/wrapped/wrapped_engine.dart@@ -0,0 +1,67 @@+import "package:computer/computer.dart";+import "package:logging/logging.dart";++import "candidate_builders.dart";+import "models.dart";++final Logger _engineLogger = Logger("WrappedEngine");+final Logger _computeLogger = Logger("WrappedEngineIsolate");++/// Orchestrates the single-isolate computation pipeline for Ente Wrapped.+class WrappedEngine {+ const WrappedEngine._();++ /// Schedules the compute pipeline on a worker isolate.+ static Future<WrappedResult> compute({required int year}) async {+ final DateTime now = DateTime.now();+ _engineLogger.fine("Scheduling Wrapped compute for $year at $now");++ return await Computer.shared().compute(+ _wrappedComputeIsolate,+ param: <String, Object?>{+ "year": year,+ "now": now,+ },+ taskName: "wrapped_compute_$year",+ ) as WrappedResult;+ }+}++Future<WrappedResult> _wrappedComputeIsolate(+ Map<String, Object?> args,+) async {+ final int year = args["year"] as int;+ final DateTime now = args["now"] as DateTime;++ _computeLogger.fine("Wrapped compute isolate running for $year");++ final WrappedEngineContext context = WrappedEngineContext(year: year, now: now);+ final List<WrappedCard> cards = <WrappedCard>[];+ for (final WrappedCandidateBuilder builder in wrappedCandidateBuilders) {+ _computeLogger.finer("Running candidate builder ${builder.debugLabel}");+ final List<WrappedCard> builtCards = await builder.build(context);+ if (builtCards.isEmpty) {+ continue;+ }+ cards.addAll(builtCards);+ }++ if (cards.isEmpty) {+ cards.add(+ WrappedCard(+ type: WrappedCardType.badge,+ title: "Wrapped $year is on its way",+ subtitle: "Full story coming soon.",+ meta: <String, Object?>{+ "generatedAt": now.toIso8601String(),+ "isStub": true,+ },+ ),+ );+ }++ return WrappedResult(+ cards: cards,+ year: year,+ );+}