Click Below to Get the Code

Browse, clone, and build from real-world templates powered by Harper.
Tutorial
GitHub Logo

How to Build a Social Graph Service (Follow/Unfollow, Newsfeed) via Harper's HTTP API

Simplify social app development with Harper’s unified architecture. Database, cache, and real-time updates run together for faster, seamless user experiences.
Tutorial

How to Build a Social Graph Service (Follow/Unfollow, Newsfeed) via Harper's HTTP API

By
Nenne Nwodo
August 6, 2025
By
Nenne Nwodo
August 6, 2025
By
Nenne Nwodo
August 6, 2025
August 6, 2025
Simplify social app development with Harper’s unified architecture. Database, cache, and real-time updates run together for faster, seamless user experiences.
Nenne Nwodo
Developer Relations

Building social features with traditional stacks means dealing with complexity that scales exponentially. You start with a simple database and API server. Then you need caching for performance, so you add Redis. Real-time notifications require a message broker like Kafka. Load balancing needs session stores. Each component solves a specific problem, but now you're managing data consistency across multiple systems, debugging network timeouts between services, and writing integration code that's often more complex than your actual business logic.

The architecture works, obviously. Twitter and Facebook built massive platforms this way. But the operational overhead is enormous. Every new feature requires coordinating updates across multiple services. A simple follow action might update three databases, invalidate four cache keys, and publish two events. When something breaks at 3 AM, you're troubleshooting whether it's a database lock, a cache miss, or a message queue backup.

Harper changes the game completely. Instead of orchestrating a symphony of separate services, everything runs in one process. Database, cache, messaging, application logic, all fused together. This approach eliminates the network overhead and coordination complexity that makes traditional social architectures so brittle.

The Real Cost of Distributed Social Architecture

The hidden expense isn't just in infrastructure costs or development time. It's in the cognitive load of maintaining consistency across systems that were never designed to work together. Your follow service needs to know about your notification service. Your feed generator needs to coordinate with your cache invalidation logic. Your real-time updates need to stay synchronized with your database writes.

Engineers spend more time writing glue code between services than building actual features. A notification that someone liked your post involves updating counters in the database, clearing cached feed data, publishing events to subscribers, and hoping all these operations complete successfully. When they don't, debugging becomes an exercise in distributed systems archaeology.

Setting Up Your Social Graph Schema

Harper uses GraphQL syntax to define your data model, but here's the cool part, it automatically generates REST endpoints from your schema. No more writing boilerplate API routes.

type User @table @export {
  id: ID @primaryKey
  username: String @indexed
  email: String @indexed
  displayName: String
  bio: String
  avatar: String
  createdAt: String
  followingIds: [ID] @indexed
  followerIds: [ID] @indexed
  followers: [User] @relationship(from: followerIds)
  following: [User] @relationship(from: followingIds)
}

type Post @table @export {
  id: ID @primaryKey
  authorId: ID @indexed
  content: String
  imageUrl: String
  createdAt: String
  likesCount: Int
  commentsCount: Int
  author: User @relationship(from: authorId)
}

type Follow @table @export {
  id: ID @primaryKey
  followerId: ID @indexed
  followeeId: ID @indexed
  createdAt: String
  follower: User @relationship(from: followerId)
  followee: User @relationship(from: followeeId)
}

The @export directive is doing the heavy lifting here. As soon as you define this schema, Harper creates REST endpoints at /User/, /Post/, and /Follow/. The @relationship directive sets up joins that actually work fast because everything is in the same process.

Writing API controllers for basic CRUD operations becomes unnecessary. The schema definition handles all the boilerplate.

Building Follow/Unfollow That Actually Works

Here's how clean the follow functionality becomes:

POST /Follow/
Content-Type: application/json

{
  "followerId": "user123",
  "followeeId": "user456",
  "createdAt": "2024-08-05T10:30:00Z"
}

DELETE /Follow/follow_id_here

What's happening under the hood is beautiful. That POST request doesn't just insert a record. Harper is simultaneously updating any relevant caches, notifying real-time subscribers, and keeping everything consistent. In a traditional setup, you'd need custom code to coordinate all this. Harper handles it automatically.

