Skip to main content

Data Relationships

Comprehensive relationship matrix for the TopLocs ecosystem

TopLocs implements a universal relations system that connects all entities through typed relationships. This document preserves the original relationship design and shows how it maps to the current Gun.js implementation.

Core Entity Types

  • Profile: User profiles representing different contexts (Sports, Work, Family, etc.)
  • Location: Geographic locations and places of interest
  • Interest: Topics, hobbies, activities, and areas of focus

Relationship Matrix

Profile-to-Profile Relations (n:m)

Social connections between users

Relation TypeDescriptionCurrent Implementation
FriendMutual friendship connectionrelations/{profileId}/friend/{friendId}
FollowAsymmetric following relationshiprelations/{profileId}/follow/{targetId}
FamilyFamily member connectionrelations/{profileId}/family/{familyId}
PartnerRomantic partnershiprelations/{profileId}/partner/{partnerId}
ColleagueProfessional relationshiprelations/{profileId}/colleague/{colleagueId}

Profile-to-Location Relations (n:m)

User's connection to places

Relation TypeSystem TypeDescriptionCurrent Implementation
CreatedSysUser created this locationrelations/{profileId}/created/{locationId}
FavoriteRelFavorite placerelations/{profileId}/favorite/{locationId}
CurrentRelCurrently at this locationrelations/{profileId}/current/{locationId}
BeenRelHas visited this locationrelations/{profileId}/been/{locationId}
Want to goRelPlans to visitrelations/{profileId}/want-to-go/{locationId}
CuriousRelInterested in visitingrelations/{profileId}/curious/{locationId}
ValueRelValues this locationrelations/{profileId}/value/{locationId}
SupportingRelSupports this locationrelations/{profileId}/supporting/{locationId}
LimitRelLimits interaction with locationrelations/{profileId}/limit/{locationId}
LivingRelLives at this locationrelations/{profileId}/living/{locationId}
WorkingRelWorks at this locationrelations/{profileId}/working/{locationId}
VisitingRelVisiting this locationrelations/{profileId}/visiting/{locationId}
TravelingRelTraveling to this locationrelations/{profileId}/traveling/{locationId}
AdminGovAdministrative controlrelations/{profileId}/admin/{locationId}

Profile-to-Interest Relations (n:m)

User's connection to topics and activities

Relation TypeSystem TypeDescriptionCurrent Implementation
CreatedSysUser created this interestrelations/{profileId}/created/{interestId}
IntoSysGeneral interestrelations/{profileId}/into/{interestId}
DoingRelActively practicingrelations/{profileId}/doing/{interestId}
ExpertRelExpert level knowledgerelations/{profileId}/expert/{interestId}
LearningRelCurrently learningrelations/{profileId}/learning/{interestId}
CuriousRelCurious to learn morerelations/{profileId}/curious/{interestId}
WatchingRelPassively followingrelations/{profileId}/watching/{interestId}
ValueRelValues this interestrelations/{profileId}/value/{interestId}
SupportingRelSupports this interestrelations/{profileId}/supporting/{interestId}
LimitRelLimits engagementrelations/{profileId}/limit/{interestId}
GivingRelGives/teaches this interestrelations/{profileId}/giving/{interestId}
ReceivingRelReceives/learns this interestrelations/{profileId}/receiving/{interestId}
AdminGovAdministrative controlrelations/{profileId}/admin/{interestId}

Location-to-Location Relations (n:m)

Geographic and hierarchical relationships

Relation TypeSystem TypeDescriptionCurrent Implementation
InRelOne location is within anotherrelations/{locationId}/in/{parentId}
ChildRelParent-child relationshiprelations/{locationId}/child/{childId}
IsACatCategorical relationshiprelations/{locationId}/category/{categoryId}

Interest-to-Interest Relations (n:m)

Topical and categorical relationships

Relation TypeSystem TypeDescriptionCurrent Implementation
Parent/ChildRelHierarchical interest relationshiprelations/{interestId}/child/{childId}
IsACatCategorical classificationrelations/{interestId}/category/{categoryId}
HasACatComposition relationshiprelations/{interestId}/has/{componentId}
IncludesGovGovernance inclusionrelations/{interestId}/includes/{includedId}

