# r-g-kjsit/fastwrite architecture

> Architecture diagram of the GitHub repository r-g-kjsit/fastwrite, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/r-g-kjsit/fastwrite
- Repository: https://github.com/r-g-kjsit/fastwrite

## Overview

##### Project Type and Purpose
- FastWrite is an open-source Python module/CLI tool for AI-assisted documentation.
- It ingests Python code files (e.g., from ZIP archives), analyzes them (AST-based data-flow), generates documentation via multiple LLM backends, and evaluates doc quality (BLEU/ROUGE).

##### File Structure Analysis
Top-level:
- .github/workflows/publish.yaml – CI/CD for publishing to PyPI
- pyproject.toml, requirements.txt – build and dependency config
- FastWrite/ – package root
– __main__.py – CLI entrypoint
– config.py – environment & API‐key loader
– file_processor.py – zip extraction, file listing, file reading
– doc_generator.py – orchestrates LLM calls per provider
– bleu.py, rouge.py – evaluation modules
– print.py – CLI output helpers (e.g., README generator)

##### Key Components
a. CLI Layer (__main__.py)
- Parses command‐line args (filename, LLM choice, modes)
- Invokes appropriate pipeline in doc_generator or data_flow
b. File Processing Module
- extract_zip, list_python_files, read_file
- Temporary‐dir management
c. Analysis Module
- DataFlow (AST parse → Graphviz code)
d. Documentation Generation Module
- Abstracts over multiple providers: Groq, Gemini, OpenAI, OpenRouter, Ollama
- Uses config loader for API keys & endpoints
- Handles prompt modes (Simplify, Formal, Research, Custom)
e. Evaluation Module
- BLEU scoring (bleu.py & calculate_bleu_*)
- ROUGE scoring (rouge.py)
f. Output/Presentation Module
- README file generator (print.readmegen)
- Console printing, file writes
g. External Services
- HTTP clients (requests, google-genai, openai, groq SDK, etc.)
- Local model host (Ollama)

##### Interactions & Data Flows
- CLI → File Processor → Code Content
- Code Content →
1) DataFlow Module → Graphviz code → Console/file
2) Doc Generator → LLM API calls → Generated docs
- Generated docs + Reference docs → Evaluation Module → BLEU/ROUGE scores
- Print Module → Formats & outputs final artifacts

##### Architectural Patterns & Principles
- Modular: Separate concerns (I/O, parsing, AI integration, evaluation, presentation)
- Adapter Pattern for LLM providers (single interface, multiple backends)
- Pipeline flow: ingestion → analysis → generation → evaluation → output
- Configuration abstraction via config.py and python-dotenv

##### Final Advice
- Be exhaustive: break down doc_generator into individual LLM adapters
- Config.py’s role in decoupling code from secrets
- Where new modules (e.g., new evaluators or LLM backends) would hook in

## Diagram (Mermaid)

```mermaid
flowchart TD
    CLI["CLI Layer"]:::internal
    Config["Configuration Manager"]:::config
    FileProc["File Processing Module"]:::internal
    DataFlow["DataFlow Analyzer"]:::internal
    DocGen["Documentation Generation Module"]:::internal
    EvalBLEU["BLEU Scoring"]:::internal
    EvalROUGE["ROUGE Scoring"]:::internal
    Output["Output/Presentation Module"]:::internal

    subgraph "External Services"
        Groq["Groq"]:::external
        Gemini["Gemini"]:::external
        OpenAI["OpenAI"]:::external
        OpenRouter["OpenRouter"]:::external
        Ollama["Ollama"]:::external
    end

    Publish["CI/CD Publishing Workflow"]:::external
    BuildCfg["Build & Dependency Config"]:::external

    CLI -->|"args"| FileProc
    FileProc -->|"code_content"| DataFlow
    FileProc -->|"code_content"| DocGen
    Config --> DocGen
    DataFlow -->|"graphviz_dot"| Output
    DocGen -->|"doc_text"| EvalBLEU
    DocGen -->|"doc_text"| EvalROUGE
    EvalBLEU -->|"bleu_scores"| Output
    EvalROUGE -->|"rouge_scores"| Output
    DocGen --> Groq
    DocGen --> Gemini
    DocGen --> OpenAI
    DocGen --> OpenRouter
    DocGen --> Ollama

    %% CI/CD and Build Config
    Publish
    BuildCfg

    click CLI "https://github.com/r-g-kjsit/fastwrite/blob/main/FastWrite/__main__.py"
    click Config "https://github.com/r-g-kjsit/fastwrite/blob/main/FastWrite/config.py"
    click FileProc "https://github.com/r-g-kjsit/fastwrite/blob/main/FastWrite/file_processor.py"
    click DataFlow "https://github.com/r-g-kjsit/fastwrite/blob/main/FastWrite/data_flow.py"
    click DocGen "https://github.com/r-g-kjsit/fastwrite/blob/main/FastWrite/doc_generator.py"
    click EvalBLEU "https://github.com/r-g-kjsit/fastwrite/blob/main/FastWrite/bleu.py"
    click EvalROUGE "https://github.com/r-g-kjsit/fastwrite/blob/main/FastWrite/rouge.py"
    click Output "https://github.com/r-g-kjsit/fastwrite/blob/main/FastWrite/print.py"
    click Publish "https://github.com/r-g-kjsit/fastwrite/blob/main/.github/workflows/publish.yaml"
    click BuildCfg "https://github.com/r-g-kjsit/fastwrite/blob/main/pyproject.toml"
    click BuildCfg "https://github.com/r-g-kjsit/fastwrite/blob/main/requirements.txt"

    classDef internal fill:#D0E8FF,stroke:#0275d8,color:#0275d8,stroke-width:1px
    classDef external fill:#DFF0D8,stroke:#5cb85c,color:#5cb85c,stroke-width:1px
    classDef config fill:#FCF8E3,stroke:#F0AD4E,color:#F0AD4E,stroke-width:1px
```
