# wazuh/wazuh-documentation architecture

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

- Interactive diagram: https://gitdiagram.com/wazuh/wazuh-documentation
- Repository: https://github.com/wazuh/wazuh-documentation

## Overview

##### Main components
- Documentation Content Repository – This is primarily found in the “source” directory. It contains all the content (user manuals, guides, integration guides, release notes, etc.) organized into numerous subdirectories (e.g., “getting-started”, “user-manual”, “compliance”, “cloud-security”, “deployment-options”, and so on). It also includes a “conf.py” file for Sphinx configuration.
- Custom Extensions – Located in “source/_exts” (for example, the wazuh-doc-images extension) which likely add custom behaviors (like image handling or other transformations) to the documentation build.
- Themes & Templates – The “source/_themes/wazuh_doc_theme_v3” and “source/_templates” directories house custom CSS/SCSS, JavaScript, and HTML template files that dictate the final rendered look of the documentation site.
- Build & Integration Tools – Files at the repository’s root include “Makefile”, “Dockerfile”, and GitHub workflows under “.github/workflows” (for example, compile.yml) to automatically build and/or deploy the documentation. Additionally, configuration files for external tools (like “pagefind.yml”) and dependency declarations (like “requirements.txt”) are present.
- Resources – The “resources” directory contains assets such as cloud configuration files, dashboards data, and SELinux policy configurations that likely support some of the guides and examples.
- Supporting Assets – Various “images” directories (inside “source/images”) and others provide the media used in the documentation.

##### Relationships and interactions
- The content written in reStructuredText is processed by Sphinx (configured via “conf.py”), which interacts with custom extensions (in “_exts”) and applies themes (from “_themes” and “_templates”) to generate the final static documentation site.
- The CI/CD pipeline (using GitHub Actions as seen in the “.github/workflows” folder) triggers the Sphinx build process to compile the documentation upon commits (or pull requests).
- The optional integration with Pagefind (with NodeJS support when needed) provides an alternative, client-side search engine.
- Auxiliary assets (such as the various images, dashboard resources, and SELinux files) are integrated within the documentation for visual examples and detailed instructions.

##### Architectural patterns and design principles
- Content Separation & Modularity – The documentation is split into logical components such as “getting-started”, “deployment-options”, “user-manual”, and so on. This separation helps maintain the extensive documentation structure while keeping the build configurations (Sphinx, extensions, themes) isolated.
- Extensibility – The presence of custom Sphinx extensions and theming shows the use of plugin and template design patterns. These allow customization of both the build process and the output look and feel.
- Automation – Continuous integration using GitHub workflows and Makefile/Dockerfile scripts demonstrates automated documentation builds and deployments.
- Optional Search Integration – An option to integrate NodeJS-based Pagefind introduces a separation of concerns where the search functionality can be optionally maintained outside the core Python/Sphinx engine.