Three-Way Relations

Profile-Profile-Interest Trust (n:m:l)

Governance and trust relationships

Relation TypeDescriptionImplementation
TrustProfile A trusts Profile B on Interest Crelations/{profileA}/trust/{profileB}/{interestC}

This enables:

  • Liquid democracy: Delegate voting power to trusted experts
  • Scoped trust: Trust someone for specific topics only
  • Governance: Community decision-making based on trust networks

System Types Explained

Rel (Relationship)

User-defined relationships that can be created, modified, and deleted by users:

  • Express personal connections and preferences
  • Drive content discovery and recommendations
  • Enable social features and matching

Sys (System)

System-managed relationships created automatically:

  • Track object creation and ownership
  • Maintain data integrity and permissions
  • Enable core platform functionality

Cat (Category)

Categorical relationships for organization:

  • Create hierarchies and taxonomies
  • Enable filtering and search
  • Support content organization

Gov (Governance)

Governance relationships for community management:

  • Define administrative powers
  • Enable democratic processes
  • Support community self-governance

Gun.js Implementation

Current Storage Pattern

// Universal relations storage
gun.get('relations').get(fromId).get(relationType).get(toId).put(relationData);

// Example: Profile likes Location
gun.get('relations').get(profileId).get('favorite').get(locationId).put({
created: timestamp,
strength: 0.8,
public: true
});

Bidirectional Relations

Many relations are bidirectional and stored in both directions:

// Profile A friends Profile B
gun.get('relations').get(profileA).get('friend').get(profileB).put(relationData);
gun.get('relations').get(profileB).get('friend').get(profileA).put(relationData);

Relation Queries

// Get all locations a profile has visited
gun.get('relations').get(profileId).get('been').map().on((data, locationId) => {
// Process visited location
});

// Get all profiles interested in a topic
gun.get('relations').map().get('into').get(interestId).map().on((data, profileId) => {
// Process interested profile
});

Relationship Strength and Metadata

Relation Properties

Each relation can include metadata:

  • Strength: Numeric weight (0.0 to 1.0)
  • Created: Timestamp of relation creation
  • Updated: Last modification timestamp
  • Public: Visibility setting
  • Context: Additional contextual information

Example Relation Object

{
created: 1635724800000,
updated: 1635724800000,
strength: 0.9,
public: true,
context: "Met at local hiking group",
verified: true
}

Privacy and Visibility

Relation Visibility

  • Public: Visible to all users
  • Friends: Visible to friends only
  • Private: Visible to profile owner only
  • Community: Visible to specific community members

Privacy Controls

Users can control:

  • Which relations are visible to whom
  • Granular privacy settings per relation type
  • Bulk privacy controls for relation categories

Use Cases and Applications

Content Discovery

  • Interest-based recommendations: Find content based on interests
  • Location-based suggestions: Discover places based on location relations
  • Social recommendations: Find content through friend networks

Community Building

  • Expertise matching: Connect experts with learners
  • Local connections: Find nearby people with shared interests
  • Activity coordination: Organize events based on mutual interests

Governance and Trust

  • Democratic processes: Vote delegation through trust networks
  • Reputation systems: Build reputation through verified relations
  • Community management: Administrative roles based on trust

Future Enhancements

Planned Features

  • Temporal relations: Relations that change over time
  • Weighted aggregation: Combine relation strengths for recommendations
  • Relation verification: Proof of relationship validity
  • Bulk operations: Efficient management of large relation sets

Research Areas

  • Graph algorithms: Shortest path, centrality measures
  • Machine learning: Relation prediction and recommendation
  • Privacy-preserving: Zero-knowledge relation proofs
  • Scalability: Efficient storage and querying of large relation graphs

This comprehensive relationship system enables rich, contextual connections between all entities in the TopLocs ecosystem, supporting both social features and community governance while preserving user privacy and control.