Mastodon architecture.
Mastodon is a self-hosted, federated microblogging server. Nodeway mapped the mastodon/mastodon repository at commit b883ea2, from 27 November 2026, and found 2,934 source files, 13,511 functions, classes and components, 692 routes and 118 database tables. This page is drawn from that map.
- Source files
- 2,934
- Functions and classes
- 13,511
- Confirmed calls
- 13,111
- Routes
- 692
- Tables
- 118
How the code is laid out
Most of it is Ruby: 2,102 files of 2,934, followed by TypeScript (684), JavaScript (146) and Shell (2).
These are its top-level folders by number of source files, with 5 more files at the root. The biggest ones show their own largest folders underneath.
- app/2,105 files22 routes · 118 tables
- javascript/806 files22 routes
- controllers/355 files
- models/265 files118 tables
- lib/159 files
- serializers/149 files
- workers/123 files
- db/642 files
- migrate/553 files
- post_migrate/82 files
- seeds/5 files
- lib/86 files
- mastodon/33 files
- tasks/12 files
- paperclip/11 files
- config/80 files666 routes
- initializers/61 files
- routes/5 files553 routes
- vite/4 files
- streaming/package9 files4 routes
- .storybook/4 files
- bin/2 files
- public/1 file
Where the code starts
Nodeway looked for files that define a main function, and for files named like a starting point (main, server, app, cli and similar) that at most one other file imports, then for index files that nothing imports. Ranked that way, then by how many files each one reaches through its imports:
| File | Reaches |
|---|---|
| app/javascript/entrypoints/application.ts | 446 files |
| app/javascript/mastodon/main.tsxdefines main | 445 files |
| lib/mastodon/cli/main.rb | 52 files |
| config/application.rb | 32 files |
| app/javascript/mastodon/reducers/server.ts | 26 files |
| streaming/index.js | 6 files |
Routes
Nodeway found 692 routes and linked 586 to the function that handles them. They by HTTP method: GET 345, POST 210, DELETE 72, PUT 63, PATCH 2. Most are under config/routes (553), config (113) and app/javascript (22).
Some of them
| Route | Method |
|---|---|
| /inboxcreate · config/routes.rb | POST |
| /metricssetupMetrics · streaming/index.js | GET |
| /admin/tagsindex · config/routes/admin.rb | GET |
| /api/v1/appscreate · config/routes/api.rb | POST |
| /api/v2/mediauploadCompose · app/javascript/mastodon/actions/compose.js | POST |
| /api/v2/filterscreateFilter · app/javascript/mastodon/actions/filters.js | POST |
| /api/v1/markerssubmitMarkersAction · app/javascript/mastodon/actions/markers.ts | POST |
| /api/v1/reportssubmitReport · app/javascript/mastodon/actions/reports.js | POST |
Data model
Nodeway found 118 database tables, defined with Active Record. Code in the repository reads or writes 103 of them. The most used:
| Table | Used by |
|---|---|
| accounts56 columns · app/models/account.rb | 137 read4 write |
| statuses28 columns · links to accounts, conversations and polls · app/models/status.rb | 73 read2 write |
| users36 columns · links to accounts, invites and user_roles · app/models/user.rb | 35 read1 write |
| follows9 columns · links to accounts · app/models/follow.rb | 25 read0 write |
| tags13 columns · app/models/tag.rb | 17 read0 write |
| follow_requests9 columns · links to accounts · app/models/follow_request.rb | 15 read2 write |
| user_roles10 columns · app/models/user_role.rb | 14 read1 write |
| preview_cards30 columns · links to accounts · app/models/preview_card.rb | 13 read1 write |
One request, traced
Nodeway followed GET /media_proxy/:id/(*any) from its route to the code that handles it, then along confirmed calls until it reached the accounts table.
- GET /media_proxy/:id/(*any)route · config/routes.rb
- showmethod · app/controllers/media_proxy_controller.rb:17
- with_redis_lockmethod · app/models/concerns/lockable.rb:8
- with_redismethod · app/models/concerns/redisable.rb:8
- blockmethod · app/controllers/api/v1/accounts_controller.rb:57
- accountmethod · app/controllers/api/v1/follow_requests_controller.rb:27
- accountstable · read here
The most-called code
Ranked by how many different functions call each one, counting only calls the analyzer could confirm from the code. These are often the helpers worth reading first.
| Function | Callers |
|---|---|
| tmethod · app/serializers/rest/admin/server_check_serializer.rb | 211 |
| rolemethod · app/policies/application_policy.rb | 145 |
| redismethod · app/models/concerns/redisable.rb | 125 |
| log_actionmethod · app/controllers/concerns/accountable_concern.rb | 107 |
| accountmethod · app/models/severed_relationship.rb | 103 |
| apifunction · app/javascript/mastodon/api.ts | 96 |
| recordmethod · app/lib/activity_tracker.rb | 88 |
| idmethod · app/models/async_refresh.rb | 88 |
Open this repo in Nodeway
Nodeway is a desktop app that draws this map on your own computer, so you can click into any folder, read the code beside the map and trace a request yourself. Clone the repository:
git clone https://github.com/mastodon/mastodon.git- Install Nodeway for macOS, Windows or Linux: the getting started guide has every installer.
- Open the cloned folder. The first map is drawn on your machine and nothing is uploaded.
- Search for
tand trace what it calls, or pick a route and follow it to the database.
New to reading a codebase this size? See how to understand a large codebase and how to read a call graph.
Questions
What language is Mastodon written in?
Mostly Ruby: 2,102 of its 2,934 source files at commit b883ea2, then TypeScript with 684.
Where does the Mastodon code start?
The entry point that reaches the most code is app/javascript/entrypoints/application.ts, which leads to 446 files through its imports.
How many routes does Mastodon have?
Nodeway found 692 routes, 586 of them linked to a handler. The most are under config/routes.
What database tables does Mastodon use?
118 tables, defined with Active Record. The most used are accounts, statuses and users.
How this page was made
Generated from a map Nodeway's analyzer (version 18) made of mastodon/mastodon at commit b883ea2, committed on 27 November 2026. Tests, dependencies and build output are mostly left out. A call counts only when the analyzer could confirm its target from the code, so real totals are higher. The project will have changed since.