How mshirazkamran/filebin-api works
Project Type & Purpose
• This is a CLI tool (“filebin-cli”) that acts as a thin wrapper around the public REST API of the file-sharing service filebin.net.
• It provides terminal commands for creating “bins,” uploading/downloading files, listing contents, locking, deleting, and archiving—with no login or local server required.
High-Level Components
a. User/CLI Layer
• fbin command invoked by the user
• Powered by the click library (entrypoint defined in pyproject.toml or setup.py)
b. Command Handlers
• Implemented in src/filebin/main.py via @click.command() and subcommands (upload, details, download, lock, delete, archive)
• Parse options (--binid, --type, --path, etc.) and dispatch workflow
c. Business Logic / Service Layer
• encoding.py: generates or parses human-readable shortcodes ↔ actual bin IDs
• utils.py: constructs HTTP endpoints, headers, query params, file-stream payloads
d. Infrastructure Layer
• HTTP Client: uses the requests library to communicate with filebin.net
• Filesystem I/O: reads local files for upload; writes downloaded files or archives to disk
e. External System
Interactions & Data Flow
1. User types fbin upload ... → CLI Layer
2. Click parses command → invokes corresponding handler in main.py
3. Handler calls encoding (if shortcode translation needed)
4. Handler calls utils to build URL, method, payload
5. requests sends HTTP request → filebin.net API
6. Response flows back through requests → handler
7. Handler prints outcome or writes files to Filesystem
Architectural Patterns & Principles
• Layered Architecture: Clear separation of CLI/Presentation, Command Handlers, Business Logic (encoding/utils), and Infrastructure (HTTP, FS).
• Single Responsibility: Each module does one thing—main.py for CLI, encoding.py for shortcodes, utils.py for API calls.
• Stateless Operations: Each command invocation is independent; state resides only in remote bins.