C4-Auto is a command-line tool that automates documentation for TypeScript projects. It parses CLI options, traverses the repository, and uses LLM prompts to produce and refresh module headers and Mermaid C4 diagrams. It interacts with the local filesystem, a prompt repository, and a hosted LLM provider (OpenAI). Developers run it locally or from CI to keep docs current.
C4Context
title C4-Auto Documentation Generator - Context Diagram
Person(dev, "Developer", "Runs CLI to generate docs for a codebase.")
Person(ci, "CI/CD Pipeline", "Automates documentation generation in builds.")
System_Boundary(c4auto, "C4-Auto") {
System(docgen, "Documentation Generator CLI", "Traverses code, generates module headers and C4 diagrams.")
}
System_Ext(openai, "OpenAI Chat API", "LLM for summaries and Mermaid C4 content (HTTPS/JSON).")
System_Ext(prompts, "Prompt Repository (Prompts.json)", "Local prompt templates loaded at runtime.")
System_Ext(fs, "Project Filesystem", "Source files and generated README outputs.")
System_Ext(git, "Git Hosting", "Remote VCS used to store updated documentation.")
Rel(dev, docgen, "Runs via CLI, provides options")
Rel(ci, docgen, "Invokes to refresh docs", "Headless job")
Rel(docgen, prompts, "Loads prompt templates", "File read")
Rel(docgen, fs, "Reads .ts/.tsx; writes READMEs", "fs/promises")
Rel(docgen, openai, "Expands prompts and requests content", "HTTPS/JSON")
Rel(docgen, git, "Commits/pushes updated docs", "git")
Key components and external interactions:
- LLM integration: The Documentation Generator expands prompt templates and calls the OpenAI Chat API to synthesize module headers and Mermaid C4 diagrams.
- Prompt sourcing: Prompts.json is read locally, decoupling prompt content from code.
- Filesystem I/O: Uses Node fs/promises to read TypeScript sources and write generated README.StrongAI.*.md files; staleness windows prevent unnecessary rewrites.
- Orchestration: Directory traversal and visitor execution determine which files and directories are processed, honoring glob filters.