Skip to content

hariomop12/FileVault

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

55 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” FileVault - Secure Cloud File Storage

Node.js React PostgreSQL Cloudflare Docker

Enterprise-grade secure file storage solution with React frontend, JWT authentication, and Cloudflare R2 integration

Features β€’ Quick Start β€’ API Docs β€’ Deployment


πŸ“‹ Table of Contents


🎯 Overview

FileVault is a full-stack secure file storage application that provides:

  • React Frontend with modern UI/UX and dark mode support
  • Node.js/Express Backend with RESTful API
  • JWT Authentication with email verification
  • Cloudflare R2 Storage for scalable file hosting
  • PostgreSQL Database with Aiven cloud hosting
  • Docker Support for easy deployment

Perfect for building secure file sharing platforms, document management systems, or cloud storage solutions.


✨ Features

πŸ” Authentication & Security

  • βœ… JWT-based authentication with secure token management
  • βœ… Email verification system with automated emails (Gmail SMTP)
  • βœ… Password reset functionality
  • βœ… Bcrypt password hashing
  • βœ… Rate limiting on all endpoints
  • βœ… CORS and security headers (Helmet.js)

πŸ“ File Management

  • βœ… Anonymous file uploads for quick sharing
  • βœ… Authenticated user file management
  • βœ… Multiple file format support (images, documents, archives, media)
  • βœ… File size validation (up to 5GB)
  • βœ… Secure file deletion with R2 cleanup
  • βœ… Shareable links with expiration controls

🎨 Frontend Features

  • βœ… Modern React UI with TypeScript
  • βœ… Dark/Light mode toggle
  • βœ… Responsive design (mobile-friendly)
  • βœ… File upload with drag-and-drop
  • βœ… User dashboard with file management
  • βœ… Real-time upload progress

☁️ Cloud Integration

  • βœ… Cloudflare R2 for scalable storage
  • βœ… Presigned URLs for secure downloads
  • βœ… Automatic file organization
  • βœ… Global edge distribution

πŸ“Š Monitoring & Logging

  • βœ… Winston logging with file rotation
  • βœ… Database query monitoring
  • βœ… Error tracking with unique IDs
  • βœ… Health check endpoints

πŸ› οΈ Tech Stack

Backend

  • Runtime: Node.js 18+
  • Framework: Express.js
  • Database: PostgreSQL (Aiven Cloud)
  • Storage: Cloudflare R2 (S3-compatible)
  • Authentication: JWT + Bcrypt
  • Email: Nodemailer (Gmail SMTP)
  • Logging: Winston
  • Security: Helmet.js, CORS, Rate Limiting

Frontend

  • Framework: React 18 with TypeScript
  • Routing: React Router v6
  • Forms: React Hook Form + Zod validation
  • HTTP Client: Axios
  • Styling: Tailwind CSS
  • Notifications: React Hot Toast
  • State: React Context API

DevOps

  • Containerization: Docker + Docker Compose
  • Development: Nodemon, Hot Reload
  • Database Migrations: dbmate

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • Docker and Docker Compose (recommended)
  • PostgreSQL database (or use Aiven free tier)
  • Cloudflare R2 bucket
  • Gmail account for SMTP (or other email service)

1. Clone Repository

git clone https://github.com/hariomop12/FileVault.git
cd FileVault

2. Environment Setup

Create .env file in the root directory:

# Server Configuration
PORT=3000
NODE_ENV=development

# Database (Aiven PostgreSQL)
DATABASE_URL=postgresql://user:password@host:port/database?sslmode=require

# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key-change-this
JWT_EXPIRES_IN=7d

# Cloudflare R2 Storage
R2_ENDPOINT=https://your-account-id.r2.cloudflarestorage.com
R2_ACCESS_KEY_ID=your-r2-access-key
R2_SECRET_ACCESS_KEY=your-r2-secret-key
R2_BUCKET_NAME=your-bucket-name

# Email Configuration (Gmail)
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_SECURE=false
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-password
EMAIL_FROM=FileVault <your-email@gmail.com>

# Frontend URL
FRONTEND_URL=http://localhost:3001

3. Run with Docker (Recommended)

# Start all services (backend, frontend, postgres)
docker-compose -f docker-compose.dev.yml up -d

# View logs
docker-compose -f docker-compose.dev.yml logs -f

# Stop services
docker-compose -f docker-compose.dev.yml down

Access the application:

4. Run Locally (Without Docker)

Backend:

# Install dependencies
npm install

# Run database migrations
npm run migrate

# Start development server
npm run dev

Frontend:

cd frontend
npm install
npm start

πŸ”§ Configuration

