Table of Contents
Fetching ...

Building a Mastodon Compatible Java Server for ActivityPub

Sean Nian, Angela Huang, Ben Reed

TL;DR

This paper tackles the problem of understanding and enabling interoperability in the Fediverse by analyzing the ActivityPub protocol and Mastodon's implementation. The authors deconstruct the core ActivityPub mechanics (objects, activities, endpoints) and examine how Mastodon adapts them through its client API and instance-based federation. They implement Moth, a Mastodon-compatible server using Java Spring Boot and MongoDB, demonstrating the practical mapping between ActivityPub and Mastodon data models (Actors/Accounts, Notes/Statuses) and the required conversion logic. The work provides a concrete, accessible path for researchers to build and experiment with federated social servers and makes the code available on GitHub.

Abstract

ActivityPub is a decentralized social networking protocol that has gained significant attention from the media for its ability to communicate through the Fediverse, short for the federated web. Servers such as Mastodon implement the ActivityPub protocol to communicate over the Fediverse. In this paper, we deconstruct the core protocols used to build the distributed servers of the Fediverse. We explore Mastodon's complex implementation of ActivityPub and created our own Mastodon instance using Java Spring Boot and ActivityPub to interoperate with Mastodon servers.

Building a Mastodon Compatible Java Server for ActivityPub

TL;DR

This paper tackles the problem of understanding and enabling interoperability in the Fediverse by analyzing the ActivityPub protocol and Mastodon's implementation. The authors deconstruct the core ActivityPub mechanics (objects, activities, endpoints) and examine how Mastodon adapts them through its client API and instance-based federation. They implement Moth, a Mastodon-compatible server using Java Spring Boot and MongoDB, demonstrating the practical mapping between ActivityPub and Mastodon data models (Actors/Accounts, Notes/Statuses) and the required conversion logic. The work provides a concrete, accessible path for researchers to build and experiment with federated social servers and makes the code available on GitHub.

Abstract

ActivityPub is a decentralized social networking protocol that has gained significant attention from the media for its ability to communicate through the Fediverse, short for the federated web. Servers such as Mastodon implement the ActivityPub protocol to communicate over the Fediverse. In this paper, we deconstruct the core protocols used to build the distributed servers of the Fediverse. We explore Mastodon's complex implementation of ActivityPub and created our own Mastodon instance using Java Spring Boot and ActivityPub to interoperate with Mastodon servers.

Paper Structure

This paper contains 20 sections, 5 figures, 1 table.

Figures (5)

  • Figure 1: Example Mastodon post.
  • Figure 2: Illustrates how the two types of ActivityPub protocols are used to enable communication between the Fediverse, ActivityPub servers, and user clients.
  • Figure 3: Depicts user interaction with the Mastodon Client and how the Mastodon instance interacts with the rest of the Fediverse with the ActivityPub protocol.
  • Figure 4: Mastodon Status serialized in JSON converted from a received Note
  • Figure 5: A Mastodon converted Activity serialized in JSON received from another Mastodon instance