Skip to main content

SPEC 016 — Google Drive Integration


1. Feature Purpose

Google Drive Integration lets organizations connect a Google account and automatically synchronize files from specific Google Drive folders into the Equa Data Room. Admins configure which Google Drive folders map to which Data Room paths, and the system handles ongoing sync — detecting new files, updates, and deletions. This eliminates manual file uploads for teams that already use Google Drive as their primary document store.

2. Current State (Verified)

2.1 OAuth Connection Flow

2.2 Sync Configuration

2.3 Sync Execution

2.4 Frontend


3. Data Model

GoogleDriveConnections

GoogleDriveSyncConfigurations

GoogleDriveSyncHistory

GoogleDriveSyncedFiles


4. API Endpoints


5. Frontend Components

Frontend Behavior

  • Feature gate — Page is hidden unless GOOGLE_DRIVE_ENABLED is true and the user has editDocuments permission.
  • OAuth popup — Connect button opens a popup for Google consent; callback closes the popup and refreshes connection status.
  • Sync progress — Manual sync triggers poll the history endpoint until the run status reaches completed or failed.
  • Error display — Configuration-level and file-level sync errors are surfaced inline with retry options.
  • Folder picker — Lazy-loads folder children on expand; caches results for the session.

6. Business Rules

  1. One connection per organization — Only one Google account can be connected at a time; connecting a new account replaces the previous one.
  2. Read-only access — The integration requests only drive.readonly scopes; it never modifies files on Google Drive.
  3. Token refresh — Access tokens are refreshed automatically before API calls when expired; refresh failures set syncError and mark the connection for re-auth.
  4. Google Drive wins — During sync, if a file’s googleModifiedTime or googleMd5Checksum differs from the stored values, the local copy is replaced.
  5. Subfolder opt-in — Subfolders are only traversed when syncSubfolders is explicitly enabled on the configuration.
  6. File type filtering — When fileTypeFilter is set, only files matching the include list (or not in the exclude list) are synced.
  7. Sync isolation — Each configuration syncs independently; a failure in one does not block others.
  8. History retention — Sync history records are retained indefinitely for audit; the details JSONB field stores per-file outcomes.
  9. Soft disconnect — Disconnecting sets isActive = false and revokes the OAuth token but preserves previously synced files in the Data Room.
  10. Google Docs export — Google-native formats (Docs, Sheets, Slides) are exported to their Microsoft Office equivalents (docx, xlsx, pptx) during sync since they lack direct download URLs.

7. Acceptance Criteria

  • Admin can connect a Google account via OAuth popup and see the connected email
  • Admin can disconnect the Google account; synced files remain in the Data Room
  • Admin can browse Google Drive folders and select one for sync
  • Admin can map a Google Drive folder to a specific Data Room path
  • Admin can enable/disable subfolder traversal per mapping
  • Admin can set file type filters (include or exclude by MIME type)
  • Manual sync detects new, updated, and deleted files correctly
  • Sync history shows accurate counts for processed/added/updated/skipped/failed files
  • Failed syncs display error messages with retry option
  • Token refresh happens transparently; expired tokens do not block sync
  • Google Docs are exported as Office-format files
  • Page is not visible when GOOGLE_DRIVE_ENABLED is false
  • Non-admin users cannot connect/disconnect or modify sync configurations

8. Risks