How embittered01/spotigod works
Purpose and Entry Point
SpotiGod is a Rust terminal client for controlling a Spotify account: playback, search, playlists, saved tracks, and playback settings. The executable starts at src/main.rs, which composes configuration, Spotify access, and terminal UI.
Runtime and External Boundary
The application runs as a native Rust CLI/TUI process built through Cargo (Cargo.toml). It integrates with Spotify’s Web API and OAuth application registration using client credentials and a localhost redirect URI. User-provided credentials are loaded from a local config.json; configuration handling is centralized in src/config/mod.rs.
Application Composition
src/main.rs is the top-level control boundary: it initializes dependencies, establishes the Spotify client/session, and enters the interactive terminal workflow. It should remain the composition root rather than carrying API or rendering details.
Spotify Integration Layer
src/spotify/mod.rs defines the Spotify subsystem boundary. src/spotify/client.rs is the API-facing client responsible for authentication and Spotify operations such as playback control, search, playlist retrieval, favorites, volume, shuffle, and repeat. src/spotify/models.rs contains domain/API data representations passed between the client layer and UI.
Terminal UI and Interaction
src/ui/mod.rs owns terminal presentation and keyboard-driven navigation. It maps the documented controls into actions—screen selection, transport controls, search, and settings—and invokes the Spotify layer rather than directly handling authentication or HTTP. The UI is the primary long-running event/control loop after startup.
Primary Flow
1. Startup in src/main.rs loads credentials through src/config/mod.rs.
2. The application constructs the Spotify integration from src/spotify/client.rs.
3. src/ui/mod.rs renders the active terminal view and accepts keyboard input.
4. User actions are translated to Spotify client calls; responses are represented with types from src/spotify/models.rs.
5. Updated playback, search, playlist, or library state is returned to the UI for display.
Architectural Boundaries
Configuration is isolated from application behavior in src/config/mod.rs. Spotify API communication and its models are grouped under src/spotify/, separating remote-service concerns from terminal interaction under src/ui/. The main executable in src/main.rs coordinates those subsystems and is the appropriate location for lifecycle and fatal-error handling.
Main entry points: client.rs Spotify Client · main.rs Application Entry · mod.rs Terminal UI · models.rs Spotify Models
Components 10
Spotify Integration
Remote API access and shared Spotify data.
- Spotify Client · Authenticates and performs playback, search, library, and settings operations.
src/spotify/client.rs - Spotify Models · API and domain representations exchanged with the UI.
src/spotify/models.rs - Spotify Subsystem · Groups remote-service access and data models.
src/spotify/mod.rs
Terminal UI
Interactive terminal presentation and controls.
- Terminal UI · Renders views and maps keyboard input to actions.
src/ui/mod.rs
Other components
- Cargo Build
Cargo.toml - Application Entry · Initializes dependencies and owns lifecycle handling.
src/main.rs - Configuration · Loads local Spotify application credentials.
src/config/mod.rs - Spotify Web API · Remote playback, search, playlist, and library service.
- Spotify OAuth · OAuth registration and localhost redirect authorization.
- Terminal User
Connections 12
- Cargo Build → Application Entry: builds
- Application Entry → Configuration: loads credentials
- Application Entry → Spotify Client: constructs session
- Application Entry → Terminal UI: starts workflow
- Terminal User → Terminal UI: keyboard input
- Terminal UI → Spotify Client: invokes actions
- Spotify Client → Spotify Models: uses
- Spotify Models → Terminal UI: display state
- Spotify Subsystem → Spotify Client: contains
- Spotify Subsystem → Spotify Models: contains
- Spotify Client → Spotify OAuth: authorizes via
- Spotify Client → Spotify Web API: calls