Chapter I
Welcome to the Discourse Codebase
Discourse is a Ruby on Rails backend paired with an Ember.js single-page frontend (now living under frontend/discourse in a pnpm workspace). The Rails side exposes a JSON API through controllers, ActiveRecord models, and serializers, while the Ember app consumes that JSON and re-hydrates it into its own client-side models. A first-class plugin system (plugins/*) and a MessageBus-based real-time layer let both official features and third-party plugins extend or react to almost anything in the system.
Discourse Request & Data Flow
Plugin Systemlib/plugin/instance.rb
Rails Controllers…rollers/application_controller.rb
ActiveRecord Modelsapp/models/topic.rb
JSON Serializersapp/serializers/post_serializer.rb
Ember.js Frontendfrontend/discourse/app/app.js
Sidekiq Background Jobsapp/jobs/base.rb
MessageBus Realtime Layerlib/discourse_event.rb