Database Setup (Aiven)

  1. Create free PostgreSQL database at Aiven.io
  2. Copy the connection string to DATABASE_URL in .env
  3. Run migrations: npm run migrate

Cloudflare R2 Setup

  1. Create R2 bucket in Cloudflare dashboard
  2. Generate API tokens with R2 permissions
  3. Add credentials to .env

Email Setup (Gmail)

  1. Enable 2-Step Verification in Google Account
  2. Generate App Password: Google App Passwords
  3. Use app password (16 characters, no spaces) in EMAIL_PASS

Rate Limiting

// Default limits (configurable in code):
API endpoints: 100 requests/15 minutes
Auth endpoints: 10 requests/15 minutes
File uploads: 5 requests/1 minute

πŸ“š API Documentation

Authentication Endpoints

POST   /api/v1/auth/signup              # User registration
POST   /api/v1/auth/login               # User login
GET    /api/v1/auth/verify-email        # Email verification
POST   /api/v1/auth/forgot-password     # Password reset request
POST   /api/v1/auth/reset-password      # Password reset
POST   /api/v1/auth/resend-verification # Resend verification email

File Management (Anonymous)

POST   /api/v1/files/upload             # Anonymous file upload
POST   /api/v1/files/download           # Anonymous file download

File Management (Authenticated)

GET    /api/v1/user/files               # Get user's files
POST   /api/v1/user/files/upload        # Upload file
GET    /api/v1/user/files/:id           # Get file metadata
GET    /api/v1/user/files/:id/download  # Get download link
DELETE /api/v1/user/files/:id           # Delete file
POST   /api/v1/user/files/:id/share     # Create shareable link

Example: User Registration

curl -X POST http://localhost:3000/api/v1/auth/signup \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "john@example.com",
    "password": "securePassword123"
  }'

Response:

{
  "success": true,
  "message": "Registration successful! Please check your email to verify your account.",
  "user": {
    "id": 1,
    "name": "John Doe",
    "email": "john@example.com"
  }
}

Example: File Upload

curl -X POST http://localhost:3000/api/v1/user/files/upload \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -F "file=@/path/to/file.pdf"

Interactive API Documentation: Visit http://localhost:3000/api-docs for Swagger UI with all endpoints.


🐳 Deployment

Docker Deployment

Development:

docker-compose -f docker-compose.dev.yml up -d

Production:

docker-compose -f docker-compose.prod.yml up -d

Manual Deployment

Backend:

npm install --production
npm run migrate
npm start

Frontend:

cd frontend
npm install
npm run build
# Serve build folder with nginx or serve

Environment Variables for Production

NODE_ENV=production
DATABASE_URL=your-production-db-url
FRONTEND_URL=https://your-domain.com

πŸ“ Project Structure

FileVault/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ config/          # Database, R2, email config
β”‚   β”œβ”€β”€ controllers/     # Request handlers
β”‚   β”œβ”€β”€ middlewares/     # Auth, validation, rate limiting
β”‚   β”œβ”€β”€ models/          # Database models
β”‚   β”œβ”€β”€ routes/          # API routes
β”‚   β”œβ”€β”€ services/        # Business logic (auth, file, R2)
β”‚   β”œβ”€β”€ utils/           # Helpers and utilities
β”‚   β”œβ”€β”€ app.js           # Express app setup
β”‚   └── server.js        # Server entry point
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/          # Static assets
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/  # React components
β”‚   β”‚   β”œβ”€β”€ contexts/    # Context providers
β”‚   β”‚   β”œβ”€β”€ pages/       # Page components
β”‚   β”‚   β”œβ”€β”€ services/    # API services
β”‚   β”‚   β”œβ”€β”€ types/       # TypeScript types
β”‚   β”‚   └── App.tsx      # Main app component
β”‚   └── package.json
β”‚
β”œβ”€β”€ db/
β”‚   └── migrations/      # Database migrations
β”‚
β”œβ”€β”€ docker-compose.dev.yml   # Development setup
β”œβ”€β”€ docker-compose.prod.yml  # Production setup
β”œβ”€β”€ Dockerfile.dev           # Backend dev image
β”œβ”€β”€ .env                     # Environment variables
└── README.md

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

Code Standards

  • Follow ESLint configuration
  • Write tests for new features
  • Update documentation as needed
  • Use conventional commits

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘¨β€πŸ’» Author

Hariom Virkhare


πŸ™ Acknowledgments


πŸ“ž Support


⭐ Star this repo if you find it helpful!

Made with ❀️ by Hariom Virkhare

About

Secure Cloud File Storage API | Enterprise-grade file management with JWT authentication, AWS S3 integration, PostgreSQL database, and comprehensive security features. Built with Node.js/Express.js, featuring rate limiting, email verification, Docker deployment, and Swagger documentation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors