Follow Object

The Follow object represents a one-way relationship between users in the Replyke social features framework. Unlike connections, follows do not require mutual agreement and establish an immediate relationship similar to Twitter/X follows.

Properties

PropertyTypeDescription
idstringUnique identifier for the follow relationship (UUID)
projectIdstringIdentifier of the associated project (UUID)
followerIdstringID of the user who initiated the follow
followedIdstringID of the user being followed
createdAtDateTimestamp when the follow relationship was created

Characteristics

One-Way Relationship

  • Immediate Effect: No approval workflow required
  • Unidirectional: Following someone doesn’t create a mutual relationship
  • Public: Follow relationships are typically visible to others
  • Content Access: Following grants access to user’s content feed

Database Constraints

  • Unique Constraint: Prevents duplicate follows between same users
  • Self-Follow Prevention: Users cannot follow themselves
  • Cascade Deletion: Follow relationships are deleted when users are removed

User Model Associations

The Follow model creates two associations with the User model:

// User hasMany Follow as "following" (as follower)
User.hasMany(Follow, {
  foreignKey: "followerId",
  as: "following",
  onDelete: "CASCADE"
});
 
// User hasMany Follow as "followers" (as followed user)
User.hasMany(Follow, {
  foreignKey: "followedId",
  as: "followers",
  onDelete: "CASCADE"
});

API Endpoints

User-Centric Operations

  • POST /users/:userId/follow - Follow a user
  • GET /users/:userId/follow - Check follow status with user
  • DELETE /users/:userId/follow - Unfollow a user
  • GET /users/:userId/followers - Get followers of specific user
  • GET /users/:userId/followers-count - Get followers count for specific user
  • GET /users/:userId/following - Get who specific user follows
  • GET /users/:userId/following-count - Get following count for specific user

Follow-Centric Operations

  • GET /follows/following - List accounts I follow
  • GET /follows/followers - List accounts that follow me
  • GET /follows/following-count - Get my following count
  • GET /follows/followers-count - Get my followers count
  • DELETE /follows/:followId - Unfollow by follow ID

Usage Examples

Following a User

POST /users/user-123/follow
→ Creates Follow record with followerId=current-user, followedId=user-123

Checking Follow Status

GET /users/user-123/follow
→ Returns: { "isFollowing": true, "followId": "follow-uuid", "followedAt": "..." }

Getting User’s Followers

GET /users/user-123/followers
→ Returns paginated list of users following user-123

Business Rules

  1. No Self-Following: Users cannot follow themselves
  2. Unique Relationships: Only one follow record between any two users
  3. Immediate Effect: Follow relationships are created instantly
  4. Public Visibility: Follow relationships are generally public
  5. No Approval Required: Unlike connections, follows don’t need acceptance

Performance Considerations

  • Indexes: Optimized for queries by followerId, followedId, and projectId
  • Pagination: All list endpoints support pagination
  • Rate Limiting: Follow actions limited to 75 requests per 5 minutes
  • Caching: Consider caching follower/following counts for popular users

  • User: The users involved in the follow relationship
  • Connection: Bidirectional relationship alternative that requires mutual agreement
  • AppNotification: Notifications can be triggered for new follows