Skip to content

About

A full-stack file-sharing platform built with Node.js, Express.js, and MongoDB, allowing users to upload files, generate unique shareable links, and securely download shared files.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

57 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Packet Picnic

Packet Picnic

A modern, full-stack file sharing platform built for fast and simple file uploads.

Upload files, store them securely, manage them from your dashboard, and share them instantly with unique links.


✨ Features

  • πŸ“€ File Uploads β€” Upload files directly to cloud storage.
  • ☁️ Cloudinary Storage β€” Store uploaded files securely using Cloudinary.
  • πŸ”— Shareable Links β€” Generate a unique link for every uploaded file.
  • πŸ“₯ File Downloads β€” Download shared files through secure generated URLs.
  • πŸ” Authentication β€” Google authentication with protected user-specific resources.
  • πŸ“Š File Dashboard β€” View, search, sort, and manage uploaded files.
  • πŸ—‘οΈ Trash Management β€” Move files to trash and restore them when needed.
  • ❌ Permanent Deletion β€” Permanently remove files from Cloudinary and MongoDB.
  • πŸ“± Responsive UI β€” Clean interface designed for desktop and mobile screens.
  • ⚑ Fast Frontend β€” Built with React, Vite, TypeScript, and Tailwind CSS.
  • πŸ”’ Server-Side Secrets β€” Sensitive Cloudinary credentials and operations remain on the backend.

πŸ› οΈ Tech Stack

Frontend

  • React
  • TypeScript
  • Vite
  • Tailwind CSS
  • shadcn/ui
  • React Router
  • Axios
  • Lucide React
  • Sonner

Backend

  • Node.js
  • Express
  • TypeScript
  • MongoDB
  • Mongoose
  • Cloudinary
  • JWT
  • Zod
  • Nanoid

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       React Client      β”‚
β”‚   Vite + TypeScript     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚
             β”‚ REST API
             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Express Backend      β”‚
β”‚      TypeScript         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚         β”‚
        β–Ό         β–Ό
 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚ MongoDB  β”‚ β”‚ Cloudinary β”‚
 β”‚ Metadata β”‚ β”‚   Files    β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The frontend handles the user interface and file-management experience, while the backend manages authentication, authorization, file metadata, Cloudinary signatures, and protected file operations.


πŸ“‚ Project Structure

The project is organized as a client-server monorepo:

packet-picnic/
β”‚
β”œβ”€β”€ client/
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”œβ”€β”€ layout/
β”‚   β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”œβ”€β”€ types/
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ App.tsx
β”‚   β”‚   └── main.tsx
β”‚   β”‚
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.ts
β”‚
β”œβ”€β”€ server/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ middlewares/
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ schemas/
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ app.ts
β”‚   β”‚   └── server.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ package.json
β”‚   └── tsconfig.json
β”‚
└── README.md

The structure above highlights the main application directories rather than listing every individual component and utility file.


πŸš€ Getting Started

1. Clone the repository

git clone https://github.com/abmdevx/packet-picnic.git

cd packet-picnic

2. Install dependencies

Install dependencies for both the frontend and backend:

cd client
npm install

cd ../server
npm install

3. Configure environment variables

Create a .env file inside both client and server.

Client

VITE_API_URL=http://localhost:8000/api/v1

VITE_CLOUDINARY_CLOUD_NAME=your_cloud_name
VITE_CLOUDINARY_API_KEY=your_api_key

Server

PORT=8000

CLIENT_URL=http://localhost:5173

MONGODB_URI=your_mongodb_connection_string

CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret

JWT_SECRET=your_jwt_secret

Important: Never expose CLOUDINARY_API_SECRET, JWT_SECRET, or other server-side secrets in the frontend.


▢️ Running the Project

Start the backend

cd server
npm run dev

The API will run at:

http://localhost:8000

Start the frontend

Open another terminal:

cd client
npm run dev

The frontend will be available at:

http://localhost:5173

πŸ”„ How File Upload Works

User
  β”‚
  β–Ό
Select File
  β”‚
  β–Ό
React Client
  β”‚
  β”‚ Request upload signature
  β–Ό
Express Backend
  β”‚
  β”‚ Generate signed request
  β–Ό
Cloudinary
  β”‚
  β”‚ Store file
  β–Ό
React Client
  β”‚
  β”‚ Send uploaded file metadata
  β–Ό
