Design Decisions¶
This document explains the key design decisions made in Kartoza Screencaster and the reasoning behind them.
Terminal User Interface¶
Decision: Use TUI Instead of GUI¶
Choice: Build a terminal-based application rather than a traditional GUI.
Reasoning:
- Target audience - Developers and power users comfortable with terminals
- Simplicity - No GUI toolkit dependencies, smaller binary
- Remote access - Works over SSH
- Keyboard-first - Efficient workflow for experienced users
- Cross-platform - Terminal works everywhere
Trade-offs:
- Less discoverable for new users
- Limited visual capabilities
- No drag-and-drop
Decision: Elm Architecture (Bubble Tea)¶
Choice: Use the Elm Architecture for UI state management.
Reasoning:
- Predictability - Unidirectional data flow
- Testability - Pure functions for Update
- Debugging - Easy to trace state changes
- Composition - Screens combine naturally
Example:
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case KeyPressMsg:
// Handle input, return new state
return m.handleKey(msg), nil
}
return m, nil
}
Recording Architecture¶
Decision: Separate FFmpeg Processes¶
Choice: Run screen, audio, and webcam capture as separate FFmpeg processes.
Reasoning:
- Isolation - One crash doesn't affect others
- Flexibility - Easy to add/remove streams
- Resource management - OS handles scheduling
- Pause support - SIGSTOP/SIGCONT works cleanly
Trade-offs:
- Synchronization complexity
- Multiple file outputs to merge
- Process management overhead
Decision: PID File Communication¶
Choice: Use PID files for tracking recording processes.
Reasoning:
- Simplicity - No IPC complexity
- Persistence - Survives TUI restart
- Debugging - Easy to inspect
- Recovery - Can detect orphaned processes
Files:
/tmp/kvp-video-pid # Screen capture PID
/tmp/kvp-audio-pid # Audio capture PID
/tmp/kvp-webcam-pid # Webcam capture PID
Decision: Post-Recording Processing¶
Choice: Process videos after recording completes, not during.
Reasoning:
- Quality - No real-time encoding pressure
- Flexibility - Can re-process with different settings
- Reliability - Recording is the critical path
- Resources - Full CPU available for encoding
Trade-offs:
- Delay before final video ready
- Raw files take temporary disk space
File Organization¶
Decision: Topic-Based Folder Structure¶
Choice: Organize recordings by topic, then by title.
Structure:
~/Videos/Screencasts/
├── QGIS sketches/
│ ├── Introduction/
│ └── Advanced/
└── GIS tutorials/
└── Getting Started/
Reasoning:
- Logical grouping - Related videos together
- Playlist alignment - Mirrors YouTube playlists
- Browsable - Easy to navigate in file manager
- Scalable - Handles many recordings
Decision: Keep Raw Files¶
Choice: Preserve raw recording files after processing.
Reasoning:
- Re-processing - Can recreate with different settings
- Quality preservation - No generation loss
- Debugging - Diagnose issues with originals
- Flexibility - Extract portions without full video
Trade-offs:
- Increased disk usage
- User must clean up manually
Configuration¶
Decision: JSON Configuration File¶
Choice: Use JSON for configuration storage.
Reasoning:
- Standard format - Well understood
- Go support - Native encoding/decoding
- Human readable - Easy to edit manually
- Tooling - Syntax highlighting, validation
Alternatives considered:
- YAML - More complex parsing
- TOML - Less common in Go ecosystem
- INI - Limited structure support
Decision: XDG Base Directory¶
Choice: Follow XDG Base Directory specification.
Paths:
Reasoning:
- Standard compliance - Expected on Linux
- Separation - Config separate from data
- Backup friendly - Clear what to backup
- Multi-user - Works in shared systems
YouTube Integration¶
Decision: OAuth Desktop Flow¶
Choice: Use OAuth 2.0 desktop application flow.
Reasoning:
- Security - No server needed for tokens
- Simplicity - Standard Google flow
- User control - Clear permission grants
- Offline access - Refresh tokens for long sessions
Flow:
- App starts local HTTP server
- Browser opens Google auth
- User grants permissions
- Redirect to local server
- App receives authorization code
- Exchange for tokens
Decision: Resumable Uploads¶
Choice: Use YouTube resumable upload protocol.
Reasoning:
- Reliability - Survives network interruptions
- Large files - Handles videos of any size
- Progress tracking - Know exactly where we are
- Efficiency - Only resend failed chunks
Cross-Platform Support¶
Decision: Build Tags for Platform Code¶
Choice: Use Go build tags for platform-specific implementations.
Example:
Reasoning:
- Clean separation - Platform code isolated
- Compile-time - No runtime checks
- Maintainability - Easy to find platform code
- Testing - Can test platform-specific code
Decision: FFmpeg as External Dependency¶
Choice: Require FFmpeg as system dependency rather than embedding.
Reasoning:
- Size - FFmpeg is huge, would bloat binary
- Updates - System FFmpeg gets security updates
- Licensing - Avoids GPL complications
- Flexibility - Users can use custom FFmpeg builds
Trade-offs:
- Installation requirement
- Version compatibility concerns
Error Handling¶
Decision: Graceful Degradation¶
Choice: Continue operation when non-critical features fail.
Examples:
- No audio device → Record without audio
- Desktop notification fails → Continue silently
- Logo file missing → Record without logo
Reasoning:
- User experience - Don't block on minor issues
- Robustness - Handle edge cases
- Feedback - Warn but don't prevent
Decision: User-Friendly Error Messages¶
Choice: Transform technical errors into actionable messages.
Example:
// Instead of: "ENOENT: audio device /dev/snd/pcm0 not found"
// Show: "No audio device found. Check microphone connection."
Reasoning:
- Accessibility - Users aren't developers
- Actionable - Tell user what to do
- Trust - Application feels polished
Future Considerations¶
Under Consideration¶
- Plugin system - For custom processing steps
- Streaming support - Direct to YouTube/Twitch
- Multi-track audio - Separate mic and system audio
- Template system - Reusable recording configurations
Explicitly Not Planned¶
- GUI version - Out of scope, TUI is the focus
- Video editing - Use dedicated tools
- Transcription - Better done by specialized services
- Mobile apps - Desktop-focused application