# hxa7241/tadist-next architecture

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

- Interactive diagram: https://gitdiagram.com/hxa7241/tadist-next
- Repository: https://github.com/hxa7241/tadist-next

## Overview

##### Main Components

a) Core Components:
- Command Line Interface (Entry Point)
- File Handlers (PDF and EPUB processors)
- Metadata Extractor
- File Operations Manager
- Internet Query Service
- Name Generator

b) External Dependencies:
- OpenLibrary.org API
- Xpdf Tools (pdfinfo, pdftotext)
- CamlZip Library

**┌─ User Interface Layer ─────────────────────┐**
- Command Line Interface (tadistTool.ml)     │
- ┬─────────────────────────┘
- ↓
**┌─ Core Processing Layer ───────────────────┐**
- ┌─────────────┐    ┌──────────────┐      │
- File Handlers│←→│Metadata Engine│      │
- ┘    └──────────────┘      │
- ↑                   ↑             │

- ┌─────────────┐    ┌──────────────┐      │
- Name Generator│←→│Query Manager │      │
- ┘    └──────────────┘      │
- ┘
- ↑                 ↑

**┌─ External Services Layer ──────────────────┐**
- ┌─────────────┐    ┌──────────────┐      │
- Xpdf Tools │    │ OpenLibrary  │      │
- (PDF Support)│    │     API      │      │
- ┘    └──────────────┘      │
- ┘

##### Component Mapping to Files

- tadistTool.ml/mli: Main entry point and CLI handling
- tadistEpub.ml/mli: EPUB file processing
- tadistPdf.ml/mli: PDF file processing
- tadistQuerier.ml/mli: OpenLibrary API integration
- tadistMelder.ml/mli: Metadata combination logic
- utf8.ml/mli: Text encoding support
- hxaGeneral.ml/mli: Utility functions

##### Important Details

a) File Format Support:
- Separate paths for EPUB and PDF processing
- Where format-specific metadata extraction occurs

b) External Dependencies:
- Integration points with OpenLibrary.org
- Where Xpdf tools are utilized
- CamlZip library usage for EPUB handling

c) Operations:
- Metadata extraction flow
- File name suggestion process
- Rename operation path

##### File renaming

Each function should have a clear flow path from input to output, showing how the different components interact to achieve the desired result.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#2196F3,stroke:#1565C0,color:white
    classDef core fill:#4CAF50,stroke:#2E7D32,color:white
    classDef file fill:#FF9800,stroke:#EF6C00,color:white
    classDef external fill:#9E9E9E,stroke:#616161,color:white
    classDef utility fill:#607D8B,stroke:#455A64,color:white

    %% User Interface Layer
    CLI["Command Line Interface"]:::ui
    click CLI "https://github.com/hxa7241/tadist-next/blob/master/tadistTool.ml"

    %% Core Processing Layer
    subgraph CoreLayer["Core Processing Layer"]
        MainModule["Main Module"]:::core
        click MainModule "https://github.com/hxa7241/tadist-next/blob/master/tadist.ml"
        
        MetadataEngine["Metadata Engine"]:::core
        click MetadataEngine "https://github.com/hxa7241/tadist-next/blob/master/tadistMelder.ml"
        
        FileHandlers["File Handlers"]:::file
        
        NameGen["Name Generator"]:::core
        QueryManager["Query Manager"]:::core
        click QueryManager "https://github.com/hxa7241/tadist-next/blob/master/tadistQuerier.ml"
        
        subgraph FileProcessors["File Processors"]
            PDFHandler["PDF Handler"]:::file
            click PDFHandler "https://github.com/hxa7241/tadist-next/blob/master/tadistPdf.ml"
            EPUBHandler["EPUB Handler"]:::file
            click EPUBHandler "https://github.com/hxa7241/tadist-next/blob/master/tadistEpub.ml"
        end
        
        Utils["Utility Functions"]:::utility
        click Utils "https://github.com/hxa7241/tadist-next/blob/master/hxaGeneral.ml"
        
        TextEnc["Text Encoding Support"]:::utility
        click TextEnc "https://github.com/hxa7241/tadist-next/blob/master/utf8.ml"
    end

    %% External Services Layer
    subgraph ExternalLayer["External Services Layer"]
        XpdfTools["Xpdf Tools"]:::external
        OpenLibAPI["OpenLibrary API"]:::external
        CamlZip["CamlZip Library"]:::external
    end

    %% Connections
    CLI --> MainModule
    MainModule --> FileHandlers
    FileHandlers --> FileProcessors
    PDFHandler --> XpdfTools
    EPUBHandler --> CamlZip
    FileProcessors --> MetadataEngine
    QueryManager --> OpenLibAPI
    MetadataEngine --> NameGen
    FileProcessors --> Utils
    FileProcessors --> TextEnc
    QueryManager --> MetadataEngine

    %% Legend
    subgraph Legend
        UI["User Interface"]:::ui
        Core["Core Component"]:::core
        FileProc["File Processing"]:::file
        Ext["External Service"]:::external
        Util["Utility"]:::utility
    end
```
