How r-g-kjsit/fastwrite works
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