https://github.com/kapilsinghnegi/project-drive
A Google Drive-inspired backend app using Node.js, Express, MongoDB, and Supabase Storage for secure user authentication, file upload, management, and download.
https://github.com/kapilsinghnegi/project-drive
ejs express jwt mongodb mongoose multer nodejs supabase-storage
Last synced: 3 months ago
JSON representation
A Google Drive-inspired backend app using Node.js, Express, MongoDB, and Supabase Storage for secure user authentication, file upload, management, and download.
- Host: GitHub
- URL: https://github.com/kapilsinghnegi/project-drive
- Owner: kapilsinghnegi
- Created: 2025-08-02T08:15:04.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-03T17:28:56.000Z (11 months ago)
- Last Synced: 2025-08-14T23:21:25.249Z (11 months ago)
- Topics: ejs, express, jwt, mongodb, mongoose, multer, nodejs, supabase-storage
- Language: EJS
- Homepage: https://project-drive-x53s.onrender.com
- Size: 34.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Project Drive
A Google Drive-like backend built with Node.js, Express, MongoDB, Supabase Storage, and JWT authentication.
This project allows users to register, log in, upload files, and download them securely. It uses Supabase for file storage and MongoDB for user management.
This is a simple implementation of a file storage system similar to Google Drive, focusing on backend functionality.
## Features
- User registration and login
- JWT-based authentication
- File upload (stored in Supabase Storage)
- File download (from Supabase Storage)
- User-specific file access
- Secure file storage and retrieval
## Tech Stack
- Node.js
- Express
- MongoDB (Mongoose)
- Supabase Storage
- Multer (for file uploads)
- JWT (jsonwebtoken)
- EJS (templating)
## Getting Started
1. **Clone the repository:**
```sh
git clone https://github.com/yourusername/drive-clone.git
cd drive-clone
```
2. **Install dependencies:**
```sh
npm install
```
3. **Configure environment variables:**
- Copy `.env.example` to `.env` and fill in your credentials:
```
MONGO_URI=your_mongo_uri
JWT_SECRET=your_jwt_secret
SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
```
4. **Start the server:**
```sh
npm start
```
5. **Access the app:**
- Visit `http://localhost:3000` in your browser.
## Folder Structure
```
project-drive/
app.js
config/
db.js
multer.config.js
supabaseClient.js
middlewares/
auth.js
models/
files.models.js
user.model.js
routes/
index.routes.js
user.routes.js
views/
home.ejs
index.ejs
login.ejs
register.ejs
.env
package.json
README.md
```
## API Routes
### **Authentication & User**
- `GET /user/register` — Render registration page
- `POST /user/register` — Register a new user
- `GET /user/login` — Render login page
- `POST /user/login` — Login user and issue JWT
- `GET /user/logout` — Logout user
### **Home & Dashboard**
- `GET /` — Render landing page
- `GET /home` — Render user dashboard (requires authentication)
### **File Operations**
- `POST /upload` — Upload a file (authenticated, stores in Supabase Storage)
- `GET /download/:path` — Download a file by its Supabase Storage path (authenticated)
- `GET /files` — List all files for the logged-in user (authenticated)
- `DELETE /file/:id` — Delete a file by its database ID (authenticated)
> **Note:**
> All file routes require the user to be authenticated via JWT.
**Security Note:**
Never expose your Supabase service role key on the frontend.
This project is intended for educational purposes. Always follow best practices for security in production applications.