# sdaqo/anipy-cli architecture

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

- Interactive diagram: https://gitdiagram.com/sdaqo/anipy-cli
- Repository: https://github.com/sdaqo/anipy-cli

## Overview

##### Main Components
- API Component:
- Core Library: Wrapped up in “api/src/anipy_api”, it includes modules for handling anime data (anime.py), error handling (error.py), and downloading.
- Player Subsystem: Located under “api/src/anipy_api/player” with multiple implementations (iina, mpv, syncplay, vlc) for launching or controlling media playback.
- Provider Subsystem: Found under “api/src/anipy_api/provider” which contains base classes, filters, and concrete provider implementations (e.g., anivibe_provider, gogo_provider) to fetch anime streams or metadata.
- Utility Modules: Support files (like locallist.py, mal.py, and players utils) indicate integrations, such as with MyAnimeList and local lists.

- CLI Component:
- Command Parsers and Interfaces: In “cli/src/anipy_cli” there is an “arg_parser.py” and a “cli.py” that likely provide the initial command-line entry point.
- Sub-Commands / Menus: Documented as different “clis” (base_cli, binge_cli, default_cli, download_cli, history_cli, mal_cli, seasonal_cli) that define specific interactions.
- Additional Modules: Components such as “discord.py” (for Discord presence), “config.py”, and a dedicated “menus” sub-package provide user interface and integration functionality.

- Supporting Infrastructure:
- Documentation: The “docs” directory (with examples and getting started guides) and mkdocs.yml for generating online docs.
- CI/CD & Deployment: GitHub workflows (.github/workflows) for automation (publishing docs and python packages), build-related configuration files (pyproject.toml in both api and cli, flake.nix, shell.nix), and scripts for bumping versions or generating reference pages.
- Contribution & Legal Files: LICENSE, CONTRIBUTING.md, DISCLAIMER.md, etc., frame the operational and legal boundaries.

##### Relationships and Interactions
- The CLI layer depends on the API component to perform all backend processing such as fetching anime data, managing downloads, and interfacing with multiple providers and players.
- Within the API, there is a clear separation between core logic, the player subsystem (handling media playback), and provider subsystem (managing content sources).
- External integrations like MyAnimeList (mal.py and related CLI commands) and Discord presence (discord.py) interact with their corresponding parts of both API and CLI.
- The utility scripts and workflows indicate an automated build/test/deployment cycle which supports continuous integration.

##### Architectural Patterns and Principles
- Separation of Concerns: Notice how the project clearly splits core API functions from the CLI (client) functionality. This encourages reusability and integration with other projects.
- Modular Design: Different functionalities (players, providers, menus, and commands) are separated into their own modules and packages.
- Extensibility: The structure (with “providers/providers” and “clis/clis”) indicates that new components can be easily added without major refactoring.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CLI Layer"
        CLI1["CLI: Command Parsers & Interfaces\n(handles arg parsing, CLI entry)"]:::cli
        CLI2["CLI Sub-Commands\n(e.g., base_cli, binge_cli, download_cli, etc.)"]:::cliSub
        CLI3["CLI Menus\n(e.g., base_menu, mal_menu, seasonal_menu)"]:::cliMenus
        CLI4["CLI Integrations\n(Discord presence, config, mal_proxy, etc.)"]:::cliInt
    end

    subgraph "API Layer"
        API1["API Core Library\n(core logic, anime, download, error handling)"]:::api
        API2["API Player Subsystem\n(player implementations: iina, mpv, syncplay, vlc)"]:::player
        API3["API Provider Subsystem\n(content providers: anivibe_provider, gogo_provider, etc.)"]:::provider
    end

    subgraph "Supporting Infrastructure"
        INF1["Documentation\n(docs directory, mkdocs.yml)"]:::infra
        INF2["CI/CD & Build Scripts\n(.github/workflows, pyproject.toml, flake.nix, shell.nix, scripts)"]:::infra
    end

    %% Connections: CLI Layer -> API Layer
    CLI1 -->|"calls"| API1
    CLI2 -->|"issues commands to"| API1
    CLI3 -->|"triggers functions in"| API1
    CLI4 -->|"integrates with"| API1

    %% Internal API Layer connections
    API1 -->|"handles playback via"| API2
    API1 -->|"fetches metadata via"| API3

    %% Supporting Infrastructure connections
    API1 ---|"built/tested via"| INF2
    CLI1 ---|"built/tested via"| INF2
    CLI2 ---|"built/tested via"| INF2
    CLI3 ---|"built/tested via"| INF2
    CLI4 ---|"built/tested via"| INF2
    API1 ---|"documented in"| INF1
    CLI1 ---|"documented in"| INF1

    %% Click Events
    click API1 "https://github.com/sdaqo/anipy-cli/tree/master/api/src/anipy_api"
    click API2 "https://github.com/sdaqo/anipy-cli/tree/master/api/src/anipy_api/player"
    click API3 "https://github.com/sdaqo/anipy-cli/tree/master/api/src/anipy_api/provider"
    click CLI1 "https://github.com/sdaqo/anipy-cli/tree/master/cli/src/anipy_cli"
    click CLI2 "https://github.com/sdaqo/anipy-cli/tree/master/cli/src/anipy_cli/clis"
    click CLI3 "https://github.com/sdaqo/anipy-cli/tree/master/cli/src/anipy_cli/menus"
    click CLI4 "https://github.com/sdaqo/anipy-cli/tree/master/cli/src/anipy_cli"
    click INF1 "https://github.com/sdaqo/anipy-cli/tree/master/docs"
    click INF2 "https://github.com/sdaqo/anipy-cli/tree/master/.github/workflows"

    %% Styles
    classDef cli fill:#FFD580,stroke:#333,stroke-width:2px;
    classDef cliSub fill:#FFE5B4,stroke:#333,stroke-width:2px;
    classDef cliMenus fill:#FFF2CC,stroke:#333,stroke-width:2px;
    classDef cliInt fill:#FFCCCB,stroke:#333,stroke-width:2px;
    classDef api fill:#C1E1C1,stroke:#333,stroke-width:2px;
    classDef player fill:#A2D5AB,stroke:#333,stroke-width:2px;
    classDef provider fill:#90C3D4,stroke:#333,stroke-width:2px;
    classDef infra fill:#B3CDE0,stroke:#333,stroke-width:2px;
```