Building Efficient Newsfeeds

Building newsfeeds used to mean complex caching strategies, background jobs, and crossing your fingers that everything stayed in sync. Harper makes it straightforward with its query parameters:

GET /Follow/?followerId=user123&limit=1000
GET /Post/?authorId=user456&authorId=user789&sort=createdAt&order=desc&limit=20
GET /Post/?authorId=user456&likesCount=gt=10&createdAt=ge=2024-08-01T00:00:00Z

These might look like multiple database calls, but remember - everything is happening in the same process. No network latency between these operations. Harper's query engine can optimize these requests in ways that separate services never could.

The syntax Harper uses for querying is actually pretty powerful. You can build complex filters for engagement-based feeds, content type preferences, whatever your algorithm needs.

Real-Time Features

Harper has WebSockets, MQTT, and Server-Sent Events built right into the database. The MQTT topics map directly to your database resources:

SUBSCRIBE Follow/user123
ws://localhost:9926/User/user123

Subscribe to Follow/${userId} and you get notified whenever someone follows or unfollows that user. No separate message broker to maintain, no complex routing logic.

Why This Architecture Matters

Harper's single-process architecture addresses the core challenges of social platform development: performance, complexity, and operational overhead. Instead of managing multiple services that need to stay synchronized, you get sub-millisecond response times from a single system that handles data, caching, and real-time updates together.

The development experience reflects this simplicity. Schema definitions automatically generate REST endpoints. Real-time features work without separate message brokers. Caching happens transparently at the storage level. You spend time building social features instead of debugging distributed system edge cases.

For social applications where user engagement depends on instant feedback and real-time interactions, Harper's performance characteristics translate directly into better user experiences. Follow buttons feel responsive. Notifications arrive immediately. Feeds load without delays that cause users to abandon interactions.

The architecture scales naturally through Harper's mesh networking, allowing global distribution while maintaining the performance benefits of the unified system. Social platforms can serve users worldwide without the complexity typically associated with distributed architectures.

Building social features with traditional stacks means dealing with complexity that scales exponentially. You start with a simple database and API server. Then you need caching for performance, so you add Redis. Real-time notifications require a message broker like Kafka. Load balancing needs session stores. Each component solves a specific problem, but now you're managing data consistency across multiple systems, debugging network timeouts between services, and writing integration code that's often more complex than your actual business logic.

The architecture works, obviously. Twitter and Facebook built massive platforms this way. But the operational overhead is enormous. Every new feature requires coordinating updates across multiple services. A simple follow action might update three databases, invalidate four cache keys, and publish two events. When something breaks at 3 AM, you're troubleshooting whether it's a database lock, a cache miss, or a message queue backup.

Harper changes the game completely. Instead of orchestrating a symphony of separate services, everything runs in one process. Database, cache, messaging, application logic, all fused together. This approach eliminates the network overhead and coordination complexity that makes traditional social architectures so brittle.

The Real Cost of Distributed Social Architecture

The hidden expense isn't just in infrastructure costs or development time. It's in the cognitive load of maintaining consistency across systems that were never designed to work together. Your follow service needs to know about your notification service. Your feed generator needs to coordinate with your cache invalidation logic. Your real-time updates need to stay synchronized with your database writes.

Engineers spend more time writing glue code between services than building actual features. A notification that someone liked your post involves updating counters in the database, clearing cached feed data, publishing events to subscribers, and hoping all these operations complete successfully. When they don't, debugging becomes an exercise in distributed systems archaeology.

Setting Up Your Social Graph Schema

Harper uses GraphQL syntax to define your data model, but here's the cool part, it automatically generates REST endpoints from your schema. No more writing boilerplate API routes.

type User @table @export {
  id: ID @primaryKey
  username: String @indexed
  email: String @indexed
  displayName: String
  bio: String
  avatar: String
  createdAt: String
  followingIds: [ID] @indexed
  followerIds: [ID] @indexed
  followers: [User] @relationship(from: followerIds)
  following: [User] @relationship(from: followingIds)
}

type Post @table @export {
  id: ID @primaryKey
  authorId: ID @indexed
  content: String
  imageUrl: String
  createdAt: String
  likesCount: Int
  commentsCount: Int
  author: User @relationship(from: authorId)
}

