# eroge-abyss/tadoku architecture

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

- Interactive diagram: https://gitdiagram.com/eroge-abyss/tadoku
- Repository: https://github.com/eroge-abyss/tadoku

## Overview

##### Project type and purpose
- Tadoku is a full‑stack, cross‑platform desktop application built with Tauri (Rust) for the backend and SvelteKit (TypeScript/Svelte) for the frontend.
- Its purpose is to let users manage and track their Visual Novel (VN) library, record playtime, and integrate with external services (VNDB API, Discord Rich Presence).

##### File structure
- Top‑level:
- package.json / bun.lock / svelte.config.js / vite.config.js: frontend build/config.
- src/: SvelteKit app (routes, components).
- src-tauri/src/commands: exposes Tauri commands for opener (launching games), storage (persistence), vndb (searching via VNDB API), scripts.
- src-tauri/src/services: encapsulates domain logic (playtime tracking, Discord RPC, store adapter, VNDB wrappers).
- Persistence: likely via local filesystem or embedded DB via store.rs.
- Configuration: tauri.conf.json defines allowed APIs and privileges.

##### README for additional insights
- Tech stack: Tauri + SvelteKit.
- Features: playtime tracking, game CRUD, NSFW filter, pinning, character info, Discord Rich Presence.
- External dependencies: VNDB API, Discord RPC, local OS for launching executables.

a. Main components
- Frontend (SvelteKit WebView)
- Tauri Core (Rust binary + embedded webview)
- IPC Layer (Tauri invoke / event system)
- Command Handlers (opener, storage, vndb, etc.)
- Services Layer (playtime monitor, Discord RPC, VNDB client, local storage adapter)
- OS (filesystem, process launcher)
- External Services (VNDB API, Discord RPC endpoint)
b. Relationships and interactions
1. User interacts with SvelteKit UI
2. UI invokes Tauri commands via IPC
3. IPC routes to specific command handler in Rust
4. Command delegates to one or more services
- Storage service ↔ local filesystem or embedded DB
- Playtime service ↔ OS process watcher
- Discord service ↔ Discord RPC endpoint over network or named pipe
- VNDB service ↔ VNDB REST API over HTTPS
5. Services return data to command handler → IPC callback → UI updates
c. Architectural patterns & principles
- MVVM‑style separation: UI <→> Commands <→> Services
- Single Rust binary (monolith) backing multiple domain services
- IPC boundary isolates UI (JavaScript) from OS‑level actions (Rust)
- Dependency injection at service layer for testability
d. Key technologies & libraries
- Frontend: SvelteKit, Vite, Bun
- IPC: @tauri-apps/api
- Backend: Tauri (Rust), serde (JSON), reqwest (HTTP), discord‑rpc crate
- Persistence: custom store.rs (file or embedded DB)

##### Essential details checklist
- Data persistence layer inside or adjacent to Storage Service

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Tier
    subgraph "Presentation Tier"
        UI["Frontend UI (SvelteKit)"]:::frontend
    end

    %% Application Tier
    subgraph "Application Tier"
        TauriCore["Tauri Core (Rust Binary)"]:::backend
        IPC["IPC Layer (Tauri invoke)"]:::backend

        subgraph "Commands Module"
            Opener["Opener Command"]:::backend
            StorageCmd["Storage Command"]:::backend
            VNDBCmd["VNDB Command"]:::backend
            ScriptsCmd["Scripts"]:::backend
        end

        subgraph "Services Module"
            StoreSvc["Storage Service"]:::service
            PlaytimeSvc["Playtime Service"]:::service
            VNDBSvc["VNDB Service"]:::service
            DiscordSvc["Discord Service"]:::service
        end
    end

    %% OS & External
    subgraph "OS & External Systems"
        OSFs["OS Filesystem & Process Launcher"]:::os
        VNDBExt["VNDB API"]:::external
        DiscordExt["Discord RPC Endpoint"]:::external
    end

    %% Connections
    UI -->|"invoke via @tauri-apps/api"| IPC
    TauriCore --> IPC

    IPC -->|dispatch| Opener
    IPC -->|dispatch| StorageCmd
    IPC -->|dispatch| VNDBCmd
    IPC -->|dispatch| ScriptsCmd

    Opener -->|uses| PlaytimeSvc
    StorageCmd -->|uses| StoreSvc
    VNDBCmd -->|uses| VNDBSvc
    ScriptsCmd -->|uses| DiscordSvc

    PlaytimeSvc -->|system calls| OSFs
    StoreSvc -->|read/write| OSFs
    VNDBSvc -->|HTTPS GET| VNDBExt
    DiscordSvc -->|RPC calls| DiscordExt

    %% Click Events
    click UI "https://github.com/eroge-abyss/tadoku/tree/main/src/"
    click Opener "https://github.com/eroge-abyss/tadoku/blob/main/src-tauri/src/commands/opener.rs"
    click StorageCmd "https://github.com/eroge-abyss/tadoku/blob/main/src-tauri/src/commands/storage.rs"
    click VNDBCmd "https://github.com/eroge-abyss/tadoku/blob/main/src-tauri/src/commands/vndb.rs"
    click ScriptsCmd "https://github.com/eroge-abyss/tadoku/blob/main/src-tauri/src/scripts.rs"
    click StoreSvc "https://github.com/eroge-abyss/tadoku/blob/main/src-tauri/src/services/store.rs"
    click PlaytimeSvc "https://github.com/eroge-abyss/tadoku/blob/main/src-tauri/src/services/playtime.rs"
    click VNDBSvc "https://github.com/eroge-abyss/tadoku/blob/main/src-tauri/src/services/vndb.rs"
    click DiscordSvc "https://github.com/eroge-abyss/tadoku/blob/main/src-tauri/src/services/discord.rs"
    click TauriCore "https://github.com/eroge-abyss/tadoku/blob/main/src-tauri/src/main.rs"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#000
    classDef backend fill:#E0FFE0,stroke:#228B22,color:#000
    classDef service fill:#FFFAE6,stroke:#DAA520,color:#000
    classDef os fill:#FFF0F0,stroke:#FF6347,color:#000
    classDef external fill:#F0F8FF,stroke:#1E90FF,color:#000
```
