# btzy/nativefiledialog-extended architecture

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

- Interactive diagram: https://gitdiagram.com/btzy/nativefiledialog-extended
- Repository: https://github.com/btzy/nativefiledialog-extended

## Overview

Native File Dialog Extended is a portable C library that lets applications request native file and folder selection without adopting a larger GUI toolkit. The main workflow is: an application initializes NFD, supplies dialog options through its API, and receives a selected path or path set from the platform-native dialog; callers then free returned data and shut down. Platform backends implement the native interaction, while optional C++ and SDL/GLFW headers adapt the API for those consumers. Backend dispatch and the macOS implementation are not shown in the excerpts, so those links rely on the README’s platform-support description.

Main entry points: [`src/include/nfd.h`](https://github.com/btzy/nativefiledialog-extended/blob/master/src/include/nfd.h) (C dialog API), [`src/nfd_gtk.cpp`](https://github.com/btzy/nativefiledialog-extended/blob/master/src/nfd_gtk.cpp) (GTK dialogs), [`src/nfd_portal.cpp`](https://github.com/btzy/nativefiledialog-extended/blob/master/src/nfd_portal.cpp) (Portal dialogs), [`src/nfd_win.cpp`](https://github.com/btzy/nativefiledialog-extended/blob/master/src/nfd_win.cpp) (Windows dialogs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public API"]
  node_api["C dialog API<br/>[nfd.h]"]
end

subgraph group_platforms["Platform dialogs"]
  node_windows["Windows dialogs<br/>[nfd_win.cpp]"]
  node_macos["macOS dialogs<br/>[nfd_cocoa.m]"]
end

subgraph group_adapters["Consumer adapters"]
  node_cpp["C++ wrapper<br/>[nfd.hpp]"]
  node_glfw["GLFW adapter<br/>[nfd_glfw3.h]"]
  node_sdl2["SDL2 adapter<br/>[nfd_sdl2.h]"]
  node_sdl3["SDL3 adapter<br/>[nfd_sdl3.h]"]
end

subgraph group_linux["Linux support"]
  node_gtk["GTK dialogs<br/>[nfd_gtk.cpp]"]
  node_portal["Portal dialogs<br/>[nfd_portal.cpp]"]
  node_linux_shared["Linux shared support"]
end

node_application(("Application"))
node_native_dialogs["Native dialog services"]

node_application -->|"requests dialogs"| node_api
node_api -.->|"dispatches"| node_windows
node_api -.->|"dispatches"| node_macos
node_api -.->|"dispatches"| node_gtk
node_api -.->|"dispatches"| node_portal
node_windows -.->|"opens native UI"| node_native_dialogs
node_macos -.->|"opens native UI"| node_native_dialogs
node_gtk -.->|"opens native UI"| node_native_dialogs
node_portal -.->|"opens native UI"| node_native_dialogs
node_gtk -->|"uses helpers"| node_linux_shared
node_portal -->|"uses helpers"| node_linux_shared
node_cpp -->|"wraps calls"| node_api
node_glfw -->|"sets window handles"| node_api
node_sdl2 -->|"sets window handles"| node_api
node_sdl3 -->|"sets window handles"| node_api

click node_api "https://github.com/btzy/nativefiledialog-extended/blob/master/src/include/nfd.h"
click node_cpp "https://github.com/btzy/nativefiledialog-extended/blob/master/src/include/nfd.hpp"
click node_glfw "https://github.com/btzy/nativefiledialog-extended/blob/master/src/include/nfd_glfw3.h"
click node_sdl2 "https://github.com/btzy/nativefiledialog-extended/blob/master/src/include/nfd_sdl2.h"
click node_sdl3 "https://github.com/btzy/nativefiledialog-extended/blob/master/src/include/nfd_sdl3.h"
click node_windows "https://github.com/btzy/nativefiledialog-extended/blob/master/src/nfd_win.cpp"
click node_macos "https://github.com/btzy/nativefiledialog-extended/blob/master/src/nfd_cocoa.m"
click node_gtk "https://github.com/btzy/nativefiledialog-extended/blob/master/src/nfd_gtk.cpp"
click node_portal "https://github.com/btzy/nativefiledialog-extended/blob/master/src/nfd_portal.cpp"
click node_linux_shared "https://github.com/btzy/nativefiledialog-extended/blob/master/src/nfd_linux_shared.hpp"

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_api toneBlue
class node_windows,node_macos toneAmber
class node_cpp,node_glfw,node_sdl2,node_sdl3 toneMint
class node_gtk,node_portal,node_linux_shared toneRose
class node_application,node_native_dialogs toneIndigo
```

## Components

### Public API

- [C dialog API](https://github.com/btzy/nativefiledialog-extended/blob/master/src/include/nfd.h): `src/include/nfd.h`

### Platform dialogs

- [Windows dialogs](https://github.com/btzy/nativefiledialog-extended/blob/master/src/nfd_win.cpp): `src/nfd_win.cpp`
- [macOS dialogs](https://github.com/btzy/nativefiledialog-extended/blob/master/src/nfd_cocoa.m): `src/nfd_cocoa.m`

### Consumer adapters

- [C++ wrapper](https://github.com/btzy/nativefiledialog-extended/blob/master/src/include/nfd.hpp): `src/include/nfd.hpp`
- [GLFW adapter](https://github.com/btzy/nativefiledialog-extended/blob/master/src/include/nfd_glfw3.h): `src/include/nfd_glfw3.h`
- [SDL2 adapter](https://github.com/btzy/nativefiledialog-extended/blob/master/src/include/nfd_sdl2.h): `src/include/nfd_sdl2.h`
- [SDL3 adapter](https://github.com/btzy/nativefiledialog-extended/blob/master/src/include/nfd_sdl3.h): `src/include/nfd_sdl3.h`

### Linux support

- [GTK dialogs](https://github.com/btzy/nativefiledialog-extended/blob/master/src/nfd_gtk.cpp): `src/nfd_gtk.cpp`
- [Portal dialogs](https://github.com/btzy/nativefiledialog-extended/blob/master/src/nfd_portal.cpp): `src/nfd_portal.cpp`
- [Linux shared support](https://github.com/btzy/nativefiledialog-extended/blob/master/src/nfd_linux_shared.hpp): `src/nfd_linux_shared.hpp`

### Other components

- **Application**
- **Native dialog services**

## Connections

- Application → C dialog API: requests dialogs (evidence: `README.md`)
- C dialog API → Windows dialogs: dispatches (evidence: `src/nfd_win.cpp`)
- C dialog API → macOS dialogs: dispatches
- C dialog API → GTK dialogs: dispatches (evidence: `src/nfd_gtk.cpp`)
- C dialog API → Portal dialogs: dispatches (evidence: `src/nfd_portal.cpp`)
- Windows dialogs → Native dialog services: opens native UI
- macOS dialogs → Native dialog services: opens native UI
- GTK dialogs → Native dialog services: opens native UI
- Portal dialogs → Native dialog services: opens native UI
- GTK dialogs → Linux shared support: uses helpers (evidence: `src/nfd_gtk.cpp`)
- Portal dialogs → Linux shared support: uses helpers (evidence: `src/nfd_portal.cpp`)
- C++ wrapper → C dialog API: wraps calls (evidence: `src/include/nfd.hpp`)
- GLFW adapter → C dialog API: sets window handles (evidence: `src/include/nfd_glfw3.h`)
- SDL2 adapter → C dialog API: sets window handles (evidence: `src/include/nfd_sdl2.h`)
- SDL3 adapter → C dialog API: sets window handles (evidence: `src/include/nfd_sdl3.h`)
