/Bunker

Primary LanguageJavaScript

Bunker

Google Drive Clone built for an assignment for Twospoon.ai

Features

  • Implemented Google OAuth for user authentication.
  • Securely manage user sessions.
  • Users can to Upload, View and Download files.
  • Implemented RESTful APIs for file operations.
  • Used MongoDB to store metadata about the files (e.g., filename, file path, user).
  • Containarized both the client and server by adding Dockerfiles and .dockerignore files and incorporated Multi-Stage Builds to reduce the Image size.

Prerequisites

  1. Node.js for running server-side/client-side JavaScript.

  2. MongoDB Atlas to store data about user and file.

  3. A Firebase account with firebase config details for the storage which will be used to store the user files.

  4. Google OAuth Client-Id and Client-Secret for google oauth.

Deployment Instructions

Setting up Firebase Storage

We need to setup firebase storage which will be used for storing the files

  • Create a project on Firebase and chose name
  • Select Storage and configer Rules
  • Make a folder 'files/'

Setting up MongoDB Atlas

We need to setup mongodb atlas which will be used for storing User and File information.

  • Regsiter and create a project on MongoDB Atlas
  • Name the project and chose your provider, location for your cluster.
  • Go to Database Access and click on connect to get the connection string or MongoURI for the driver nodejs
  • Go to Network Access and select allow from anywhere

Database Configuration

  • User model stores details regarding to the user and the files belonging to that user
  • File model stores details regarding to the file

To run this project locally

  1. Install nodejs
  2. Create a mongodb atlas account and get your MONGODB URI
  3. Create a Firebase account and configer for storage.
  4. Clone this repository and install the required packages using npm.
git clone https://github.com/AMS003010/Bunker.git
cd server
npm install
cd client
npm install
  1. Create a .env file in the backend directory and add your MONGODB_URI and also a SECRET to hash your passwords.
PORT = 8000
REMOTE = http://localhost:3000

GOOGLE_CLIENT_ID =
GOOGLE_CLIENT_SECRET =

DATABASE=<MONGODB_URI>
DATABASE_PASSWORD=<PASSWORD>

JWT_SECRET=
JWT_TIMEOUT=90d
JWT_COOKIE_EXPIRES_IN=7776000000
  1. Make a firebase.js file inside the client/src folder and add your firebase config details.
import { initializeApp } from "firebase/app";
import { getStorage } from "firebase/storage";
const firebaseConfig = {
    <config details>
};

const app = initializeApp(firebaseConfig);
export const storage = getStorage(app);
  1. From the root directory, run
cd server
npm start
  1. Open another terminal and run
cd client
npm start
  1. Then go to localhost:3000.

Built With

  • Node.js - Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
  • express - Fast, unopinionated, minimalist web framework for Node.js
  • MongoDB Atlas - The cloud database for modern applications
  • Mongoose - Elegant MongoDB object modeling for Node.js
  • React - The library for web and native user interfaces
  • Tailwind CSS - This node-module helps to rapidly build modern websites without ever leaving your HTML.
  • Firebase Storage