Skip to content
Steven-HarrisPublic

About

Self-hosted application for managing media by date

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

91 Commits

Folders and files

Repository files navigation

πŸ“Έ Sortify

Intelligent media file organizer with drag-and-drop web interface

Sortify automatically organizes your photos and media files by date with a clean, modern web interface. Simply drag and drop your files, and Sortify will intelligently extract dates from filenames and EXIF data to organize them into a structured folder hierarchy.

License Docker Pulls GitHub release Build Status

Buy Me A Coffee

✨ Features

  • πŸ–₯️ Modern Web Interface - Responsive UI built with Lit web components
  • πŸ“ Smart Organization - Automatic date-based folder structure (YYYY/Month)
  • πŸ”„ Chunked Uploads - Handle large files with resume capability
  • πŸ–ΌοΈ Real-time Thumbnails - Image previews during upload
  • 🚨 Duplicate Detection - Prevents duplicate files with checksum verification
  • πŸ›‘οΈ Security First - Minimal scratch-based Docker image, non-root execution
  • βš™οΈ Configurable - Environment-based configuration for all settings
  • 🌐 Platform Support - Optimized for AMD64 architecture

πŸš€ Quick Start

Docker Compose (Recommended)

  1. Download docker-compose.yml:
curl -O https://raw.githubusercontent.com/Steven-Harris/sortify/main/docker-compose.yml
  1. Start Sortify:
docker compose up -d
  1. Open your browser: http://localhost:8080

Docker Run

docker run -d \
  --name sortify \
  -p 8080:8080 \
  -e MEDIA_PATH=/media \
  -e TEMP_PATH=/tmp \
  -v ./media:/media:rw \
  -v ./temp:/tmp:rw \
  Steven-Harris/sortify:latest

πŸ“‹ Configuration

Environment Variables

Variable Default Description
MEDIA_PATH /media Path for organized media files
TEMP_PATH /tmp Path for temporary upload files
PORT 8080 Server port
LOG_LEVEL info Log level (debug, info, warn, error)
CORS_ORIGINS * CORS allowed origins (comma-separated or * for all)

Volume Mounts

Host Path Container Path Purpose
./media /media Persistent storage for organized files
./temp /tmp Temporary storage for upload processing

Custom User and Group IDs

To avoid permission issues, you can run the container with custom user and group IDs using the --user flag:

docker run -d \
  --name sortify \
  --user 1234:1234 \
  -p 8080:8080 \
  -v ./media:/media:rw \
  -v ./temp:/tmp:rw \
  Steven-Harris/sortify:latest

Find your user ID:

id -u  # User ID
id -g  # Group ID

Important: Make sure the host directories have the correct ownership:

sudo chown -R 1234:1234 ./media ./temp
# Or for unRAID: sudo chown -R 99:100 ./media ./temp

οΏ½ Mobile Compatibility

Sortify supports uploading files from mobile devices. Some features to be aware of:

  • Checksum Verification: For improved reliability on mobile devices, Sortify includes fallback mechanisms for handling checksum verification issues that may occur on some mobile browsers.
  • Video Files: When uploading large video files from mobile devices, Sortify will automatically handle format differences and process them accordingly.

οΏ½πŸ”§ Development

Prerequisites

Setup

# Clone the repository
git clone https://github.com/Steven-Harris/sortify.git
cd sortify

# Install dependencies (if using just)
just setup

# Or manually
cd frontend && pnpm install

Development Server

# Start both backend and frontend (if using just)
just dev

# Or manually
# Terminal 1: Backend
cd backend && go run cmd/server/main.go

# Terminal 2: Frontend
cd frontend && pnpm run dev

Available Commands

just setup          # Install dependencies
just dev            # Start development environment
just build          # Build both frontend and backend
just test           # Run tests
just docker-build   # Build Docker image
just docker-run     # Run with Docker Compose

πŸ“ How It Works

File Organization

Sortify organizes files using this structure:

