$ show szabodanika/microbin
MicroBin is a self-hosted pastebin and URL shortener implemented as a monolithic Rust web application using actix-web. It stores pastes (text, files, or URL redirects) in either SQLite (default) or a JSON file, with all state held in memory behind a single global Mutex. The application supports server-side and client-side AES encryption, expiration and burn-after-read limits, QR code generation, server-side syntax highlighting via syntect, multiple file attachments, and animal-name or hash-based opaque identifiers. It is configured entirely through CLI arguments or environment variables, and ships as a single static binary with templates and assets embedded via rust-embed and askama. The architecture is straightforward: actix-web route handlers in src/endpoints process HTTP requests, while src/util contains the database backends, encryption helpers, ID encoders, telemetry, and HTTP client construction. The system is designed for single-instance self-hosting with a small memory footprint. External dependencies include actix-web, rusqlite, askama, syntect, magic-crypt, and reqwest. A background telemetry thread posts anonymized configuration to api.microbin.eu every 24 hours unless disabled, and the admin panel checks for updates against the same API. Maintenance is active with recent commits, multi-platform release CI, and clippy analysis. Technical drift is medium: clap 3, env_logger 0.9, and askama 0.10 lag behind current major versions, and the CI pipeline uses deprecated actions-rs tooling and ::set-output syntax. The codebase has notable duplication (six near-identical auth handlers, repeated SQL schema definitions across every db_sqlite function) and a latent bug in the JSON database path where remove_expired calls delete(None, ...) which panics in JSON mode; the JSON path also hardcodes pasta_data/database.json instead of honoring the data_dir argument. The encryption scheme pads passwords with '#' instead of using a proper KDF, a design weakness for a security-focused feature.
The LLM identified 4 files worth highlighting for reuse:
Converts u64 IDs to human-friendly hyphenated animal names (a base-64 encoding over a 64-animal vocabulary) and back. Pure std, zero internal imports, includes round-trip unit tests. Demonstrates a clean bijective encoding scheme that could be extracted into any project needing memorable opaque identifiers.
Wraps syntect to convert arbitrary text plus a file extension into HTML with syntax highlighting, including theme color rewrites for light/dark mode compatibility. Only depends on syntect and is fully self-contained; reusable in any Rust project needing server-side code highlighting without JavaScript.
Provides reqwest client construction with a custom rustls TLS provider (rustls-rustcrypto) for fully Rust-based builds without OpenSSL C dependencies, with a compile_error guard for invalid feature combinations. Demonstrates non-obvious TLS configuration that is directly reusable for cross-compilation or no-C-deps build scenarios.
Implements atomic JSON persistence using a two-stage write (serialize to a .tmp file, then rename over the database) so the data file is never left in a corrupt or partially-written state. The atomic-write pattern is generic and directly transferable to other persistence needs, though the file itself is coupled to the internal Pasta type.