# astrada/google-drive-ocamlfuse architecture

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

- Interactive diagram: https://gitdiagram.com/astrada/google-drive-ocamlfuse
- Repository: https://github.com/astrada/google-drive-ocamlfuse

## Overview

google-drive-ocamlfuse mounts Google Drive as a Linux FUSE filesystem. The documented user flow is to authorize the application, configure an account, then run it against a mount point; filesystem operations provide read/write access to ordinary files and folders, with read-only export for Google documents. The tree identifies likely implementation modules, but no source excerpts were provided, so internal calls are not asserted; dashed edges mark relationships whose precise implementation is unverified.

Main entry points: [`src/drive.ml`](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/drive.ml) (Filesystem operations), [`src/gdfuseCli.ml`](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/gdfuseCli.ml) (Command line), [`src/gdfuseFuseNative.ml`](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/gdfuseFuseNative.ml) (FUSE operations), [`src/gdfuseFlow.ml`](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/gdfuseFlow.ml) (Application flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_cli["Command line<br/>[gdfuseCli.ml]"]
  node_app["Application flow<br/>[gdfuseFlow.ml]"]
end

subgraph group_auth["Authorization and config"]
  node_config["Account config<br/>[config.ml]"]
  node_oauth["OAuth2<br/>[oauth2.ml]"]
  node_loopback["OAuth callback<br/>[loopbackServer.ml]"]
end

subgraph group_filesystem["Mounted filesystem"]
  node_fuse_native["FUSE operations"]
  node_drive["Filesystem operations<br/>[drive.ml]"]
  node_directory["Directory reads"]
  node_mutations["File mutations"]
  node_xattrs["Extended attributes<br/>[driveXattrs.ml]"]
  node_exports["Document exports<br/>[mime.ml]"]
end

subgraph group_drive["Drive data and cache"]
  node_cache[("Metadata cache<br/>[cache.ml]")]
  node_db_cache[("Persistent cache<br/>[dbCache.ml]")]
  node_downloads["File downloads<br/>[driveDownloads.ml]"]
  node_streaming["Read-ahead streaming<br/>[driveStreaming.ml]"]
  node_uploads["Upload queue<br/>[uploadQueue.ml]"]
  node_background_fetch["Folder fetching"]
end

node_user(("User"))
node_fuse(("FUSE kernel"))
node_drive_api["Google Drive API"]

node_user -->|"runs"| node_cli
node_cli -.->|"authorizes"| node_oauth
node_oauth -.->|"receives callback"| node_loopback
node_cli -->|"selects account"| node_config
node_cli -.->|"starts mount"| node_app
node_app -->|"mounts filesystem"| node_fuse_native
node_fuse -.->|"issues operations"| node_fuse_native
node_fuse_native -.->|"dispatches operations"| node_drive
node_drive -.->|"reads directories"| node_directory
node_drive -.->|"changes files"| node_mutations
node_drive -.->|"handles attributes"| node_xattrs
node_drive -.->|"exports documents"| node_exports
node_drive -.->|"caches metadata"| node_cache
node_cache -.->|"persists entries"| node_db_cache
node_drive -.->|"downloads content"| node_downloads
node_downloads -.->|"streams reads"| node_streaming
node_drive -.->|"queues writes"| node_uploads
node_drive -.->|"fetches folders"| node_background_fetch
node_drive -->|"accesses remote files"| node_drive_api

click node_cli "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/gdfuseCli.ml"
click node_app "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/gdfuseFlow.ml"
click node_config "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/config.ml"
click node_oauth "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/oauth2.ml"
click node_loopback "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/loopbackServer.ml"
click node_fuse_native "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/gdfuseFuseNative.ml"
click node_drive "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/drive.ml"
click node_directory "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/driveDirectoryReads.ml"
click node_mutations "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/driveFileMutations.ml"
click node_xattrs "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/driveXattrs.ml"
click node_exports "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/mime.ml"
click node_cache "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/cache.ml"
click node_db_cache "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/dbCache.ml"
click node_downloads "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/driveDownloads.ml"
click node_streaming "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/driveStreaming.ml"
click node_uploads "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/uploadQueue.ml"
click node_background_fetch "https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/backgroundFolderFetching.ml"

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_cli,node_app,node_user toneBlue
class node_config,node_oauth,node_loopback toneAmber
class node_fuse_native,node_drive,node_directory,node_mutations,node_xattrs,node_exports,node_drive_api toneMint
class node_cache,node_db_cache,node_downloads,node_streaming,node_uploads,node_background_fetch toneRose
class node_fuse toneIndigo
```

## Components

### Application entry

- [Command line](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/gdfuseCli.ml): `src/gdfuseCli.ml`
- [Application flow](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/gdfuseFlow.ml): `src/gdfuseFlow.ml`

### Authorization and config

- [Account config](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/config.ml): `src/config.ml`
- [OAuth2](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/oauth2.ml): `src/oauth2.ml`
- [OAuth callback](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/loopbackServer.ml): `src/loopbackServer.ml`

### Mounted filesystem

- [FUSE operations](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/gdfuseFuseNative.ml): `src/gdfuseFuseNative.ml`
- [Filesystem operations](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/drive.ml): `src/drive.ml`
- [Directory reads](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/driveDirectoryReads.ml): `src/driveDirectoryReads.ml`
- [File mutations](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/driveFileMutations.ml): `src/driveFileMutations.ml`
- [Extended attributes](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/driveXattrs.ml): `src/driveXattrs.ml`
- [Document exports](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/mime.ml): `src/mime.ml`

### Drive data and cache

- [Metadata cache](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/cache.ml): `src/cache.ml`
- [Persistent cache](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/dbCache.ml): `src/dbCache.ml`
- [File downloads](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/driveDownloads.ml): `src/driveDownloads.ml`
- [Read-ahead streaming](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/driveStreaming.ml): `src/driveStreaming.ml`
- [Upload queue](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/uploadQueue.ml): `src/uploadQueue.ml`
- [Folder fetching](https://github.com/astrada/google-drive-ocamlfuse/blob/beta/src/backgroundFolderFetching.ml): `src/backgroundFolderFetching.ml`

### Other components

- **User**
- **FUSE kernel**
- **Google Drive API**

## Connections

- User → Command line: runs (evidence: `README.md`)
- Command line → OAuth2: authorizes
- OAuth2 → OAuth callback: receives callback
- Command line → Account config: selects account (evidence: `README.md`)
- Command line → Application flow: starts mount
- Application flow → FUSE operations: mounts filesystem (evidence: `README.md`)
- FUSE kernel → FUSE operations: issues operations
- FUSE operations → Filesystem operations: dispatches operations
- Filesystem operations → Directory reads: reads directories
- Filesystem operations → File mutations: changes files
- Filesystem operations → Extended attributes: handles attributes
- Filesystem operations → Document exports: exports documents
- Filesystem operations → Metadata cache: caches metadata
- Metadata cache → Persistent cache: persists entries
- Filesystem operations → File downloads: downloads content
- File downloads → Read-ahead streaming: streams reads
- Filesystem operations → Upload queue: queues writes
- Filesystem operations → Folder fetching: fetches folders
- Filesystem operations → Google Drive API: accesses remote files (evidence: `README.md`)
