Skip to content

SashaMarchuk/S3-Media-Service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

S3 Media Service

A full-stack application for efficient media file management using AWS S3 storage. The project consists of a custom NodeJS backend server (without Express) and a modern Next.js frontend interface.

🎯 Project Overview

This project implements a media management service that allows users to:

  • Upload media files to AWS S3
  • View and manage uploaded files
  • Update existing files
  • Delete files from storage
  • Preview supported media types

🏗 Architecture

The project is structured as a monorepo with two main components:

S3-Media-Service/
├── backend/          # Custom NodeJS server
├── frontend/         # Next.js web interface
└── docker-compose.yml

Backend Features

  • Custom HTTP Server

    • Pure NodeJS implementation (no Express)
    • Custom router for API endpoints
    • Support for GET, POST, PUT, DELETE methods
    • Efficient file upload handling
  • AWS S3 Integration

    • Direct file uploads to S3
    • Secure file retrieval
    • Metadata management
    • Large file handling
  • Security & Validation

    • File type validation
    • Error handling
    • Request logging
    • Environment-based configuration

Frontend Features

  • Modern UI/UX

    • Responsive design
    • Real-time upload progress
    • File preview capabilities
    • Error state handling
  • Technical Implementation

    • Built with Next.js 14
    • TypeScript for type safety
    • Tailwind CSS for styling
    • Clean component architecture

🚀 Getting Started

Prerequisites

  • Node.js 18.x or later
  • AWS Account with S3 access
  • Docker and Docker Compose (optional)
  • Git

Installation

  1. Clone the repository:
git clone https://github.com/SashaMarchuk/S3-Media-Service.git
cd S3-Media-Service
  1. Set up environment variables:
# Backend (.env)
cp backend/.env.example backend/.env
# Frontend (.env.local)
cp frontend/.env.example frontend/.env.local
  1. Configure AWS credentials in backend/.env:
AWS_ACCESS_KEY_ID=your_access_key_id
AWS_SECRET_ACCESS_KEY=your_secret_access_key
AWS_REGION=your_region
AWS_BUCKET_NAME=your_bucket_name

Running with Docker

The easiest way to run the entire stack:

docker-compose up --build

This will start:

Manual Setup

Backend

cd backend
npm install
npm start

Frontend

cd frontend
npm install
npm run dev

📡 API Documentation

Endpoints

File Upload

  • POST /api/media
  • Content-Type: multipart/form-data
  • Returns: { fileId, url, message, contentType, size }

Get Files

  • GET /api/media
  • Query params: page, limit
  • Returns: { files: [], totalFiles, currentPage, totalPages }

Update File

  • PUT /api/media/:fileId
  • Content-Type: multipart/form-data
  • Returns: { fileId, url, message, contentType, size }

Delete File

  • DELETE /api/media/:fileId
  • Returns: { message: "File deleted successfully" }

Supported File Types

  • Images: JPEG, PNG, GIF
  • Videos: MP4, MOV
  • Documents: PDF, DOCX

🔒 Security

  • Environment-based configuration
  • File type validation
  • Secure S3 access
  • Error handling for all endpoints

🧪 Testing

# Backend tests
cd backend
npm test

# Frontend tests
cd frontend
npm test

📦 Deployment

The application can be deployed using:

  1. Docker containers (recommended)
  2. Manual deployment
  3. Cloud services (AWS ECS, Heroku, etc.)

Detailed deployment instructions are available in DEPLOYMENT.md.

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

📝 Task Completion Checklist

  • Custom HTTP Server Implementation
  • AWS S3 Integration
  • File Operations (CRUD)
  • Metadata Storage
  • File Type Validation
  • Error Handling
  • Logging
  • Documentation
  • Modern Frontend Interface
  • Docker Support

📄 License

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

👤 Author

Sasha Marchuk

About

A lightweight Node.js media service without Express for uploading, retrieving, updating, and deleting media files on AWS S3. Supports large file uploads using streaming and native modules.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors