# the-algorithm

> Open-source codebase powering X's recommendation engine and timelines.

This repository contains the source code for the services and recommendation models powering X (formerly Twitter), including the For You timeline, Search, and notifications. It reveals how candidate tweets are sourced, scored, filtered, and ranked using graph algorithms and machine learning models. Developers and marketers use it to study social media ranking mechanics and optimize content reach.

Website: https://github.com/twitter/the-algorithm

## What it is for

- Understand the scoring mechanisms behind X's For You timeline
- Identify algorithmic penalties and engagement boosts for content strategy
- Study large-scale recommendation system architecture and graph processing

## Features

- Candidate sourcing pipelines for in-network and out-of-network posts
- Light and heavy ranking machine learning models for tweet scoring
- Visibility filtering logic for trust, safety, and spam downranking
- PageRank-based user reputation scoring (Tweepcred)
- GraphJet-based real-time graph traversal and candidate selection

## Pricing

Open source. Free and open source under AGPL-3.0

## Details

- Type: Web app
- Category: [Development](https://xiry.app/topics/development.md)
- Open source: yes
- Platforms: Self-hosted
- For: Machine learning engineers, data scientists, and social media strategists
- Tags: algorithms, recommendation engine, scala, machine learning, social media, ranking

## Why it was saved

- [@aidenybai, 20 January 2026](https://x.com/aidenybai/status/2013656265273287156): Replace github.com with repogrep.com in any repo URL to instantly ask questions of that codebase; demo shows Fast/Smart modes, semantic code search with per-query timings, cached repo detection, and cited answers with code snippets, file references and practical takeaways.

## Related

- [x-algorithm](https://xiry.app/resources/x-algorithm): The open-source code powering the For You recommendation feed on X. (GitHub repo, Open source)
- [Bytez](https://xiry.app/resources/bytez): Unified serverless API to discover and run open and closed AI models (Web app, Freemium)
- [Social SDK](https://xiry.app/resources/social-sdk): Typed TypeScript SDK for publishing, analytics, and interactions across social platforms (Web app, Open source)

Updated 10 October 2026. Page: https://xiry.app/resources/the-algorithm

Make your own library: Xiry takes your saved reels, tweets, Reddit bookmarks and Watch Later videos, makes them searchable and pulls the useful stuff out, like this library. It's invite-only for now; join the waitlist at https://xiry.app/#waitlist.
