# oreoxmt/tidocs architecture

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

- Interactive diagram: https://gitdiagram.com/oreoxmt/tidocs
- Repository: https://github.com/oreoxmt/tidocs

## Overview

##### Main Components

a) Core Components:
- CLI Interface
- Document Processing Engine
- Web Interface (Marimo-based)
- File Handlers
- External Tool Integration

b) External Dependencies:
- Pandoc (as a crucial external tool)
- File System
- Web Browser

##### Specific Implementation Details

- The file handling pipeline (markdown_handler.py → docx_handler.py)
- The merge operation workflow
- Pandoc integration points
- Resource management (custom templates)

**[User Interface Layer]**
- CLI Interface (cli.py)
- Web Interface (merge/main_marimo.py)

**[Processing Layer]**
- Document Handlers
- Markdown Handler (markdown_handler.py)
- DOCX Handler (docx_handler.py)
- Pandoc Wrapper (pandoc_wrapper.py)
- Utilities (util.py)

**[External Layer]**
- Pandoc Binary
- File System
- Resources
- Custom Templates

##### Key Interactions to Highlight

- File upload flow
- Document processing pipeline
- Template application process
- Output generation

- Component types and their roles
- Any abbreviations or technical terms

This system design should clearly communicate how TiDocs improves upon standard Pandoc functionality while maintaining a clear and organized structure that other developers can easily understand and maintain.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#2374ab,color:white
    classDef processing fill:#48a9a6,color:white
    classDef external fill:#e4572e,color:white
    classDef resource fill:#686963,color:white
    
    %% User Interface Layer
    subgraph UI["User Interface Layer"]
        CLI["CLI Interface"]:::ui
        WEB["Web Interface\n(Marimo-based)"]:::ui
    end
    
    %% Processing Layer
    subgraph PROC["Processing Layer"]
        subgraph DH["Document Handlers"]
            MD["Markdown Handler"]:::processing
            DOCX["DOCX Handler"]:::processing
        end
        
        PANDOC_W["Pandoc Wrapper"]:::processing
        UTILS["Utilities"]:::processing
        CORE["Core Package"]:::processing
        VERSION["Version Management"]:::processing
    end
    
    %% External Layer
    subgraph EXT["External Layer"]
        PANDOC["Pandoc Binary"]:::external
        FS["File System"]:::external
        
        subgraph RES["Resources"]
            TEMPL["Custom Templates"]:::resource
        end
    end
    
    %% Relationships
    CLI --> CORE
    WEB --> CORE
    CORE --> MD
    CORE --> DOCX
    MD --> PANDOC_W
    DOCX --> PANDOC_W
    PANDOC_W --> PANDOC
    PANDOC_W --> TEMPL
    MD --> FS
    DOCX --> FS
    UTILS --> FS
    
    %% Click Events
    click CLI "https://github.com/Oreoxmt/tidocs/blob/main/src/tidocs/cli.py"
    click WEB "https://github.com/Oreoxmt/tidocs/blob/main/src/tidocs/merge/main_marimo.py"
    click MD "https://github.com/Oreoxmt/tidocs/blob/main/src/tidocs/markdown_handler.py"
    click DOCX "https://github.com/Oreoxmt/tidocs/blob/main/src/tidocs/docx_handler.py"
    click PANDOC_W "https://github.com/Oreoxmt/tidocs/blob/main/src/tidocs/pandoc_wrapper.py"
    click UTILS "https://github.com/Oreoxmt/tidocs/blob/main/src/tidocs/util.py"
    click TEMPL "https://github.com/Oreoxmt/tidocs/blob/main/src/tidocs/resources/custom-pdf-reference.docx"
    click VERSION "https://github.com/Oreoxmt/tidocs/blob/main/src/tidocs/__version__.py"
    click CORE "https://github.com/Oreoxmt/tidocs/blob/main/src/tidocs/__init__.py"
    
    %% Legend
    subgraph Legend
        UI_L["User Interface"]:::ui
        PROC_L["Processing Component"]:::processing
        EXT_L["External Tool"]:::external
        RES_L["Resource"]:::resource
    end
```
