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.
