# aibox22/readmex architecture

> Architecture diagram of the GitHub repository aibox22/readmex, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aibox22/readmex
- Repository: https://github.com/aibox22/readmex

## Overview

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: [`src/readmex/core.py`](https://github.com/aibox22/readmex/blob/main/src/readmex/core.py) (Core), [`tests`](https://github.com/aibox22/readmex/tree/main/tests) (Tests), [`src/readmex/utils/cli.py`](https://github.com/aibox22/readmex/blob/main/src/readmex/utils/cli.py) (CLI), [`src/readmex/website_core.py`](https://github.com/aibox22/readmex/blob/main/src/readmex/website_core.py) (Website Core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_src["Source"]
  node_node_main["Entrypoint<br/>python module<br/>[__main__.py]"]
  node_node_cli["CLI<br/>command layer<br/>[cli.py]"]
  node_node_core["Core<br/>orchestrator<br/>[core.py]"]
  node_node_website_core["Website Core<br/>orchestrator<br/>[website_core.py]"]
  node_node_file_handler["Files<br/>io boundary<br/>[file_handler.py]"]
  node_node_language_analyzer["Languages<br/>classifier"]
  node_node_dependency_analyzer["Dependencies<br/>analyzer"]
  node_node_code_rag["RAG<br/>retrieval layer<br/>[code_rag.py]"]
  node_node_model_client["Model Client<br/>llm adapter<br/>[model_client.py]"]
  node_node_logo_generator["Logo<br/>image generator<br/>[logo_generator.py]"]
  node_node_config["Config<br/>[config.py]"]
  node_node_init["Package<br/>[__init__.py]"]
end

subgraph group_group_config["Config & Assets"]
  node_node_template["README Template<br/>markdown template<br/>[BLANK_README.md]"]
  node_node_dep_config["Dependency Rules<br/>json rules"]
  node_node_ignore_patterns["Ignore Patterns<br/>json rules"]
  node_node_language_mapping["Language Map<br/>json rules"]
  node_node_config_template["Config Template<br/>json template"]
end

subgraph group_group_tests["Tests"]
  node_node_tests["Tests<br/>test suite"]
end

node_node_main -->|"starts"| node_node_cli
node_node_cli -->|"README mode"| node_node_core
node_node_cli -->|"website mode"| node_node_website_core
node_node_cli -->|"loads"| node_node_config
node_node_core -->|"scans"| node_node_file_handler
node_node_core -->|"classifies"| node_node_language_analyzer
node_node_core -->|"extracts"| node_node_dependency_analyzer
node_node_core -->|"retrieves"| node_node_code_rag
node_node_code_rag -->|"prompts"| node_node_model_client
node_node_core -->|"generates text"| node_node_model_client
node_node_core -->|"creates logo"| node_node_logo_generator
node_node_core -->|"fills"| node_node_template
node_node_file_handler -->|"filters by"| node_node_ignore_patterns
node_node_language_analyzer -->|"maps by"| node_node_language_mapping
node_node_dependency_analyzer -->|"rules"| node_node_dep_config
node_node_config -.->|"documents"| node_node_config_template
node_node_website_core -->|"reuses"| node_node_core
node_node_tests -.->|"covers"| node_node_core
node_node_tests -.->|"covers"| node_node_model_client
node_node_tests -.->|"covers"| node_node_logo_generator
node_node_tests -.->|"covers"| node_node_website_core

click node_node_main "https://github.com/aibox22/readmex/blob/main/src/readmex/__main__.py"
click node_node_cli "https://github.com/aibox22/readmex/blob/main/src/readmex/utils/cli.py"
click node_node_core "https://github.com/aibox22/readmex/blob/main/src/readmex/core.py"
click node_node_website_core "https://github.com/aibox22/readmex/blob/main/src/readmex/website_core.py"
click node_node_file_handler "https://github.com/aibox22/readmex/blob/main/src/readmex/utils/file_handler.py"
click node_node_language_analyzer "https://github.com/aibox22/readmex/blob/main/src/readmex/utils/language_analyzer.py"
click node_node_dependency_analyzer "https://github.com/aibox22/readmex/blob/main/src/readmex/utils/dependency_analyzer.py"
click node_node_code_rag "https://github.com/aibox22/readmex/blob/main/src/readmex/code_rag.py"
click node_node_model_client "https://github.com/aibox22/readmex/blob/main/src/readmex/utils/model_client.py"
click node_node_logo_generator "https://github.com/aibox22/readmex/blob/main/src/readmex/utils/logo_generator.py"
click node_node_config "https://github.com/aibox22/readmex/blob/main/src/readmex/config.py"
click node_node_init "https://github.com/aibox22/readmex/blob/main/src/readmex/__init__.py"
click node_node_template "https://github.com/aibox22/readmex/blob/main/src/readmex/templates/BLANK_README.md"
click node_node_dep_config "https://github.com/aibox22/readmex/blob/main/src/readmex/config/dependency_config.json"
click node_node_ignore_patterns "https://github.com/aibox22/readmex/blob/main/src/readmex/config/ignore_patterns.json"
click node_node_language_mapping "https://github.com/aibox22/readmex/blob/main/src/readmex/config/language_mapping.json"
click node_node_config_template "https://github.com/aibox22/readmex/blob/main/config_template.json"
click node_node_tests "https://github.com/aibox22/readmex/tree/main/tests"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_main,node_node_cli,node_node_core,node_node_website_core,node_node_file_handler,node_node_language_analyzer,node_node_dependency_analyzer,node_node_code_rag,node_node_model_client,node_node_logo_generator,node_node_config,node_node_init toneBlue
class node_node_template,node_node_dep_config,node_node_ignore_patterns,node_node_language_mapping,node_node_config_template toneAmber
class node_node_tests toneMint
```

## Components

### Source

Package code for CLI, orchestration, analysis, and generation.

- [Entrypoint](https://github.com/aibox22/readmex/blob/main/src/readmex/__main__.py): python module · Package entrypoint that launches the CLI. · `src/readmex/__main__.py`
- [CLI](https://github.com/aibox22/readmex/blob/main/src/readmex/utils/cli.py): command layer · User-facing argument parsing and command routing. · `src/readmex/utils/cli.py`
- [Core](https://github.com/aibox22/readmex/blob/main/src/readmex/core.py): orchestrator · Main README generation pipeline coordinator. · `src/readmex/core.py`
- [Website Core](https://github.com/aibox22/readmex/blob/main/src/readmex/website_core.py): orchestrator · Alternate orchestration path for website generation. · `src/readmex/website_core.py`
- [Files](https://github.com/aibox22/readmex/blob/main/src/readmex/utils/file_handler.py): io boundary · Repository scanning, filtering, reading, and output writing. · `src/readmex/utils/file_handler.py`
- [Languages](https://github.com/aibox22/readmex/blob/main/src/readmex/utils/language_analyzer.py): classifier · Identifies supported file types and languages. · `src/readmex/utils/language_analyzer.py`
- [Dependencies](https://github.com/aibox22/readmex/blob/main/src/readmex/utils/dependency_analyzer.py): analyzer · Extracts project structure and dependency signals. · `src/readmex/utils/dependency_analyzer.py`
- [RAG](https://github.com/aibox22/readmex/blob/main/src/readmex/code_rag.py): retrieval layer · Retrieval-augmented context assembly over repository content. · `src/readmex/code_rag.py`
- [Model Client](https://github.com/aibox22/readmex/blob/main/src/readmex/utils/model_client.py): llm adapter · Text generation backend for local or remote model calls. · `src/readmex/utils/model_client.py`
- [Logo](https://github.com/aibox22/readmex/blob/main/src/readmex/utils/logo_generator.py): image generator · Creates the project logo via external image service support. · `src/readmex/utils/logo_generator.py`
- [Config](https://github.com/aibox22/readmex/blob/main/src/readmex/config.py): runtime config · Defines and loads runtime settings and precedence. · `src/readmex/config.py`
- [Package](https://github.com/aibox22/readmex/blob/main/src/readmex/__init__.py): python package · Package namespace marker and public surface. · `src/readmex/__init__.py`

### Config & Assets

Runtime configuration and bundled templates/data.

- [README Template](https://github.com/aibox22/readmex/blob/main/src/readmex/templates/BLANK_README.md): markdown template · Base README template used during composition. · `src/readmex/templates/BLANK_README.md`
- [Dependency Rules](https://github.com/aibox22/readmex/blob/main/src/readmex/config/dependency_config.json): json rules · Extraction rules for dependency analysis. · `src/readmex/config/dependency_config.json`
- [Ignore Patterns](https://github.com/aibox22/readmex/blob/main/src/readmex/config/ignore_patterns.json): json rules · Path filtering rules for repository scanning. · `src/readmex/config/ignore_patterns.json`
- [Language Map](https://github.com/aibox22/readmex/blob/main/src/readmex/config/language_mapping.json): json rules · Maps file patterns to supported languages. · `src/readmex/config/language_mapping.json`
- [Config Template](https://github.com/aibox22/readmex/blob/main/config_template.json): json template · Example configuration file for users. · `config_template.json`

### Tests

Architecture coverage for generation, integration, and error handling.

- [Tests](https://github.com/aibox22/readmex/tree/main/tests): test suite · Coverage for core generation, models, images, and error handling. · `tests`

## Connections

- 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.
