Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
9

9drive

> 编程语言
Open source

9Drive is a storage gateway web app for connecting multiple Google Drive accounts into one virtual storage dashboard. Users can connect Google Drive accounts, t

1.4K stars0 likes1 views
WebsiteGitHub

About

9Drive is a storage gateway web app for connecting multiple Google Drive accounts into one virtual storage dashboard. Users can connect Google Drive accounts, t

9Drive

9Drive is a storage gateway web app for connecting multiple Google Drive accounts into one virtual storage dashboard. Users can register with email/password or Google, automatically connect their first Google Drive account during Google sign-in, track quota, upload files into a dedicated 9drive Drive folder, organize files with virtual folders, preview files, sync MySQL from Google Drive, and let the backend route uploads to the Drive account with enough free space.

License

Copyright 2026 Zenhosta

Licensed under the Apache License, Version 2.0. See LICENSE for details.

Features

  • Google Drive and S3-compatible storage gateway in one virtual storage dashboard.
  • S3-compatible storage support with custom endpoints for providers like MinIO, Cloudflare R2, Wasabi, Backblaze B2, and AWS S3.
  • Direct upload stream to Google Drive. Files are not stored on the server.
  • Google Drive uploads are stored under a root 9drive folder.
  • Direct upload stream to S3-compatible storage through the backend without exposing storage credentials to the frontend.
  • Upload routing policies with most-available, round-robin, and priority-order modes.
  • External upload API using API keys at POST /api/v1/uploads.
  • API key management with one-time secret display, hashed key storage, last-used tracking, and revocation.
  • Email/password auth plus Google sign-in/register with automatic first Drive connection.
  • Multi-account storage quota summary.
  • Quota tracker page.
  • Manual sync from the Google Drive 9drive folder back into MySQL.
  • Virtual folders.
  • File preview, download, rename, move, and delete actions.
  • In-app API documentation with cURL and JavaScript upload examples.
  • Bottom-right upload progress panel.
  • Bearer token authentication.
  • Global Google OAuth config stored encrypted in DB (can be set via seed command or directly in Settings UI).
  • Automated system updates via update.sh directly from the Settings UI (PM2 setup).
  • Optional reCAPTCHA on email/password registration.
  • MySQL database with Prisma migrations.
  • Express + TypeScript backend.
  • React + Vite frontend.

Preview

Live preview: https://9drive.zenhosta.com

Star History

Project Structure

txt
backend/   Express API, Prisma schema, Google Drive integration
frontend/  Vite React app

Requirements

  • Node.js 20+
  • npm
  • MySQL running locally
  • Google Cloud project
  • Google OAuth Client ID and Client Secret

Default database used by this project:

txt
host: localhost
port: 3306
database: 9drive
user: root
password: empty

1. Quick Setup & Installation (Recommended)

The easiest way to prepare the project is using the automated setup script. It generates local environment files with secure keys, installs dependencies, and generates the Prisma client. MySQL 8+ must already be running for local development; Docker setup includes MySQL.

Windows (PowerShell)

Make sure to open PowerShell and navigate to the project directory first. For example, if you cloned the project to E:\AUTO KLIK\9Drive:

powershell
# 1. Switch to the drive where the project is located (if necessary)
E:

# 2. Navigate to the project folder
cd "E:\AUTO KLIK\9Drive"

# 3. Run the automated setup script
powershell -ExecutionPolicy Bypass -File .\setup.ps1

Linux/macOS

bash
bash ./setup.sh

Enter your MySQL connection URL when prompted. Google Client ID/Secret can be skipped and configured later.

Once setup is complete, apply migrations and start backend and frontend in separate terminals:

bash
cd backend
npm run prisma:migrate
npm run dev
bash
cd frontend
npm run dev

2. Manual Installation (Alternative)

If you prefer to configure the project manually:

2.1 Install Dependencies

Install backend dependencies:

bash
cd backend
npm install

Install frontend dependencies:

bash
cd ../frontend
npm install