media/
β”œβ”€β”€ 2024/
β”‚   β”œβ”€β”€ January/
β”‚   β”‚   β”œβ”€β”€ IMG_20240115_143022.jpg
β”‚   β”‚   └── vacation_photo.png
β”‚   └── December/
β”‚       └── holiday_pics.jpg
└── 2025/
    └── March/
        └── spring_cleanup.jpg

Date Extraction Priority

  1. EXIF DateTimeOriginal - Most accurate for photos
  2. EXIF DateTime - Camera timestamp
  3. Filename patterns - Recognizes common formats:
    • IMG_20240115_143022.jpg
    • 2024-01-15_photo.png
    • photo_2024_01_15.jpg
  4. File modification time - Fallback option

Upload Process

  1. File Selection - Drag & drop or click to select
  2. Thumbnail Generation - Real-time image previews
  3. Chunked Upload - Large files uploaded in chunks
  4. Metadata Extraction - Date and EXIF analysis
  5. Duplicate Check - SHA256 checksum verification
  6. Organization - File moved to date-based folder

πŸ›‘οΈ Security

  • Scratch-based container - Minimal attack surface
  • Non-root execution - Runs as user 1001
  • No shell access - Container has no shell or utilities
  • Dependency scanning - Automated security scans in CI/CD
  • CORS protection - Configurable origin restrictions

οΏ½ CORS Configuration

The application is configured with permissive CORS headers (CORS_ORIGINS=*) by default to ensure it works correctly in various deployment scenarios:

Why This Configuration

This permissive CORS configuration ensures:

  1. File uploads work correctly regardless of access method
  2. Users don't need to configure CORS settings themselves
  3. The application is compatible with various deployment scenarios

Security Considerations

While wildcard CORS (*) is less restrictive than specific origins, the security impact is minimal for this application because:

  • The application is typically deployed in a controlled environment
  • Authentication (if any) uses its own security mechanisms
  • The main functionality (file uploads) requires permissive access anyway

Alternative Options

If you need to restrict access, modify the CORS_ORIGINS environment variable:

- CORS_ORIGINS=https://your-specific-domain.com,https://another-domain.com

Troubleshooting Upload Issues

If you experience upload problems:

  1. Check browser developer tools (F12) for any CORS-related errors
  2. Verify the CORS_ORIGINS=* setting is properly applied in your Docker environment
  3. Ensure your proxy server (if any) is configured to forward all necessary headers

�🐳 Production Deployment

System Requirements

  • Architecture: AMD64 (x86_64) required
  • Memory: Minimum 512MB RAM recommended
  • Storage: Adequate space for media files
  • Docker: Version 20.10+ or compatible container runtime

Docker Compose Production

services:
  sortify:
    image: Steven-Harris/sortify:latest
    restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      - MEDIA_PATH=/media
      - TEMP_PATH=/tmp
      - LOG_LEVEL=warn
      # Default wildcard CORS allows access from any origin
      - CORS_ORIGINS=*
      # For restricted access, use specific domains:
      # - CORS_ORIGINS=https://yourdomain.com
    volumes:
      - /path/to/media:/media:rw
      - /path/to/temp:/tmp:rw
    healthcheck:
      test: ["/healthcheck"]
      interval: 30s
      timeout: 10s
      retries: 3

Reverse Proxy (Nginx)

server {
    listen 80;
    server_name sortify.yourdomain.com;
    
    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        
        # For large file uploads
        client_max_body_size 500M;
        proxy_read_timeout 600s;
        proxy_send_timeout 600s;
    }
}

πŸ“Š Monitoring

Health Check

curl http://localhost:8080/api/health

Logs

# Docker logs
docker logs sortify --tail 100 -f

# Or with Docker Compose
docker compose logs -f

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Code Style

  • Go: Follow standard Go conventions, use gofmt
  • TypeScript: Prettier formatting, ESLint rules
  • Commits: Conventional commits format

πŸ“ License

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

πŸ™ Acknowledgments

  • Lit - Web components framework
  • Tailwind CSS - Utility-first CSS framework
  • Vite - Next generation frontend tooling

⭐ Star this repo if you find it helpful!

About

Self-hosted application for managing media by date

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages