How nguyenkien/shortwave works
Project type and purpose
• Shortwave is a desktop full-stack application written in Rust, targeting the GNOME desktop (and Linux phones via libadwaita). Its purpose is to provide an Internet radio player that fetches station data from a remote community database and lets users browse, play, and record streams.
File structure
• Top-level build & config files:
• Cargo.toml, Cargo.lock – Rust package and dependency manifest
• meson.build + meson_options.txt + build-aux/ – Meson build scripts, Flatpak manifest
• po/ – localization resources
• Source code (src/):
• src/ui/ – GTK UI layer (dialogs, pages, widgets)
• src/api/ – client, data models, station lookup and sorting logic
• src/audio/ – GStreamer audio backend, MPRIS integration, playback & recording state
• src/database/ – local SQLite connection, schema, migrations, queries, models
• src/device/ – device discovery (UPnP/Chromecast), casting logic, device models
• src/settings/ – settings manager abstraction over key/value storage
• src/app.rs, src/main.rs – application bootstrap and orchestration
• utils.rs, i18n.rs, path.rs – helper utilities
README insights
• Uses Flatpak + GNOME Builder for packaging
• Relies on radio-browser.info community database
• Adaptive UI via libadwaita/GTK
• Database migrations in data/database for local library storage
• Debug via Rust logging and backtraces
Main components and interactions
a. Components:
• UI Layer (GTK/libadwaita)
• Application Core (app.rs/orchestrator)
• API Client (http calls to radio-browser.info)
• Local Database (SQLite with migrations)
• Audio Backend (GStreamer, MPRIS, Recorder)
• Device Manager (UPnP/Chromecast, mDNS/SSDP)
• Settings Manager
• External Services: Internet (radio API), OS (DB file, audio subsystem, D-Bus for MPRIS)
b. Relationships:
1. UI → Core: user events (play, search, add station)
2. Core ↔ API Client: fetch station lists, covers, metadata
4. Core → Audio Backend: play/stop streams, record
5. Core → Device Manager: discover and cast to devices
6. UI ↔ Settings: read/write user preferences
7. Audio Backend ↔ D-Bus (MPRIS) ↔ Other apps
c. Architectural patterns:
• Layered architecture: UI → domain/core → data (API/DB) → external
• MVC/MVVM‐like separation in UI pages and models (e.g., station_model, track_model)
• Event‐driven playback & device discovery
d. Key technologies:
• Rust crates: reqwest/serde (API), rusqlite or diesel (DB), gstreamer-rs (audio), zbus (MPRIS), glib-rs/gtk4 (UI)
• Meson/Ninja build
• Flatpak sandboxing
• gettext/po for i18n
Detail without over-splitting
• Audio backend as one block even though it has submodules (player, recorder, MPRIS)