# mdwiki-td/mdwiki-python-files architecture

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

- Interactive diagram: https://gitdiagram.com/mdwiki-td/mdwiki-python-files
- Repository: https://github.com/mdwiki-td/mdwiki-python-files

## Overview

- Bot Modules/Packages: Each major directory (for example, copy_text, copy_to_en, fix_use, md_core, td_core, wprefs, newupdater, md_core_helps) should be represented as independent modules or sub-systems. These modules appear to encapsulate various automated tasks such as copying text, fixing references, adding data to wiki pages, and handling one-time operations.
- API & Integration Interfaces: Within some modules (especially in md_core_helps and related directories) there are files that reference API interactions (e.g., wikidataapi, mdwiki_api). Mark these as external interface components that communicate with external systems.
- Data and Database Access Components: There are several files that deal with SQL (in modules like mdapi_sql in md_core_helps and also in td_core). Represent these as a “Database Access/SQL Module” to show how data is queried, updated, or integrated within the processing pipeline.
- Testing & Configuration: Although not part of the main execution flow, include a component for tests (as many directories include tests subfolders and unit tests like test_*.py) and notice the configuration files (.gitattributes, .gitignore, .pre-commit-config.yaml, and others) that regulate development practices.

##### Relationships and Interactions
- How each bot module may act as an independent service or script that potentially interacts with a shared database and/or calls shared utility functions across the project.
- That scheduling and automation may be externally controlled (e.g., via GitHub workflows found in .github/workflows) which could be represented as an “Automation/CI/CD” component that triggers these scripts or bots.

##### Architectural Patterns and Design Principles
- Extensibility: The presence of many “bots” and subdirectories within them (like bots, tests, and one_time tasks) indicates a design that allows adding or updating discrete functionality without affecting the entire system.
- Reusability: Common functionality (for example, repeated API wrappers or shared SQL utilities) is likely abstracted into central helper modules, e.g., md_core_helps, underscoring an emphasis on code reuse.

##### Relevant Technologies, Frameworks, or Libraries
- Based on file names and structure, the project is written in Python. You might note the use of YAML configuration files (such as .coderabbit.yaml and sweep.yaml) that suggest integration with external tools.
- Testing frameworks: The unit test files imply the use of a Python testing framework (like pytest or unittest), so adding a “Testing Framework” component may be useful.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Automation/CI/CD"]:::automation
    T["Testing & Configuration"]:::testconfig

    subgraph "Bot/Task Layer"
        B1["copy_text Module"]:::bot
        B2["copy_to_en Module"]:::bot
        B3["fix_use Module"]:::bot
        B4["md_core Module"]:::bot
        B5["newupdater Module"]:::bot
        B6["td_core Module"]:::bot
        B7["wprefs Module"]:::bot
    end

    subgraph "Data Processing/Helper Layer"
        C1["md_core_helps API Layer"]:::api
        C2["Database/SQL Module"]:::db
    end

    D["External Wiki Systems"]:::external

    A -->|"triggers"| B1
    A -->|"triggers"| B2
    A -->|"triggers"| B3
    A -->|"triggers"| B4
    A -->|"triggers"| B5
    A -->|"triggers"| B6
    A -->|"triggers"| B7
    A -->|"integrates"| T

    B1 -->|"processes"| C1
    B2 -->|"processes"| C1
    B7 -->|"processes"| C1
    B4 -->|"queries"| C2
    B6 -->|"queries"| C2
    B3 -->|"updates"| D
    B5 -->|"updates"| D

    C1 -->|"integrates"| D
    C2 -->|"updates"| D

    click A "https://github.com/mdwiki-td/mdwiki-python-files/blob/main/.github/workflows/d.yml"
    click B1 "https://github.com/mdwiki-td/mdwiki-python-files/blob/main/copy_text/bot.py"
    click B2 "https://github.com/mdwiki-td/mdwiki-python-files/blob/main/copy_to_en/bot.py"
    click B3 "https://github.com/mdwiki-td/mdwiki-python-files/blob/main/fix_use/bot.py"
    click B4 "https://github.com/mdwiki-td/mdwiki-python-files/tree/main/md_core/"
    click B5 "https://github.com/mdwiki-td/mdwiki-python-files/blob/main/newupdater/MedWorkNew.py"
    click B6 "https://github.com/mdwiki-td/mdwiki-python-files/blob/main/td_core/after_translate/sql_new.py"
    click B7 "https://github.com/mdwiki-td/mdwiki-python-files/blob/main/wprefs/bot.py"
    click C1 "https://github.com/mdwiki-td/mdwiki-python-files/blob/main/md_core_helps/apis/mdwiki_api.py"
    click C2 "https://github.com/mdwiki-td/mdwiki-python-files/blob/main/md_core_helps/mdapi_sql/sql.py"
    click T "https://github.com/mdwiki-td/mdwiki-python-files/blob/main/.pre-commit-config.yaml"

    classDef automation fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef testconfig fill:#ff9966,stroke:#333,stroke-width:2px;
    classDef bot fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef api fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef db fill:#e6ffe6,stroke:#333,stroke-width:2px;
    classDef external fill:#ffe6f2,stroke:#333,stroke-width:2px;
```
