Skip to main content

Recommendation Algorithm for the Dating App

The Dating app can use Firebase Functions and Firestore to generate compatible profiles for each user. The exact implementation depends on the package version, but the same operational rules apply: complete profile data, indexed queries, bounded recommendation sets, and careful cost controls.

Quick Answer

Recommendations are computed when a user profile becomes complete or when key preference fields change. The backend filters compatible users by preference, existing swipes, distance settings, and app-specific constraints, then writes a limited recommendation list for fast client reads.

Required Profile Data

The recommendation function usually needs fields such as:

DataPurpose
User idRecommendation owner and candidate identity.
Gender or preference fieldsCandidate compatibility.
LocationDistance filtering if enabled.
Search radiusMaximum distance for recommendations.
Age or birthdayAge filtering if enabled.
Profile completenessPrevent incomplete profiles from appearing.
PhotosImprove profile quality and prevent empty cards.

If recommendations are empty, first verify that enough test users have complete profiles with the fields your app expects.

Computation Flow

Typical backend flow:

  1. profile is created or updated;
  2. function checks whether required fields are present;
  3. function clears stale recommendations if needed;
  4. function builds a compatible user query;
  5. function excludes users already swiped, blocked, or matched;
  6. function applies distance and preference filters;
  7. function writes a bounded recommendations subcollection;
  8. app reads recommendations directly for a fast swipe screen.

The recommendation list is intentionally limited. A bounded list prevents one user from triggering unbounded writes or expensive reads.

Refreshing Recommendations

Many packages also refresh recommendations when the existing list gets low.

Example policy:

If recommendations count < threshold, compute another batch.

Tune the threshold and batch size for your product. Small values reduce cost but can make the swipe screen run out of profiles. Large values improve UX but increase Firestore reads/writes.

Firestore and Indexes

Recommendation queries can require composite indexes for fields such as:

  • profile completeness;
  • preference fields;
  • location/geohash fields;
  • age or birthday;
  • active/visible status;
  • blocked or deleted state.

If Firebase logs a missing index error, create the index from the Firebase error link or deploy firestore.indexes.json if the app package includes it.

Cost Controls

Before production:

  • limit recommendation batch size;
  • avoid recomputing on every minor profile update;
  • debounce or restrict profile fields that trigger recomputation;
  • exclude inactive, blocked, or deleted users early;
  • monitor Function invocations and Firestore reads/writes;
  • add budget alerts in Firebase/Google Cloud;
  • test with realistic user counts before launch.

Security and Privacy

Recommendations should not expose private user data. Verify that:

  • users can read only recommended public profile fields;
  • blocked users are excluded;
  • deleted or hidden profiles are excluded;
  • location precision is appropriate for the product;
  • server-side code owns expensive or sensitive filtering;
  • users cannot write their own recommendation results directly.

Verification Checklist

  • Complete profiles generate recommendations.
  • Incomplete profiles are excluded.
  • Existing swipes are excluded.
  • Blocked users are excluded.
  • Distance and preference filters work.
  • Recommendation count refreshes when low.
  • Missing indexes are deployed.
  • Function logs are clean during test swipes.

Troubleshooting

ProblemFix
New user has no recommendationsAdd more complete test profiles and check required fields.
Function does not runDeploy Functions and check trigger path, region, and logs.
Query fails with missing indexCreate the index from the Firebase error link or deploy indexes.
Recommendations include old swipesCheck swipe exclusion query and cleanup logic.
Costs are highReduce batch size, avoid repeated recompute triggers, and monitor reads/writes.

Next Steps