Skip to main content

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


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:

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

Checking Follow Status

Getting User’s Followers


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