# aftabahmedfahim/driveaudit architecture

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

- Interactive diagram: https://gitdiagram.com/aftabahmedfahim/driveaudit
- Repository: https://github.com/aftabahmedfahim/driveaudit

## Overview

DriveAudit is a React dashboard for connecting multiple Google Drive accounts, scanning owned files for duplicates and cleanup candidates, visualizing storage and estimated carbon impact, and trashing selected files. The principal workflow is authentication, Google OAuth connection, metadata scanning, cross-drive analysis, then review and cleanup. The graph includes the documented search and storage-visualization capabilities. Source excerpts establish key calls; some feature wiring is documented only in the README, so those edges cite it.

Main entry points: [`src/App.jsx`](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/App.jsx) (App routes), [`src/lib/drive.js`](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/lib/drive.js) (Drive metadata and analysis), [`src/pages/Dashboard.jsx`](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/pages/Dashboard.jsx) (Dashboard), [`src/components/DriveCard.jsx`](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/components/DriveCard.jsx) (Drive scan card)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and routing"]
  node_app["App routes<br/>[App.jsx]"]
  node_authpage["Sign in / sign up<br/>[AuthPage.jsx]"]
  node_auth["Auth state<br/>[AuthContext.jsx]"]
  node_landing["Landing page<br/>[Landing.jsx]"]
  node_privacy["Privacy page<br/>[Privacy.jsx]"]
  node_protected["Protected routes<br/>[ProtectedRoute.jsx]"]
end

subgraph group_connections["Drive connections"]
  node_supabaseclient["Supabase client<br/>[supabase.js]"]
  node_oauthcallback["OAuth callback<br/>[OAuthCallback.jsx]"]
  node_drives["Drive connections<br/>[DrivesContext.jsx]"]
  node_drivestore[("Connected-drive records<br/>[schema.sql]")]
  node_exchange["Token exchange<br/>[index.ts]"]
  node_refresh["Token refresh<br/>[index.ts]"]
end

subgraph group_audit["Scanning and cleanup"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_drivecard["Drive scan card<br/>[DriveCard.jsx]"]
  node_drivehelpers["Drive metadata and analysis<br/>[drive.js]"]
  node_scanresults["Scan results and cleanup<br/>[ScanResults.jsx]"]
  node_search["Cross-drive search<br/>[DriveSearch.jsx]"]
end

subgraph group_insights["Dashboard insights"]
  node_carbon["Carbon calculations<br/>[carbon.js]"]
  node_carbonsummary["Carbon summary<br/>[CarbonSummary.jsx]"]
end

node_user(("Drive user"))
node_authservice["Supabase Auth"]
node_googleoauth["Google OAuth"]
node_googleapi["Google Drive API"]

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_authpage
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_oauthcallback
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_privacy
node_app -->|"guards routes"| node_protected
node_authpage -->|"uses auth"| node_auth
node_auth -->|"calls"| node_supabaseclient
node_supabaseclient -.->|"configures"| node_authservice
node_protected -->|"checks session"| node_auth
node_dashboard -->|"uses connections"| node_drives
node_dashboard -->|"renders"| node_drivecard
node_dashboard -->|"renders"| node_scanresults
node_dashboard -->|"renders"| node_search
node_dashboard -->|"renders"| node_carbonsummary
node_drives -->|"reads records"| node_supabaseclient
node_drives -->|"reads and deletes"| node_drivestore
node_oauthcallback -->|"gets session"| node_supabaseclient
node_oauthcallback -->|"invokes"| node_exchange
node_exchange -.->|"exchanges code"| node_googleoauth
node_oauthcallback -->|"upserts connection"| node_drivestore
node_oauthcallback -->|"refreshes list"| node_drives
node_drives -->|"posts refresh request"| node_refresh
node_refresh -.->|"refreshes token"| node_googleoauth
node_drivecard -->|"fetches metadata"| node_drivehelpers
node_drivecard -->|"fetches quota"| node_drivehelpers
node_drivecard -->|"analyzes files"| node_drivehelpers
node_drivehelpers -->|"requests files and info"| node_googleapi
node_scanresults -->|"finds cross-drive copies"| node_drivehelpers
node_scanresults -->|"trashes selected files"| node_googleapi
node_search -->|"trashes selected files"| node_googleapi
node_drivecard -->|"calculates footprint"| node_carbon
node_scanresults -->|"formats impact"| node_carbon
node_carbonsummary -->|"uses calculations"| node_carbon
node_search -.->|"searches all drives"| node_drivehelpers
node_drivecard -.->|"visualizes storage"| node_googleapi
node_scanresults -.->|"flags stale and large files"| node_drivehelpers

click node_app "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/App.jsx"
click node_authpage "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/pages/AuthPage.jsx"
click node_auth "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/context/AuthContext.jsx"
click node_supabaseclient "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/lib/supabase.js"
click node_oauthcallback "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/pages/OAuthCallback.jsx"
click node_drives "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/context/DrivesContext.jsx"
click node_drivestore "https://github.com/aftabahmedfahim/driveaudit/blob/main/supabase/schema.sql"
click node_exchange "https://github.com/aftabahmedfahim/driveaudit/blob/main/supabase/functions/exchange-drive-token/index.ts"
click node_refresh "https://github.com/aftabahmedfahim/driveaudit/blob/main/supabase/functions/refresh-drive-token/index.ts"
click node_dashboard "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/pages/Dashboard.jsx"
click node_drivecard "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/components/DriveCard.jsx"
click node_drivehelpers "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/lib/drive.js"
click node_scanresults "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/components/ScanResults.jsx"
click node_search "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/components/DriveSearch.jsx"
click node_carbon "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/lib/carbon.js"
click node_carbonsummary "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/components/CarbonSummary.jsx"
click node_landing "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/pages/Landing.jsx"
click node_privacy "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/pages/Privacy.jsx"
click node_protected "https://github.com/aftabahmedfahim/driveaudit/blob/main/src/components/ProtectedRoute.jsx"

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_app,node_authpage,node_auth,node_landing,node_privacy,node_protected,node_user toneBlue
class node_supabaseclient,node_oauthcallback,node_drives,node_drivestore,node_exchange,node_refresh toneAmber
class node_dashboard,node_drivecard,node_drivehelpers,node_scanresults,node_search,node_googleapi toneMint
class node_carbon,node_carbonsummary toneRose
class node_authservice,node_googleoauth toneIndigo
```

## Components

### Identity and routing

- [App routes](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/App.jsx): `src/App.jsx`
- [Sign in / sign up](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/pages/AuthPage.jsx): `src/pages/AuthPage.jsx`
- [Auth state](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`
- [Landing page](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/pages/Landing.jsx): `src/pages/Landing.jsx`
- [Privacy page](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/pages/Privacy.jsx): `src/pages/Privacy.jsx`
- [Protected routes](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/components/ProtectedRoute.jsx): `src/components/ProtectedRoute.jsx`

### Drive connections

- [Supabase client](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/lib/supabase.js): `src/lib/supabase.js`
- [OAuth callback](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/pages/OAuthCallback.jsx): `src/pages/OAuthCallback.jsx`
- [Drive connections](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/context/DrivesContext.jsx): `src/context/DrivesContext.jsx`
- [Connected-drive records](https://github.com/aftabahmedfahim/driveaudit/blob/main/supabase/schema.sql): `supabase/schema.sql`
- [Token exchange](https://github.com/aftabahmedfahim/driveaudit/blob/main/supabase/functions/exchange-drive-token/index.ts): `supabase/functions/exchange-drive-token/index.ts`
- [Token refresh](https://github.com/aftabahmedfahim/driveaudit/blob/main/supabase/functions/refresh-drive-token/index.ts): `supabase/functions/refresh-drive-token/index.ts`

### Scanning and cleanup

- [Dashboard](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/pages/Dashboard.jsx): `src/pages/Dashboard.jsx`
- [Drive scan card](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/components/DriveCard.jsx): `src/components/DriveCard.jsx`
- [Drive metadata and analysis](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/lib/drive.js): `src/lib/drive.js`
- [Scan results and cleanup](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/components/ScanResults.jsx): `src/components/ScanResults.jsx`
- [Cross-drive search](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/components/DriveSearch.jsx): `src/components/DriveSearch.jsx`

### Dashboard insights

- [Carbon calculations](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/lib/carbon.js): `src/lib/carbon.js`
- [Carbon summary](https://github.com/aftabahmedfahim/driveaudit/blob/main/src/components/CarbonSummary.jsx): `src/components/CarbonSummary.jsx`

### Other components

- **Drive user**
- **Supabase Auth**
- **Google OAuth**
- **Google Drive API**

## Connections

- Drive user → App routes: opens (evidence: `src/App.jsx`)
- App routes → Sign in / sign up: routes to (evidence: `src/App.jsx`)
- App routes → Dashboard: routes to (evidence: `src/App.jsx`)
- App routes → OAuth callback: routes to (evidence: `src/App.jsx`)
- App routes → Landing page: routes to (evidence: `src/App.jsx`)
- App routes → Privacy page: routes to (evidence: `src/App.jsx`)
- App routes → Protected routes: guards routes (evidence: `src/App.jsx`)
- Sign in / sign up → Auth state: uses auth (evidence: `src/pages/AuthPage.jsx`)
- Auth state → Supabase client: calls (evidence: `src/context/AuthContext.jsx`)
- Supabase client → Supabase Auth: configures (evidence: `src/lib/supabase.js`)
- Protected routes → Auth state: checks session (evidence: `src/components/ProtectedRoute.jsx`)
- Dashboard → Drive connections: uses connections (evidence: `src/pages/Dashboard.jsx`)
- Dashboard → Drive scan card: renders (evidence: `src/pages/Dashboard.jsx`)
- Dashboard → Scan results and cleanup: renders (evidence: `src/pages/Dashboard.jsx`)
- Dashboard → Cross-drive search: renders (evidence: `src/pages/Dashboard.jsx`)
- Dashboard → Carbon summary: renders (evidence: `src/pages/Dashboard.jsx`)
- Drive connections → Supabase client: reads records (evidence: `src/context/DrivesContext.jsx`)
- Drive connections → Connected-drive records: reads and deletes (evidence: `src/context/DrivesContext.jsx`)
- OAuth callback → Supabase client: gets session (evidence: `src/pages/OAuthCallback.jsx`)
- OAuth callback → Token exchange: invokes (evidence: `src/pages/OAuthCallback.jsx`)
- Token exchange → Google OAuth: exchanges code
- OAuth callback → Connected-drive records: upserts connection (evidence: `src/pages/OAuthCallback.jsx`)
- OAuth callback → Drive connections: refreshes list (evidence: `src/pages/OAuthCallback.jsx`)
- Drive connections → Token refresh: posts refresh request (evidence: `src/context/DrivesContext.jsx`)
- Token refresh → Google OAuth: refreshes token
- Drive scan card → Drive metadata and analysis: fetches metadata (evidence: `src/components/DriveCard.jsx`)
- Drive scan card → Drive metadata and analysis: fetches quota (evidence: `src/components/DriveCard.jsx`)
- Drive scan card → Drive metadata and analysis: analyzes files (evidence: `src/components/DriveCard.jsx`)
- Drive metadata and analysis → Google Drive API: requests files and info (evidence: `src/lib/drive.js`)
- Scan results and cleanup → Drive metadata and analysis: finds cross-drive copies (evidence: `src/components/ScanResults.jsx`)
- Scan results and cleanup → Google Drive API: trashes selected files (evidence: `src/components/ScanResults.jsx`)
- Cross-drive search → Google Drive API: trashes selected files (evidence: `src/components/DriveSearch.jsx`)
- Drive scan card → Carbon calculations: calculates footprint (evidence: `src/components/DriveCard.jsx`)
- Scan results and cleanup → Carbon calculations: formats impact (evidence: `src/components/ScanResults.jsx`)
- Carbon summary → Carbon calculations: uses calculations (evidence: `src/components/CarbonSummary.jsx`)
- Cross-drive search → Drive metadata and analysis: searches all drives (evidence: `README.md`)
- Drive scan card → Google Drive API: visualizes storage (evidence: `README.md`)
- Scan results and cleanup → Drive metadata and analysis: flags stale and large files (evidence: `README.md`)
