# getgrav/grav architecture

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

- Interactive diagram: https://gitdiagram.com/getgrav/grav
- Repository: https://github.com/getgrav/grav

## Overview

Grav is a file-based CMS and web platform. A web request enters through the front controller, is handled by the Grav runtime and its processors, and produces a rendered response. Its content model includes pages backed by filesystem storage, while configuration and structured data support site setup. Separate product capabilities include Twig and Markdown rendering, plugin/theme extensibility, package management, and scheduled jobs. The README documents the rendering and package-management capabilities; source excerpts show runtime setup and Flex storage, but do not expose the full request-to-render sequence.

Main entry points: [`system/src/Grav/Common/Grav.php`](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Grav.php) (Grav runtime), [`system/src/Grav/Framework/Flex/Storage/FolderStorage.php`](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Framework/Flex/Storage/FolderStorage.php) (Folder storage), [`system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php`](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php) (Page storage), [`index.php`](https://github.com/getgrav/grav/blob/develop/index.php) (Front controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Request runtime"]
  node_front["Front controller<br/>[index.php]"]
  node_grav["Grav runtime<br/>[Grav.php]"]
  node_processors["Request processors"]
  node_config["Configuration<br/>[Config.php]"]
  node_debugger["Debugger<br/>[Debugger.php]"]
end

subgraph group_content["Content and storage"]
  node_pages["Page model<br/>[Page.php]"]
  node_page_collection["Page collections<br/>[Pages.php]"]
  node_flex["Flex data model<br/>[Flex.php]"]
  node_page_storage["Page storage<br/>[PageStorage.php]"]
  node_folder_storage["Folder storage<br/>[FolderStorage.php]"]
  node_filesystem["Filesystem<br/>[Filesystem.php]"]
  node_data["Structured data<br/>[Data.php]"]
end

subgraph group_rendering["Rendering"]
  node_markdown["Markdown engine<br/>[Parsedown.php]"]
  node_twig["Twig templates<br/>[Twig.php]"]
end

subgraph group_extensions["Extensions and operations"]
  node_plugin_system["Plugin system<br/>[Plugins.php]"]
  node_themes["Theme system<br/>[Themes.php]"]
  node_gpm["Package manager<br/>[GPM.php]"]
  node_scheduler["Scheduler<br/>[Scheduler.php]"]
end

node_visitor(("Site visitor"))
node_cli_user(("CLI operator"))

node_visitor -->|"requests"| node_front
node_front -->|"starts runtime"| node_grav
node_grav -->|"registers processors"| node_processors
node_grav -->|"uses configuration"| node_config
node_config -->|"loads data"| node_data
node_grav -->|"uses debugger"| node_debugger
node_grav -->|"references pages"| node_pages
node_grav -->|"references page collections"| node_page_collection
node_page_storage -->|"uses page model"| node_pages
node_page_storage -->|"extends storage"| node_folder_storage
node_folder_storage -->|"uses filesystem"| node_filesystem
node_flex -->|"uses storage"| node_folder_storage
node_markdown -.->|"renders with"| node_twig
node_visitor -.->|"authors content"| node_markdown
node_cli_user -->|"manages packages"| node_gpm
node_grav -.->|"loads plugins"| node_plugin_system
node_grav -.->|"loads themes"| node_themes

click node_front "https://github.com/getgrav/grav/blob/develop/index.php"
click node_grav "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Grav.php"
click node_processors "https://github.com/getgrav/grav/tree/develop/system/src/Grav/Common/Processors"
click node_config "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Config/Config.php"
click node_debugger "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Debugger.php"
click node_pages "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Page/Page.php"
click node_page_collection "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Page/Pages.php"
click node_flex "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Framework/Flex/Flex.php"
click node_page_storage "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php"
click node_folder_storage "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Framework/Flex/Storage/FolderStorage.php"
click node_filesystem "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Framework/Filesystem/Filesystem.php"
click node_data "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Data/Data.php"
click node_markdown "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Markdown/Parsedown.php"
click node_twig "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Twig/Twig.php"
click node_plugin_system "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Plugins.php"
click node_themes "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Themes.php"
click node_gpm "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/GPM/GPM.php"
click node_scheduler "https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Scheduler/Scheduler.php"

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_front,node_grav,node_processors,node_config,node_debugger toneBlue
class node_pages,node_page_collection,node_flex,node_page_storage,node_folder_storage,node_filesystem,node_data toneAmber
class node_markdown,node_twig toneMint
class node_plugin_system,node_themes,node_gpm,node_scheduler toneRose
class node_visitor,node_cli_user toneIndigo
```

## Components

### Request runtime

- [Front controller](https://github.com/getgrav/grav/blob/develop/index.php): `index.php`
- [Grav runtime](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Grav.php): `system/src/Grav/Common/Grav.php`
- [Request processors](https://github.com/getgrav/grav/tree/develop/system/src/Grav/Common/Processors): `system/src/Grav/Common/Processors`
- [Configuration](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Config/Config.php): `system/src/Grav/Common/Config/Config.php`
- [Debugger](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Debugger.php): `system/src/Grav/Common/Debugger.php`

### Content and storage

- [Page model](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Page/Page.php): `system/src/Grav/Common/Page/Page.php`
- [Page collections](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Page/Pages.php): `system/src/Grav/Common/Page/Pages.php`
- [Flex data model](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Framework/Flex/Flex.php): `system/src/Grav/Framework/Flex/Flex.php`
- [Page storage](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php): `system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php`
- [Folder storage](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Framework/Flex/Storage/FolderStorage.php): `system/src/Grav/Framework/Flex/Storage/FolderStorage.php`
- [Filesystem](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Framework/Filesystem/Filesystem.php): `system/src/Grav/Framework/Filesystem/Filesystem.php`
- [Structured data](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Data/Data.php): `system/src/Grav/Common/Data/Data.php`

### Rendering

- [Markdown engine](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Markdown/Parsedown.php): `system/src/Grav/Common/Markdown/Parsedown.php`
- [Twig templates](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Twig/Twig.php): `system/src/Grav/Common/Twig/Twig.php`

### Extensions and operations

- [Plugin system](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Plugins.php): `system/src/Grav/Common/Plugins.php`
- [Theme system](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Themes.php): `system/src/Grav/Common/Themes.php`
- [Package manager](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/GPM/GPM.php): `system/src/Grav/Common/GPM/GPM.php`
- [Scheduler](https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Scheduler/Scheduler.php): `system/src/Grav/Common/Scheduler/Scheduler.php`

### Other components

- **Site visitor**
- **CLI operator**

## Connections

- Site visitor → Front controller: requests (evidence: `README.md`)
- Front controller → Grav runtime: starts runtime (evidence: `index.php`)
- Grav runtime → Request processors: registers processors (evidence: `system/src/Grav/Common/Grav.php`)
- Grav runtime → Configuration: uses configuration (evidence: `system/src/Grav/Common/Grav.php`)
- Configuration → Structured data: loads data (evidence: `system/src/Grav/Common/Config/Config.php`)
- Grav runtime → Debugger: uses debugger (evidence: `system/src/Grav/Common/Config/Config.php`)
- Grav runtime → Page model: references pages (evidence: `system/src/Grav/Common/Grav.php`)
- Grav runtime → Page collections: references page collections (evidence: `system/src/Grav/Common/Grav.php`)
- Page storage → Page model: uses page model (evidence: `system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php`)
- Page storage → Folder storage: extends storage (evidence: `system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php`)
- Folder storage → Filesystem: uses filesystem (evidence: `system/src/Grav/Framework/Flex/Storage/FolderStorage.php`)
- Flex data model → Folder storage: uses storage (evidence: `system/src/Grav/Framework/Flex/Storage/FolderStorage.php`)
- Markdown engine → Twig templates: renders with (evidence: `README.md`)
- Site visitor → Markdown engine: authors content (evidence: `README.md`)
- CLI operator → Package manager: manages packages (evidence: `README.md`)
- Grav runtime → Plugin system: loads plugins (evidence: `system/src/Grav/Common/Grav.php`)
- Grav runtime → Theme system: loads themes (evidence: `system/src/Grav/Common/Grav.php`)
