How rusq/slackdump works
Main Components
• Command-Line Interface (CLI):
• Located primarily in the “cmd/slackdump” directory.
• Handles parsing command-line arguments, routing to different commands (dumping, listing, archiving, exporting, viewing, etc.), and interfacing with the user.
• Authentication & Authorization:
• The “auth” package (along with subdirectories like auth_ui and browser/…) manages token-based authentication, EZ-Login 3000, and, when needed, browser-based login.
• This component interfaces with Slack’s API by handling token retrieval (using methods like obtaining tokens and cookies).
• Core Processing Modules:
• The “internal” directory (including subfolders such as “chunk”, “convert”, “edge”, “network”, “cache”, “source”, “structures”, etc.) contains the bulk of the application’s business logic.
• Modules here are responsible for ingesting Slack data (from export files or live sessions), processing it (chunking, conversion between formats, data transformations), and orchestrating the data flow.
• User Interface / Viewer:
• Found in “internal/viewer” and in “auth/auth_ui”, this module provides the built-in viewer functionality, which allows for previewing archives, exports, or dumps.
• Additional submodules in “internal/ui” and its bubbles (for menus, input, datepicker, etc.) add to an interactive user interface.
• File and Data Management:
• The project deals extensively with file I/O and data conversion. The “internal/source” package and several “internal/chunk” subpackages manage reading, writing, conversion, and even temporary file storage.
• Supporting Utilities & Helpers:
• Packages such as “internal/fasttime”, “utils”, “contrib”, and others provide scripts, extra functionalities (for incremental backups, testing scripts, etc.) and integrations.
Relationships and Data Flow
• The CLI (front façade) accepts user commands (like dump, list, export, archive, view). These commands are then routed to the core processing modules.
• The Authentication module is used early on (or on-demand) to initialize a session and secure the necessary tokens that will be passed to the processing layers.
• The processing layer interacts with the data access layer (“internal/source” and file management) to ingest the Slack data, then uses conversion and chunking modules (in “internal/chunk” and “internal/convert”) to transform the data into various supported formats.
• For generating output (in export, archive, or dump formats), the system relies on conversion controllers that interconnect with utility modules. Finally, the Viewer module can be invoked to display the result.
• The network boundaries and external endpoints (Slack’s API, user’s browser authentication, etc.) are abstracted within the “auth” and “edge” packages.
Architectural Patterns and Principles
• Modular Monolith: Although the application is a single program, its functionalities are clearly modularized by domain (authentication, processing, viewing, conversion) with well-defined package boundaries.
• Separation of Concerns: UI/CLI, authentication, domain logic, and file/ data management remain separated making maintenance and potential future refactoring easier.
• Layered Architecture: There is a clear flow between presentation (CLI/UI), application logic (commands/logics) and infrastructure (file system, network, database mocks) layers.
• Testability: The inclusion of “_test.go” files across many directories (auth, cache, chunk, convert, etc.) shows a heavy emphasis on ensuring that each module is independently testable.
Additional Detail
• Within the processing layer, you might further decompose into sub-components such as “Chunking & Archive Creation”, “Conversion and Export Formatting”, and “Cache & Data Structures”.
• Optionally, highlight the integration of logging (using Go’s slog) and note how the logger can be replaced/customized.