How calchiwo/etr works
1. This repository is a multi-distribution product centered on a Python analysis engine called explain_this_repo, with a Node.js wrapper/binary distribution and a separate Next.js marketing/docs site under apps/web.
2. The main architectural boundary is between input normalization + repository inspection and LLM-backed explanation generation. The tool accepts GitHub repositories, GitHub file paths, local directories, or single files, then converts those inputs into a normalized repository/file view before generating an explanation.
3. In the Python core, cli.py and __main__.py are the command entrypoints. config.py, init.py, and github.py handle user setup, model/provider selection, and GitHub access concerns such as private repos and API tokens.
4. Repository and file ingestion is split across dedicated readers: repo_reader.py, local_reader.py, and file_reader.py. This suggests a clear separation between remote GitHub analysis, local filesystem analysis, and single-file analysis, with generate.py orchestrating the downstream flow.
5. The analysis pipeline builds a structured prompt from repo signals. stack_detector.py and stack_printer.py infer the technology stack from manifests, configs, entrypoints, and other high-signal files, while prompt.py packages those signals into the model input that drives the explanation.
6. LLM integration is abstracted behind providers/. There is a provider interface plus concrete adapters for Anthropic, Gemini, Groq, Ollama, OpenAI, and OpenRouter, with providers/registry.py handling provider lookup/selection. This makes model choice a pluggable runtime concern rather than something hardcoded into the analysis pipeline.
7. Output is handled separately from generation. writer.py is responsible for formatting and emitting the result to EXPLAIN.md, stdout, or alternate output targets, which keeps the analysis engine independent from presentation and file-writing concerns.
8. The Node.js side in node_version/ mirrors the Python capabilities and serves as the packaging layer for npm users and standalone binaries. The _legacy/ subtree indicates a previous TypeScript implementation retained for compatibility or reference, while cli.ts is the current Node entrypoint.
9. scripts/build_pyinstaller.py and scripts/pyinstaller_entry.py show that the Python application is also packaged into standalone executables. Combined with the release workflows, this repo supports three distribution modes: Python package, npm package/binary, and direct downloadable release assets.
10. apps/web is a separate Next.js application used for the public site. Its component structure (hero, features, downloads, install, terminal-demo, etc.) indicates a marketing/documentation frontend rather than part of the core analysis engine.
11. The GitHub Actions workflows reflect the repo’s release-oriented architecture. ci.yml covers validation, while release-binaries.yml builds and publishes binaries, supporting the cross-runtime distribution strategy described in the README.
12. Overall, the system is organized as: input normalization → repo/file signal extraction → stack detection → prompt construction → LLM provider call → formatted output. The key diagram boundaries are between the analysis core, provider adapters, output/writer layer, and the separate packaging/frontend surfaces.
Main entry points: generate.py Generate · workflows CI / release · web Next.js app · config.py Config
Components 20
Python core
Main analysis engine and CLI.
- CLI · Python command entrypoints for the tool.
explain_this_repo/cli.py - Module run · Python package execution entrypoint.
explain_this_repo/__main__.py - Config · User configuration and model/provider selection.
explain_this_repo/config.py - Init · Initialization and first-run setup flow.
explain_this_repo/init.py - GitHub access · GitHub repo access, auth, and private repo handling.
explain_this_repo/github.py - Readers · Repository, local, and single-file input normalization.
- Generate · Coordinates ingestion, analysis, provider calls, and result assembly.
explain_this_repo/generate.py - Stack detect · Infers technology stack from repo signals.
explain_this_repo/stack_detector.py - Stack print · Formats detected stack information for prompts/output.
explain_this_repo/stack_printer.py - Prompt · Builds structured LLM input from repo signals.
explain_this_repo/prompt.py - Providers · Provider implementations and runtime selection.
explain_this_repo/providers - Writer · Writes results to files or stdout.
explain_this_repo/writer.py
Node distribution
npm/binary packaging layer and legacy implementation.
Web site
Next.js marketing and docs frontend.
- Next.js app · Public marketing and documentation site.
apps/web - Site sections · Hero, features, install, downloads, terminal demo, and related sections.
apps/web/components - App shell · Root app layout and landing page.
apps/web/app
Release infra
Build, packaging, and CI automation.
- PyInstaller build · Builds standalone Python executables.
scripts/build_pyinstaller.py - PyInstaller entry · Entry shim used by the executable build.
scripts/pyinstaller_entry.py - CI / release · Validation and binary release workflows.
.github/workflows
Connections 18
- CLI → Generate: starts · CLI dispatches into the main analysis pipeline.
- Module run → Generate: starts · Module execution enters the same pipeline.
- Generate → Readers: loads input · Normalizes repository, directory, file, or GitHub input.
- Readers → GitHub access: uses · GitHub-based ingestion relies on auth and access helpers.
- Generate → Stack detect: analyzes · Derives stack and framework signals from the ingested tree.
- Stack detect → Stack print: formats · Detected stack information is rendered for prompt use.
- Generate → Prompt: builds · Assembles the model prompt from repo signals and stack data.
- Generate → Providers: calls · Sends the prompt through the selected LLM provider.
- Providers → Writer: returns output · Provider response is handed to the output layer for emission.
- Config → Generate: configures · Controls provider choice and runtime settings.
- Init → Config: boots · Initialization prepares configuration for first use.
- Node CLI → Legacy TS: mirrors · Node package retains the prior implementation as a legacy subtree.
- Next.js app → Site sections: composes · Landing page is assembled from section components.
- Next.js app → App shell: renders · Next.js app shell provides layout and home page.
- PyInstaller build → PyInstaller entry: packages · Executable build uses the dedicated entry shim.
- CI / release → PyInstaller build: builds · Release automation produces standalone binaries.
- CI / release → Node CLI: releases · CI/release workflows support the Node distribution path.
- CI / release → Next.js app: publishes · Repository automation supports the public web site surface.