A modern, secure file sharing platform built with Next.js, NestJS, and Appwrite. Share files with expirable links, track downloads, and manage your uploads with a beautiful, responsive interface.
- JWT-based authentication with secure token management
- User registration and login with email verification
- Protected routes and API endpoints
- Session management with automatic token refresh
- Drag & drop file upload with progress indicators
- Support for all file types and sizes
- File metadata storage and management
- User-specific file organization
- File deletion with cascade cleanup
- Generate unique, secure share links
- Configurable expiration dates
- Download count tracking and limits
- Public access without authentication required
- Share link management and revocation
- Modern, responsive design that works on all devices
- Dark/Light theme support
- Intuitive drag & drop interface
- Real-time upload progress
- Beautiful file management dashboard
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Next.js β β Next.js β β NestJS β
β Frontend βββββΆβ API Routes βββββΆβ Backend β
β (Port 3000) β β (Middleware) β β (Port 8000) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βββββββββββββββββββ
β Appwrite β
β Database & β
β Storage β
βββββββββββββββββββ
- Frontend Layer: Next.js React application with TypeScript
- API Layer: Next.js API routes acting as middleware
- Backend Layer: NestJS application with Appwrite integration
- Next.js 14 - React framework with App Router
- TypeScript - Type-safe JavaScript
- Tailwind CSS - Utility-first CSS framework
- React Context - State management
- Fetch API - HTTP client
- NestJS - Progressive Node.js framework
- TypeScript - Type-safe server-side development
- JWT - JSON Web Token authentication
- Passport - Authentication middleware
- Multer - File upload handling
- Appwrite - Backend-as-a-Service platform
- Appwrite Database - Document-based database
- Appwrite Storage - File storage with CDN
- Appwrite Auth - User authentication service
- Node.js 18+ and npm
- Appwrite account and project setup
- Git for version control
git clone https://github.com/Amanbig/FileShare.git
cd FileShare
- Create an Appwrite account
- Create a new project
- Set up the following collections in your database:
Users Collection (users
):
{
"user_id": "string",
"email": "string",
"name": "string",
"created_at": "datetime",
"updated_at": "datetime"
}
Files Collection (files
):
{
"fileId": "string",
"originalName": "string",
"size": "integer",
"mimeType": "string",
"userId": "string",
"createdAt": "datetime"
}
Shares Collection (shares
):
{
"fileId": "string",
"shareToken": "string",
"downloadCount": "integer",
"maxDownloads": "integer",
"expiresAt": "datetime",
"createdAt": "datetime"
}
- Create a storage bucket for files
- Get your project credentials
Backend (backend/.env
):
# Appwrite Configuration
APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1
APPWRITE_PROJECT_ID=your_project_id
APPWRITE_API_KEY=your_api_key
APPWRITE_DATABASE_ID=your_database_id
APPWRITE_USER_COLLECTION_ID=users
APPWRITE_FILES_COLLECTION_ID=files
APPWRITE_SHARES_COLLECTION_ID=shares
APPWRITE_BUCKET_ID=your_bucket_id
# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
JWT_EXPIRES_IN=24h
# Application Configuration
BASE_URL=http://localhost:8000
PORT=8000
Frontend (frontend/.env.local
):
# Next.js Frontend Configuration
NEXT_PUBLIC_BACKEND_URL=/api
# NestJS Backend URL (for Next.js API routes to communicate with)
NESTJS_BACKEND_URL=http://localhost:8000
Backend:
cd backend
npm install
Frontend:
cd frontend
npm install
Start NestJS Backend (Terminal 1):
cd backend
npm run start:dev
Start Next.js Frontend (Terminal 2):
cd frontend
npm run dev -- --port 3001
- Main Application: http://localhost:3000
- Share Links: http://localhost:3000/share/[token]
- Backend API: http://localhost:8000
- Visit http://localhost:3000
- Create an account or sign in
- Upload files using drag & drop or file picker
- Manage your files from the dashboard
- Click the "Share" button on any file
- Share link is automatically copied to clipboard
- Set expiration dates and download limits (optional)
- Share the link with anyone
- Open the shared link in any browser
- View file information and download statistics
- Download the file (if not expired or limit reached)
FileShare/
βββ backend/ # NestJS Backend
β βββ src/
β β βββ auth/ # Authentication module
β β βββ files/ # File management module
β β βββ shares/ # Share management module
β β βββ appwrite/ # Appwrite integration
β β βββ config/ # Configuration files
β βββ package.json
βββ frontend/ # Next.js Frontend
β βββ src/
β β βββ app/ # App Router pages
β β βββ components/ # React components
β β βββ contexts/ # React contexts
β β βββ lib/ # Utility functions
β β βββ api/ # API route handlers
β βββ package.json
βββ README.md
Backend:
npm run start:dev
- Start development servernpm run build
- Build for productionnpm run start:prod
- Start production servernpm run test
- Run tests
Frontend:
npm run dev
- Start development servernpm run build
- Build for productionnpm run start
- Start production servernpm run lint
- Run ESLint
- JWT Authentication - Secure token-based authentication
- Route Protection - Protected API endpoints and pages
- File Ownership - Users can only access their own files
- Share Validation - Expiration dates and download limits
- Input Validation - Server-side validation for all inputs
- CORS Protection - Configured for secure cross-origin requests
- Build the application:
npm run build
- Set production environment variables
- Deploy to your preferred platform (Heroku, DigitalOcean, AWS, etc.)
- Build the application:
npm run build
- Set production environment variables
- Deploy to Vercel, Netlify, or your preferred platform
- Change
JWT_SECRET
to a strong, unique secret - Update
BASE_URL
to your production domain - Configure CORS settings for production domains
- Set up proper SSL certificates
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Include error messages and steps to reproduce
- Next.js - The React framework for production
- NestJS - A progressive Node.js framework
- Appwrite - Secure backend server for web & mobile apps
- Tailwind CSS - A utility-first CSS framework
Built with β€οΈ by the FileShare team