# niyakipham/anisub architecture

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

- Interactive diagram: https://gitdiagram.com/niyakipham/anisub
- Repository: https://github.com/niyakipham/anisub

## Overview

##### Project Type and Purpose
- This is a command-line interface (CLI) application aimed at viewing anime (with Vietnamese subtitles) in the terminal, inspired by similar tools like ani-cli.
- Its core functionality includes searching for anime, viewing TV shows, cutting video segments, downloading episodes, playing previous/next episodes, and integrating manga viewing.
- Although the project is minimal—with just a shell script (anisub.sh), an HTML file (likely for a static or promotional page), and a sample video file (possibly as a demonstration)—it leverages several external utilities (e.g., ffmpeg, yt-dlp, manga-tui) for its operations.

##### Analyzing the File Structure
- The project’s top-level files are:
- README.md: Contains setup info, features, installation instructions, and usage details.
- anisub.sh: The main executable shell script that implements the CLI logic.
- index.html: Likely used as a landing/promotional page or documentation.
- A video file (2025-01-16-20-40-18.mp4): Could be a demo or sample video.
- There are no separate directories for frontend/backend or modules, indicating a lightweight, single-script solution that glues several external tools together.

##### Key Components and Their Roles
a. User Interface:
- The primary user interface is the terminal (CLI). The script takes user commands, searches, and executes functions.
b. Core Script (anisub.sh):
- This is the heart of the application. It likely contains functions for:
- Searching anime databases.
- Handling video download, cutting, and merging using tools like yt-dlp and ffmpeg.
- Invoking manga-tui for manga reading.
- It serves as the orchestrator that coordinates calls to external utilities.
c. External Dependencies:
- The project relies on several command-line tools:
- ffmpeg – for video processing (cutting, joining).
- yt-dlp – for downloading videos.
- grep, curl, awk, jq – for text processing and data parsing.
- fzf – for interactive searching.
- pup – for HTML parsing if needed.
- manga-tui – for reading manga in the terminal.
- These should be represented as an “external utilities” layer that the core script communicates with.
d. Data Source / External Data:
- The README mentions data from a CSV file on Google Drive. Although there’s no CSV in the file tree, it implies that the script processes external data (anime metadata, episode lists, etc.), so represent a data integration component.

##### Relationships and Interactions
- Search & Selection: The script accepts search keywords and uses tools like fzf and grep.
- Video Processing & Download: The script calls yt-dlp and ffmpeg to retrieve and manipulate video files.
- Manga & Data Handling: The script can launch manga-tui and also process CSV or API data (from Google Drive).
- That anisub.sh acts as the “orchestrator”, receiving user input and coordinating the external modules.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Terminal["CLI Terminal"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        Core["ANISUB-CLI Core (anisub.sh)"]:::business
    end

    %% Integration Layer
    subgraph "Integration Layer"
        Video["Video Processing Module (ffmpeg,yt-dlp)"]:::integration
        Manga["Manga Viewing Module (manga-tui)"]:::integration
        Data["Data Integration Module (CSV/GoogleDrive)"]:::integration
    end

    %% Support Files
    subgraph "Support Files"
        Web["Static Content / Web UI (index.html)"]:::static
        Demo["Demo Video Sample (2025-01-16-20-40-18.mp4)"]:::static
        Doc["Documentation & Setup Info (README.md)"]:::static
    end

    %% Data Flow Connections
    Terminal -->|"commandInput"| Core
    Core -->|"videoFunctions"| Video
    Core -->|"mangaFunctions"| Manga
    Core -->|"dataHandling"| Data
    Core -->|"displayInfo"| Web
    Core -->|"demoPlayback"| Demo
    Core -->|"referDocs"| Doc

    %% Click Events for Component Mapping
    click Core "https://github.com/niyakipham/anisub/blob/main/anisub.sh"
    click Web "https://github.com/niyakipham/anisub/blob/main/index.html"
    click Demo "https://github.com/niyakipham/anisub/blob/main/2025-01-16-20-40-18.mp4"
    click Doc "https://github.com/niyakipham/anisub/blob/main/README.md"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef business fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef integration fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef static fill:#FFB6C1,stroke:#333,stroke-width:2px;
```
