Skip to content

Feature Request: Architecture Discovery (archctl suggest) #10

@qiuethan

Description

@qiuethan

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

  1. 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").
  2. 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.
  3. 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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions