# discourse/discourse architecture

> Architecture diagram of the GitHub repository discourse/discourse, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/discourse/discourse
- Repository: https://github.com/discourse/discourse
- Video tour (about a minute): https://gitdiagram.com/discourse/discourse/video

## Overview

Discourse is a self-hostable community platform. Members create discussion topics and interact through conversations, while the Rails API serves the Ember frontend; Markdown processing and Onebox turn authored text and links into rendered content. The README also highlights real-time chat, themes, and plugins, and identifies PostgreSQL and Redis as storage and cache/transient-data services. Sampled source supports the Markdown and Onebox internals; broader feature links reflect README descriptions and repository paths rather than inspected implementation details.

Main entry points: [`frontend/discourse`](https://github.com/discourse/discourse/tree/main/frontend/discourse) (Ember frontend), [`app/controllers`](https://github.com/discourse/discourse/tree/main/app/controllers) (Rails API), [`frontend/discourse-markdown-it/src/engine.js`](https://github.com/discourse/discourse/blob/main/frontend/discourse-markdown-it/src/engine.js) (Markdown engine), [`frontend/discourse-markdown-it/src/features/text-post-process.js`](https://github.com/discourse/discourse/blob/main/frontend/discourse-markdown-it/src/features/text-post-process.js) (Text post-process)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_community["Community discussions"]
  node_rails["Rails API"]
  node_topics["Discussion topics"]
  node_posts["Posts and replies"]
  node_postgres[("PostgreSQL")]
  node_redis[("Redis cache")]
  node_ember["Ember frontend"]
end

subgraph group_rendering["Content rendering"]
  node_markdown["Markdown engine<br/>[engine.js]"]
  node_text_rules["Text post-process"]
  node_bbcode["BBCode rules<br/>[bbcode-block.js]"]
  node_onebox["Onebox engine<br/>[engine.rb]"]
  node_onebox_adapters["Link adapters"]
  node_github_mixins["GitHub helpers"]
end

subgraph group_extensions["Realtime and extensions"]
  node_chat["Realtime chat"]
  node_themes["Themes"]
  node_plugins["Plugin extensions"]
end

subgraph group_operations["Administration"]
  node_admin["Site administration"]
  node_moderation["Review and moderation"]
end

node_member(("Community member"))

node_member -->|"uses"| node_ember
node_ember -->|"calls REST API"| node_rails
node_member -->|"creates discussions"| node_topics
node_rails -->|"stores data"| node_postgres
node_rails -->|"caches transient data"| node_redis
node_ember -.->|"cooks content"| node_markdown
node_markdown -->|"installs ruler"| node_text_rules
node_text_rules -->|"uses parsing helpers"| node_bbcode
node_markdown -.->|"embeds links"| node_onebox
node_onebox -->|"loads adapters"| node_onebox_adapters
node_onebox_adapters -->|"uses GitHub helpers"| node_github_mixins
node_member -->|"chats in real time"| node_chat
node_member -->|"customizes experience"| node_themes
node_plugins -.->|"extends platform"| node_ember
node_admin -.->|"manages themes"| node_themes
node_member -.->|"submits content for review"| node_moderation

click node_rails "https://github.com/discourse/discourse/tree/main/app/controllers"
click node_topics "https://github.com/discourse/discourse/blob/main/app/controllers/topics_controller.rb"
click node_posts "https://github.com/discourse/discourse/blob/main/app/controllers/posts_controller.rb"
click node_ember "https://github.com/discourse/discourse/tree/main/frontend/discourse"
click node_markdown "https://github.com/discourse/discourse/blob/main/frontend/discourse-markdown-it/src/engine.js"
click node_text_rules "https://github.com/discourse/discourse/blob/main/frontend/discourse-markdown-it/src/features/text-post-process.js"
click node_bbcode "https://github.com/discourse/discourse/blob/main/frontend/discourse-markdown-it/src/features/bbcode-block.js"
click node_onebox "https://github.com/discourse/discourse/blob/main/lib/onebox/engine.rb"
click node_onebox_adapters "https://github.com/discourse/discourse/tree/main/lib/onebox/engine"
click node_github_mixins "https://github.com/discourse/discourse/tree/main/lib/onebox/mixins"
click node_chat "https://github.com/discourse/discourse/tree/main/plugins/chat"
click node_themes "https://github.com/discourse/discourse/blob/main/app/controllers/admin/themes_controller.rb"
click node_plugins "https://github.com/discourse/discourse/tree/main/plugins"
click node_admin "https://github.com/discourse/discourse/tree/main/app/controllers/admin"
click node_moderation "https://github.com/discourse/discourse/blob/main/app/controllers/reviewables_controller.rb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_rails,node_topics,node_posts,node_postgres,node_redis,node_ember toneBlue
class node_markdown,node_text_rules,node_bbcode,node_onebox,node_onebox_adapters,node_github_mixins toneAmber
class node_chat,node_themes,node_plugins toneMint
class node_admin,node_moderation toneRose
class node_member toneIndigo
```

## Components

### Community discussions

- [Rails API](https://github.com/discourse/discourse/tree/main/app/controllers): `app/controllers`
- [Discussion topics](https://github.com/discourse/discourse/blob/main/app/controllers/topics_controller.rb): `app/controllers/topics_controller.rb`
- [Posts and replies](https://github.com/discourse/discourse/blob/main/app/controllers/posts_controller.rb): `app/controllers/posts_controller.rb`
- **PostgreSQL**
- **Redis cache**
- [Ember frontend](https://github.com/discourse/discourse/tree/main/frontend/discourse): `frontend/discourse`

### Content rendering

- [Markdown engine](https://github.com/discourse/discourse/blob/main/frontend/discourse-markdown-it/src/engine.js): `frontend/discourse-markdown-it/src/engine.js`
- [Text post-process](https://github.com/discourse/discourse/blob/main/frontend/discourse-markdown-it/src/features/text-post-process.js): `frontend/discourse-markdown-it/src/features/text-post-process.js`
- [BBCode rules](https://github.com/discourse/discourse/blob/main/frontend/discourse-markdown-it/src/features/bbcode-block.js): `frontend/discourse-markdown-it/src/features/bbcode-block.js`
- [Onebox engine](https://github.com/discourse/discourse/blob/main/lib/onebox/engine.rb): `lib/onebox/engine.rb`
- [Link adapters](https://github.com/discourse/discourse/tree/main/lib/onebox/engine): `lib/onebox/engine`
- [GitHub helpers](https://github.com/discourse/discourse/tree/main/lib/onebox/mixins): `lib/onebox/mixins`

### Realtime and extensions

- [Realtime chat](https://github.com/discourse/discourse/tree/main/plugins/chat): `plugins/chat`
- [Themes](https://github.com/discourse/discourse/blob/main/app/controllers/admin/themes_controller.rb): `app/controllers/admin/themes_controller.rb`
- [Plugin extensions](https://github.com/discourse/discourse/tree/main/plugins): `plugins`

### Administration

- [Site administration](https://github.com/discourse/discourse/tree/main/app/controllers/admin): `app/controllers/admin`
- [Review and moderation](https://github.com/discourse/discourse/blob/main/app/controllers/reviewables_controller.rb): `app/controllers/reviewables_controller.rb`

### Other components

- **Community member**

## Connections

- Community member → Ember frontend: uses (evidence: `README.md`)
- Ember frontend → Rails API: calls REST API (evidence: `README.md`)
- Community member → Discussion topics: creates discussions (evidence: `README.md`)
- Rails API → PostgreSQL: stores data (evidence: `README.md`)
- Rails API → Redis cache: caches transient data (evidence: `README.md`)
- Ember frontend → Markdown engine: cooks content
- Markdown engine → Text post-process: installs ruler (evidence: `frontend/discourse-markdown-it/src/engine.js`)
- Text post-process → BBCode rules: uses parsing helpers (evidence: `frontend/discourse-markdown-it/src/features/text-post-process.js`)
- Markdown engine → Onebox engine: embeds links
- Onebox engine → Link adapters: loads adapters (evidence: `lib/onebox/engine.rb`)
- Link adapters → GitHub helpers: uses GitHub helpers (evidence: `lib/onebox/engine/github_issue_onebox.rb`)
- Community member → Realtime chat: chats in real time (evidence: `README.md`)
- Community member → Themes: customizes experience (evidence: `README.md`)
- Plugin extensions → Ember frontend: extends platform
- Site administration → Themes: manages themes
- Community member → Review and moderation: submits content for review
