# Implement Missing Roadmap Features (Phase 2) I will implement the key missing features from **Phase 2** of the roadmap to improve compatibility with the Supabase client SDK. ## 1. Realtime Presence (`realtime` crate) **Goal**: Enable user state tracking (online/offline, custom status) compatible with `supabase-js`. - **Dependencies**: Add `dashmap` for thread-safe concurrent state management. - **State Management**: Update `RealtimeState` to store presence data in memory: `Arc>>`. - **WebSocket Logic**: - Handle `presence` events (join, leave, sync). - Implement `track` (user joins/updates state) and `untrack` (user leaves). - Broadcast `presence_diff` events to all subscribers on a topic when state changes. ## 2. Storage Image Transformations (`storage` crate) **Goal**: Support on-the-fly image resizing and formatting via query parameters. - **Dependencies**: Add `image` crate (with `jpeg`, `png`, `webp` support). - **Handler Update**: Modify `download_object` to parse query parameters: - `w` / `width`: Target width. - `h` / `height`: Target height. - `q` / `quality`: Compression quality. - `f` / `format`: Output format (e.g., `webp`, `png`). - **Processing Logic**: - If parameters are present, decode the downloaded image bytes. - Apply resizing (using `Lanczos3` filter for quality). - Encode to the target format/quality. - Return the processed image with correct `Content-Type`. ## Execution Steps 1. **Update Dependencies**: Add `dashmap` to `realtime/Cargo.toml` and `image` to `storage/Cargo.toml`. 2. **Refactor Realtime**: Modify `RealtimeState` and `ws.rs` to implement the Presence protocol. 3. **Refactor Storage**: Modify `handlers.rs` to implement the Image Transformation pipeline. 4. **Verification**: Verify compilation and basic functionality (via `cargo check` and manual review of the logic).