##### Relevant technologies and libraries
- Python 3.9+ and Sphinx (version 7.2.6) – For the documentation build process.
- sphinx-tabs, jsmin and sphinx-reredirects – To enhance content formatting, minimize JS assets, and manage URL redirects respectively.
- Optional NodeJS (v16+) – To run the Pagefind search engine if that advanced search setup is chosen.
- Custom JavaScript, SCSS, and image assets – Found in the theme directories to control the front-end behavior and styling of the final documentation site.
- GitHub Actions – To automate build and compile tasks during the CI/CD process.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Documentation Content and Assets
    DocContent["Documentation Content Repository\n(source/)"]:::content
    SphinxConfig["Sphinx Config\n(conf.py)"]:::content
    Resources["Resources"]:::resource
    CloudConfig["Cloud Config"]:::resource
    Dashboards["Dashboards"]:::resource
    SELinux["SELinux Policies"]:::resource
    Images["Images (Supporting Assets)"]:::asset

    %% Build Engine & Output
    SphinxEngine["Sphinx Build Engine (Python3.9)"]:::engine
    StaticSite["Static Documentation Site"]:::output
    SearchIntegration["Pagefind/NodeJS Integration"]:::search

    %% Custom Extensions
    CustomExt["Custom Extensions\n(source/_exts)"]:::extension
    WazuhDocImagesFile["wazuh-doc-images.py"]:::extension
    WazuhDocImagesFolder["wazuh-doc-images Folder"]:::extension

    %% Themes & Templates
    WazuhTheme["Wazuh Theme\n(source/_themes/wazuh_doc_theme_v3)"]:::theme
    Templates["Templates\n(source/_templates)"]:::theme

    %% CI/CD Pipeline & Build Tools
    CIPipeline["CI/CD Pipeline"]:::ci
    subgraph "Build & Integration Tools"
        Makefile["Makefile"]:::ci
        Dockerfile["Dockerfile"]:::ci
        GitHubWorkflow["GitHub Workflow\n(.github/workflows/compile.yml)"]:::ci
        PagefindConfig["Pagefind Config\n(pagefind.yml)"]:::ci
        Dependencies["Dependencies\n(requirements.txt)"]:::ci
    end

    %% Build the relationships
    %% Documentation Content receives assets
    Resources --> DocContent
    CloudConfig --> Resources
    Dashboards --> Resources
    SELinux --> Resources
    Images --> DocContent
    DocContent --> SphinxConfig

    %% CI/CD and Build Tools trigger build process
    Makefile --> CIPipeline
    Dockerfile --> CIPipeline
    GitHubWorkflow --> CIPipeline
    PagefindConfig --> CIPipeline
    Dependencies --> CIPipeline
    CIPipeline --> SphinxEngine

    %% Sphinx Build Engine integrates content, extensions, and themes
    DocContent --> SphinxEngine
    SphinxConfig --> SphinxEngine
    CustomExt --> SphinxEngine
    WazuhDocImagesFile --> CustomExt
    WazuhDocImagesFolder --> CustomExt
    WazuhTheme --> SphinxEngine
    Templates --> SphinxEngine

    %% Build Engine outputs final site and connects to optional search
    SphinxEngine --> StaticSite
    SearchIntegration --> StaticSite

    %% Click Events
    click DocContent "https://github.com/wazuh/wazuh-documentation/tree/main/source/"
    click SphinxConfig "https://github.com/wazuh/wazuh-documentation/blob/main/source/conf.py"
    click CustomExt "https://github.com/wazuh/wazuh-documentation/tree/main/source/_exts"
    click WazuhDocImagesFile "https://github.com/wazuh/wazuh-documentation/blob/main/source/_exts/wazuh-doc-images.py"
    click WazuhDocImagesFolder "https://github.com/wazuh/wazuh-documentation/tree/main/source/_exts/wazuh-doc-images"
    click WazuhTheme "https://github.com/wazuh/wazuh-documentation/tree/main/source/_themes/wazuh_doc_theme_v3"
    click Templates "https://github.com/wazuh/wazuh-documentation/tree/main/source/_templates"
    click Makefile "https://github.com/wazuh/wazuh-documentation/tree/main/Makefile"
    click Dockerfile "https://github.com/wazuh/wazuh-documentation/tree/main/Dockerfile"
    click GitHubWorkflow "https://github.com/wazuh/wazuh-documentation/blob/main/.github/workflows/compile.yml"
    click PagefindConfig "https://github.com/wazuh/wazuh-documentation/blob/main/pagefind.yml"
    click Dependencies "https://github.com/wazuh/wazuh-documentation/blob/main/requirements.txt"
    click CloudConfig "https://github.com/wazuh/wazuh-documentation/tree/main/resources/cloud"
    click Dashboards "https://github.com/wazuh/wazuh-documentation/tree/main/resources/dashboards"
    click SELinux "https://github.com/wazuh/wazuh-documentation/tree/main/resources/selinux"
    click Images "https://github.com/wazuh/wazuh-documentation/tree/main/source/images"

    %% Styles
    classDef content fill:#E6F7FF,stroke:#1890FF,stroke-width:2px;
    classDef engine fill:#FFF7E6,stroke:#D48806,stroke-width:2px;
    classDef extension fill:#F6FFED,stroke:#52C41A,stroke-width:2px;
    classDef theme fill:#FFF2E8,stroke:#FA8C16,stroke-width:2px;
    classDef ci fill:#F9F0FF,stroke:#722ED1,stroke-width:2px;
    classDef resource fill:#E6FFFB,stroke:#13C2C2,stroke-width:2px;
    classDef asset fill:#FFFBE6,stroke:#FAAD14,stroke-width:2px;
    classDef search fill:#FFF0F6,stroke:#EB2F96,stroke-width:2px;
    classDef output fill:#F6FFED,stroke:#52C41A,stroke-width:2px;
```
