StarFlix is a self-hosted video streaming platform that allows you to manage and stream your personal video collection through a modern web interface. It features a Netflix-inspired UI, real-time video streaming, genre-based organization, and an intuitive upload system.
- Modern Web Interface: Netflix-style UI with smooth animations and responsive design
- Video Streaming: HTTP range request support for efficient streaming
- Genre Organization: Categorize videos by genres
- Live Upload: Real-time upload progress with drag-and-drop support
- Cover Images: Custom thumbnail support for videos
- Metadata Management: Store and display video metadata (title, description, year, etc.)
- Responsive Design: Works seamlessly on desktop and mobile devices
- Net/HTTP: Core HTTP server and routing
- Database: PostgreSQL with
lib/pqdriver - File System: Local storage for videos and cover images
- Middleware: Custom middleware for logging, CORS, and error handling
- Pure JavaScript: No framework dependencies
- HTML5: Semantic markup
- CSS3: Modern styling with Flexbox and Grid
- Media Features: HTML5 video player with custom controls
- Go 1.23.0
- PostgreSQL
- Modern web browser with HTML5 video support
streamer/
├── api/ # HTTP API handlers
├── config/ # Application configuration
├── db/ # Database operations
├── models/ # Data models
├── services/ # Business logic
├── utils/ # Utility functions
└── server/ # Server setup and static files
-
API Layer (
api/)- Routes registration
- Request handling
- Response formatting
-
Service Layer (
services/)- Video streaming logic
- File upload handling
- Metadata management
-
Database Layer (
db/)- PostgreSQL connection
- CRUD operations
- Schema management
-
Static Files (
server/static/)- Frontend application
- Styles and scripts
- Media assets
- Video Streaming
Client Request → HTTP Server → Video Service → File System → Streamed Response
- Video Upload
File Upload → Upload Service → File System Storage → Database Entry → Response
- Video Listing
Client Request → Database Query → Video Service → JSON Response
CREATE TABLE videos (
id SERIAL PRIMARY KEY,
filename VARCHAR(255) NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
genre VARCHAR(100),
release_year INTEGER,
cover_image_path VARCHAR(255),
file_path VARCHAR(255) NOT NULL,
file_size BIGINT NOT NULL,
duration INTEGER,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);CREATE TABLE genres (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL UNIQUE
);- Go 1.23.0 or later
- PostgreSQL
- Modern web browser
- Database Setup
CREATE DATABASE starflix;
CREATE USER xyz WITH PASSWORD 'xyz';
GRANT ALL PRIVILEGES ON DATABASE starflix TO xyz;- Environment Configuration
// db/db.go
var (
DB_HOST = "localhost"
DB_PORT = 5432
DB_NAME = "starflix"
DB_USER = "xyz"
DB_PASSWORD = "xyz"
)- Clone the repository
git clone https://github.com/prajjwa-lit/Starflix.git
cd streamer- Install dependencies
go mod download- Create necessary directories
mkdir videos covers- Build and run
go build
./streamer -port=5101 -videos=./videos -covers=./covers- Access the web interface at
http://localhost:5101 - Upload videos through the upload tab
- Browse and stream videos through the main interface
- Implements path traversal protection
- Validates file types and sizes
- Sanitizes filenames
- Uses prepared SQL statements
-port: HTTP server port (default: 5101)-videos: Video storage directory (default: ./videos)-covers: Cover images directory (default: ./covers)-max-upload: Maximum upload size in MB (default: 1024)
- Chunked video streaming
- HTTP range request support
- Database connection pooling
- Efficient file copying
- Client-side caching support
go build -o streamer main.gogo test ./...Contributions are welcome! Please feel free to submit a Pull Request.