# mariadb/server architecture

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

- Interactive diagram: https://gitdiagram.com/mariadb/server
- Repository: https://github.com/mariadb/server

## Overview

MariaDB Server is a relational database server with client tools, SQL and table abstractions, pluggable storage engines, replication/clustering, backup utilities, and instrumentation. The central workflow is a client connecting over the MariaDB/MySQL protocol and working with SQL-managed tables through a storage engine. The README documents additional capabilities; their implementation details and most runtime calls were not sampled, so those links are dashed where the source evidence is incomplete.

Main entry points: [`sql/table.h`](https://github.com/mariadb/server/blob/main/sql/table.h) (Table metadata), [`sql/handler.h`](https://github.com/mariadb/server/blob/main/sql/handler.h) (Engine handler API), [`sql/mysqld.h`](https://github.com/mariadb/server/blob/main/sql/mysqld.h) (MariaDB server), [`sql/sql_class.h`](https://github.com/mariadb/server/blob/main/sql/sql_class.h) (Session and statements)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_connection["Client access"]
  node_clientlib["Client library<br/>[client.c]"]
  node_cli["Command-line tools<br/>[mysql.cc]"]
end

subgraph group_sql["SQL server"]
  node_server["MariaDB server<br/>[mysqld.h]"]
  node_session["Session and statements<br/>[sql_class.h]"]
  node_sqlfields["SQL field types<br/>[field.h]"]
  node_tablemodel["Table metadata<br/>[table.h]"]
  node_handlerapi["Engine handler API<br/>[handler.h]"]
end

subgraph group_storage["Storage and backup"]
  node_innodb[("InnoDB engine")]
  node_aria[("Aria engine")]
  node_myrocks[("MyRocks engine")]
  node_spider[("Spider engine")]
  node_duckdb["DuckDB integration"]
  node_backup["Physical backup<br/>[common_engine.cc]"]
  node_backupio["Backup data sinks<br/>[datasink.h]"]
end

subgraph group_replication["Replication and clustering"]
  node_replication["Replication"]
  node_wsrep["WSREP storage service"]
  node_binlogreader["InnoDB binlog reader"]
end

subgraph group_features["Server capabilities"]
  node_perfschema[("Performance Schema")]
  node_security["Authentication plugins"]
  node_vector["Vector search"]
  node_advancedsql["Advanced SQL"]
  node_spatialfulltext["Spatial and full-text"]
end

node_application(("Client application"))

node_application -.->|"connects through"| node_clientlib
node_clientlib -.->|"uses compatible protocol"| node_server
node_cli -.->|"connects through"| node_server
node_server -.->|"manages sessions"| node_session
node_session -.->|"works with tables"| node_tablemodel
node_tablemodel -.->|"defines fields"| node_sqlfields
node_tablemodel -.->|"uses engine API"| node_handlerapi
node_handlerapi -.->|"dispatches to"| node_innodb
node_handlerapi -.->|"dispatches to"| node_aria
node_handlerapi -.->|"dispatches to"| node_myrocks
node_handlerapi -.->|"dispatches to"| node_spider
node_duckdb -->|"scans across engines"| node_session
node_backup -->|"writes through"| node_backupio
node_backup -.->|"backs up engine data"| node_innodb
node_replication -.->|"replicates database changes"| node_server
node_wsrep -->|"starts and commits transactions"| node_session
node_binlogreader -.->|"reads binlog data"| node_replication
node_perfschema -.->|"exposes instrumented tables"| node_tablemodel
node_security -.->|"authenticates connections"| node_server
node_vector -.->|"adds vector type and indexes"| node_tablemodel
node_advancedsql -.->|"supports SQL features"| node_session
node_spatialfulltext -.->|"indexes spatial and text data"| node_tablemodel

click node_clientlib "https://github.com/mariadb/server/blob/main/sql-common/client.c"
click node_cli "https://github.com/mariadb/server/blob/main/client/mysql.cc"
click node_server "https://github.com/mariadb/server/blob/main/sql/mysqld.h"
click node_session "https://github.com/mariadb/server/blob/main/sql/sql_class.h"
click node_sqlfields "https://github.com/mariadb/server/blob/main/sql/field.h"
click node_tablemodel "https://github.com/mariadb/server/blob/main/sql/table.h"
click node_handlerapi "https://github.com/mariadb/server/blob/main/sql/handler.h"
click node_innodb "https://github.com/mariadb/server/tree/main/storage/innobase"
click node_aria "https://github.com/mariadb/server/tree/main/storage/maria"
click node_myrocks "https://github.com/mariadb/server/tree/main/storage/rocksdb"
click node_spider "https://github.com/mariadb/server/tree/main/storage/spider"
click node_duckdb "https://github.com/mariadb/server/blob/main/storage/duckdb/runtime/cross_engine_scan.cc"
click node_backup "https://github.com/mariadb/server/blob/main/extra/mariabackup/common_engine.cc"
click node_backupio "https://github.com/mariadb/server/blob/main/extra/mariabackup/datasink.h"
click node_replication "https://github.com/mariadb/server/tree/main/sql"
click node_wsrep "https://github.com/mariadb/server/blob/main/sql/wsrep_storage_service.cc"
click node_binlogreader "https://github.com/mariadb/server/blob/main/client/mysqlbinlog-engine.cc"
click node_perfschema "https://github.com/mariadb/server/blob/main/storage/perfschema/pfs_engine_table.cc"
click node_security "https://github.com/mariadb/server/tree/main/plugin"
click node_vector "https://github.com/mariadb/server/tree/main/sql"
click node_advancedsql "https://github.com/mariadb/server/tree/main/sql"
click node_spatialfulltext "https://github.com/mariadb/server/tree/main/sql"

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_clientlib,node_cli,node_application toneBlue
class node_server,node_session,node_sqlfields,node_tablemodel,node_handlerapi toneAmber
class node_innodb,node_aria,node_myrocks,node_spider,node_duckdb,node_backup,node_backupio toneMint
class node_replication,node_wsrep,node_binlogreader toneRose
class node_perfschema,node_security,node_vector,node_advancedsql,node_spatialfulltext toneIndigo
```

## Components

### Client access

- [Client library](https://github.com/mariadb/server/blob/main/sql-common/client.c): `sql-common/client.c`
- [Command-line tools](https://github.com/mariadb/server/blob/main/client/mysql.cc): `client/mysql.cc`

### SQL server

- [MariaDB server](https://github.com/mariadb/server/blob/main/sql/mysqld.h): `sql/mysqld.h`
- [Session and statements](https://github.com/mariadb/server/blob/main/sql/sql_class.h): `sql/sql_class.h`
- [SQL field types](https://github.com/mariadb/server/blob/main/sql/field.h): `sql/field.h`
- [Table metadata](https://github.com/mariadb/server/blob/main/sql/table.h): `sql/table.h`
- [Engine handler API](https://github.com/mariadb/server/blob/main/sql/handler.h): `sql/handler.h`

### Storage and backup

- [InnoDB engine](https://github.com/mariadb/server/tree/main/storage/innobase): `storage/innobase`
- [Aria engine](https://github.com/mariadb/server/tree/main/storage/maria): `storage/maria`
- [MyRocks engine](https://github.com/mariadb/server/tree/main/storage/rocksdb): `storage/rocksdb`
- [Spider engine](https://github.com/mariadb/server/tree/main/storage/spider): `storage/spider`
- [DuckDB integration](https://github.com/mariadb/server/blob/main/storage/duckdb/runtime/cross_engine_scan.cc): `storage/duckdb/runtime/cross_engine_scan.cc`
- [Physical backup](https://github.com/mariadb/server/blob/main/extra/mariabackup/common_engine.cc): `extra/mariabackup/common_engine.cc`
- [Backup data sinks](https://github.com/mariadb/server/blob/main/extra/mariabackup/datasink.h): `extra/mariabackup/datasink.h`

### Replication and clustering

- [Replication](https://github.com/mariadb/server/tree/main/sql): `sql`
- [WSREP storage service](https://github.com/mariadb/server/blob/main/sql/wsrep_storage_service.cc): `sql/wsrep_storage_service.cc`
- [InnoDB binlog reader](https://github.com/mariadb/server/blob/main/client/mysqlbinlog-engine.cc): `client/mysqlbinlog-engine.cc`

### Server capabilities

- [Performance Schema](https://github.com/mariadb/server/blob/main/storage/perfschema/pfs_engine_table.cc): `storage/perfschema/pfs_engine_table.cc`
- [Authentication plugins](https://github.com/mariadb/server/tree/main/plugin): `plugin`
- [Vector search](https://github.com/mariadb/server/tree/main/sql): `sql`
- [Advanced SQL](https://github.com/mariadb/server/tree/main/sql): `sql`
- [Spatial and full-text](https://github.com/mariadb/server/tree/main/sql): `sql`

### Other components

- **Client application**

## Connections

- Client application → Client library: connects through
- Client library → MariaDB server: uses compatible protocol
- Command-line tools → MariaDB server: connects through
- MariaDB server → Session and statements: manages sessions
- Session and statements → Table metadata: works with tables
- Table metadata → SQL field types: defines fields (evidence: `sql/table.h`)
- Table metadata → Engine handler API: uses engine API (evidence: `sql/table.h`)
- Engine handler API → InnoDB engine: dispatches to
- Engine handler API → Aria engine: dispatches to
- Engine handler API → MyRocks engine: dispatches to
- Engine handler API → Spider engine: dispatches to
- DuckDB integration → Session and statements: scans across engines (evidence: `storage/duckdb/runtime/cross_engine_scan.cc`)
- Physical backup → Backup data sinks: writes through (evidence: `extra/mariabackup/common_engine.cc`)
- Physical backup → InnoDB engine: backs up engine data (evidence: `extra/mariabackup/common_engine.cc`)
- Replication → MariaDB server: replicates database changes (evidence: `sql/wsrep_storage_service.cc`)
- WSREP storage service → Session and statements: starts and commits transactions (evidence: `sql/wsrep_storage_service.cc`)
- InnoDB binlog reader → Replication: reads binlog data (evidence: `client/mysqlbinlog-engine.cc`)
- Performance Schema → Table metadata: exposes instrumented tables
- Authentication plugins → MariaDB server: authenticates connections
- Vector search → Table metadata: adds vector type and indexes (evidence: `sql/field.h`)
- Advanced SQL → Session and statements: supports SQL features (evidence: `sql/wsrep_storage_service.cc`)
- Spatial and full-text → Table metadata: indexes spatial and text data (evidence: `sql/field.h`)
