# kruk2/jasna architecture

> Architecture diagram of the GitHub repository kruk2/jasna, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kruk2/jasna
- Repository: https://github.com/kruk2/jasna

## Overview

Jasna is a GPU-focused video and still-image mosaic restoration application with GUI and CLI entry points. Its main video workflow inspects media, detects and tracks mosaic regions, restores tracked clips, then encodes or streams the result. The graph also preserves documented capabilities such as segment editing, VR180 handling, optional secondary restoration, and still-image restoration. Some subsystem links rely on README descriptions or SOURCE INDEX references; unsampled implementation details are not asserted.

Main entry points: [`jasna/pipeline.py`](https://github.com/kruk2/jasna/blob/main/jasna/pipeline.py) (Video orchestration), [`jasna/pipeline_threads.py`](https://github.com/kruk2/jasna/blob/main/jasna/pipeline_threads.py) (Processing workers), [`jasna/gui/app.py`](https://github.com/kruk2/jasna/blob/main/jasna/gui/app.py) (Desktop GUI), [`jasna/pipeline_processing.py`](https://github.com/kruk2/jasna/blob/main/jasna/pipeline_processing.py) (Crop and overlap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_gui["Desktop GUI<br/>[app.py]"]
  node_cli["CLI<br/>[main.py]"]
  node_segments["Segment editor<br/>[segment_editor.py]"]
end

subgraph group_video["Video processing"]
  node_session["Session setup<br/>[session_factory.py]"]
  node_pipeline["Video orchestration<br/>[pipeline.py]"]
  node_threads["Processing workers"]
  node_detection["Mosaic detection"]
  node_tracking["Clip tracking<br/>[clip_tracker.py]"]
  node_scene["Scene cuts<br/>[scene_detector.py]"]
  node_processing["Crop and overlap"]
  node_vr180["VR180 handling<br/>[vr180.py]"]
end

subgraph group_restoration["Restoration models"]
  node_restoration_pipeline["Restoration pipeline"]
  node_basicvsr["BasicVSR++"]
  node_secondary["Secondary restoration"]
  node_still["Still-image restoration<br/>[image_restore.py]"]
  node_ltx["LTX restoration<br/>[restore.py]"]
  node_accelerator["GPU backend<br/>[accelerator.py]"]
  node_engine["Engine preparation<br/>[engine_compiler.py]"]
end

subgraph group_media["Media and delivery"]
  node_metadata["Media probing<br/>[probe.py]"]
  node_decoder["Video decoding<br/>[video_decoder.py]"]
  node_encoder["Video encoding<br/>[video_encoder.py]"]
  node_streaming["Streaming pipeline"]
end

node_user(("User"))
node_browser(("Browser player"))

node_user -->|"starts work"| node_gui
node_user -->|"starts work"| node_cli
node_gui -.->|"configures jobs"| node_session
node_cli -.->|"configures jobs"| node_session
node_gui -->|"edits ranges"| node_segments
node_session -->|"runs restoration"| node_pipeline
node_pipeline -->|"probes input"| node_metadata
node_pipeline -->|"decodes frames"| node_decoder
node_pipeline -->|"starts workers"| node_threads
node_threads -.->|"detects regions"| node_detection
node_threads -->|"processes frames"| node_processing
node_processing -->|"updates tracks"| node_tracking
node_processing -->|"checks cuts"| node_scene
node_threads -->|"restores clips"| node_restoration_pipeline
node_restoration_pipeline -->|"uses model"| node_basicvsr
node_threads -->|"enhances clips"| node_secondary
node_pipeline -->|"encodes output"| node_encoder
node_user -->|"restores image"| node_still
node_still -.->|"uses restoration"| node_ltx
node_user -->|"requests stream"| node_streaming
node_streaming -->|"serves playback"| node_browser
node_pipeline -->|"handles VR180"| node_vr180
node_pipeline -.->|"prepares engines"| node_engine
node_engine -.->|"targets GPU"| node_accelerator

click node_gui "https://github.com/kruk2/jasna/blob/main/jasna/gui/app.py"
click node_cli "https://github.com/kruk2/jasna/blob/main/jasna/main.py"
click node_segments "https://github.com/kruk2/jasna/blob/main/jasna/gui/segment_editor.py"
click node_session "https://github.com/kruk2/jasna/blob/main/jasna/session_factory.py"
click node_metadata "https://github.com/kruk2/jasna/blob/main/jasna/media/probe.py"
click node_decoder "https://github.com/kruk2/jasna/blob/main/jasna/media/video_decoder.py"
click node_pipeline "https://github.com/kruk2/jasna/blob/main/jasna/pipeline.py"
click node_threads "https://github.com/kruk2/jasna/blob/main/jasna/pipeline_threads.py"
click node_detection "https://github.com/kruk2/jasna/blob/main/jasna/mosaic/detection_registry.py"
click node_tracking "https://github.com/kruk2/jasna/blob/main/jasna/tracking/clip_tracker.py"
click node_scene "https://github.com/kruk2/jasna/blob/main/jasna/tracking/scene_detector.py"
click node_processing "https://github.com/kruk2/jasna/blob/main/jasna/pipeline_processing.py"
click node_restoration_pipeline "https://github.com/kruk2/jasna/blob/main/jasna/restorer/restoration_pipeline.py"
click node_basicvsr "https://github.com/kruk2/jasna/blob/main/jasna/restorer/basicvsrpp_mosaic_restorer.py"
click node_secondary "https://github.com/kruk2/jasna/blob/main/jasna/restorer/secondary_restorer.py"
click node_still "https://github.com/kruk2/jasna/blob/main/jasna/image_restore.py"
click node_ltx "https://github.com/kruk2/jasna/blob/main/jasna/ltx/restore.py"
click node_encoder "https://github.com/kruk2/jasna/blob/main/jasna/media/video_encoder.py"
click node_streaming "https://github.com/kruk2/jasna/blob/main/jasna/streaming_pipeline.py"
click node_vr180 "https://github.com/kruk2/jasna/blob/main/jasna/vr180.py"
click node_accelerator "https://github.com/kruk2/jasna/blob/main/jasna/accelerator.py"
click node_engine "https://github.com/kruk2/jasna/blob/main/jasna/engine_compiler.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gui,node_cli,node_segments,node_user,node_browser toneBlue
class node_session,node_pipeline,node_threads,node_detection,node_tracking,node_scene,node_processing,node_vr180 toneAmber
class node_restoration_pipeline,node_basicvsr,node_secondary,node_still,node_ltx,node_accelerator,node_engine toneMint
class node_metadata,node_decoder,node_encoder,node_streaming toneRose
```

## Components

### User interaction

- [Desktop GUI](https://github.com/kruk2/jasna/blob/main/jasna/gui/app.py): `jasna/gui/app.py`
- [CLI](https://github.com/kruk2/jasna/blob/main/jasna/main.py): `jasna/main.py`
- [Segment editor](https://github.com/kruk2/jasna/blob/main/jasna/gui/segment_editor.py): `jasna/gui/segment_editor.py`

### Video processing

- [Session setup](https://github.com/kruk2/jasna/blob/main/jasna/session_factory.py): `jasna/session_factory.py`
- [Video orchestration](https://github.com/kruk2/jasna/blob/main/jasna/pipeline.py): `jasna/pipeline.py`
- [Processing workers](https://github.com/kruk2/jasna/blob/main/jasna/pipeline_threads.py): `jasna/pipeline_threads.py`
- [Mosaic detection](https://github.com/kruk2/jasna/blob/main/jasna/mosaic/detection_registry.py): `jasna/mosaic/detection_registry.py`
- [Clip tracking](https://github.com/kruk2/jasna/blob/main/jasna/tracking/clip_tracker.py): `jasna/tracking/clip_tracker.py`
- [Scene cuts](https://github.com/kruk2/jasna/blob/main/jasna/tracking/scene_detector.py): `jasna/tracking/scene_detector.py`
- [Crop and overlap](https://github.com/kruk2/jasna/blob/main/jasna/pipeline_processing.py): `jasna/pipeline_processing.py`
- [VR180 handling](https://github.com/kruk2/jasna/blob/main/jasna/vr180.py): `jasna/vr180.py`

### Restoration models

- [Restoration pipeline](https://github.com/kruk2/jasna/blob/main/jasna/restorer/restoration_pipeline.py): `jasna/restorer/restoration_pipeline.py`
- [BasicVSR++](https://github.com/kruk2/jasna/blob/main/jasna/restorer/basicvsrpp_mosaic_restorer.py): `jasna/restorer/basicvsrpp_mosaic_restorer.py`
- [Secondary restoration](https://github.com/kruk2/jasna/blob/main/jasna/restorer/secondary_restorer.py): `jasna/restorer/secondary_restorer.py`
- [Still-image restoration](https://github.com/kruk2/jasna/blob/main/jasna/image_restore.py): `jasna/image_restore.py`
- [LTX restoration](https://github.com/kruk2/jasna/blob/main/jasna/ltx/restore.py): `jasna/ltx/restore.py`
- [GPU backend](https://github.com/kruk2/jasna/blob/main/jasna/accelerator.py): `jasna/accelerator.py`
- [Engine preparation](https://github.com/kruk2/jasna/blob/main/jasna/engine_compiler.py): `jasna/engine_compiler.py`

### Media and delivery

- [Media probing](https://github.com/kruk2/jasna/blob/main/jasna/media/probe.py): `jasna/media/probe.py`
- [Video decoding](https://github.com/kruk2/jasna/blob/main/jasna/media/video_decoder.py): `jasna/media/video_decoder.py`
- [Video encoding](https://github.com/kruk2/jasna/blob/main/jasna/media/video_encoder.py): `jasna/media/video_encoder.py`
- [Streaming pipeline](https://github.com/kruk2/jasna/blob/main/jasna/streaming_pipeline.py): `jasna/streaming_pipeline.py`

### Other components

- **User**
- **Browser player**

## Connections

- User → Desktop GUI: starts work (evidence: `README.md`)
- User → CLI: starts work (evidence: `README.md`)
- Desktop GUI → Session setup: configures jobs
- CLI → Session setup: configures jobs
- Desktop GUI → Segment editor: edits ranges (evidence: `README.md`)
- Session setup → Video orchestration: runs restoration (evidence: `jasna/pipeline.py`)
- Video orchestration → Media probing: probes input (evidence: `jasna/pipeline.py`)
- Video orchestration → Video decoding: decodes frames (evidence: `jasna/pipeline.py`)
- Video orchestration → Processing workers: starts workers (evidence: `jasna/pipeline.py`)
- Processing workers → Mosaic detection: detects regions
- Processing workers → Crop and overlap: processes frames (evidence: `jasna/pipeline_threads.py`)
- Crop and overlap → Clip tracking: updates tracks (evidence: `jasna/pipeline_processing.py`)
- Crop and overlap → Scene cuts: checks cuts (evidence: `jasna/pipeline_processing.py`)
- Processing workers → Restoration pipeline: restores clips (evidence: `jasna/pipeline_threads.py`)
- Restoration pipeline → BasicVSR++: uses model (evidence: `jasna/restorer/restoration_pipeline.py`)
- Processing workers → Secondary restoration: enhances clips (evidence: `jasna/pipeline_threads.py`)
- Video orchestration → Video encoding: encodes output (evidence: `jasna/pipeline.py`)
- User → Still-image restoration: restores image (evidence: `README.md`)
- Still-image restoration → LTX restoration: uses restoration
- User → Streaming pipeline: requests stream (evidence: `README.md`)
- Streaming pipeline → Browser player: serves playback (evidence: `README.md`)
- Video orchestration → VR180 handling: handles VR180 (evidence: `jasna/pipeline.py`)
- Video orchestration → Engine preparation: prepares engines
- Engine preparation → GPU backend: targets GPU (evidence: `jasna/engine_compiler.py`)
