Note: There are some issues with deployment in free tier of Render, It is explained here for better understanding
This is a full-stack application that allows users to sign in with Google, upload, manage, search, download, and share files, similar to Google Drive.
Built using React.js + Node.js (TypeScript), with AWS S3 for storage and MongoDB for database.
- Frontend: React.js + Vite
- Backend: Node.js + Express + TypeScript
- Database: MongoDB Atlas
- Authentication: Google OAuth 2.0
- File Storage: AWS S3
- Containerization: Docker & Docker Compose
- Install Docker
- Install Docker Compose
- Install Node.js
git clone https://github.com/mondeep31/GDrive.git
cd twospooncd serverUse .env.sample as a reference:
cp .env.sample .envFill in all necessary environment variables:
PORT=5000
MONGODB_URI=your_mongodb_connection_uri
SESSION_SECRET=your_secret_session_key
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
CALLBACK_URL=http://localhost:5000/auth/google/callback
FRONTEND_URL=http://localhost:5173
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key
AWS_REGION=your_aws_region
S3_BUCKET_NAME=your_s3_bucket_namedocker compose up --build- Backend will start at
http://localhost:5000
cd ../clientnpm installUse .env.sample as a reference:
cp .env.sample .envFill in all necessary environment variables:
VITE_AXIOS_BASE_URL=http://localhost:5000npm run dev- Frontend will start at
http://localhost:5173
- Visit: http://localhost:5173
- Login with your Google account
- Start uploading files!
This app can be deployed to Render, Vercel, AWS EC2, or any other cloud provider.
- Deploy backend on your server/cloud instance.
- Setup Environment Variables on the server:
- Same as your local
.env - But update:
CALLBACK_URL=https://yourbackenddomain.com/auth/google/callbackFRONTEND_URL=https://yourfrontenddomain.com
- Same as your local
- Expose the port (5000 or use reverse proxy like Nginx).
- Remember to set
app.set('trust proxy', 1);for session cookies.
- Update frontend
.env:
VITE_AXIOS_BASE_URL=https://yourbackenddomain.com- Build frontend:
npm run build- Deploy frontend to Vercel (recommended) or any static hosting.
- Go to Google Cloud Console.
- Create a new project or select existing.
- Setup OAuth consent screen:
- Application name
- Support email
- Authorized domains (example:
yourfrontenddomain.com)
- Setup OAuth credentials:
- Authorized Redirect URIs:
https://yourbackenddomain.com/auth/google/callback
- Authorized Redirect URIs:
- Save the
CLIENT_IDandCLIENT_SECRETand use them in.env.
- Create a free MongoDB cluster on MongoDB Atlas.
- Create a new database and user.
- Whitelist your server's IP.
- Get the connection URI and set it in
MONGODB_URIin backend.env.
- Create an S3 bucket on AWS S3.
- Create IAM User with S3 full access.
- Save the:
- AWS Access Key
- AWS Secret Key
- Set Bucket name, Region, and keys into
.env.
| Key | Description |
|---|---|
PORT |
Backend running port |
MONGODB_URI |
MongoDB connection string |
SESSION_SECRET |
Session encryption secret key |
GOOGLE_CLIENT_ID |
Google OAuth Client ID |
GOOGLE_CLIENT_SECRET |
Google OAuth Client Secret |
CALLBACK_URL |
Google OAuth redirect URL |
FRONTEND_URL |
Your deployed frontend URL |
AWS_ACCESS_KEY_ID |
AWS IAM Access Key |
AWS_SECRET_ACCESS_KEY |
AWS IAM Secret Key |
AWS_REGION |
AWS region for your S3 bucket |
S3_BUCKET_NAME |
Your S3 bucket name |
- Make sure
secure: trueandsameSite: noneis used for session cookies in production andsameSite: laxin development. - Always deploy backend and frontend on HTTPS domains in production.
- Set correct CORS allowed origins in your backend!
Scroll down in this notion link to find screenshots
Made with ❤️ by Mondeep