You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -17,24 +17,46 @@ The application entry point follows a structured initialization sequence:
17
17
5.**Component Setup** - All subsystem initialization and connection
18
18
6.**Event Loop** - Tkinter main loop with error handling
19
19
20
-
### Central Orchestrator (`core/player.py`)
20
+
### Central Orchestrator (`core/player/`)
21
21
22
-
The `MusicPlayer` class serves as the central orchestrator, managing:
22
+
The `core/player/` package contains the `MusicPlayer` class and its composed managers, serving as the central orchestrator. The package uses a **manager composition pattern** to separate concerns:
23
23
24
-
-**Window Management**: Size, position, and platform-specific styling (macOS integration)
25
-
-**Component Lifecycle**: Initialization order and dependency injection
-**Schema Management**: Automatic table creation and migration
70
-
-**Query Interface**: High-level operations for library and queue
121
+
-**Schema Management**: Automatic table creation via `DB_TABLES` dict
122
+
-**Query Interface**: High-level operations delegated to domain modules
71
123
-**Preference Storage**: JSON-serialized configuration data
72
124
-**Transaction Safety**: Atomic operations for data consistency
73
125
@@ -84,10 +136,67 @@ The `LibraryManager` handles:
84
136
85
137
### Performance Optimizations
86
138
87
-
-**Zig Integration**: High-performance directory scanning via `core/_scan.py`
139
+
-**Zig Integration**: High-performance directory scanning via `src/scan.zig`
88
140
-**Batch Operations**: Bulk database insertions for large libraries
89
141
-**Background Processing**: Non-blocking UI during scan operations
90
142
143
+
## Zig Performance Extension (`src/`)
144
+
145
+
The `src/` directory contains a Zig-based native extension for high-performance file system operations, built using [ziggy-pydust](https://github.com/spiraldb/ziggy-pydust) for Python FFI.
146
+
147
+
### Module Structure
148
+
149
+
```
150
+
src/
151
+
βββ build.zig # Zig build configuration
152
+
βββ pydust.build.zig # Pydust integration
153
+
βββ scan.zig # Music directory scanner
154
+
```
155
+
156
+
### scan.zig - Directory Scanner
157
+
158
+
High-performance recursive directory scanner for audio files:
-**Memory Safety**: Uses Zig's `GeneralPurposeAllocator` with leak detection
170
+
171
+
### Build Process
172
+
173
+
```bash
174
+
# Build via Python script
175
+
uv run python build.py
176
+
177
+
# Or via hatch during package installation
178
+
hatch build
179
+
180
+
# Output: core/_scan.so (Python extension)
181
+
```
182
+
183
+
### Python Integration
184
+
185
+
```python
186
+
# Import the Zig extension
187
+
from core._scan import scan_music_directory
188
+
189
+
# Count audio files in directory
190
+
count = scan_music_directory("/path/to/music")
191
+
```
192
+
193
+
### Why Zig?
194
+
195
+
-**Performance**: 10-100x faster than pure Python for large directory trees
196
+
-**Memory Efficiency**: Zero-copy string handling, no GC pressure
197
+
-**Safety**: Compile-time memory safety without runtime overhead
198
+
-**Cross-Platform**: Single codebase for macOS/Linux
199
+
91
200
## Queue System (`core/queue.py`)
92
201
93
202
### Queue Management
@@ -122,14 +231,101 @@ The `PlayerCore` class wraps VLC functionality:
122
231
-**Thread Safety**: UI updates via `window.after()` for main thread execution
123
232
-**Event Handling**: VLC event callbacks with proper synchronization
124
233
125
-
## User Interface (`core/gui.py`)
234
+
## API Server (`api/server.py`)
235
+
236
+
The `APIServer` class provides programmatic control of the music player via a socket-based JSON protocol, enabling LLM and automation tool integration.
0 commit comments