# mukeshsoni/vikara architecture

> Architecture diagram of the GitHub repository mukeshsoni/vikara, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mukeshsoni/vikara
- Repository: https://github.com/mukeshsoni/vikara

## Overview

##### Project type and purpose
- This is a cross‐platform desktop application (“Vikara”) for image conversion.
- It uses Tauri as the shell: a Rust‐based backend (image processing) paired with a web frontend (React/TypeScript + Vite).
- The app loads images (JPEG, PNG, RAW, HEIC, etc.), applies transformations (resize, quality), and writes the converted file back to disk.

##### File structure
- Top level:
- index.html, public/, src/, package.json, vite.config.ts → front-end code & build
- src-tauri/ → Tauri Rust backend & configuration
- scripts/update_libs.js → updates bundled native image-codec libraries
- src/ (front-end): React/TypeScript components (App.tsx, main.tsx), CSS modules, constants and schema for the conversion form.
- src-tauri/src/ (backend):
- main.rs → Tauri event loop / command registration
- image_helpers.rs → business logic (invokes external image libs)
- lib.rs → shared modules or utility glue
- src-tauri/external-libs/: dynamic libraries for codecs (libheif, libdav1d, libx265, etc.).
- Configuration: tauri.conf.json, Cargo.toml, postcss.config.cjs, tsconfig.json.

##### README
- Confirms it’s an image‐conversion desktop app built with Tauri.
- Lists supported formats and a TODO to persist user settings via Tauri store.

##### Components & interactions
a. Main components:
1. UI Layer (React + Vite)
2. Tauri Runtime (IPC bridge)
3. Rust Backend (Tauri command handlers)
4. External Image Libraries (FFmpeg-style dynamic libs)
5. File System / OS (file dialogs, read/write)
6. (Future) Tauri Store for settings persistence
b. Relationships & data flow:
- User interacts with UI → selects files & parameters →
- UI issues Tauri.invoke(“convert_image”, payload) →
- Tauri runtime forwards to Rust main.rs →
- image_helpers.rs loads input file, calls external‐libs (libheif, libx265, etc.) →
- Generates output buffer/file → backend returns result (path/status) →
- UI receives result, displays success & writes file if needed.
c. Architectural patterns:
- Separation of concerns: UI (presentation) vs. Rust (business logic)
- IPC pattern (command/response) via Tauri
- Plugin-style external libs for codec support (dynamic linking)
d. Key technologies:
- React + Vite + TypeScript
- Tauri (Rust + WebView2 / WebKit)
- image_helpers.rs + native libs
- Node scripts for updating native libs

##### Additional details to capture
- Build artifacts: Vite dev server vs. production build.
- Configuration files (tauri.conf.json) influencing windowing & permissions.
- Script for native-lib updates (scripts/update_libs.js).

