Everything you need to set up StitchDrive on your local machine. From Clerk authentication to Google Drive API pooling.
Production app: https://stitchdrive.vercel.app/
Begin by cloning the stitch-drive repository to your local development environment.
git clone https://github.com/Atifhasan250/stitch-drive.git
cd stitch-driveStitchDrive uses Clerk for enterprise-grade authentication. It's free for individual developers.
Publishable Key and Secret Key.CLERK_SECRET_KEY strictly confidential.You need a Google Cloud Project to interface with the Drive API. One project is enough for infinite accounts.
https://stitchdrive.vercel.app/api/accounts/oauth/callbackhttp://localhost:3000/api/accounts/oauth/callbackStitchDrive now runs as a single Next.js app. Configure the environment variables in frontend/.env.
frontend/.env
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_...
CLERK_SECRET_KEY=sk_test_...
MONGO_URI=mongodb://.../stitchdrive
FRONTEND_URL=http://localhost:3000
STATE_SECRET=your-random-secret
ENCRYPTION_KEY=your-base64-keyMONGO_URI, use MongoDB Atlas (recommended) or local MongoDB. When testing from phone/LAN, keep FRONTEND_URL for your main local web URL and also whitelist your LAN callback URI in Google Cloud.Run the Next.js development server. API routes are served from the same app.
cd frontend
npm install
npm run devOnce you log in via Clerk, you'll need to provide the app with your Google Client secrets.
With credentials initialized, you can now start pooling storage accounts.
10 × 15 GB = 150 GB
The Storage Pool Math
How is my data secured?
OAuth refresh tokens are encrypted using AES-128-CBC (Fernet compatible) before MongoDB storage. Clerk manages identity, and Google handles the physical files.
Is there a limit on accounts?
No. You can add as many Google accounts as you need. StitchDrive will automatically use the account with the most free space for every upload.
What is the 'Sync' feature for?
Since StitchDrive is a layer over Drive, clicking Sync pulls metadata for files you've uploaded directly to Drive via other devices.
Can I use it for collaboration?
Yes. Files shared with your connected accounts appear in the 'Shared with me' section and can be managed just like local files.
! CORS issues in the browser
Ensure FRONTEND_URL is correctly set in frontend/.env. For local development this should be http://localhost:3000.
! Clerk 'User Not Found' or Redirect loop
Verify that your Redirect URLs in the Clerk Dashboard include http://localhost:3000 and matches the env URLs.
! Google 'Access Blocked: Project is in Testing'
Ensure the Gmail account you are trying to connect is added as a 'Test User' in the Google Cloud Console OAuth consent screen.