Designing a Temporary Activity-Partner Matching System: Data Model, Matching Strategy, Lifecycle, and Risk Governance
Temporary activity partners are people who agree to do a specific activity together—such as a meal, workout, or trip—around a shared interest or time window. These relationships are goal-limited and carry no fixed obligations. This article presents an engineering-oriented design for matching and managing such relationships. It defines three computable constraints: vertical domain, limited goal, and time boundary. It then describes a data model for user profiles and partner pairs, a two-stage matching strategy that combines inverted-index recall with tag, time, and region scoring, and a state-machine-based lifecycle for confirmation, completion, expiry, and cancellation. The article also covers boundary control and risk governance, including detection of paid companionship, rate limits, credit and reporting signals, and privacy and offline safety measures. It ends with observability metrics for evaluating matching precision, completion behavior, and early cancellation.
I. Background and Problem Definition
A temporary activity partner refers to a short-term companionship relationship formed around a specific interest, moment, or scenario. Its level of intimacy sits between that of friends and colleagues, and it carries no fixed relationship obligations. A meal partner agrees on the same meal; a fitness partner agrees on the same training slot; a travel partner agrees on the same itinerary. For product developers, the value of this relationship model lies in its clear objective, low cost, and ability to end at any time.
There are three common problems when implementing this type of feature.
The first is low matching precision. Recommending only by geographic location or age often produces candidates who do not match the user’s real needs, causing users to ignore recommendation results frequently.
The second is blurred boundaries. The relationship has no clear termination mechanism, making it difficult for users to exit gracefully and potentially causing psychological pressure.
The third is risk exposure. When temporary activity partners are used for paid companionship or paid group organizing, a lack of platform governance rules can lead to disputes and may also create personal safety issues.
This article breaks down these problems from an engineering perspective and provides reference approaches for the data model, matching strategy, lifecycle management, and risk governance. All weights, thresholds, and other numeric values in this article are examples; actual values need to be tuned against business data.
II. Abstracting the Core Characteristics
A temporary activity-partner relationship can be abstracted into three computable constraints.
- Vertical domain: Each relationship is bound to an explicit interest or scenario tag, such as “morning run,” “Sichuan cuisine,” or “weekend hiking.” The tag is the primary basis for matching and the reason the relationship exists.
- Limited goal: Each relationship has an explicit goal and termination condition, such as “complete three workouts this week” or “complete one trip.” Once the goal is achieved, the relationship naturally ends.
- Time boundary: Each relationship has a start and end time. After the time window expires, the relationship is automatically dissolved or enters an optional renewal process for both parties.
These three constraints determine the main direction of the system design. Matching needs to find the intersection of tags and time windows; relationships need a state machine to manage their lifecycle; and when a relationship ends, neither party should need to explain why, nor should the system require an explanation.
III. Data Model Design
The following data model covers both user profiles and relationship entities.
from dataclasses import dataclass, fieldfrom datetime import datetime, timezonefrom enum import Enumclass PairStatus(Enum):PENDING = "pending" # Initiated, awaiting confirmationACTIVE = "active" # Confirmed by both parties, relationship is activeCOMPLETED = "completed" # Goal achieved, ended normallyEXPIRED = "expired" # Time window exceeded, ended automaticallyCANCELLED = "cancelled" # Cancelled by either party@dataclassclass PartnerProfile:user_id: strtags: set[str] # Interest or scenario tagsavailability: list[tuple[datetime, datetime]] # Available time slots; should not overlapregion: str # Coarse-grained region, such as city or districtmax_active_pairs: int = 3 # Maximum number of simultaneously active relationships@dataclassclass PartnerPair:pair_id: struser_a: struser_b: strscene_tag: strwindow_start: datetimewindow_end: datetimegoal: str # Textual description of the limited goalstatus: PairStatus = PairStatus.PENDINGcreated_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
Several fields are designed for the following reasons.
regionstores only a coarse-grained region and does not store precise location, reducing privacy exposure.availabilityis used only during the matching phase; users do not need to display their complete schedule externally.max_active_pairslimits the number of relationships a single user can have at the same time, preventing relationship accumulation and avoiding excessive time occupation by temporary activity-partner relationships.goalis required and must contain a textual description. The clarity of the goal directly reflects the limited-commitment characteristic.
IV. Matching Strategy
Matching is divided into two steps: candidate recall and fine-grained scoring.
4.1 Candidate Recall
Calculating all pairwise matches is too expensive. In practice, inverted indexes are built for tags and regions. Candidates are first recalled by “same region and at least one shared tag,” and then enter the scoring phase. The recall phase does not calculate time because time matching has a higher computational cost and should be placed later.
4.2 Scoring Function
The scoring function consists of three parts: tag similarity, time overlap, and region consistency.
def jaccard(a: set[str], b: set[str]) -> float:"""Jaccard similarity between tag sets, in the range [0, 1]."""if not a or not b:return 0.0return len(a & b) / len(a | b)def overlap_hours(slots_a: list[tuple[datetime, datetime]],slots_b: list[tuple[datetime, datetime]],) -> float:"""Calculate the total overlap duration in hours between two sets of time slots.Assumes that time slots within each set do not overlap; otherwise,durations will be double-counted."""total = 0.0for a_start, a_end in slots_a:for b_start, b_end in slots_b:start = max(a_start, b_start)end = min(a_end, b_end)if end > start:total += (end - start).total_seconds() / 3600return totaldef match_score(x: PartnerProfile,y: PartnerProfile,min_hours: float = 1.0,full_hours: float = 4.0,) -> float:"""Return the match score between two users; 0 means no match."""if x.region != y.region:return 0.0tag_score = jaccard(x.tags, y.tags)if tag_score == 0.0:return 0.0hours = overlap_hours(x.availability, y.availability)if hours < min_hours:return 0.0# Once the overlap reaches full_hours, cap the time score at 1time_score = min(hours / full_hours, 1.0)return 0.7 * tag_score + 0.3 * time_score
The design notes are as follows.
- Hard filtering comes first: Different regions, no shared tags, and insufficient time overlap all return 0 directly. Hard filtering reduces unnecessary computation and ensures that recommendation results meet the most basic feasibility conditions.
- Tag weight is higher than time weight: Shared interests are the prerequisite for a temporary activity-partner relationship. Inconvenient time can be adjusted, but inconsistent interests cannot form stable companionship. Therefore, the tag weight is set to 0.7. This value is only an example.
- Time score is capped: Beyond a certain duration, additional overlap contributes limited improvement to match quality. Capping prevents users with long available time slots from gaining an excessive ranking advantage.
4.3 Tag Normalization
Tag quality directly affects matching performance. Common practices include building a tag dictionary and normalizing capitalization and full-width/half-width characters; merging synonyms in user input, for example, mapping “running” and “jogging” to the same tag; and limiting the number of tags per user to prevent tag stuffing from distorting similarity.
V. Relationship Lifecycle Management
Relationships need to be described by a state machine; otherwise, concurrent operations can easily produce illegal states, such as reactivating an expired relationship.
ALLOWED_TRANSITIONS: dict[PairStatus, set[PairStatus]] = {PairStatus.PENDING: {PairStatus.ACTIVE,PairStatus.CANCELLED,PairStatus.EXPIRED,},PairStatus.ACTIVE: {PairStatus.COMPLETED,PairStatus.EXPIRED,PairStatus.CANCELLED,},# COMPLETED, EXPIRED, and CANCELLED are terminal states; no further transitions are allowed}def transition(pair: PartnerPair, target: PairStatus) -> PartnerPair:allowed = ALLOWED_TRANSITIONS.get(pair.status, set())if target not in allowed:raise ValueError(f"Invalid state transition: {pair.status.value} -> {target.value}")pair.status = targetreturn pair
The main relationship flows are as follows.
- One party initiates, and the relationship enters PENDING.
- The other party confirms, and the relationship enters ACTIVE. If the other party rejects or does not respond before the timeout, the relationship enters CANCELLED or EXPIRED.
- Both parties complete the goal within the window, and the relationship enters COMPLETED.
- If the window ends without completion, the relationship enters EXPIRED.
Expiration processing requires a scheduled job. The job periodically scans ACTIVE relationships whose window_end is earlier than the current time and transitions them to EXPIRED. Every state transition should be written to an audit log, recording the operator, time, and previous state for dispute investigation.
VI. Boundary Control and Risk Governance
The boundary issue of the temporary activity-partner model is both a product issue and a compliance issue. The following measures can serve as a baseline approach.
6.1 Identifying Paid Companionship and Paid Group Organizing
The core characteristic of paid companionship is a direct link between service and compensation. The system can identify risk at two levels.
- Text layer: Apply keyword and semantic classification to initiation content and direct messages to identify quotes, payment on behalf, hourly charges, and similar expressions. When a match is found, route the case to manual review instead of banning directly, to reduce false positives.
- Transaction layer: Do not allow relationship parties to direct funds off-platform. Paid group activities should be required to use a traceable formal transaction process, and organizers should undergo qualification verification.
6.2 Rate Limits and Quotas
- Limit the number of match initiations per user per day to prevent mass solicitation or abuse by automated scripts.
- Use
max_active_pairsto limit the number of simultaneous relationships and prevent users from being passively drawn into multiple relationships. - Apply a cooldown limit to repeated short-term initiations between the same pair of users.
6.3 Credit Records and Reports
Record completion rate, cancellation rate, and reports as auxiliary signals for matching ranking. Two points need attention. First, cancellation is a normal operation and should not be treated directly as negative behavior; only high-frequency anomalies such as “unreasonable cancellation near the start of the window” may be counted. Second, credit scores must not be tied to personal character evaluation; they should be used only to assess platform risk.
6.4 Privacy and Offline Safety
- Display region information only down to the district level, not precise location.
- Use time slots only for matching calculation and do not externally display a complete schedule.
- For offline meeting scenarios, recommend public places by default and display basic safety tips.
- Provide a one-click reporting entry point and a quick path to end a relationship; ending a relationship should not require a reason.
VII. Observability and Evaluation Metrics
After launch, the following metrics need to be continuously observed to determine whether the approach is effective.
| Metric | Meaning | Purpose |
|---|---|---|
| Match acceptance rate | Share of recommended users who agree to confirm | Evaluate matching precision |
| Relationship completion rate | Number of COMPLETED relationships as a share of active relationships | Evaluate whether goal setting is reasonable |
| Early cancellation rate | Share of ACTIVE relationships cancelled voluntarily | — |