- Top: User & UI (React),
- Middle: Tauri IPC bridge,
- Bottom: Rust logic + external libs + file system,
- Side: Build & packaging pipeline.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer (React + Vite)"
        direction TB
        IDX["index.html"]:::frontend
        PUB["public/"]:::frontend
        MAIN["src/main.tsx"]:::frontend
        APP["src/App.tsx"]:::frontend
        CSS1["src/button.module.css"]:::frontend
        CSS2["src/layout.css"]:::frontend
        CSS3["src/styles.css"]:::frontend
        CONST["src/constants.ts"]:::frontend
        CFG1["src/export_form_input_config.ts"]:::frontend
        SCHEMA["src/export_form_schema.ts"]:::frontend
        VENV["src/vite-env.d.ts"]:::frontend
        VITECFG["vite.config.ts"]:::frontend
        TSCONF["tsconfig.json"]:::frontend
        TSCONF2["tsconfig.node.json"]:::frontend
        POSTCSS["postcss.config.cjs"]:::frontend
        PKG["package.json"]:::frontend
        LOCK["pnpm-lock.yaml"]:::frontend
    end

    %% Tauri Runtime Layer
    subgraph "Tauri Runtime (IPC Bridge & Config)" 
        direction TB
        TAURICONF["src-tauri/tauri.conf.json"]:::tauri
        CARGO["src-tauri/Cargo.toml"]:::tauri
        BUILDRS["src-tauri/build.rs"]:::tauri
        CAP["src-tauri/capabilities/default.json"]:::tauri
    end

    %% Rust Backend Layer
    subgraph "Rust Backend (Tauri Commands & Business Logic)"
        direction TB
        MAINRS["src-tauri/src/main.rs"]:::backend
        HELPERS["src-tauri/src/image_helpers.rs"]:::backend
        LIBRS["src-tauri/src/lib.rs"]:::backend
    end

    %% External Image Libraries
    subgraph "External Image Libraries" 
        direction TB
        LIBDIR["src-tauri/external-libs/"]:::externallibs
        AOM["libaom.3.12.1.dylib"]:::externallibs
        DAV1D["libdav1d.7.dylib"]:::externallibs
        DE265["libde265.0.dylib"]:::externallibs
        HEIF["libheif.1.19.8.dylib"]:::externallibs
        OMP["libomp.dylib"]:::externallibs
        SHARPYUV["libsharpyuv.0.1.1.dylib"]:::externallibs
        VMAF["libvmaf.3.dylib"]:::externallibs
        X265["libx265.215.dylib"]:::externallibs
    end

    %% Native libs update script
    SCRIPTS["scripts/update_libs.js"]:::script

    %% File System / OS
    FS["File System / OS"]:::filesystem
    STORE["Tauri Store (Future)"]:::filesystem

    %% Build & Packaging
    subgraph "Build & Packaging Pipeline"
        direction TB
        VDEV["Vite Dev Server"]:::build
        PROD["Vite Production Build"]:::build
        TAURIBUILD["Tauri Bundler"]:::build
        NATIVE["Native Executable"]:::build
    end

    %% Connections
    IDX -->|"loads UI"| TAURICONF
    PUB --> TAURICONF
    MAIN -->|"serves bundle"| TAURICONF
    TAURICONF -->|"invoke command"| MAINRS
    MAINRS -->|"dispatch"| HELPERS
    HELPERS -->|"link & call"| LIBDIR
    LIBDIR --> AOM
    LIBDIR --> DAV1D
    LIBDIR --> DE265
    LIBDIR --> HEIF
    LIBDIR --> OMP
    LIBDIR --> SHARPYUV
    LIBDIR --> VMAF
    LIBDIR --> X265
    HELPERS -->|"read/write"| FS
    HELPERS -->|"return response"| MAIN
    MAIN -->|"display result"| APP
    SCRIPTS --> LIBDIR

    VDEV --> PROD
    PROD --> TAURIBUILD
    TAURIBUILD --> NATIVE

    %% Click Events
    click IDX "https://github.com/mukeshsoni/vikara/blob/main/index.html"
    click PUB "https://github.com/mukeshsoni/vikara/tree/main/public/"
    click MAIN "https://github.com/mukeshsoni/vikara/blob/main/src/main.tsx"
    click APP "https://github.com/mukeshsoni/vikara/blob/main/src/App.tsx"
    click CSS1 "https://github.com/mukeshsoni/vikara/blob/main/src/button.module.css"
    click CSS2 "https://github.com/mukeshsoni/vikara/blob/main/src/layout.css"
    click CSS3 "https://github.com/mukeshsoni/vikara/blob/main/src/styles.css"
    click CONST "https://github.com/mukeshsoni/vikara/blob/main/src/constants.ts"
    click CFG1 "https://github.com/mukeshsoni/vikara/blob/main/src/export_form_input_config.ts"
    click SCHEMA "https://github.com/mukeshsoni/vikara/blob/main/src/export_form_schema.ts"
    click VENV "https://github.com/mukeshsoni/vikara/blob/main/src/vite-env.d.ts"
    click VITECFG "https://github.com/mukeshsoni/vikara/blob/main/vite.config.ts"
    click TSCONF "https://github.com/mukeshsoni/vikara/blob/main/tsconfig.json"
    click TSCONF2 "https://github.com/mukeshsoni/vikara/blob/main/tsconfig.node.json"
    click POSTCSS "https://github.com/mukeshsoni/vikara/blob/main/postcss.config.cjs"
    click PKG "https://github.com/mukeshsoni/vikara/blob/main/package.json"
    click LOCK "https://github.com/mukeshsoni/vikara/blob/main/pnpm-lock.yaml"
    click TAURICONF "https://github.com/mukeshsoni/vikara/blob/main/src-tauri/tauri.conf.json"
    click CARGO "https://github.com/mukeshsoni/vikara/blob/main/src-tauri/Cargo.toml"
    click BUILDRS "https://github.com/mukeshsoni/vikara/blob/main/src-tauri/build.rs"
    click CAP "https://github.com/mukeshsoni/vikara/blob/main/src-tauri/capabilities/default.json"
    click MAINRS "https://github.com/mukeshsoni/vikara/blob/main/src-tauri/src/main.rs"
    click HELPERS "https://github.com/mukeshsoni/vikara/blob/main/src-tauri/src/image_helpers.rs"
    click LIBRS "https://github.com/mukeshsoni/vikara/blob/main/src-tauri/src/lib.rs"
    click LIBDIR "https://github.com/mukeshsoni/vikara/tree/main/src-tauri/external-libs/"
    click SCRIPTS "https://github.com/mukeshsoni/vikara/blob/main/scripts/update_libs.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef tauri fill:#E0E0E0,stroke:#606060,color:#303030;
    classDef backend fill:#E6F4EA,stroke:#238636,color:#238636;
    classDef externallibs fill:#FFF5B1,stroke:#D4A72C,color:#735C0F;
    classDef script fill:#F0DBDB,stroke:#E03E2D,color:#E03E2D;
    classDef filesystem fill:#FFEFE6,stroke:#D15704,color:#D15704;
    classDef build fill:#F4F0FF,stroke:#6F42C1,color:#6F42C1;
```
