Skip to content

Aditya-Coomar/file-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Server - Developer Documentation

Project Structure

  • backend/: FastAPI application, runs using Uvicorn.
  • frontend/: Next.js application, runs using npm.

Prerequisites

Install Python

Windows

  1. Download the latest Python installer from the official website.
  2. Run the installer and check the box for "Add Python to PATH".
  3. Click Install Now and follow the setup instructions.

Verify installation:

python --version

Linux (Debian/Ubuntu)

sudo apt update && sudo apt install -y python3

Verify installation:

python3 --version

macOS

Using Homebrew:

brew install python

Verify installation:

python3 --version

Install Node.js & npm

Install Node.js and npm from the official website, or use:

# macOS/Linux
brew install node
# Windows (via Chocolatey)
choco install nodejs

Verify installation:

node -v
npm -v

Install MongoDB & MongoDB Compass

MongoDB Installation

Windows
  1. Download MongoDB Community Server from MongoDB Official Website.

  2. Run the installer (.msi file) and follow the setup instructions.

  3. Choose Complete setup.

  4. Ensure the option 'Install MongoDB as a service' is checked.

  5. Complete the installation and verify using:

    mongod --version
macOS (Using Homebrew)
  1. Open Terminal and run:

    brew tap mongodb/brew
    brew install [email protected]
  2. Start MongoDB service:

    brew services start [email protected]
  3. Verify installation:

    mongod --version
Linux (Ubuntu/Debian)
  1. Import the MongoDB public key:

    wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
  2. Add the MongoDB repository:

    echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
  3. Update the package database:

    sudo apt update
  4. Install MongoDB:

    sudo apt install -y mongodb-org
  5. Start MongoDB:

    sudo systemctl start mongod
  6. Enable MongoDB to start on boot:

sudo systemctl enable mongod
  1. Verify installation:
mongod --version

MongoDB Compass Installation

  1. Download MongoDB Compass from MongoDB Compass Official Website.

  2. Run the installer and follow the setup process.

  3. Open MongoDB Compass and connect using:

    mongodb://localhost:27017
    

Installation

Clone the repository:

git clone https://github.com/Aditya-Coomar/file-server.git
cd your-repo

Backend Setup (FastAPI)

Navigate to the backend folder:

cd backend

Create and configure a .env file:

FILE_SERVER_ROOT_STORE='Local_Folder_Path'
JWT_SECRET='your_jwt_secret'
MAIL_USER='[email protected]'
MAIL_SECRET='your_mail_secret'
MAIL_PORT=your_mail_port
MAIL_HOST='your_mail_host'

Configure the Database Connection accordingly in main.py file:

100  class DatabaseConnection:
101     def __init__(self):
102         self.client = MongoClient("mongodb://localhost:27017/")
103         self.db = self.client["file_server"]
104         self.users_collection = self.db["users"]
105         
106         self.users_collection.create_index("email", unique=True)
107         self.users_collection.create_index("username", unique=True)

Install dependencies and start the backend:

pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000 --reload

Frontend Setup (Next.js)

Navigate to the frontend folder:

cd ../frontend

Create and configure a .env.local file:

SERVER_URL="http://localhost:8000"

Install dependencies and start the frontend:

npm install
npm run dev

Usage

Run the backend and frontend, then open the frontend in a browser:

http://localhost:3000

License

This project is licensed under the MIT License.

Releases

No releases published

Packages

No packages published