# aoi20031020/ripogram-generator architecture

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

- Interactive diagram: https://gitdiagram.com/aoi20031020/ripogram-generator
- Repository: https://github.com/aoi20031020/ripogram-generator

## Overview

##### Project type and purpose
- This is a text-generation tool/library with both Japanese (LLM-based) and English (BERT+WordNet) pipelines.
- It provides two “front ends”: Streamlit web apps (Japanese, English, integrated) and CLI interfaces, plus example scripts.
- Core functionality is packaged under `ripogram/` as a reusable library.

##### File structure
- Top-level directories:
- `apps/` – Streamlit UIs
- `ripogram/` – core package (CLI modules, config, core rewriting/tokenization logic)
- `examples/` – demonstration scripts and a Jupyter notebook
- `tests/` – unit tests for both languages
- `docs/` – design/docs/PDF slides
- Key config files: `.env.example`, `requirements.txt`
- No persistent database; external dependencies include OpenAI API (GPT-4), SpaCy, WordNet.

##### README for additional insights
- Japanese pipeline uses an LLM via OpenAI API.
- English pipeline uses SpaCy+pretrained BERT embeddings + WordNet synonym replacement.
- Configurable via `ripogram/config.py` pulling from environment (`.env`).
- Users launch with Streamlit or CLI (`ripogram.cli`, `ripogram.english_cli`).

##### Detailed separation of components
- UI Layer:
- Streamlit Apps
- CLI modules
- Application Orchestrator: entry scripts → config loader
- Core Library Subsystems:
- Tokenization → Rewriting → Utilities
- External Services:
- OpenAI GPT-4
- SpaCy en_core_web_sm
- WordNet database
- Demonstration/Test:
- `examples/`
- `tests/`

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        SJP["Streamlit App (Japanese)"]:::ui
        SPE["Streamlit App (English)"]:::ui
        SPI["Streamlit App (Integrated)"]:::ui
        CLIJ["CLI Wrapper (Japanese)"]:::ui
        CLIE["CLI Wrapper (English)"]:::ui
    end

    %% Application Orchestrator
    subgraph "Application Orchestrator"
        CFG["Config Manager"]:::config
    end

    %% Core Library
    subgraph "Core Library"
        subgraph "Tokenization"
            TJ["Japanese Tokenizer"]:::core
            TE["English Tokenizer"]:::core
        end
        subgraph "Rewriting"
            RJ["Japanese Rewriter"]:::core
            RE["English BERT-based Rewriter"]:::core
        end
        UT["Core Utilities"]:::core
    end

    %% External Services
    subgraph "External Services"
        GPT["OpenAI GPT-4 API"]:::ext
        SPACY["SpaCy en_core_web_sm"]:::ext
        WN["WordNet Database"]:::ext
    end

    %% Supporting Artifacts
    subgraph "Artifacts"
        EX["Examples"]:::periph
        TS["Unit Tests"]:::periph
        ENV[".env.example"]:::periph
        REQ["requirements.txt"]:::periph
        DOC["Documentation & Slides"]:::periph
    end

    %% Connections
    SJP --> CFG
    SPE --> CFG
    SPI --> CFG
    CLIJ --> CFG
    CLIE --> CFG

    CFG --> TJ
    CFG --> TE

    TJ --> RJ
    TE --> RE

    RJ --> GPT
    RE --> SPACY
    RE --> WN

    RJ --> SPI
    RE --> SPI

    %% Click Events
    click SJP "https://github.com/aoi20031020/ripogram-generator/blob/main/apps/streamlit_app.py"
    click SPE "https://github.com/aoi20031020/ripogram-generator/blob/main/apps/english_streamlit_app.py"
    click SPI "https://github.com/aoi20031020/ripogram-generator/blob/main/apps/integrated_streamlit_app.py"
    click CLIJ "https://github.com/aoi20031020/ripogram-generator/blob/main/ripogram/cli.py"
    click CLIE "https://github.com/aoi20031020/ripogram-generator/blob/main/ripogram/english_cli.py"
    click CFG "https://github.com/aoi20031020/ripogram-generator/blob/main/ripogram/config.py"
    click TJ "https://github.com/aoi20031020/ripogram-generator/blob/main/ripogram/core/tokenizer.py"
    click TE "https://github.com/aoi20031020/ripogram-generator/blob/main/ripogram/core/english_tokenizer.py"
    click RJ "https://github.com/aoi20031020/ripogram-generator/blob/main/ripogram/core/rewriter.py"
    click RE "https://github.com/aoi20031020/ripogram-generator/blob/main/ripogram/core/english_bert_rewriter.py"
    click UT "https://github.com/aoi20031020/ripogram-generator/blob/main/ripogram/core/utils.py"
    click EX "https://github.com/aoi20031020/ripogram-generator/tree/main/examples/"
    click TS "https://github.com/aoi20031020/ripogram-generator/tree/main/tests/"
    click ENV "https://github.com/aoi20031020/ripogram-generator/blob/main/.env.example"
    click REQ "https://github.com/aoi20031020/ripogram-generator/blob/main/requirements.txt"
    click DOC "https://github.com/aoi20031020/ripogram-generator/tree/main/docs/"

    %% Styles
    classDef ui fill:#a0d8f1,stroke:#333,stroke-width:1px
    classDef core fill:#a3f7a8,stroke:#333,stroke-width:1px
    classDef ext fill:#f7c26b,stroke:#333,stroke-width:1px
    classDef periph fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef config fill:#cccccc,stroke:#333,stroke-width:1px
```