2.2 Create Database (For MySQL)

Create a database:

sql
CREATE DATABASE 9drive;

If using MySQL CLI:

bash
mysql -u root -e "CREATE DATABASE IF NOT EXISTS 9drive;"

2.3 Environment Setup

Create backend/.env:

env
DATABASE_URL="mysql://root@localhost:3306/9drive"
APP_PORT=4000
FRONTEND_URL="http://localhost:5173"
JWT_ACCESS_SECRET="change-this-jwt-secret-at-least-32-chars"
TOKEN_ENCRYPTION_KEY="change-this-encryption-key-32bytes!"
ACCESS_TOKEN_TTL_SECONDS=900
REFRESH_TOKEN_TTL_DAYS=30
MAX_UPLOAD_BYTES=5368709120
RECAPTCHA_SECRET_KEY=""

# Used only by `npm run seed:google-config`.
# These values are encrypted and stored in DB as global Google OAuth config.
GOOGLE_CLIENT_ID=""
GOOGLE_CLIENT_SECRET=""
GOOGLE_REDIRECT_URI="http://localhost:4000/connected-accounts/google/callback"

Important:

  • JWT_ACCESS_SECRET should be long and random.
  • TOKEN_ENCRYPTION_KEY should be long and random.
  • Do not commit backend/.env.
  • Google OAuth credentials are used by the seed script, then stored encrypted in the database.

4. Frontend Environment

Create or confirm frontend/.env:

env
VITE_API_URL=http://localhost:4000
VITE_RECAPTCHA_SITE_KEY=

Captcha is disabled when VITE_RECAPTCHA_SITE_KEY or backend RECAPTCHA_SECRET_KEY is empty. Set both values to enable captcha on registration.

5. Run Prisma Migrations

bash
cd backend
npm run prisma:migrate

If Prisma client generation is blocked on Windows by a running Node process, stop running backend/frontend dev servers and run:

bash
npx prisma generate

6. Google Cloud Setup

Google setup is done in Google Cloud Console, not Google Search Console. Google Search Console is for website indexing/search ownership. OAuth and Drive API are managed in Google Cloud Console.

Open Google Cloud Console:

txt
https://console.cloud.google.com/

6.1 Create Or Select Project

  1. Open Google Cloud Console.
  2. Click project selector in top bar.
  3. Create a new project or select an existing project.
  4. Remember the project name because OAuth client and Drive API must be in the same project.

6.2 Enable Google Drive API

  1. Go to:
txt
APIs & Services -> Library
  1. Search:
txt
Google Drive API
  1. Open Google Drive API.
  2. Click Enable.
  3. Wait a few minutes if Google says the API was enabled recently.

Direct URL pattern:

txt
https://console.developers.google.com/apis/api/drive.googleapis.com/overview?project=YOUR_PROJECT_ID

If Google Drive API is disabled, you will see an error like:

txt
Google Drive API has not been used in project ... before or it is disabled.

6.3 Configure OAuth Consent Screen

  1. Go to:
txt
APIs & Services -> OAuth consent screen
  1. Choose app type:
txt
External
  1. Fill required fields:
txt
App name
User support email
Developer contact email
  1. Add scopes:
txt
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile

Full Drive access is required so Google sign-in can connect the first Drive account automatically and sync files manually added to the 9drive folder.

  1. If publishing status is Testing, add test users.

Add every Google account that will test the app:

txt
OAuth consent screen -> Test users -> Add users

If you do not add test users, Google may show:

txt
Access blocked: app has not completed the Google verification process
Error 403: access_denied

6.4 Create OAuth Client

  1. Go to:
txt
APIs & Services -> Credentials
  1. Click:
txt
Create Credentials -> OAuth client ID
  1. Application type:
txt
Web application
  1. Add authorized JavaScript origin:
txt
http://localhost:5173
  1. Add authorized redirect URI:
txt
http://localhost:4000/connected-accounts/google/callback
  1. Click Create.
  2. Copy:
