Discourse architecture.
Discourse is a platform for community discussion. Nodeway mapped the discourse/discourse repository at commit 4ff81e1, from 29 November 2026, and found 11,070 source files, 65,965 functions, classes and components, 1,851 routes and 387 database tables. This page is drawn from that map.
- Source files
- 11,070
- Functions and classes
- 65,965
- Confirmed calls
- 83,291
- Routes
- 1,851
- Tables
- 387
How the code is laid out
Most of it is Ruby: 8,195 files of 11,070, followed by JavaScript (2,462), TypeScript (386) and Shell (27).
The repository is split into 55 packages: folders with their own manifest, such as a package.json, pyproject.toml or go.mod. The largest are frontend/discourse (1,751 files), plugins/discourse-ai (1,107 files), plugins/chat (571 files), plugins/discourse-events (239 files), plugins/live (203 files) and plugins/blog (152 files).
These are its top-level folders by number of source files, with 4 more files at the root. The biggest ones show their own largest folders underneath.
- plugins/4,214 files712 routes · 154 tables
- discourse-ai/package1,107 files167 routes · 47 tables
- chat/package571 files81 routes · 23 tables
- discourse-workflows/520 files90 routes · 16 tables
- discourse-events/package239 files25 routes · 7 tables
- live/package203 files70 routes · 6 tables
- blog/package152 files58 routes · 6 tables
- db/1,858 files
- migrate/1,795 files
- post_migrate/40 files
- fixtures/22 files
- frontend/1,827 files
- discourse/package1,751 files
- asset-processor/package32 files
- discourse-markdown-it/package28 files
- app/1,359 files233 tables
- models/396 files233 tables
- services/273 files
- jobs/249 files
- lib/1,161 files
- json_api_kit/246 files
- onebox/95 files
- validators/79 files
- migrations/374 files
- core/lib/118 files
- tooling/108 files
- converters/lib/75 files
- script/164 files
- import_scripts/107 files
- bulk_import/8 files
- bundle_analysis/7 files
- config/66 files1,139 routes
- initializers/54 files
- environments/4 files
- locales/1 file
- bin/20 files
- docker/18 files
- themes/horizon/package9 files
- javascripts/discourse/8 files
- migrations/settings/1 file
- docs/developer-guides/package5 files
- lib/3 files
- stylelint-rules/4 files
- public/javascripts/3 files
- .devcontainer/scripts/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 |
|---|---|
| config/application.rb | 59 files |
| frontend/discourse/app/routes/application.js | 44 files |
| frontend/discourse/app/controllers/application.js | 4 files |
| frontend/discourse/app/routes/group/manage.js | 3 files |
| plugins/live/scripts/live-fake-participants.mjsdefines main | – |
| plugins/chat/admin/assets/javascripts/discourse/routes/admin-plugins/show/discourse-chat-incoming-webhooks/index.js | 15 files |
Routes
Nodeway found 1,851 routes and linked 1,649 to the function that handles them. They by HTTP method: GET 986, POST 403, PUT 286, DELETE 175, PATCH 1. Most are under config (1,139), plugins/discourse-ai (167) and plugins/discourse-workflows (90).
Some of them
| Route | Method |
|---|---|
| /index · plugins/blog/lib/blog/routes.rb | GET |
| /create · plugins/discourse-user-notes/config/routes.rb | POST |
| /mcpcreate · config/routes.rb | POST |
| /:idrespond · plugins/discourse-gamification/config/routes.rb | GET |
| /whowho · plugins/discourse-topic-voting/config/routes.rb | GET |
| /listlist · plugins/discourse-patreon/config/routes.rb | GET |
| /votedestroy · plugins/discourse-post-voting/config/routes.rb | DELETE |
| /votevote · plugins/poll/config/routes.rb | PUT |
Data model
Nodeway found 387 database tables, defined with Active Record. Code in the repository reads or writes 335 of them. The most used:
| Table | Used by |
|---|---|
| users4 columns · links to groups and uploads · app/models/user.rb | 486 read30 write |
| site_settingsapp/models/site_setting.rb | 208 read231 write |
| posts4 columns · links to topics, uploads and users · app/models/post.rb | 350 read22 write |
| topics9 columns · links to categories, uploads and users · app/models/topic.rb | 302 read18 write |
| categories9 columns · links to posts, topics and uploads · app/models/category.rb | 227 read23 write |
| groups2 columns · links to uploads and users · app/models/group.rb | 184 read9 write |
| user_histories6 columns · links to categories, posts and reviewables · app/models/user_history.rb | 26 read125 write |
| tags1 column · app/models/tag.rb | 98 read16 write |
One request, traced
Nodeway followed POST /#{root_path}/:username/preferences/revoke-account from its route to the code that handles it, then along confirmed calls until it reached the notifications table.
- POST /#{root_path}/:username/preferences/revoke-accountroute · config/routes.rb
- revoke_accountmethod · app/controllers/users_controller.rb:1986
- hijackmethod · lib/hijack.rb:9
- timingsmethod · app/controllers/topics_controller.rb:1098
- process_timingsmethod · app/models/post_timing.rb:159
- mark_posts_readmethod · app/models/notification.rb:190
- notificationstable · 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 |
|---|---|
| objectmethod · app/serializers/topic_tracking_state_item_serializer.rb | 1,074 |
| present?method · plugins/discourse-workflows/lib/discourse_workflows/executor/step_log.rb | 826 |
| includemethod · migrations/tooling/lib/migrations/tooling/schema/dsl/table_builder.rb | 723 |
| blank?method · lib/guardian.rb | 664 |
| to_imethod · script/import_scripts/phpbb3/support/bbcode/xml_to_markdown.rb | 653 |
| idmethod · app/models/email_style.rb | 555 |
| ajaxfunction · frontend/discourse/app/lib/ajax.ts | 447 |
| system_usermethod · lib/discourse.rb | 406 |
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/discourse/discourse.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
objectand 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 Discourse written in?
Mostly Ruby: 8,195 of its 11,070 source files at commit 4ff81e1, then JavaScript with 2,462.
Where does the Discourse code start?
The entry point that reaches the most code is config/application.rb, which leads to 59 files through its imports.
How many routes does Discourse have?
Nodeway found 1,851 routes, 1,649 of them linked to a handler. The most are under config.
What database tables does Discourse use?
387 tables, defined with Active Record. The most used are users, site_settings and posts.
How this page was made
Generated from a map Nodeway's analyzer (version 18) made of discourse/discourse at commit 4ff81e1, committed on 29 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.