How iuroc/bilidown works
Main Components
• Client (Frontend):
• Built with HTML, TypeScript/JavaScript (index.ts, header.ts, and multiple feature-specific modules like login, task, setting, work)
• Uses external libraries (VanJS, Bootstrap, p-queue for concurrency, and routing utilities like vanjs-router)
• Organized in several submodules (login, task, work, setting, and shared elements like error handling and SCSS styling)
• Built and bundled using Vite and configured via tsconfig and vite.config.ts
• Server (Backend):
• Developed in Go with a modular structure
• Contains functional packages such as:
▪ bilibili – handling Bilibili-specific API interactions and video parsing logic (including testing files)
▪ router – defines HTTP routes and endpoints (login, task, video)
▪ task – manages background processing and queued tasks
▪ util and common – shared utility functions (for database operations, error responses, concurrency control, etc.)
• Uses external dependencies like SQLite (through modernc.org/sqlite) and systray for system tray integration
• Build and cross-compilation tools are included (with Docker and goreleaser support)
Relationships and Interactions
• The Client sends HTTP requests to the Server’s API endpoints (as defined in the router directory)
• The Server processes tasks such as login, video parsing, and task management through dedicated Go packages (bilibili for video parsing, task package for work processing)
• Utility modules support the overall operations (e.g., db.go for database interaction and semaphore.go for concurrency)
• External tools (e.g., FFmpeg) and libraries are required for media processing and merging
Important Architectural Patterns
• Separation of Concerns: Clear division between the user interface and backend services
• Modular Design: Both client and server are broken down into features and function-specific modules
• Concurrency Control: The use of p-queue on the client side and semaphore utilities on the server side
• Cross-Compilation and Containerization: The server is designed to be easily built for multiple architectures using tools like goreleaser and Docker
• Main UI (index.html, index.ts)
• Feature modules (Login, Task, Setting, Work)
• Supporting libraries (VanJS, Bootstrap, p-queue)
• Main entrypoint (main.go) that orchestrates the API requests.
• Submodules:
▪ Router: Handles different routes – login, task, video endpoints.
▪ Bilibili Package: Video parsing logic and communication with Bilibili API.
▪ Task Package: Manages asynchronous video parsing or downloading tasks.
▪ Util & Common Modules: Utility functions, database management, and error handling.
• Use of external libraries (SQLite, systray, go-qrcode) near or inside the relevant server modules.