Skip to content

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Personal CDN

A self-hosted CDN solution with a React dashboard for managing files and a Rust backend for serving content.

Features

  • 📁 Project-based organization — Create projects with custom endpoints (e.g., /my-project/)
  • 🔗 File aliases — Multiple URLs can point to the same file
  • 🔄 Smart renaming — Automatic alias suggestions when renaming files
  • 🔐 Multi-user auth — JWT-based authentication with refresh tokens
  • 📊 Storage stats — Monitor your storage usage
  • 🐳 Docker-ready — Easy deployment with Docker Compose

Tech Stack

Component Technology
Backend Rust, Axum, SQLx, SQLite
Frontend React, Vite, TanStack Query, Tailwind CSS
Infrastructure Docker, Docker Compose

Quick Start

Prerequisites

  • Docker & Docker Compose
  • (For development) Rust 1.75+, Node.js 20+

Production Deployment

# Clone the repository
git clone https://github.com/yourusername/personal-cdn.git
cd personal-cdn

# Configure environment
cp .env.example .env
# Edit .env with your settings (especially JWT_SECRET!)

# Start services
docker compose up -d

The application will be available at:

Development Setup

Backend

cd backend

# Install sqlx-cli for migrations
cargo install sqlx-cli --no-default-features --features sqlite

# Copy environment file
cp .env.example .env

# Create database and run migrations
cargo sqlx database create
cargo sqlx migrate run

# Run with hot reload
cargo install cargo-watch
cargo watch -x run

Frontend

cd frontend

# Install dependencies
npm install

# Start dev server
npm run dev

Project Structure

personal-cdn/
├── backend/           # Rust API server
│   ├── src/
│   │   ├── handlers/  # Route handlers
│   │   ├── models/    # Data models
│   │   ├── services/  # Business logic
│   │   └── ...
│   └── migrations/    # SQL migrations
├── frontend/          # React dashboard
│   └── src/
│       ├── components/
│       ├── pages/
│       └── ...
└── docker-compose.yml

API Overview

Public Endpoints

  • GET /cdn/{endpoint}/{filename} — Serve files (supports aliases)
  • GET /health — Health check

Protected Endpoints (require authentication)

  • POST /api/auth/* — Authentication
  • GET/POST/PUT/DELETE /api/projects/* — Project management
  • GET/POST/PUT/DELETE /api/projects/{id}/files/* — File management
  • GET /api/system/storage — Storage statistics

See PROJECT_SPEC.md for full API documentation.

Configuration

Environment Variables

Variable Description Default
JWT_SECRET Secret key for JWT signing (required)
DATABASE_URL SQLite database path sqlite:./data/cdn.db
STORAGE_PATH File storage directory ./storage/files
MAX_UPLOAD_SIZE Max upload size in bytes 52428800 (50MB)
CORS_ORIGIN Allowed CORS origin http://localhost:3000

Deployment with Coolify

  1. Create a new project in Coolify
  2. Add this repository as a Docker Compose service
  3. Set environment variables in Coolify's UI
  4. Configure your domain and SSL
  5. Deploy!

License

MIT

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages