How thevickypedia/rustream works
Project type and purpose
• RuStream is a self-hosted, Rust‐based streaming engine with an embedded web UI. It uses Actix Web for HTTP serving, a custom “Squire” framework for routing, authentication, session management, and server-side templates for rendering HTML.
File structure
• Top‐level: Cargo.toml, src/
• src/main.rs: application entry point
• src/lib.rs: library entrypoint exposing start()
• src/constant.rs: global constants
• src/routes/*: route handlers (auth, basics/health check, file I/O, media streaming, upload), wired into Actix’s App in startup
• src/squire/*: internal framework modules (startup/bootstrap, settings/config, middleware, authentication, parsing, content‐serving, security, subtitles, ASCII art previews, custom handlers)
• src/templates/*: server‐side HTML templates (landing page, index, listing, upload form, session handling, error pages)
Insights from the README
• actix_rt::main with rustream::start()
• Environment‐driven configuration (authorization map, media_source, ports, SSL, CORS, session duration, payload limits)
• No external database; state is in‐memory session tokens and file system for media
• Optional SSL termination or CDN tunneling via environment variables
a. Main components
• Client (Web Browser / Media Player)
• RuStream HTTP Server (Actix Web)
• Router / Middleware (Squire startup + middleware pipeline)
• Authentication & Session Manager (Squire authenticator, secure sessions)
• Route Handlers (auth.rs, fileio.rs, media.rs, upload.rs, basics.rs)
• Template Engine (src/templates modules)
• Media Processing (subtitles, ASCII art generator, parser modules)
• Filesystem Media Store (media_source directory, uploaded files)
• Configuration Service (environment variables via settings.rs)
• Optional SSL / CORS Layer (key_file, cert_file, websites list)
b. Relationships & interactions
1. Client HTTP request → Actix Web Server
2. Request enters Squire middleware pipeline (CORS, logging, session validation)
3. Router directs to appropriate route handler
– /login, /logout → Authenticator → Session Cookie
– /media/<id> → Media Service → file streaming (byte‐range support)
– /upload → File IO Service → write to filesystem
– / → Template Engine → rendered HTML
4. Handlers consult Configuration Service and Media Store
5. Responses (JSON, HTML, or media byte stream) flow back to Client
c. Architectural patterns and design principles
• Layered architecture (Presentation / Application / Data)
• MVC-style separation: templates = View, routes = Controller, file system = Model
• Dependency injection of config and middleware at startup
• Modular design via “Squire” internal crate for reusability
• In-process state (sessions in cookies) instead of external DB
d. Key technologies/frameworks
• Rust language
• Actix Web (HTTP server, routing, middleware)
• Squire (custom framework for startup, routing, auth, config)
• Environment variables (.env) for configuration
• Server-side templates (Rust modules)
• File system as storage for media and uploads
• Optional SSL/TLS