type Follow @table @export {
  id: ID @primaryKey
  followerId: ID @indexed
  followeeId: ID @indexed
  createdAt: String
  follower: User @relationship(from: followerId)
  followee: User @relationship(from: followeeId)
}

The @export directive is doing the heavy lifting here. As soon as you define this schema, Harper creates REST endpoints at /User/, /Post/, and /Follow/. The @relationship directive sets up joins that actually work fast because everything is in the same process.

Writing API controllers for basic CRUD operations becomes unnecessary. The schema definition handles all the boilerplate.

Building Follow/Unfollow That Actually Works

Here's how clean the follow functionality becomes:

POST /Follow/
Content-Type: application/json

{
  "followerId": "user123",
  "followeeId": "user456",
  "createdAt": "2024-08-05T10:30:00Z"
}

DELETE /Follow/follow_id_here

What's happening under the hood is beautiful. That POST request doesn't just insert a record. Harper is simultaneously updating any relevant caches, notifying real-time subscribers, and keeping everything consistent. In a traditional setup, you'd need custom code to coordinate all this. Harper handles it automatically.

Building Efficient Newsfeeds

Building newsfeeds used to mean complex caching strategies, background jobs, and crossing your fingers that everything stayed in sync. Harper makes it straightforward with its query parameters:

GET /Follow/?followerId=user123&limit=1000
GET /Post/?authorId=user456&authorId=user789&sort=createdAt&order=desc&limit=20
GET /Post/?authorId=user456&likesCount=gt=10&createdAt=ge=2024-08-01T00:00:00Z

These might look like multiple database calls, but remember - everything is happening in the same process. No network latency between these operations. Harper's query engine can optimize these requests in ways that separate services never could.

The syntax Harper uses for querying is actually pretty powerful. You can build complex filters for engagement-based feeds, content type preferences, whatever your algorithm needs.

Real-Time Features

Harper has WebSockets, MQTT, and Server-Sent Events built right into the database. The MQTT topics map directly to your database resources:

SUBSCRIBE Follow/user123
ws://localhost:9926/User/user123

Subscribe to Follow/${userId} and you get notified whenever someone follows or unfollows that user. No separate message broker to maintain, no complex routing logic.

Why This Architecture Matters

Harper's single-process architecture addresses the core challenges of social platform development: performance, complexity, and operational overhead. Instead of managing multiple services that need to stay synchronized, you get sub-millisecond response times from a single system that handles data, caching, and real-time updates together.

The development experience reflects this simplicity. Schema definitions automatically generate REST endpoints. Real-time features work without separate message brokers. Caching happens transparently at the storage level. You spend time building social features instead of debugging distributed system edge cases.

For social applications where user engagement depends on instant feedback and real-time interactions, Harper's performance characteristics translate directly into better user experiences. Follow buttons feel responsive. Notifications arrive immediately. Feeds load without delays that cause users to abandon interactions.

The architecture scales naturally through Harper's mesh networking, allowing global distribution while maintaining the performance benefits of the unified system. Social platforms can serve users worldwide without the complexity typically associated with distributed architectures.

Simplify social app development with Harper’s unified architecture. Database, cache, and real-time updates run together for faster, seamless user experiences.

Download

White arrow pointing right
Simplify social app development with Harper’s unified architecture. Database, cache, and real-time updates run together for faster, seamless user experiences.

Download

White arrow pointing right
Simplify social app development with Harper’s unified architecture. Database, cache, and real-time updates run together for faster, seamless user experiences.

Download

White arrow pointing right

Explore Recent Resources

Tutorial
GitHub Logo

Real-Time Pub/Sub Without the Stack

Explore a real-time pub/sub architecture where MQTT, WebSockets, Server-Sent Events, and REST work together with persistent data storage in one end-to-end system, enabling real-time interoperability, stateful messaging, and simplified service-to-device and browser communication.
Harper Learn
Tutorial
Explore a real-time pub/sub architecture where MQTT, WebSockets, Server-Sent Events, and REST work together with persistent data storage in one end-to-end system, enabling real-time interoperability, stateful messaging, and simplified service-to-device and browser communication.
A man with short dark hair, glasses, and a goatee smiles slightly, wearing a black shirt in front of a nature background.
Ivan R. Judson, Ph.D.
Distinguished Solution Architect
Tutorial

Real-Time Pub/Sub Without the Stack

Explore a real-time pub/sub architecture where MQTT, WebSockets, Server-Sent Events, and REST work together with persistent data storage in one end-to-end system, enabling real-time interoperability, stateful messaging, and simplified service-to-device and browser communication.
Ivan R. Judson, Ph.D.
Jan 2026
Tutorial

Real-Time Pub/Sub Without the Stack

Explore a real-time pub/sub architecture where MQTT, WebSockets, Server-Sent Events, and REST work together with persistent data storage in one end-to-end system, enabling real-time interoperability, stateful messaging, and simplified service-to-device and browser communication.
Ivan R. Judson, Ph.D.
Tutorial

Real-Time Pub/Sub Without the Stack

Explore a real-time pub/sub architecture where MQTT, WebSockets, Server-Sent Events, and REST work together with persistent data storage in one end-to-end system, enabling real-time interoperability, stateful messaging, and simplified service-to-device and browser communication.
Ivan R. Judson, Ph.D.
News
GitHub Logo

Harper Recognized on Built In’s 2026 Best Places to Work in Colorado Lists

Harper is honored as a Built In 2026 Best Startup to Work For and Best Place to Work in Colorado, recognizing its people-first culture, strong employee experience, and values of accountability, authenticity, empowerment, focus, and transparency that help teams thrive and grow together.
Announcement
News
Harper is honored as a Built In 2026 Best Startup to Work For and Best Place to Work in Colorado, recognizing its people-first culture, strong employee experience, and values of accountability, authenticity, empowerment, focus, and transparency that help teams thrive and grow together.
Colorful geometric illustration of a dog's head resembling folded paper art in shades of teal and pink.
Harper
News

Harper Recognized on Built In’s 2026 Best Places to Work in Colorado Lists

Harper is honored as a Built In 2026 Best Startup to Work For and Best Place to Work in Colorado, recognizing its people-first culture, strong employee experience, and values of accountability, authenticity, empowerment, focus, and transparency that help teams thrive and grow together.
Harper
Jan 2026
News

Harper Recognized on Built In’s 2026 Best Places to Work in Colorado Lists

Harper is honored as a Built In 2026 Best Startup to Work For and Best Place to Work in Colorado, recognizing its people-first culture, strong employee experience, and values of accountability, authenticity, empowerment, focus, and transparency that help teams thrive and grow together.
Harper
News

Harper Recognized on Built In’s 2026 Best Places to Work in Colorado Lists

Harper is honored as a Built In 2026 Best Startup to Work For and Best Place to Work in Colorado, recognizing its people-first culture, strong employee experience, and values of accountability, authenticity, empowerment, focus, and transparency that help teams thrive and grow together.
Harper
Comparison
GitHub Logo

Harper vs. Standard Microservices: Performance Comparison Benchmark

A detailed performance benchmark comparing a traditional microservices architecture with Harper’s unified runtime. Using a real, fully functional e-commerce application, this report examines latency, scalability, and architectural overhead across homepage, category, and product pages, highlighting the real-world performance implications between two different styles of distributed systems.
Comparison
A detailed performance benchmark comparing a traditional microservices architecture with Harper’s unified runtime. Using a real, fully functional e-commerce application, this report examines latency, scalability, and architectural overhead across homepage, category, and product pages, highlighting the real-world performance implications between two different styles of distributed systems.
Person with short dark hair and moustache, wearing a colorful plaid shirt, smiling outdoors in a forested mountain landscape.
Aleks Haugom
Senior Manager of GTM & Marketing
Comparison

Harper vs. Standard Microservices: Performance Comparison Benchmark

A detailed performance benchmark comparing a traditional microservices architecture with Harper’s unified runtime. Using a real, fully functional e-commerce application, this report examines latency, scalability, and architectural overhead across homepage, category, and product pages, highlighting the real-world performance implications between two different styles of distributed systems.
Aleks Haugom
Dec 2025
Comparison

