A REST API service for social listening and monitoring of ActivityPub/Fediverse instances. Monitor and analyze content from federated social networks such as Friendica, Mastodon, Lemmy, PeerTube, GNU social, Pleroma and other ActivityPub-compatible platforms.
ActivityPub Listener is a Spring Boot-based service that enables organizations to:
- Monitor keywords, accounts, instances, and regions across Fediverse instances
- Collect and analyze ActivityPub activities in real-time
- Retrieve analytics and insights from monitored content
- Manage monitoring configurations via REST API
Target Platforms: ActivityPub/Fediverse instances only (Mastodon, Lemmy, PeerTube, etc.)
Excluded Platforms: Commercial social networks (Twitter/X, Facebook, Instagram, LinkedIn, TikTok)
- CRUD Operations: Create, read, update, and delete monitoring configurations
- Multiple Monitor Types:
- Keyword-based monitoring
- Account/profile analysis
- Regional/geographic monitoring
- Managed accounts and pages
- Lifecycle Management: Approval workflow, pause/resume functionality
- Multi-Instance Support: Monitor across multiple Fediverse servers simultaneously
- Protocol Compliance: Full W3C ActivityPub 1.0 specification support
- Federation: Connect to and collect data from any ActivityPub-compatible instance
- Activity Collection: Monitor Create, Update, Delete, Announce, Like, and other activities
- Actor Tracking: Track users, groups, and organizations across instances
- WebFinger Discovery: Automatic actor and instance discovery
- Real-time Streaming: Kafka-based real-time data streaming
- Social Listening Data: Retrieve analytics and metrics for monitors
- Widget Support: Various data visualization widgets (engagements, posts, topics, sentiment, etc.)
- Advanced Filtering: Filter by topics, sentiment, languages, accounts, and more
- Date Range Queries: Flexible date range filtering
- RESTful API: Comprehensive REST API with OpenAPI documentation
- Message Queue Integration: Kafka for async processing and real-time updates
- Database: MongoDB for persistent storage
- Authentication: JWT-based authentication and authorization
- Rate Limiting: Per-instance rate limiting with exponential backoff
- Health Monitoring: Instance health checks and monitoring
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Client Applications β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β HTTP/REST API
β
ββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββ
β ActivityPub Listener Service (Spring Boot) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β REST API Controllers β β
β β Business Logic Layer β β
β β ActivityPub Integration Layer β β
β β Data Access Layer (JPA) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββ¬ββββββββββββββββββββ¬ββββββββββββββββββββ¬βββββββββββββββ
β β β
ββββββββΌβββββββ ββββββββββΌβββββββββ ββββββββΌβββββββββββββββ
β Database β β Message Queue β β Fediverse Instances β
β (MongoDB) β β (Kafka) β β - mastodon.social β
β β β β β - lemmy.ml β
β β β β β - peertube.io β
βββββββββββββββ βββββββββββββββββββ βββββββββββββββββββββββ
- Java: 17 or higher (LTS)
- Spring Boot: 3.2.x
- Spring Web: REST API
- Spring Data JPA: Database access
- Spring Kafka: Kafka integration
- activityPub4j: W3C ActivityPub implementation for Java/Spring Boot
- Mastodon4J: Mastodon API client library
- BigBone: Alternative Mastodon client (if needed)
- MongoDB: 7.0+ (primary database)
- Apache Kafka: 3.5+ (message queue)
- Jackson: JSON processing
- Bean Validation: Input validation
- Lombok: Reduce boilerplate
- JWT: Authentication
- JUnit 5 + Mockito: Testing
- Java 17 or higher
- Maven 3.8+ or Gradle 7+
- MongoDB 7.0+
- Apache Kafka 3.5+ (with Zookeeper)
- Docker & Docker Compose (optional, for local development)
-
Clone the repository
git clone <repository-url> cd ActivityPubListener
-
Set up environment variables
cp .env.example .env # Edit .env with your configuration -
Start dependencies with Docker Compose
docker-compose up -d
This starts MongoDB, Zookeeper, and Kafka containers.
-
Build and run the application
./mvnw spring-boot:run # or ./gradlew bootRun -
Verify the service is running
curl -H "API-Version: v1" http://localhost:8080/api/actuator/health
Key environment variables:
# Database
MONGODB_URI=mongodb://localhost:27017/activitypub_listener
MONGODB_DATABASE=activitypub_listener
# Kafka
KAFKA_BOOTSTRAP_SERVERS=localhost:9092
KAFKA_CONSUMER_GROUP_ID=activitypub-listener
# ActivityPub
ACTIVITYPUB_USER_AGENT=ActivityPubListener/1.0
ACTIVITYPUB_DEFAULT_RATE_LIMIT=300
# JWT
JWT_PUBLIC_KEY=your_jwt_public_key
JWT_ISSUER=AMRITECHhttp://localhost:8080/api
All endpoints use header-based versioning. Include the API-Version header in your requests:
API-Version: v1If no version header is provided, the API defaults to v1.
All endpoints require JWT authentication:
Authorization: Bearer <jwt_token>POST /api/monitors
API-Version: v1
Content-Type: application/json
{
"name": "Brand Monitoring",
"monitor_type_id": 1,
"product_id": 1,
"data_sources": [1],
"monitor_options": {
"KEYWORD": {
"MASTODON": {
"keywords": "brand, product",
"spam_keywords": "spam, test"
}
}
},
"languages": "en,ar",
"exact_search": false
}GET /api/monitors?page=1&per_page=10&search=brand
API-Version: v1GET /api/monitors/{id}
API-Version: v1PUT /api/monitors/{id}
API-Version: v1
Content-Type: application/jsonDELETE /api/monitors/{id}
API-Version: v1POST /api/monitors/{id}/pause
API-Version: v1
POST /api/monitors/{id}/resume
API-Version: v1POST /api/social-listening/data
API-Version: v1
Content-Type: application/json
{
"monitor_id": 123,
"data_source": "MASTODON",
"page_name": "account_page",
"start_date": 1706352000,
"end_date": 1706438400,
"filters": {
"topics": [1, 2],
"sentiment": ["positive"],
"languages": ["en"]
},
"widgets_names": ["engagements", "posts", "topics"],
"page_number": 1
}GET /api/social-listening/widgets?monitor_id=123&data_source=MASTODON&page_name=account_page
API-Version: v1GET /api/instances
API-Version: v1GET /api/actors/discover?resource=acct:[email protected]
API-Version: v1POST /api/actors/discover?resource=... is also supported for backward compatibility.
GET /api/actors/{actor_id}
API-Version: v1GET /api/actors/{actor_id}/activities?page=1&per_page=20
API-Version: v1POST /api/actors/{actor_id}/poll?monitorId=optional
API-Version: v1GET /api/instances
API-Version: v1Optional query: ?paged=true&page=1&per_page=20
GET /api/instances/{id}/health
API-Version: v1Monitor content containing specific keywords across Fediverse instances.
Use Cases:
- Brand mention tracking
- Topic monitoring
- Trend analysis
Monitor specific users and their activities.
Use Cases:
- Competitor monitoring
- Influencer tracking
- Community analysis
Monitor content based on geographic regions (if location data is available).
Use Cases:
- Geographic trend analysis
- Regional sentiment monitoring
src/
βββ main/
β βββ java/
β β βββ com/activitypub/listener/
β β βββ ActivityPubListenerApplication.java
β β βββ config/
β β βββ controller/
β β βββ service/
β β βββ repository/
β β βββ model/
β β βββ dto/
β β βββ exception/
β β βββ activitypub/
β βββ resources/
β βββ application.properties
β βββ db/migration/
βββ test/
./mvnw test
# or
./gradlew test- Follow Java coding conventions
- Use Lombok to reduce boilerplate
- Write comprehensive unit and integration tests
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Write tests for new features
- Follow the existing code style
- Update documentation as needed
- Ensure all tests pass before submitting
See LICENSE file for details.
- Rate Limiting: Each Fediverse instance has different rate limits. The service implements per-instance rate limiting, but aggressive monitoring may hit limits.
- Content Format: ActivityPub content may be in HTML or Markdown. Content extraction and normalization may be needed.
- Federation Delays: Activities may arrive with delays due to federation. The service handles out-of-order activities.
- Instance Diversity: Different ActivityPub implementations (Mastodon, Lemmy, PeerTube) may require different handling.
- Project specification and planning
- Phase 1: Foundation & Core Infrastructure β
- Spring Boot project setup with Maven
- Database schema with MongoDB collections
- JPA entities and repositories (9 entities, 7 repositories)
- REST API for monitor management (7 endpoints)
- ActivityPub client integration (WebFinger, actor discovery)
- Docker Compose with MongoDB and Kafka
- Error handling and validation
- Phase 2: ActivityPub Data Collection β
- ActivityPub polling implementation (outbox, pagination, ActivityStreams parser)
- Data collection (OutboxPollingService, CollectedActivity, Kafka activities topic)
- Kafka integration for activity streaming and tracker config (tracker-new)
- Instance management (list, CRUD, health check)
- API alignment: GET /api/actors/discover, GET /api/actors/{id}/activities, POST /api/actors/{id}/poll
- Phase 3: Monitor Types & Business Logic β
- Keyword monitor (matching + spam filtering via ActivityFilterService)
- Account analysis monitor (follow/excluded accounts)
- Regional monitor (MBR placeholder; ActivityFilterService)
- Monitor lifecycle (approve/reject endpoints, Kafka monitor-lifecycle)
- List monitors: filters (monitor_type_id, product_id, data_source_id, is_approved, paused) and sort (id, name, created_at, monitor_type, status, etc.)
- MonitorDTO: companyId, dataSources from all monitor types
- ManagedAccount/ManagedPage support in create/update
- GET /api/monitors/{id}/activities
- Phase 4: Social Listening Data & Analytics β
- POST /api/social-listening/data (validation, Kafka send, topic + consumer_group response)
- GET /api/social-listening/widgets?monitor_id=&data_source=&page_name=
- ParameterPreparationService + SocialListeningAnalyticsMessage (filters as JSON)
- Public API async: POST/GET /api/public-api/social-listening/data (job store)
- Filters support (topics, sentiment, languages, etc.) in request and Kafka payload
- Phase 5: Advanced Features (ActivityPub Server)
- ActivityPub server implementation
- Enhanced federation
- Performance optimization
- Monitoring & observability
- Phase 6: Testing & Documentation
- Unit and integration tests
- API documentation (OpenAPI/Swagger)
- Deployment guides
See IMPLEMENTATION_PLAN.md for detailed roadmap.
For issues, questions, or contributions:
- Open an issue on GitHub
- Check the documentation in
SPECIFICATION.mdandIMPLEMENTATION_PLAN.md
- activityPub4j - ActivityPub Java library
- Mastodon4J - Mastodon API client
- The Fediverse community for the ActivityPub protocol
Built with β€οΈ for the Fediverse