Overview
This guide will help you set up your development environment to work with X’s Recommendation Algorithm. The codebase is a complex, production-scale system written primarily in Scala, with components in Java, Python, and Rust.Prerequisites
Before you begin, ensure you have the following installed:Install Java Development Kit (JDK)
Install JDK 11 or later. The project uses Java 11 as the runtime platform.
Install Bazel
The project uses Bazel as its build system. Install Bazel following the official installation guide.Verify your installation:
Install Scala (Optional)
While Bazel manages Scala dependencies, you may want to install Scala for IDE support.
Clone the Repository
Clone the X Recommendation Algorithm repository:Repository Structure
Understanding the repository structure will help you navigate the codebase:Core Data Services
- tweetypie/ - Core service for reading and writing post data
- unified_user_actions/ - Real-time stream of user actions
- user-signal-service/ - Centralized platform for user signals (likes, replies, clicks)
Models and Algorithms
- src/scala/com/twitter/simclusters_v2/ - SimClusters community detection
- trust_and_safety_models/ - NSFW and abusive content detection
- src/scala/com/twitter/interaction_graph/ - Real-Graph user interaction predictions
- src/scala/com/twitter/graph/batch/job/tweepcred/ - TweepCred reputation algorithm
Software Frameworks
- navi/ - High-performance ML model serving (Rust)
- product-mixer/ - Framework for building content feeds
- timelines/data_processing/ml_util/aggregation_framework/ - Feature aggregation
- representation-manager/ - Embedding retrieval service
- twml/ - Legacy ML framework (TensorFlow v1)
Product Surfaces
- home-mixer/ - Main service for Home Timeline (For You, Following, Lists)
- pushservice/ - Recommendation service for notifications
- tweet-mixer/ - Coordination layer for out-of-network tweet candidates
- follow-recommendations-service/ - Account and post recommendations
Candidate Sources and Ranking
- src/java/com/twitter/search/ - Search index for in-network posts
- src/scala/com/twitter/recos/ - GraphJet-based recommendation services
- timelineranker/ - Legacy ranking service
- visibilitylib/ - Content filtering and compliance
Source Code Organization
- src/java/ - Java implementations
- src/scala/ - Scala implementations
- src/python/ - Python ML models and scripts
- src/thrift/ - Thrift service definitions
IDE Setup
IntelliJ IDEA (Recommended for Scala/Java)
Install IntelliJ IDEA
Download and install IntelliJ IDEA (Community or Ultimate edition).
Visual Studio Code
Install VS Code
Download and install Visual Studio Code.
Install Extensions
Install the following extensions:
- Scala (Metals)
- Bazel
- Python
- rust-analyzer (for Navi)
Verify Your Setup
Test your development environment by checking if you can query the build targets:Next Steps
- Learn about building and testing the codebase
- Review the contributing guidelines
- Explore the engineering blog for algorithm details