How aibox22/readmex works
1. Repository purpose
- readmex is a Python CLI package that analyzes a target repository and generates documentation artifacts: a README.md, supporting analysis files, a project logo image, and optionally an interactive documentation website.
2. Primary execution path
- The entrypoint is src/readmex/__main__.py, which routes into the package CLI.
- The user-facing command layer lives in src/readmex/utils/cli.py.
- From there, control flows into the core generation pipeline in src/readmex/core.py, with an alternate website-oriented path in src/readmex/website_core.py.
3. Core orchestration layer
- core.py appears to be the main coordinator: it likely drives repository scanning, language/dependency analysis, LLM prompting, artifact generation, and file writes.
- This is the boundary where the tool turns “a folder of source code” into documentation outputs.
4. Repository inspection and file handling
- src/readmex/utils/file_handler.py is the I/O boundary for walking the target project, reading files, filtering ignored paths, and writing generated outputs.
- The config resources ignore_patterns.json and language_mapping.json suggest this layer normalizes repository contents into a language-aware, filterable representation before analysis.
5. Language and dependency understanding
- src/readmex/utils/language_analyzer.py identifies file types and supported languages.
- src/readmex/utils/dependency_analyzer.py extracts project structure and dependencies, likely feeding both the README narrative and the generated project_structure.txt / requirements.txt artifacts mentioned in the README.
6. LLM/RAG subsystem
- src/readmex/code_rag.py and src/readmex/utils/model_client.py form the AI-generation backend.
- The README mentions both local and remote embedding support, so this subsystem likely supports retrieval-augmented prompting over repository content plus one or more model clients for text generation.
7. Configuration boundary
- src/readmex/config.py and config_template.json define the runtime configuration model.
- The README shows precedence between environment variables and a global config file, so configuration is a first-class boundary controlling API keys, model names, endpoints, concurrency, and user metadata.
8. Logo and image generation
- src/readmex/utils/logo_generator.py handles text-to-image/logo creation.
- The README’s logo.png output and the T2I_API_KEY / T2I_BASE_URL settings indicate this is a separate external service path from the text LLM pipeline.
9. Website generation mode
- website_core.py is a separate orchestration path for generating an MkDocs-style site rather than only a README.
- The CLI flags --website, --serve, and --deploy imply this mode builds documentation pages and can optionally serve locally or publish.
10. Templates and generated content
- src/readmex/templates/BLANK_README.md is the base template/input used when composing the final README.
- The pipeline likely combines template structure, analysis summaries, and model-generated prose into the final markdown output.
11. Project-level configuration assets
- src/readmex/config/dependency_config.json probably defines dependency extraction rules.
- source.env and .github/workflows/publish.yml indicate packaged distribution/release automation, while requirements.txt and pyproject.toml define the Python runtime and packaging dependencies.
12. Observability and UX
- The project depends on Rich for terminal presentation, so the CLI likely provides formatted progress, prompts, and status output.
- Debug and silent modes in the CLI suggest the pipeline has interactive and non-interactive execution branches.
13. Testing scope
- The tests/ directory covers core generation, threading, error handling, LLM/embedding behavior, Azure OpenAI compatibility, image generation, and logo generation.
- This indicates the architecture is intentionally modular around analysis, model integration, concurrency, and artifact creation.
14. High-level data flow
- Input: a local repository path.
- Processing: scan files → classify languages → extract structure/dependencies → optionally retrieve relevant context → call LLM and image services.
- Output: documentation files and, in website mode, a generated docs site; deployment can optionally publish that site via GitHub Pages.
Main entry points: core.py Core · tests Tests · cli.py CLI · website_core.py Website Core
Components 18
Source
Package code for CLI, orchestration, analysis, and generation.
- Entrypoint · Package entrypoint that launches the CLI.
src/readmex/__main__.py - CLI · User-facing argument parsing and command routing.
src/readmex/utils/cli.py - Core · Main README generation pipeline coordinator.
src/readmex/core.py - Website Core · Alternate orchestration path for website generation.
src/readmex/website_core.py - Files · Repository scanning, filtering, reading, and output writing.
src/readmex/utils/file_handler.py - Languages · Identifies supported file types and languages.
src/readmex/utils/language_analyzer.py - Dependencies · Extracts project structure and dependency signals.
src/readmex/utils/dependency_analyzer.py - RAG · Retrieval-augmented context assembly over repository content.
src/readmex/code_rag.py - Model Client · Text generation backend for local or remote model calls.
src/readmex/utils/model_client.py - Logo · Creates the project logo via external image service support.
src/readmex/utils/logo_generator.py - Config · Defines and loads runtime settings and precedence.
src/readmex/config.py - Package · Package namespace marker and public surface.
src/readmex/__init__.py
Config & Assets
Runtime configuration and bundled templates/data.
- README Template · Base README template used during composition.
src/readmex/templates/BLANK_README.md - Dependency Rules · Extraction rules for dependency analysis.
src/readmex/config/dependency_config.json - Ignore Patterns · Path filtering rules for repository scanning.
src/readmex/config/ignore_patterns.json - Language Map · Maps file patterns to supported languages.
src/readmex/config/language_mapping.json - Config Template · Example configuration file for users.
config_template.json
Tests
Architecture coverage for generation, integration, and error handling.
- Tests · Coverage for core generation, models, images, and error handling.
tests
Connections 21
- Entrypoint → CLI: starts · Entrypoint hands control to the CLI layer.
- CLI → Core: README mode · CLI routes the main documentation flow into core orchestration.
- CLI → Website Core: website mode · CLI can switch into website-oriented generation.
- CLI → Config: loads · CLI and orchestration use runtime configuration.
- Core → Files: scans · Core relies on file walking, filtering, reading, and writing.
- Core → Languages: classifies · Core uses language detection to understand repository contents.
- Core → Dependencies: extracts · Core derives structural and dependency signals.
- Core → RAG: retrieves · Core may gather relevant context for prompting.
- RAG → Model Client: prompts · RAG hands context to the model adapter for generation.
- Core → Model Client: generates text · Core uses model output for README and analysis prose.
- Core → Logo: creates logo · Core can trigger image generation for project branding.
- Core → README Template: fills · Core composes output from the base README template.
- Files → Ignore Patterns: filters by · File handling applies ignore rules while walking the target repo.
- Languages → Language Map: maps by · Language detection is guided by bundled mappings.
- Dependencies → Dependency Rules: rules · Dependency extraction is driven by bundled configuration.
- Config → Config Template: documents · Template shows the user-facing configuration schema.
- Website Core → Core: reuses · Website generation builds on the main orchestration layer.
- Tests → Core: covers · Tests validate the main generation pipeline.
- Tests → Model Client: covers · Tests exercise LLM and embedding behavior.
- Tests → Logo: covers · Tests verify image/logo generation paths.
- Tests → Website Core: covers · Tests include website-generation flows.