How noppanut15/depthviz works
Project Type and Purpose
• depthviz is a Python-based CLI tool (no GUI/web frontend) that transforms dive-computer or manual dive-log data into depth and time overlay videos.
• Key purpose: parse a variety of input formats (CSV, FIT, XML), smooth/interpolate depth-time data, and render overlay MP4s ready for video editing.
File Structure Analysis
• Top level:
• .github/, docs/, tests/, CI/CD and documentation.
• pyproject.toml for packaging and dependencies.
• src/depthviz/ containing the application code.
• src/depthviz/ modules:
• __main__.py / main.py: CLI entry point (argument parsing, command dispatch).
• parsers/: subpackages for each source format (garmin, suunto, shearwater, apnealizer, manual, generic), implementing a parser Strategy pattern.
• optimizer/linear_interpolation.py: smoothing/missing‐data fill.
• video/: modules for time/depth overlay video creation (frame generation, logging).
• assets/: fonts and static assets for overlay styling.
• banner.py, __version__.py: branding and metadata.
• Tests mirror structure under tests/, verifying parsers, optimizer, video.
Main Components
A. CLI Layer
• Parses user flags (-i, -s, -o, --time, styling options).
• Invokes Controller in main.py.
B. Parser Subsystem
• Parser Factory selects concrete parser based on --source.
• Each parser reads raw file (CSV, FIT, XML) → emits standardized time-depth sequences.
C. Optimizer Subsystem
• Receives raw sequence → applies Linear Interpolation → outputs uniform time series.
D. Video Generation Subsystem
• DepthOverlayCreator + TimeOverlayCreator take interpolated data + styling options + font assets → generate video frames (via ffmpeg or moviepy) → assemble MP4.
E. External Services / Artifacts
• Input dive-log files (local FS).
• Output MP4(s).
• Downstream: video editors (Premiere, CapCut) integrate overlays via chroma-key.
Relationships & Data Flow
1. User CLI → Controller (main.py)
2. Controller → Parser Factory → Concrete Parser → DataModel (time-depth pairs)
3. DataModel → Optimizer → SmoothedDataModel
4. SmoothedDataModel + Styling → VideoCreator
5. VideoCreator → FFmpeg / MoviePy → Output Videos
6. (Optional) Controller triggers TimeOverlayCreator in parallel for time-only MP4.
Architectural Patterns & Principles
• Strategy/Factory: parsers for each source share a common interface.
• Single Responsibility: parsing, optimization, rendering split into separate modules.
• Dependency Injection: styling and font assets injected into video modules.
• Pipeline/Chain of Responsibility: sequential steps (parse → optimize → render).
• All major modules (main.py, parsers/, optimizer/, video/, assets/) shown.
• Parser submodules grouped or called out individually if needed.
• Styling options and assets shown as configuration inputs.
• Output artifacts (depth video, time video) clearly indicated.
• CI/CD (.github/workflows/deploy.yaml) and packaging (pyproject.toml) can be shown as secondary artifacts if documenting deployment.