Harper vs. Standard Microservices: Performance Comparison Benchmark

A detailed performance benchmark comparing a traditional microservices architecture with Harper’s unified runtime. Using a real, fully functional e-commerce application, this report examines latency, scalability, and architectural overhead across homepage, category, and product pages, highlighting the real-world performance implications between two different styles of distributed systems.
Aleks Haugom
Comparison

Harper vs. Standard Microservices: Performance Comparison Benchmark

A detailed performance benchmark comparing a traditional microservices architecture with Harper’s unified runtime. Using a real, fully functional e-commerce application, this report examines latency, scalability, and architectural overhead across homepage, category, and product pages, highlighting the real-world performance implications between two different styles of distributed systems.
Aleks Haugom
Tutorial
GitHub Logo

A Simpler Real-Time Messaging Architecture with MQTT, WebSockets, and SSE

Learn how to build a unified real-time backbone using Harper with MQTT, WebSockets, and Server-Sent Events. This guide shows how to broker messages, fan out real-time data, and persist events in one runtime—simplifying real-time system architecture for IoT, dashboards, and event-driven applications.
Harper Learn
Tutorial
Learn how to build a unified real-time backbone using Harper with MQTT, WebSockets, and Server-Sent Events. This guide shows how to broker messages, fan out real-time data, and persist events in one runtime—simplifying real-time system architecture for IoT, dashboards, and event-driven applications.
A man with short dark hair, glasses, and a goatee smiles slightly, wearing a black shirt in front of a nature background.
Ivan R. Judson, Ph.D.
Distinguished Solution Architect
Tutorial

A Simpler Real-Time Messaging Architecture with MQTT, WebSockets, and SSE

Learn how to build a unified real-time backbone using Harper with MQTT, WebSockets, and Server-Sent Events. This guide shows how to broker messages, fan out real-time data, and persist events in one runtime—simplifying real-time system architecture for IoT, dashboards, and event-driven applications.
Ivan R. Judson, Ph.D.
Dec 2025
Tutorial

A Simpler Real-Time Messaging Architecture with MQTT, WebSockets, and SSE

Learn how to build a unified real-time backbone using Harper with MQTT, WebSockets, and Server-Sent Events. This guide shows how to broker messages, fan out real-time data, and persist events in one runtime—simplifying real-time system architecture for IoT, dashboards, and event-driven applications.
Ivan R. Judson, Ph.D.
Tutorial

A Simpler Real-Time Messaging Architecture with MQTT, WebSockets, and SSE

Learn how to build a unified real-time backbone using Harper with MQTT, WebSockets, and Server-Sent Events. This guide shows how to broker messages, fan out real-time data, and persist events in one runtime—simplifying real-time system architecture for IoT, dashboards, and event-driven applications.
Ivan R. Judson, Ph.D.
Podcast
GitHub Logo

Turn Browsing into Buying with Edge AI

Discover how Harper’s latest features streamline development, boost performance, and simplify integration. This technical showcase breaks down real-world workflows, powerful updates, and practical tips for building faster, smarter applications.
Select*
Podcast
Discover how Harper’s latest features streamline development, boost performance, and simplify integration. This technical showcase breaks down real-world workflows, powerful updates, and practical tips for building faster, smarter applications.
Person with short hair wearing a light blue patterned shirt, smiling widely outdoors with blurred greenery and trees in the background.
Austin Akers
Head of Developer Relations
Podcast

Turn Browsing into Buying with Edge AI

Discover how Harper’s latest features streamline development, boost performance, and simplify integration. This technical showcase breaks down real-world workflows, powerful updates, and practical tips for building faster, smarter applications.
Austin Akers
Dec 2025
Podcast

Turn Browsing into Buying with Edge AI

Discover how Harper’s latest features streamline development, boost performance, and simplify integration. This technical showcase breaks down real-world workflows, powerful updates, and practical tips for building faster, smarter applications.
Austin Akers
Podcast

Turn Browsing into Buying with Edge AI

Discover how Harper’s latest features streamline development, boost performance, and simplify integration. This technical showcase breaks down real-world workflows, powerful updates, and practical tips for building faster, smarter applications.
Austin Akers