Express Backend
  β”‚
  β”‚ Save metadata
  β–Ό
MongoDB
  β”‚
  β–Ό
Unique Share Link

Each uploaded file receives a unique identifier generated with nanoid.

Example:

http://localhost:5173/files/abc123xyz

πŸ—‘οΈ Trash & File Lifecycle

Packet Picnic uses a soft-delete approach for normal deletion.

Active File
    β”‚
    β”‚ Delete
    β–Ό
  Trash
    β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚               β”‚
    β”‚ Restore       β”‚ Permanent Delete
    β–Ό               β–Ό
Active File     Cloudinary
                    β”‚
                    β–Ό
                 MongoDB

When a file is moved to trash:

  • The file remains in Cloudinary.
  • Its MongoDB record remains.
  • isTrashed is set to true.
  • The file is hidden from the main dashboard.

When a file is restored:

  • isTrashed is set back to false.
  • The file becomes visible again in the dashboard.

When permanently deleted:

  • The Cloudinary asset is deleted.
  • The MongoDB metadata is deleted.
  • The operation cannot be undone.

πŸ” Authentication & Security

Packet Picnic protects user-specific resources through authentication and authorization.

Security measures include:

  • Google authentication.
  • JWT-based authentication.
  • Protected dashboard APIs.
  • Authenticated file ownership.
  • Server-side Cloudinary signatures.
  • Server-side Cloudinary deletion.
  • Server-side Cloudinary API secret.
  • Zod request validation.
  • Unique file identifiers using nanoid.
  • User ownership checks before modifying or permanently deleting files.

The backend verifies that a file belongs to the authenticated user before allowing protected file-management operations.


πŸ“‘ API Overview

Authentication

Method Endpoint Description
POST /api/v1/auth/google Authenticate with Google
GET /api/v1/auth/me Get the authenticated user

File Upload & Sharing

Method Endpoint Description
POST /api/v1/files/upload/signature Generate Cloudinary upload signature
POST /api/v1/files Save uploaded file metadata
GET /api/v1/files/:uniqueId Get shared file information
GET /api/v1/files/:uniqueId/download Generate download URL

File Management

Method Endpoint Description
GET /api/v1/files/get-all-files Get authenticated user's active files
GET /api/v1/files/get-trash-files Get authenticated user's trash files
PATCH /api/v1/files/update-trash-status Move files to trash or restore them
DELETE /api/v1/files/permanent Permanently delete files

Protected endpoints require authentication.


🎨 User Interface

Packet Picnic provides a clean and minimal interface focused on quick file management and sharing.

Main areas

  • 🏠 Landing page
  • πŸ” Authentication
  • πŸ“Š Dashboard
  • πŸ“ My Files
  • πŸ”— Shared File Page
  • πŸ—‘οΈ Trash
  • πŸ“€ Upload Dialog
  • πŸ“± Responsive navigation

The dashboard supports:

  • List view
  • Grid view
  • File search
  • File sorting
  • File upload
  • File download
  • Share-link copying
  • Trash management
  • File restoration
  • Permanent deletion

☁️ Cloudinary Integration

Packet Picnic uses Cloudinary for file storage.

The upload process uses a server-generated signature so that the Cloudinary API secret never needs to be exposed to the frontend.

Cloudinary stores the uploaded asset while MongoDB stores the associated metadata, including:

originalName
storedName
mimeType
size
storageUrl
cloudinaryPublicId
cloudinaryResourceType
uniqueId
downloadCount
owner
isTrashed
trashedAt

πŸ“Š File Metadata

Each uploaded file is associated with metadata stored in MongoDB.

This allows Packet Picnic to provide:

  • File ownership
  • File search
  • File sorting
  • Download statistics
  • Trash management
  • File restoration
  • Permanent deletion
  • Unique sharing links

πŸ“Œ Project Status

In Development

Packet Picnic is an actively developed full-stack project built for learning, experimentation, and portfolio development.

Current functionality includes:

  • Authentication
  • File uploads
  • Cloudinary storage
  • File sharing
  • File downloads
  • Dashboard
  • Search and sorting
  • List and grid views
  • Trash management
  • File restoration
  • Permanent deletion
  • Responsive UI

πŸ“„ License

This project is currently developed for educational and portfolio purposes.

About

A full-stack file-sharing platform built with Node.js, Express.js, and MongoDB, allowing users to upload files, generate unique shareable links, and securely download shared files.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages