A secure and user-friendly cloud-based file storage application built with Node.js and Express. This application allows users to register, log in, and manage their personal files with features including upload, download, rename, and delete. It implements robust security measures with bcryptjs for password encryption and session-based authentication to ensure that user data and files are protected.
- Key Features
- Getting Started
- Project Structure & Architecture
- Usage Guide
- API Endpoints
- Technologies Used
- Security Features
- Contributing
- License
- Author
- User Authentication System: Secure registration and login with encrypted passwords using bcryptjs. Session management ensures a protected user experience.
- Comprehensive File Management: Users can easily upload files, view their file list, download, rename, and delete files directly from their dashboard.
- Security First: Passwords are hashed, and session-based authentication prevents unauthorized access. Authorization checks ensure users can only manage their own files.
- Intuitive User Interface: A clean and responsive frontend built with vanilla HTML, CSS, and JavaScript provides a seamless experience across login, registration, and file management dashboards.
Follow these instructions to set up and run the project locally.
Make sure you have the following installed:
- Node.js (version 14 or higher)
- MySQL Server (version 5.7 or higher)
- npm (Node Package Manager)
-
Clone the repository
git clone https://github.com/username/G-drive.git cd G-drive -
Install dependencies
npm install
This will install all necessary packages including
express,bcryptjs,mysql2,multer, anddotenv.
-
Open your MySQL client and create the database:
CREATE DATABASE file_storage_dbb;
-
Use the newly created database and run the following SQL script to create the required tables:
USE file_storage_dbb; CREATE TABLE users ( id INT PRIMARY KEY AUTO_INCREMENT, username VARCHAR(255) UNIQUE NOT NULL, password VARCHAR(255) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); CREATE TABLE files ( id INT PRIMARY KEY AUTO_INCREMENT, user_id INT NOT NULL, file_name VARCHAR(255) NOT NULL, file_path VARCHAR(255) NOT NULL, upload_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE );
-
Configure your database connection by creating a
.envfile in the root directory:DB_HOST=localhost DB_USER=root DB_PASSWORD= DB_NAME=file_storage_dbb
-
Create the
uploadsdirectory in the root of the project to store uploaded files:mkdir uploads
Start the server with the following command:
node server/app.jsThe application will be running at http://localhost:3000.
The project follows a modular MVC-like pattern to separate concerns, making it scalable and maintainable.
G-drive/
├── .env # Environment variables
├── package.json # Project dependencies and scripts
├── public/ # Frontend assets
│ ├── css/style.css # Stylesheets
│ ├── html/ # HTML pages
│ └── js/script.js # Client-side scripts
├── server/
│ ├── app.js # Express server setup
│ ├── controllers/ # Business logic
│ ├── middleware/ # Custom middleware (e.g., auth)
│ └── routes/ # API routes
└── uploads/ # Storage for uploaded files
- Navigate to
http://localhost:3000. - Click "Register here" to create a new account.
- After registering, use your credentials to log in.
- username : user
- password : user123
- Upload: Use the upload form on the dashboard to add files.
- View: All your uploaded files are listed on the dashboard.
- Download: Click on a file name to download it.
- Rename: Click the "Rename" button next to a file to change its name.
- Delete: Click the "Delete" button to permanently remove a file.
POST /register- Register a new user.POST /login- Authenticate a user and create a session.POST /logout- End the user's session.GET /check-login- Verify if a user is logged in.
POST /upload- Upload a file to the server.GET /files- Retrieve a list of files for the logged-in user.PUT /files/:id- Update the name of a specific file.DELETE /files/:id- Delete a specific file.
- Backend: Node.js, Express.js
- Database: MySQL
- Authentication: bcryptjs, express-session
- File Handling: Multer
- Frontend: HTML, CSS, JavaScript (Vanilla)
- Environment Management: dotenv
- Password Hashing: User passwords are hashed using bcryptjs before storage.
- Session Management: Secure session handling to maintain user login state.
- Authorization: Server-side checks to ensure users can only access their own files.
- Input Validation: Backend validation to prevent malicious input.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the Apache License 2.0—see the LICENSE file for the full terms and the NOTICE file for copyright and attribution details.