Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ankit-bista/Final-Project/llms.txt

Use this file to discover all available pages before exploring further.

Blockchain Drive runs three processes simultaneously: an Express.js backend (port 5000), a Next.js frontend (port 3000), and an IPFS Kubo daemon (port 5002). This guide walks you through each step to get all three running and upload your first file.
1

Install prerequisites

Before you begin, make sure the following are available on your machine:
  • Node.js 18 or later — the backend uses ES modules ("type": "module" in package.json) and requires Node 18+.
  • MetaMask browser extension — your wallet is your identity; no username/password is used.
  • IPFS Kubo daemon — the backend talks to Kubo’s HTTP API. Install Kubo from docs.ipfs.tech and start it with ipfs daemon. Your Kubo API must run on a different port than the Express backend — the default Kubo API port used in this project is 5002.
  • MongoDB — the backend uses MongoDB to store file metadata, users, shares, and drive records. The default connection URI is mongodb://127.0.0.1:27017 (set via MONGO_URI) and the default database name is ipfs_app (set via MONGO_DB_NAME or DB_NAME).
The IPFS Kubo daemon and the Express API must not share a port. This project defaults to Kubo on 5002 and Express on 5000. If your Kubo API is on a different port, you will update IPFS_API_URL in the next step.
2

Clone and install backend dependencies

Clone the repository and install backend Node.js dependencies from the project root.
git clone https://github.com/ankit-bista/Final-Project.git
cd Final-Project
The root package.json includes express, ethers, ipfs-http-client, mongodb, multer, bcrypt, express-session, tweetnacl, and other runtime dependencies.
3

Configure environment variables

Copy .env.example to .env and fill in the values for your environment.
Copy the example file
cp .env.example .env
The key variables to configure:
VariableDefaultDescription
PORT5000Express API port
SESSION_SECRETmy-super-secret-session-keyChange this in production
MONGO_URImongodb://127.0.0.1:27017MongoDB connection URI
MONGO_DB_NAMEipfs_appMongoDB database name (also accepted as DB_NAME)
IPFS_API_URLhttp://127.0.0.1:5002/api/v0Kubo daemon HTTP API
IPFS_GATEWAY_URLhttp://127.0.0.1:5002Kubo gateway for file retrieval
RPC_URLhttps://rpc-mumbai.maticvigil.comEthereum RPC endpoint
STORAGE_ALLOC_CONTRACT0x000...0001Deployed quota contract address
DRIVE_V2_CONTRACT0x000...0002Deployed file access contract address
ADMIN_PRIVATE_KEYBackend wallet private key for contract calls
USE_REAL_CONTRACTSfalseSet to true to enable live on-chain transactions
A minimal .env for local development looks like this:
.env (local development)
PORT=5000
SESSION_SECRET=change-this-before-going-to-production

# MongoDB
MONGO_URI=mongodb://127.0.0.1:27017
MONGO_DB_NAME=ipfs_app

# IPFS Kubo daemon (check `ipfs config show | grep API`)
IPFS_API_URL=http://127.0.0.1:5002/api/v0
IPFS_GATEWAY_URL=http://127.0.0.1:5002

# Blockchain (mock mode — no real transactions)
RPC_URL=https://rpc-mumbai.maticvigil.com
STORAGE_ALLOC_CONTRACT=0x0000000000000000000000000000000000000001
DRIVE_V2_CONTRACT=0x0000000000000000000000000000000000000002
ADMIN_PRIVATE_KEY=your_metamask_private_key_here
USE_REAL_CONTRACTS=false
Set USE_REAL_CONTRACTS=false while prototyping. In this mode the backend accepts all uploads without checking on-chain quota, and file anchoring writes metadata into transaction calldata on a local chain rather than calling the real contract functions.
Never commit your .env file to version control. The ADMIN_PRIVATE_KEY value is the private key of the wallet used for all contract calls. Exposure gives full access to that wallet’s funds and contract permissions.
4

Install and run the frontend

The frontend lives in the front end subdirectory and is a Next.js 16 application.
cd "front end"
npm install
The Next.js dev server starts on port 3000 by default. It proxies /auth, /files, /upload, and other API paths to the Express backend, so session cookies work without cross-origin issues.
5

Start the backend

From the repository root (not the front end directory), start the Express server:
Start the backend
npm start
This runs node server.js. On startup you will see output confirming the API and IPFS configuration:
Expected startup output
=== Blockchain Drive backend (Node / Express) ===
  API (login, files, uploads): http://127.0.0.1:5000
  This is NOT IPFS. Keep this on a port different from Kubo (often 5002).

=== IPFS (Kubo daemon) — separate process ===
  IPFS API:     http://127.0.0.1:5002/api/v0
  IPFS Gateway: http://127.0.0.1:5002

Node environment: development
Blockchain mode: mock
You can verify the backend is healthy by calling the health endpoint:
Check backend health
curl http://127.0.0.1:5000/health
A healthy response returns {"ok":true,"database":"connected"}.
6

Connect MetaMask

Open http://localhost:3000 in a browser with MetaMask installed.
  1. Click Connect wallet in the application.
  2. MetaMask will prompt you to select an account — choose the account you want to use.
  3. The app fetches a one-time nonce from GET /auth/nonce and asks MetaMask to sign it.
  4. You sign the message — no transaction fee is involved; this is a plain signature.
  5. The backend calls ethers.verifyMessage to recover your address, creates a session, and sets an HTTP-only session cookie (24-hour expiry).
  6. On first login you will be prompted to choose a username (3–20 characters, letters/numbers/underscores only).
Signing the authentication message does not cost gas — it is an off-chain signature, not a blockchain transaction.
7

Upload your first file

Once authenticated, your default personal drive is created automatically.
  1. Click Upload in the drive interface.
  2. Select a file from your local machine.
  3. Optionally enable encryption — if enabled, the file is encrypted with AES on the client using a key derived from your MetaMask wallet before it leaves your browser. Only your wallet can decrypt it.
  4. Confirm the upload.
Under the hood, the backend receives the file via multipart form data (handled by multer), passes the buffer to ipfs.add() in ipfsService.js, receives a content identifier (CID) back from Kubo, generates a custom hash, and stores the file record in MongoDB. When USE_REAL_CONTRACTS=false, a mock blockchain transaction is written to anchor the file metadata without requiring a deployed contract.

File management

Learn how to view, download, rename, and delete files

Encryption

Understand how MetaMask-backed AES encryption works

Sharing

Share files and drives with role-based access control

Smart contracts

Deploy the unified contract and enable real on-chain mode

Build docs developers (and LLMs) love