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.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.
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"inpackage.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 viaMONGO_URI) and the default database name isipfs_app(set viaMONGO_DB_NAMEorDB_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.Clone and install backend dependencies
Clone the repository and install backend Node.js dependencies from the project root.The root
package.json includes express, ethers, ipfs-http-client, mongodb, multer, bcrypt, express-session, tweetnacl, and other runtime dependencies.Configure environment variables
Copy The key variables to configure:
A minimal
.env.example to .env and fill in the values for your environment.Copy the example file
| Variable | Default | Description |
|---|---|---|
PORT | 5000 | Express API port |
SESSION_SECRET | my-super-secret-session-key | Change this in production |
MONGO_URI | mongodb://127.0.0.1:27017 | MongoDB connection URI |
MONGO_DB_NAME | ipfs_app | MongoDB database name (also accepted as DB_NAME) |
IPFS_API_URL | http://127.0.0.1:5002/api/v0 | Kubo daemon HTTP API |
IPFS_GATEWAY_URL | http://127.0.0.1:5002 | Kubo gateway for file retrieval |
RPC_URL | https://rpc-mumbai.maticvigil.com | Ethereum RPC endpoint |
STORAGE_ALLOC_CONTRACT | 0x000...0001 | Deployed quota contract address |
DRIVE_V2_CONTRACT | 0x000...0002 | Deployed file access contract address |
ADMIN_PRIVATE_KEY | — | Backend wallet private key for contract calls |
USE_REAL_CONTRACTS | false | Set to true to enable live on-chain transactions |
.env for local development looks like this:.env (local development)
Install and run the frontend
The frontend lives in the The Next.js dev server starts on port 3000 by default. It proxies
front end subdirectory and is a Next.js 16 application./auth, /files, /upload, and other API paths to the Express backend, so session cookies work without cross-origin issues.Start the backend
From the repository root (not the This runs You can verify the backend is healthy by calling the health endpoint:A healthy response returns
front end directory), start the Express server:Start the backend
node server.js. On startup you will see output confirming the API and IPFS configuration:Expected startup output
Check backend health
{"ok":true,"database":"connected"}.Connect MetaMask
Open http://localhost:3000 in a browser with MetaMask installed.
- Click Connect wallet in the application.
- MetaMask will prompt you to select an account — choose the account you want to use.
- The app fetches a one-time nonce from
GET /auth/nonceand asks MetaMask to sign it. - You sign the message — no transaction fee is involved; this is a plain signature.
- The backend calls
ethers.verifyMessageto recover your address, creates a session, and sets an HTTP-only session cookie (24-hour expiry). - 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.
Upload your first file
Once authenticated, your default personal drive is created automatically.
- Click Upload in the drive interface.
- Select a file from your local machine.
- 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.
- Confirm the upload.
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