# helitoo/sharptex architecture

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

- Interactive diagram: https://gitdiagram.com/helitoo/sharptex
- Repository: https://github.com/helitoo/sharptex

## Overview

##### Main Components
- User Interface (Frontend):
- HTML (index.html, src/page/document.html): These files provide the primary visual interface for the application.
- CSS (files in src/style): Responsible for styling the document, dropdown menus, floating windows, and loading elements.
- JavaScript (files in src/script): Includes various engines (sharptex_engine.js, dropdown_menu_engine.js, find_n_replace_engine) that handle user actions, text transformations, and UI interactions.
- Conversion/Processing Engine (Backend):
- Python Module (src/generator_engine): Contains app.py, process.py, and other resources (instruction.txt, syntax.csv) that process the custom syntax into LaTeX.
- This component reads input data, applies the conversion logic defined by the custom syntax, and then outputs formatted LaTeX code.
- Supporting Assets and Data:
- The syntax definitions in syntax.csv, which appear to drive how SharpTeX maps its custom syntax to the LaTeX standard.
- Static assets like images (in img/) and presentation material.

##### Relationships and Interactions
- The User Interface receives raw text input from the user (or an uploaded file) through the web pages.
- JavaScript components (sharptex_engine.js and related modules) likely handle client-side validations and interactivity (e.g., dropdown menus, shortcuts).
- Once the user triggers the conversion (for example, by clicking “Export”), the client-side code sends a request (could be a direct function call if running entirely in-browser, or it may interact with the Python engine if a backend is deployed) to the generator engine.
- The Python generator engine (app.py and process.py) then processes the text using rules defined in syntax.csv and returns the converted LaTeX document.
- The processed document is made available for download as a .zip file that can then be uploaded to an external LaTeX compiler (e.g., Overleaf).

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- The project cleanly separates UI (HTML/CSS/JS) from the processing logic (Python-based generator engine).
- Modular Design:
- The generator engine itself is isolated in its own directory, indicating that all conversion logic is encapsulated here.
- JavaScript is modular with components for different UI interactions (i.e., find & replace, dropdown menus, character counting).
- Data Flow Control:
- The process starts with user input, then moves through client-side enhancements, and finally to backend processing for conversion before delivering the output.

##### Relevant Technologies and Frameworks
- Frontend: HTML, CSS, JavaScript – for creating a dynamic interface.
- Backend: Python – responsible for parsing the custom syntax and converting it to LaTeX.
- Other Assets: CSV for syntax mapping; possibly static hosting technology (hinted by the .nojekyll file) for deployment on platforms such as GitHub Pages.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface (Frontend)"
        UI1["index.html"]:::frontend
        UI2["document.html"]:::frontend
        CSS["CSS Styles"]:::frontend
        JS["JavaScript Modules"]:::frontend
    end

    subgraph "Conversion Engine (Backend)"
        APP["Python App (app.py)"]:::backend
        PROCESS["Processing Module (process.py)"]:::backend
        SYNTAX["Syntax Rules (syntax.csv)"]:::backend
        CONFIG["Configuration (instruction.txt)"]:::backend
    end

    subgraph "Assets & Data"
        ASSET["Static Assets"]:::assets
    end

    subgraph "Output"
        OUTPUT["LaTeX Output (.zip)"]:::output
        OVERLEAF["Overleaf"]:::output
    end

    JS -->|"triggers_conversion"| APP
    APP -->|"processes_text"| PROCESS
    PROCESS -->|"uses_syntax"| SYNTAX
    PROCESS -->|"reads_config"| CONFIG
    APP -->|"produces_output"| OUTPUT
    OUTPUT -->|"uploaded_to"| OVERLEAF
    ASSET -->|"supplies_assets"| CSS

    classDef frontend fill:#CCFFCC,stroke:#333,stroke-width:2px;
    classDef backend fill:#FFCCCC,stroke:#333,stroke-width:2px;
    classDef assets fill:#CCCCFF,stroke:#333,stroke-width:2px;
    classDef output fill:#FFFFCC,stroke:#333,stroke-width:2px;

    click UI1 "https://github.com/helitoo/sharptex/blob/main/index.html"
    click UI2 "https://github.com/helitoo/sharptex/blob/main/src/page/document.html"
    click CSS "https://github.com/helitoo/sharptex/tree/main/src/style/"
    click JS "https://github.com/helitoo/sharptex/tree/main/src/script/"
    click APP "https://github.com/helitoo/sharptex/blob/main/src/generator_engine/app.py"
    click PROCESS "https://github.com/helitoo/sharptex/blob/main/src/generator_engine/process.py"
    click SYNTAX "https://github.com/helitoo/sharptex/blob/main/src/generator_engine/syntax.csv"
    click CONFIG "https://github.com/helitoo/sharptex/blob/main/src/generator_engine/instruction.txt"
    click ASSET "https://github.com/helitoo/sharptex/tree/main/img/"
```
