# yuanhes/4cornerindex-to-text architecture

> Architecture diagram of the GitHub repository yuanhes/4cornerindex-to-text, 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/yuanhes/4cornerindex-to-text
- Repository: https://github.com/yuanhes/4cornerindex-to-text

## Overview

##### Data Processing Pipeline
- Flow from raw data sources to final output

##### Web Application Layer
- Frontend and backend components
- API endpoints
- User interaction flow

A. Core Components (Top to Bottom):

##### Data Sources Layer (Blue)
- Pi Digit Sources (External)
- 4-Corner Index Mapping File (CHM/HTML)

##### Data Processing Layer (Green)
- Pi Digit Generator/Parser
- 4-Corner Index Extractor
- Mapping Database (JSON)

##### Translation Engine Layer (Yellow)
- Number-to-Index Converter
- Index-to-Character Translator

##### Output Generation Layer (Orange)
- Text Output Generator
- PDF Renderer (TeX)

##### Web Application Layer (Purple)
- Frontend (HTML/CSS/JS)
- Flask Backend
- API Endpoints

B. Connections and Data Flow:

- Raw Pi Digits → Parser → Translation Engine
- 4-Corner Index File → Extractor → Mapping Database
- Translation Results → Output Generator

- User Input → Frontend → Backend
- Backend → Translation Engine → Frontend
- Frontend → User Display

C. Important Elements to Highlight:

##### Technical Details
- File formats
- Key technologies (Python, Flask, TeX)
- Character encoding considerations

##### System Requirements
- Browser compatibility notes
- Font rendering dependencies
- Processing capacity for large numbers

- The unique transformation process from pi digits to Chinese characters
- The scalability of the system for different digit lengths
- The multiple output formats (text, PDF)
- The web interface for user interaction

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Input Layer"
        PiDigits["Pi Digits Storage"]
        FourCI["4-Corner Index Data"]
    end

    subgraph "Processing Layer"
        Translator["Translation Engine"]
        MapExtractor["Mapping Extractor"]
        MappingFile["4CI Mapping File"]
    end

    subgraph "Output Layer"
        TextOut["Text Output Files"]
        PDFOut["PDF Documents"]
        LaTeXSrc["LaTeX Sources"]
    end

    subgraph "Web Application"
        Frontend["Frontend Interface"]
        Backend["FastAPI Backend"]
        StaticFiles["Static Assets"]
    end

    %% Data Flow
    PiDigits --> Translator
    FourCI --> MapExtractor
    MapExtractor --> MappingFile
    MappingFile --> Translator
    Translator --> TextOut
    TextOut --> LaTeXSrc
    LaTeXSrc --> PDFOut

    %% Web App Flow
    Frontend --> Backend
    Backend --> Translator
    StaticFiles --> Frontend

    %% Component Mappings with Click Events
    click PiDigits "https://github.com/yuanhes/4CornerIndex-to-Text/tree/main/pi_calculation/pi50m/"
    click TextOut "https://github.com/yuanhes/4CornerIndex-to-Text/blob/main/PiBook/text_from_pi_1M_digits.txt"
    click PDFOut "https://github.com/yuanhes/4CornerIndex-to-Text/blob/main/PiBook/PiBook_1M.pdf"
    click LaTeXSrc "https://github.com/yuanhes/4CornerIndex-to-Text/blob/main/PiBook/PiBook_1M.tex"
    click Backend "https://github.com/yuanhes/4CornerIndex-to-Text/blob/main/app.py"
    click Frontend "https://github.com/yuanhes/4CornerIndex-to-Text/blob/main/templates/index.html"
    click StaticFiles "https://github.com/yuanhes/4CornerIndex-to-Text/tree/main/static/"
    click Translator "https://github.com/yuanhes/4CornerIndex-to-Text/blob/main/translate_4CI.py"
    click MapExtractor "https://github.com/yuanhes/4CornerIndex-to-Text/blob/main/extract_map.py"
    click MappingFile "https://github.com/yuanhes/4CornerIndex-to-Text/blob/main/results/4CornerIndex_mapping.json"

    %% Styling
    classDef storage fill:#3498db,stroke:#2980b9,color:white
    classDef process fill:#2ecc71,stroke:#27ae60,color:white
    classDef webapp fill:#e67e22,stroke:#d35400,color:white
    classDef output fill:#95a5a6,stroke:#7f8c8d,color:white

    class PiDigits,FourCI,MappingFile storage
    class Translator,MapExtractor process
    class Frontend,Backend,StaticFiles webapp
    class TextOut,PDFOut,LaTeXSrc output

    %% Legend
    subgraph Legend
        Storage["Storage Component"]:::storage
        Process["Processing Component"]:::process
        WebApp["Web Application Component"]:::webapp
        OutputComp["Output Component"]:::output
    end
```
