Summary
Setting up archctl on an existing ("brownfield") project can be daunting. Users often don't know where to start defining their layers and contexts. This feature proposes a new command, archctl suggest, that analyzes the codebase and generates a "best guess" configuration.
Problem
New users trying archctl init on a large legacy codebase currently have to manually map every folder to a layer or context. This high friction prevents adoption.
Proposed Solution
Implement archctl suggest (or archctl discover) that uses graph theory to infer architectural patterns.
Key Capabilities
- Cluster Detection: Use community detection algorithms (e.g., Louvain or Leiden) on the dependency graph to identify natural clusters of files. These clusters likely correspond to Contexts (e.g., "Billing", "Auth").
- Layer Inference: Analyze dependency direction.
- Files with 0 imports are likely Domain/Utils.
- Files with many outgoing dependencies to external libraries are likely Infrastructure.
- Files imported by everything are likely Shared/Core.
- Config Generation: Output a draft
archctl.config.json that reflects the current reality, which the user can then tighten to enforce improvements.
Benefits
- Drastically reduces setup time.
- Provides immediate value ("Here is what your architecture actually looks like right now").
- Helps identify "God classes" or "Big balls of mud" instantly.
Summary
Setting up
archctlon an existing ("brownfield") project can be daunting. Users often don't know where to start defining their layers and contexts. This feature proposes a new command,archctl suggest, that analyzes the codebase and generates a "best guess" configuration.Problem
New users trying
archctl initon a large legacy codebase currently have to manually map every folder to a layer or context. This high friction prevents adoption.Proposed Solution
Implement
archctl suggest(orarchctl discover) that uses graph theory to infer architectural patterns.Key Capabilities
archctl.config.jsonthat reflects the current reality, which the user can then tighten to enforce improvements.Benefits