A modern, secure file management system built with Next.js, Convex, and Clerk authentication. Upload different format files (images, PDFs, text files, spreadsheets), add them to favorites, delete and recover files with a beautiful, responsive interface.
- Secure Authentication - Powered by Clerk
- Real-time File Management - Built with Convex
- File Upload & Storage - Support for images, PDFs, text files, and spreadsheets
- File Organization - Favorites, search, and filtering
- Responsive Design - Works on desktop and mobile
- Modern UI - Built with Tailwind CSS and shadcn/ui
- Frontend: Next.js 14, React, TypeScript
- Backend: Convex (Database & Real-time)
- Authentication: Clerk
- Styling: Tailwind CSS, shadcn/ui
- File Storage: Convex File Storage
- Deployment: Vercel (Frontend), Convex (Backend)
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher)
- npm or yarn
- Git
git clone https://github.com/devpayoub/FileDrive.git
cd filedrive
npm install
Create a .env.local
file in the root directory with the following variables:
# Convex Configuration
NEXT_PUBLIC_CONVEX_URL=your_convex_deployment_url
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_your_clerk_publishable_key
CLERK_SECRET_KEY=sk_test_your_clerk_secret_key
CLERK_WEBHOOK_SECRET=whsec_your_webhook_secret
# Optional: For webhook configuration
CLERK_HOSTNAME=https://your-ngrok-url.ngrok-free.app
- Install Convex CLI (if not already installed):
npm install -g convex
- Login to Convex:
npx convex dev --configure
- Start Convex Development Server:
npx convex dev --prod
-
Create a Clerk Account:
- Go to clerk.com
- Create a new application
-
Configure JWT Template:
- Go to Clerk Dashboard β JWT Templates
- Create a new template named
convex
- Add the following claims:
{ "aud": "convex", "name": "{{user.first_name}} {{user.last_name}}", "email": "{{user.primary_email_address.email_address}}", "picture": "{{user.image_url}}" }
-
Configure Webhook (Optional):
- Go to Clerk Dashboard β Webhooks
- Add endpoint:
https://your-convex-url.convex.cloud/clerk
- Select events:
user.created
,user.updated
,organizationMembership.created
,organizationMembership.updated
npm run dev
Open http://localhost:3000 in your browser.
Variable | Description | Example |
---|---|---|
NEXT_PUBLIC_CONVEX_URL |
Your Convex deployment URL | https://your-deployment.convex.cloud |
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY |
Clerk publishable key | pk_test_... |
CLERK_SECRET_KEY |
Clerk secret key | sk_test_... |
CLERK_WEBHOOK_SECRET |
Webhook verification secret | whsec_... |
Variable | Description | When to Use |
---|---|---|
CLERK_HOSTNAME |
Custom domain for webhooks | When using ngrok for local development |
filedrive/
βββ app/ # Next.js app directory
β βββ dashboard/ # Dashboard pages and components
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout
βββ convex/ # Convex backend
β βββ files.ts # File management functions
β βββ users.ts # User management functions
β βββ http.ts # Webhook handlers
β βββ schema.ts # Database schema
β βββ auth.config.ts # Authentication configuration
βββ components/ # Reusable UI components
βββ public/ # Static assets
βββ .env.local # Environment variables
- User signs up/logs in via Clerk
- JWT token is sent to Convex with user information
- User is created in Convex database (if new)
- File operations are authenticated using the JWT
- Generate upload URL from Convex storage
- Upload file to Convex storage
- Create file record in database
- Display file in the dashboard
- Push your code to GitHub
- Connect your repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy
npx convex deploy
-
"Missing Clerk Secret Key"
- Ensure
CLERK_SECRET_KEY
is set in.env.local
- Restart the development server
- Ensure
-
"Failed to authenticate"
- Check JWT template configuration in Clerk
- Verify
NEXT_PUBLIC_CONVEX_URL
is correct - Ensure Convex auth config matches Clerk domain
-
"File storage not configured"
- Configure file storage in Convex dashboard
- Or use external storage provider (S3, etc.)
-
"User not found"
- Check if webhook is properly configured
- Verify user creation in Convex database
Enable debug logging by adding to your Convex functions:
console.log('Debug info:', { identity, user })
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is licensed under the MIT License.
Devpayoub - GitHub