txt
Client ID
Client Secret

6.5 Seed Google OAuth Config

Put values into backend/.env:

env
GOOGLE_CLIENT_ID="your-client-id"
GOOGLE_CLIENT_SECRET="your-client-secret"
GOOGLE_REDIRECT_URI="http://localhost:4000/connected-accounts/google/callback"

Then run:

bash
cd backend
npm run seed:google-config

This stores the Google OAuth config as a global encrypted provider config in MySQL. Google sign-in uses the same config and automatically connects the first Drive account. Logged-in users can still click Connect Drive in Settings to add more Drive accounts.

7. Run Development Servers

Start backend:

bash
cd backend
npm run dev

Backend runs at:

txt
http://localhost:4000

Start frontend:

bash
cd frontend
npm run dev

Frontend runs at:

txt
http://localhost:5173

Docker Deployment

This repository includes Docker files for running MySQL, backend, and frontend together.

Files:

txt
docker-compose.yml
.env.docker.example
backend/Dockerfile
frontend/Dockerfile
frontend/nginx.conf

1. Prepare Docker Env

Copy the example env file:

bash
cp .env.docker.example .env

On Windows PowerShell:

powershell
Copy-Item .env.docker.example .env

Edit .env:

env
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=9drive

FRONTEND_URL=http://localhost:5173
VITE_API_URL=http://localhost:4000
VITE_RECAPTCHA_SITE_KEY=

JWT_ACCESS_SECRET=replace-with-long-random-secret
TOKEN_ENCRYPTION_KEY=replace-with-long-random-secret
RECAPTCHA_SECRET_KEY=

GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=http://localhost:4000/connected-accounts/google/callback

Captcha is disabled when either VITE_RECAPTCHA_SITE_KEY or RECAPTCHA_SECRET_KEY is empty.

2. Start Containers

bash
docker compose up -d --build

Services:

txt
frontend: http://localhost:5173
backend:  http://localhost:4000
mysql:    localhost:3306

The backend container runs Prisma migrations automatically on startup:

txt
npm run db:migrate:deploy

This applies pending migrations such as S3 storage support before the API starts, so deployments from an older database can update safely without dropping data.

It also seeds the global Google OAuth config automatically when GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET are set to real values in .env. If those values are blank or still placeholders, the backend still starts and logs a warning. Google connect/sign-in will be unavailable until you set real Google OAuth credentials and restart the stack:

bash
docker compose up -d --build

3. Seed Google OAuth Config Manually

Automatic Docker startup seeding is usually enough. If you update Google OAuth values while containers are already running, seed the global Google OAuth config manually:

bash
docker compose exec backend npm run seed:google-config

This stores GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and GOOGLE_REDIRECT_URI from Docker env into MySQL as encrypted global config.

4. View Logs

bash
docker compose logs -f backend
docker compose logs -f frontend
docker compose logs -f mysql

5. Stop Containers

bash
docker compose down

Remove database volume too:

bash
docker compose down -v

Docker Production Notes

  • Replace localhost URLs with production domain.
  • Update Google OAuth authorized JavaScript origin.
  • Update Google OAuth redirect URI.
  • Use strong JWT_ACCESS_SECRET and TOKEN_ENCRYPTION_KEY.
  • Do not expose MySQL port publicly in production.
  • Put frontend/backend behind HTTPS reverse proxy.
  • Rebuild frontend when VITE_API_URL changes because Vite embeds env at build time.
  • Rebuild frontend when VITE_RECAPTCHA_SITE_KEY changes because Vite embeds env at build time.

VPS Deployment (Step-by-Step)

Follow these steps to deploy 9Drive to a VPS (such as Ubuntu/Debian) using Docker:

1. Install Docker & Docker Compose on your VPS

bash
sudo apt update
sudo apt install -y docker.io docker-compose
sudo systemctl enable --now docker

2. Clone the Repository

bash
git clone https://github.com/your-git

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptdrivegatewayproxystorage

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言