A full-stack image uploading application built with React, Node.js/Express, MongoDB, and AWS S3.
- π User authentication (Register/Login)
- π€ Image upload to AWS S3
- πΌοΈ Image gallery with grid view
- ποΈ Delete images (owner only)
- βοΈ CloudFront or direct S3 URL support
- π± Fully responsive design
- β¨ Modern, beautiful UI with animations
- Runtime: Bun
- Framework: Express.js
- Database: MongoDB with Mongoose
- Storage: AWS S3
- Authentication: JWT
- File Upload: Multer + Multer-S3
- Framework: React 19 with TypeScript
- Build Tool: Vite
- Routing: React Router DOM
- HTTP Client: Axios
- Styling: CSS with modern gradients and animations
- Bun installed (
curl -fsSL https://bun.sh/install | bash) - MongoDB Atlas account or local MongoDB
- AWS account with S3 bucket created
- AWS IAM credentials with S3 permissions
cd backend
# Install dependencies
bun install
# Configure environment variables
# Edit backend/.env and add your credentials:
# - MongoDB URI (already configured)
# - AWS credentials (Access Key ID, Secret Access Key, Bucket Name, Region)
# - JWT secret
# Start the backend server
bun run devThe backend will run on http://localhost:3000
cd frontend
# Install dependencies
bun install
# Start the development server
bun run devThe frontend will run on http://localhost:5173
PORT=3000
NODE_ENV=development
# MongoDB Connection
MONGODB_URI=mongodb+srv://neverlearnacademy:Neverlearn2024@neverlearn.lk0wklk.mongodb.net/s3-crud?retryWrites=true&w=majority
# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
# AWS S3 Configuration
AWS_ACCESS_KEY_ID=your-aws-access-key-id
AWS_SECRET_ACCESS_KEY=your-aws-secret-access-key
AWS_REGION=us-east-1
S3_BUCKET_NAME=your-s3-bucket-name
# CloudFront Configuration (Optional - leave empty to use direct S3 URLs)
CLOUDFRONT_DOMAIN=
# Upload Configuration
MAX_FILE_SIZE=10485760VITE_API_URL=http://localhost:3000-
Create an S3 Bucket:
- Go to AWS S3 Console
- Create a new bucket
- Enable public access if using direct S3 URLs (or use CloudFront)
-
Configure Bucket Permissions:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadGetObject", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::your-bucket-name/*" } ] } -
Create IAM User:
- Create an IAM user with programmatic access
- Attach policy:
AmazonS3FullAccess(or create custom policy) - Save Access Key ID and Secret Access Key
-
Optional - CloudFront Setup:
- Create a CloudFront distribution
- Set S3 bucket as origin
- Add CloudFront domain to backend
.env
POST /api/auth/register- Register new userPOST /api/auth/login- Login user
GET /api/images- Get all images (with pagination)GET /api/images/user/:userId- Get user's imagesPOST /api/images- Upload image (requires authentication)DELETE /api/images/:id- Delete image (requires authentication, owner only)
-
Register/Login:
- Create a new account or login with existing credentials
-
Upload Images:
- Click "Upload Image" button
- Drag & drop or browse for an image
- Add optional title and description
- Click "Upload Image"
-
View Gallery:
- Browse all uploaded images
- Filter by "All Images" or "My Images"
- Click on any image to view fullscreen
-
Delete Images:
- Only your own images will show a delete button
- Click "Delete" and confirm to remove
backend/
βββ src/
β βββ config/ # Database and AWS configuration
β βββ controllers/ # Request handlers
β βββ middleware/ # Auth and error middleware
β βββ models/ # Mongoose models
β βββ routes/ # API routes
βββ index.ts # Server entry point
βββ .env # Environment variables
frontend/
βββ src/
β βββ components/ # React components
β βββ context/ # Auth context
β βββ pages/ # Page components
β βββ services/ # API services
β βββ App.tsx # Main app component
β βββ main.tsx # Entry point
βββ .env # Environment variables
# Build and run
cd backend
bun install --production
bun run start# Build for production
cd frontend
bun run build
# Preview production build
bun run previewβ οΈ Change JWT_SECRET in productionβ οΈ Use environment-specific AWS credentialsβ οΈ Configure CORS properly for production domainsβ οΈ Use HTTPS in productionβ οΈ Implement rate limiting for production
MIT
Built with β€οΈ using React, Express, MongoDB, and AWS S3