Mattermost
Audited from github.com/mattermost/mattermost
Mattermost is an open-core, self-hosted collaboration platform combining chat, workflow automation, and AI integration, distributed as a single Go binary with a React web client and PostgreSQL as its database.
- Language
- TypeScript
- Database
- PostgreSQL
- Hosting
- Docker
- Running for
- 9 years
- Team
- 20+ people
Why this architecture
A single Go binary keeps the API, scheduler, and websocket hub in one deployable process backed by a required PostgreSQL database, while optional Redis, Elasticsearch, and OpenSearch clients let larger deployments add caching and full-text search without changing the core architecture.
Tech stack by layer
12 technologies · audited Sep 17, 2026- Reactwebapp/channels is the main React SPA; webapp/platform holds shared component libraries.
- Material UINewer UI surfaces use MUI components alongside legacy Bootstrap markup.
- TiptapPowers the rich-text message composer via its React bindings and table extensions.
- Goserver/ is the primary Go application; go.mod pins the module and Go toolchain version.
- PostgreSQLRequired relational database, accessed via the lib/pq driver and sqlx.
- RedisOptional cache and pub-sub layer via the rueidis client for larger deployments.
- ElasticsearchOptional full-text search backend for channels and posts.
- OpenSearchAlternative search backend supported alongside Elasticsearch.
- MinIOS3-compatible client for storing uploaded files and compliance exports.
- DockerPackages the compiled Mattermost binary with a Postgres client for production images.
- PrometheusExposes runtime metrics for monitoring deployments.
- GitHub ActionsDozens of workflows run server, webapp, and end-to-end tests plus Docker builds.
Mattermost architecture diagram
Open SVGDiagram as text
- Web app (React SPA) → Mattermost server (Go · gorilla/mux): REST v4
- Web app (React SPA) → WebSocket hub (gorilla/websocket): events
- Desktop & plugins (shared webapp platform) → Mattermost server (Go · gorilla/mux): REST v4
- Mattermost server (Go · gorilla/mux) → Plugin host (server/public API): RPC
- Mattermost server (Go · gorilla/mux) → PostgreSQL (sqlx · morph): sqlx
- Mattermost server (Go · gorilla/mux) → File storage (S3 / MinIO): uploads
- Mattermost server (Go · gorilla/mux) → Search (Elasticsearch / OpenSearch): index
- Mattermost server (Go · gorilla/mux) → Redis (optional cache · pub-sub): cache
- Scheduler & jobs (in-binary) → PostgreSQL (sqlx · morph): batch work
Key architectural decisions
5 decisions- 01
Mattermost ships as a single Go binary, not microservices
server/go.mod defines one module (github.com/mattermost/mattermost/server/v8) that compiles into a single binary bundling the API, scheduler, plugin host, and websocket hub, matching the READMEs description of running as a single Linux binary.
- 02
PostgreSQL is required; Redis, Elasticsearch, and OpenSearch are optional
server/go.mod imports lib/pq for the required Postgres connection alongside optional clients for Redis (redis/rueidis), Elasticsearch (elastic/go-elasticsearch), and OpenSearch (opensearch-go), letting deployments add caching and search independently of the core database.
- 03
Schema migrations run through Mattermost's own morph tool
server/go.mod depends on github.com/mattermost/morph rather than a generic migration framework, giving the team control over Postgres migration ordering and rollback behavior across major versions.
- 04
The webapp is a monorepo of React packages, not one flat app
webapp/platform holds shared client, components, and eslint-plugin packages consumed by webapp/channels (the main SPA), letting the desktop app and plugins reuse the same @mattermost/client and @mattermost/types packages.
- 05
File storage abstracts over S3-compatible object storage via a MinIO client
server/go.mod's minio-go/v7 dependency lets Mattermost read and write uploaded files and exports against any S3-compatible backend, whether that is AWS S3, MinIO, or another provider, through one client library.
How Mattermost is built
How Mattermost is structured
The repository is a monorepo with three top-level applications: server/ (the Go backend and monolith binary), webapp/ (the React web client), and api/ (OpenAPI specs and API documentation tooling, per api/v4 and api/.spectral.yaml). server/channels contains the main product code, server/platform holds shared platform services, server/enterprise and server/einterfaces gate enterprise-only features behind interfaces, and server/public is a separately versioned Go module (server/public/go.mod) exposing the plugin API surface. webapp/platform mirrors this split on the frontend with shared client, components, and eslint-plugin packages consumed by webapp/channels, the main single-page app. tools/ provides Go-based developer tooling (mmgotool, mattermost-govet).
Frontend
webapp/channels/package.json defines the primary React SPA, built with a mix of established and newer UI libraries: legacy Bootstrap markup alongside Material UI (@mui/material, @mui/base) for newer surfaces, styled-components for component styling, and Tiptap (@tiptap/react, with table, link, and placeholder extensions) powering the rich-text message composer. Drag-and-drop interactions use Atlassian's Pragmatic drag-and-drop library (@atlaskit/pragmatic-drag-and-drop), and @mattermost/desktop-api integrates with the separate Electron desktop app. @mattermost/client, @mattermost/types, and @mattermost/shared, versioned at 12.0.0 alongside the webapp itself, are shared packages published from webapp/platform and consumed by both the web client and plugins.
Backend & APIs
server/go.mod declares the module github.com/mattermost/mattermost/server/v8, pinned to Go 1.26.7. Routing and middleware use gorilla/mux, gorilla/handlers, and gorilla/websocket for the real-time event hub; jmoiron/sqlx and lib/pq handle Postgres access; and github.com/mattermost/morph runs schema migrations instead of a generic Go migration library. Enterprise SSO uses mattermost/gosaml2 for SAML and mattermost/ldap for LDAP/AD integration. Feature experimentation goes through splitio/go-client, and getsentry/sentry-go plus prometheus/client_golang cover error tracking and metrics. server/public is published as its own Go module so plugins can depend on the public API surface without pulling in the entire server. An AI plugin dependency (mattermost/mattermost-plugin-ai) is vendored directly into go.mod, and tools/mattermost-govet is a custom Go static-analysis vet tool the team runs against its own codebase alongside tools/mmgotool, a general-purpose maintenance CLI.
Data & persistence
PostgreSQL is the required datastore, accessed through lib/pq; the README explicitly states the server "relies on PostgreSQL." Beyond the database, server/go.mod lists several optional data-layer clients: redis/rueidis for caching and pub-sub in larger deployments, elastic/go-elasticsearch/v8 and opensearch-project/opensearch-go/v4 as alternative full-text search backends, and minio/minio-go/v7 for S3-compatible object storage of uploaded files and compliance exports. server/docker-compose.pgvector.yml provides a pgvector-enabled Postgres variant for development, distinct from the production Dockerfile's plain client dependency.
Build, test & deploy
The server builds through server/Makefile, and the webapp through webapp/Makefile, both wired into mise.toml for toolchain version management (server/.go-version, .nvmrc). CI runs an extensive suite of GitHub Actions workflows: server-ci.yml, server-ci-nightly-race.yml (which specifically hunts for Go race conditions), and server-ci-weekly.yml run the Go test suite at different cadences; webapp-ci.yml covers the frontend; and e2e-tests-cypress.yml plus e2e-tests-playwright.yml (with dedicated rolling-upgrade variants, e2e-tests-playwright-rolling-upgrades.yml, that test mixed-version compatibility during upgrades) run end-to-end suites. codeql-analysis.yml and scorecards-analysis.yml handle security scanning, and docs-ci.yaml/docs-cd.yml build and deploy the separate docs/ site with its own Vale prose-linting configuration (docs/.vale.ini). config-change-checker.yml guards against unreviewed changes to server/config, and i18n-ci-pr.yml validates translation files against the glossary in i18n/glossary.
Self-hosting notes
server/build/Dockerfile is the official production image: a builder stage installs document-processing dependencies (unrtf, wv, poppler-utils, tidy) and downloads a specific Mattermost release tarball via the MM_PACKAGE build argument (defaulting to the latest enterprise edition), then a final stage sets up a non-root mattermost user and a .postgresql directory for SSL client certificates. server/docker-compose.yaml and server/docker-compose.makefile.yml support local development against a containerized Postgres. The README links dedicated install guides for Docker, Ubuntu 20.04, tar-based installs, Kubernetes, and Helm, reflecting that self-hosting is the primary distribution model alongside the managed Mattermost Cloud offering.
Sources & repo audit
- Audited
- Sep 17, 2026
- Commit
- de7a2dc
- License
- NOASSERTION
- server/go.mod (Go module; Postgres, Redis, Elasticsearch, OpenSearch, MinIO clients)
- webapp/channels/package.json (React SPA dependencies)
- server/build/Dockerfile (production image)
- README.md (single-binary architecture, Go + React, PostgreSQL requirement)
Independent analysis of repository at github.com/mattermost/mattermost. Spotted an inaccuracy? Use the claim form to request a correction.
Show this stack on your README or website
[](https://stackitfast.com/project/mattermost)Paste it into your README. It shows your current stack and links to this page.
Scaffold it with your agent
Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with Mattermost's architecture.
- 1Copy the promptThe full markdown spec, with every layer and decision.
- 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
- 3Paste and scaffoldUse it as the first instruction; review before you ship.
# MISSION: Scaffold "Mattermost" Production Architecture
You are an expert Senior Staff Software Architect and Full-Stack Engineer. Your mission is to scaffold and implement a production-grade, highly reliable, and modular codebase following the proven architecture of **Mattermost**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: Mattermost
- **What It Does**: Mattermost is an open-core, self-hosted collaboration platform combining chat, workflow automation, and AI integration, distributed as a single Go binary with a React web client and PostgreSQL as its database.
- **Domain & Category**: Team Collaboration Suite
- **Production Scale**: 20+ people
- **Development Mode**: CLASSIC
- **Architectural Rationale**: A single Go binary keeps the API, scheduler, and websocket hub in one deployable process backed by a required PostgreSQL database, while optional Redis, Elasticsearch, and OpenSearch clients let larger deployments add caching and full-text search without changing the core architecture.
- **Live Website Reference**: https://mattermost.com
- **Source Repository**: https://github.com/mattermost/mattermost
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: TypeScript, Go, React, PostgreSQL, Redis, Elasticsearch, OpenSearch, MinIO, Prometheus, Material UI, Tiptap, Docker
- **Primary Language(s)**: TypeScript, Go
- **License of the reference repo**: NOASSERTION
- **Frontend**: React — webapp/channels is the main React SPA; webapp/platform holds shared component libraries.; Material UI — Newer UI surfaces use MUI components alongside legacy Bootstrap markup.; Tiptap — Powers the rich-text message composer via its React bindings and table extensions.
- **Backend & APIs**: Go — server/ is the primary Go application; go.mod pins the module and Go toolchain version.
- **Data & persistence**: PostgreSQL — Required relational database, accessed via the lib/pq driver and sqlx.; Redis — Optional cache and pub-sub layer via the rueidis client for larger deployments.; Elasticsearch — Optional full-text search backend for channels and posts.; OpenSearch — Alternative search backend supported alongside Elasticsearch.; MinIO — S3-compatible client for storing uploaded files and compliance exports.
- **Infrastructure & deploy**: Docker — Packages the compiled Mattermost binary with a Postgres client for production images.; Prometheus — Exposes runtime metrics for monitoring deployments.; GitHub Actions — Dozens of workflows run server, webapp, and end-to-end tests plus Docker builds.
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/mattermost/mattermost @ de7a2dc)
1. **Mattermost ships as a single Go binary, not microservices**: server/go.mod defines one module (github.com/mattermost/mattermost/server/v8) that compiles into a single binary bundling the API, scheduler, plugin host, and websocket hub, matching the READMEs description of running as a single Linux binary.
2. **PostgreSQL is required; Redis, Elasticsearch, and OpenSearch are optional**: server/go.mod imports lib/pq for the required Postgres connection alongside optional clients for Redis (redis/rueidis), Elasticsearch (elastic/go-elasticsearch), and OpenSearch (opensearch-go), letting deployments add caching and search independently of the core database.
3. **Schema migrations run through Mattermost's own morph tool**: server/go.mod depends on github.com/mattermost/morph rather than a generic migration framework, giving the team control over Postgres migration ordering and rollback behavior across major versions.
4. **The webapp is a monorepo of React packages, not one flat app**: webapp/platform holds shared client, components, and eslint-plugin packages consumed by webapp/channels (the main SPA), letting the desktop app and plugins reuse the same @mattermost/client and @mattermost/types packages.
5. **File storage abstracts over S3-compatible object storage via a MinIO client**: server/go.mod's minio-go/v7 dependency lets Mattermost read and write uploaded files and exports against any S3-compatible backend, whether that is AWS S3, MinIO, or another provider, through one client library.
---
## 4. NON-NEGOTIABLE ARCHITECTURAL GUARDRAILS
1. **Monorepo & Modular Separation**:
- Structure as a Turborepo monorepo with strict package boundaries:
- `apps/web`: Application UI, routing, layouts, and server endpoints.
- `packages/ui`: Shared design tokens, CSS variables, and Radix UI primitive components.
- `packages/db`: Database schemas, client singleton, declarative migrations, and seed scripts.
- `packages/config`: Shared TypeScript, ESLint, and build configurations.
2. **Strict Type Safety & Zero `any` Policy**:
- Enable `strict: true`, `noImplicitAny: true`, and `strictNullChecks: true`.
- Validate ALL external inputs, API request bodies, and query parameters with **Zod** schemas before execution.
3. **Frontend & Rendering Guidelines**:
- Isolate interactive UI state to leaf components. Keep core pages lightweight and performant.
4. **Design System & Aesthetics**:
- Keep every color, radius, shadow and font in a single token file (CSS variables) and consume tokens everywhere; never hardcode hex values in components.
- Prefer crisp 1px borders and one subtle shadow scale over blurry default shadows. Pair one sans-serif for body/headings with one monospace for tags, badges, metrics, and code.
5. **Data Layer & Reliability**:
- Write declarative schema definitions with foreign keys, composite indexes on queried filters, and automated timestamp triggers.
- Use connection pooling and prepared statements for serverless database execution.
---
## 5. STEP-BY-STEP SCAFFOLDING ROADMAP
- **Phase 1: Workspace & Root Config**: Initialize package manager, monorepo configuration (`turbo.json`, `tsconfig.base.json`, `package.json`).
- **Phase 2: Database Schema & Client**: Set up the data layer (PostgreSQL, Redis, Elasticsearch, OpenSearch, MinIO): client, connection pool, models, and migration scripts.
- **Phase 3: Design Tokens & UI Primitives**: Build accessible `Button`, `Input`, `Card`, `Badge`, and layout wrappers inside `packages/ui`.
- **Phase 4: Core Application Routes & Handlers**: Implement primary authentication, user session handling, and application routes.
- **Phase 5: Quality Assurance & Build Verification**: Run `tsc --noEmit`, ESLint, Prettier, and smoke test suites to ensure zero compilation or runtime errors.
---
## 6. EXECUTION INSTRUCTIONS
1. Review all specifications, architectural guardrails, and stack choices above.
2. Present the full monorepo directory tree structure.
3. Systematically generate the complete, production-ready codebase according to the 5-phase roadmap above — starting with the root workspace setup, followed by the database schema, UI design system package, and full-stack application routes until the repository is fully scaffolded and ready to run.Copied 1 time · 1 of 1 reported launches succeeded (100%)
Frequently asked about Mattermost
What is Mattermost built with?
Mattermost's server is written in Go (server/go.mod) and compiles to a single binary; the webapp is a React single-page app in webapp/channels, and PostgreSQL is the required database.
Does Mattermost require PostgreSQL?
Yes. server/go.mod includes the lib/pq Postgres driver as a core dependency, and the README states the server relies on PostgreSQL; Redis, Elasticsearch, and OpenSearch are optional additions.
Can I self-host Mattermost?
Yes, Mattermost is self-hosted by default; the docs link Docker, Ubuntu, tar, Kubernetes, and Helm install guides, and server/build/Dockerfile defines the official production image.
Does Mattermost support Elasticsearch or OpenSearch for search?
Yes, server/go.mod includes clients for both elastic/go-elasticsearch/v8 and opensearch-project/opensearch-go/v4, so deployments can choose either search backend.
What does the Mattermost architecture look like?
A Go monolith in server/ compiles the API, scheduler, plugin host and websocket hub into a single binary, and a React SPA lives in webapp/. PostgreSQL is the main store, uploaded files go to S3-compatible storage such as MinIO, and Redis and Elasticsearch/OpenSearch are optional add-ons.
One email a month: new deep dives and stack trends
New source-audited architectures, head-to-head comparisons and the monthly stack report. No spam, unsubscribe anytime.
Similar architectures
- ChatwootHybridCustomer Support Suite · 6-20 peopleShares PostgreSQL · Redis · OpenSearch
- InfisicalHybridSecret Management · 6-20 peopleShares React · TypeScript · Go
- TemporalClassicDistributed Workflow Orchestrator · 20+ PeopleShares Go · PostgreSQL · Elasticsearch
- LagoClassicBilling & Metering Engine · 6-20 peopleShares React · Go · PostgreSQL
- WeKnoraClassicLLM Knowledge Base & RAG Platform · 20+ peopleShares Go · PostgreSQL · Redis
- AFFiNEHybridCollaborative Workspace · 6-20 peopleShares TypeScript · React · PostgreSQL