# ticgal/gdrive architecture

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

- Interactive diagram: https://gitdiagram.com/ticgal/gdrive
- Repository: https://github.com/ticgal/gdrive

## Overview

Gdrive is a GLPI plugin that lets users select Google Drive files and add them to GLPI assets. The main workflow is exposed through GLPI item-form hooks: the plugin renders a picker button, obtains a temporary Google access token, retrieves selected file content, and hands it to GLPI's upload mechanism. Configuration stores Google API credentials and is managed through GLPI's protected configuration page. The excerpts show these responsibilities but not all upload internals; the result handoff is represented at the GLPI boundary.

Main entry points: [`src/Ticket.php`](https://github.com/ticgal/gdrive/blob/develop/src/Ticket.php) (Picker button), [`src/Config.php`](https://github.com/ticgal/gdrive/blob/develop/src/Config.php) (Google settings), [`setup.php`](https://github.com/ticgal/gdrive/blob/develop/setup.php) (Hook registration), [`front/config.form.php`](https://github.com/ticgal/gdrive/blob/develop/front/config.form.php) (Config endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["GLPI Integration"]
  node_plugin_hooks["Hook registration<br/>[setup.php]"]
  node_item_ui["Item form UI<br/>[Ticket.php]"]
end

subgraph group_configuration["Plugin Configuration"]
  node_config_page["Config endpoint<br/>[config.form.php]"]
  node_config_model["Google settings<br/>[Config.php]"]
  node_config_db[("Plugin config table<br/>[Config.php]")]
  node_install_hooks["Install lifecycle<br/>[hook.php]"]
end

subgraph group_transfer["Drive File Transfer"]
  node_picker_button["Picker button<br/>[Ticket.php]"]
  node_file_transfer["File retrieval and upload<br/>[Ticket.php]"]
end

node_user(("GLPI user"))
node_glpi["GLPI host"]
node_oauth["Google OAuth"]
node_google_picker["Google Picker"]
node_drive_api["Google Drive API"]
node_glpi_upload["GLPI file upload"]

node_glpi -->|"initializes plugin"| node_plugin_hooks
node_plugin_hooks -->|"registers item hooks"| node_item_ui
node_user -.->|"opens asset"| node_glpi
node_item_ui -->|"loads settings"| node_config_model
node_user -.->|"manages credentials"| node_config_page
node_config_page -->|"updates settings"| node_config_model
node_config_model -->|"reads and writes"| node_config_db
node_install_hooks -->|"installs or removes"| node_config_model
node_item_ui -->|"renders picker"| node_picker_button
node_user -.->|"selects files"| node_picker_button
node_picker_button -->|"requests token"| node_oauth
node_picker_button -->|"opens picker"| node_google_picker
node_google_picker -.->|"returns selection"| node_file_transfer
node_file_transfer -->|"fetches file"| node_drive_api
node_file_transfer -->|"uploads content"| node_glpi_upload
node_glpi_upload -.->|"adds file to asset"| node_glpi

click node_plugin_hooks "https://github.com/ticgal/gdrive/blob/develop/setup.php"
click node_item_ui "https://github.com/ticgal/gdrive/blob/develop/src/Ticket.php"
click node_config_page "https://github.com/ticgal/gdrive/blob/develop/front/config.form.php"
click node_config_model "https://github.com/ticgal/gdrive/blob/develop/src/Config.php"
click node_config_db "https://github.com/ticgal/gdrive/blob/develop/src/Config.php"
click node_install_hooks "https://github.com/ticgal/gdrive/blob/develop/hook.php"
click node_picker_button "https://github.com/ticgal/gdrive/blob/develop/src/Ticket.php"
click node_file_transfer "https://github.com/ticgal/gdrive/blob/develop/src/Ticket.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_plugin_hooks,node_item_ui,node_user toneBlue
class node_config_page,node_config_model,node_config_db,node_install_hooks toneAmber
class node_picker_button,node_file_transfer,node_drive_api toneMint
class node_glpi,node_oauth,node_google_picker,node_glpi_upload toneIndigo
```

## Components

### GLPI Integration

- [Hook registration](https://github.com/ticgal/gdrive/blob/develop/setup.php): `setup.php`
- [Item form UI](https://github.com/ticgal/gdrive/blob/develop/src/Ticket.php): `src/Ticket.php`

### Plugin Configuration

- [Config endpoint](https://github.com/ticgal/gdrive/blob/develop/front/config.form.php): `front/config.form.php`
- [Google settings](https://github.com/ticgal/gdrive/blob/develop/src/Config.php): `src/Config.php`
- [Plugin config table](https://github.com/ticgal/gdrive/blob/develop/src/Config.php): `src/Config.php`
- [Install lifecycle](https://github.com/ticgal/gdrive/blob/develop/hook.php): `hook.php`

### Drive File Transfer

- [Picker button](https://github.com/ticgal/gdrive/blob/develop/src/Ticket.php): `src/Ticket.php`
- [File retrieval and upload](https://github.com/ticgal/gdrive/blob/develop/src/Ticket.php): `src/Ticket.php`

### Other components

- **GLPI user**
- **GLPI host**
- **Google OAuth**
- **Google Picker**
- **Google Drive API**
- **GLPI file upload**

## Connections

- GLPI host → Hook registration: initializes plugin (evidence: `setup.php`)
- Hook registration → Item form UI: registers item hooks (evidence: `setup.php`)
- GLPI user → GLPI host: opens asset (evidence: `README.md`)
- Item form UI → Google settings: loads settings (evidence: `src/Ticket.php`)
- GLPI user → Config endpoint: manages credentials (evidence: `README.md`)
- Config endpoint → Google settings: updates settings (evidence: `front/config.form.php`)
- Google settings → Plugin config table: reads and writes (evidence: `src/Config.php`)
- Install lifecycle → Google settings: installs or removes (evidence: `hook.php`)
- Item form UI → Picker button: renders picker (evidence: `src/Ticket.php`)
- GLPI user → Picker button: selects files (evidence: `README.md`)
- Picker button → Google OAuth: requests token (evidence: `src/Ticket.php`)
- Picker button → Google Picker: opens picker (evidence: `src/Ticket.php`)
- Google Picker → File retrieval and upload: returns selection
- File retrieval and upload → Google Drive API: fetches file (evidence: `src/Ticket.php`)
- File retrieval and upload → GLPI file upload: uploads content (evidence: `src/Ticket.php`)
- GLPI file upload → GLPI host: adds file to asset (evidence: `README.md`)
