How biliticket/bili_ticket_rush works
Project type and purpose
• From the root Cargo.toml plus three sub-crates (“backend”, “common”, “frontend”) and the README (“bili_ticket_gui: A GUI based rust for Bilibili mall ticket”), we see this is a desktop GUI application with a split between a GUI client (frontend) and a local API server (backend), both sharing core logic in a common library. Its purpose is to let users log in, monitor and grab Bilibili mall tickets, show order lists, manage tasks, and push notifications.
File structure
• Top-level:
• .github/ — CI workflows
• Cargo.toml — workspace definition
• backend/ — local API server crate
• common/ — shared domain logic crate
• frontend/ — GUI application crate
• “common” contains modules for HTTP utilities, cookie management, captcha, login flows, push notifications, record logging, order‐listing, task manager, ticket operations.
• “backend” exposes REST-style endpoints (api.rs) that invoke common’s show_orderlist and taskmanager.
• “frontend” contains GUI code (app.rs, main.rs) with UI components (tabs, windows for login, ticket grabbing, order list, settings, etc.), likely using a Rust GUI framework.
README for additional insights
• README is minimal but confirms: a Rust-based GUI for Bilibili mall ticket grabbing. No database present—state/logs likely written to file via common::record_log.
a. Main components
• User’s Desktop (User interacts via GUI)
• Frontend GUI application (Rust executable)
• Backend API server (Rust executable spawning local HTTP endpoints)
• Common library (Rust crate with core logic)
• External services:
– Bilibili Mall HTTP APIs (login, fetch tickets, captcha)
– Optional push notification endpoints (e.g. via common::push)
– Selenium (for automated login flows, invoked in login_selenium.rs)
b. Relationships & data flow
1. User clicks buttons in the GUI → frontend issues HTTP calls (or direct function calls) to backend API.
2. Backend handlers (api.rs) call into common:: modules (login, show_orderlist, taskmanager).
3. common::http_utils communicates over the network with Bilibili Mall endpoints (login, fetch/snap ticket data).
4. Responses bubble back: common → backend → frontend → GUI/User.
5. common::push may send out notifications via external push services.
6. common::record_log logs events to local storage.
7. Optional: frontend may launch Selenium-based browser sessions for complex logins (login_selenium.rs).
c. Architectural patterns & design principles
– Modular crates: clear separation of concerns (UI vs API vs domain logic).
– Client-Server pattern (within the same machine) between frontend and backend.
– Layered approach: UI layer → API layer → domain & infra layer → external services.
– Reuse via a shared library (common).
d. Key technologies/frameworks
– Rust/cargo workspace
– HTTP server library in backend (e.g., warp, actix-web—inspect Cargo.toml)
– Rust GUI toolkit in frontend (possibly iced or egui)
– Selenium binding for Rust (login_selenium.rs)
– External HTTP calls (reqwest or hyper) in common::http_utils
Callouts for essential details
• Don’t forget:
• The shared common crate is at the heart—everything funnels logic through it.
• GUI windows (login, grab_ticket, show_orderlist) correspond to specific API endpoints and common logic modules.
• Selenium integration is a special path—show it explicitly if login automation is critical.