StrucIn analyzes local Python repositories and generates architecture artifacts you can use for technical discovery, refactoring planning, onboarding, and dependency risk review.
- Repository indexing with module mapping and file metadata
- Static AST analysis for imports, classes, functions, docstrings, and complexity
- Dependency graph and cycle detection
- Architecture report (
docs/REPORT.md) - Semantic code/document search (
semantic_index.jsonat repo root) - Architecture narration (
docs/EXPLAIN.md) with caching and redaction - Interactive web dashboard for dependency exploration
- Language: Python repositories
- Input: local filesystem paths
- Output: JSON and Markdown artifacts written to the target repository
src/strucin/core/: analysis, reporting, semantic indexing, explanationssrc/strucin/cli/: command parsing, UX, orchestrationsrc/strucin/web/: dashboard generation and local servingsrc/strucin/core/config.py: configuration loading and defaultssrc/strucin/utils/: shared utility helperstests/: unit and regression test suite with fixtures
python3 -m venv .venv
source .venv/bin/activatepip install --upgrade pip
pip install ruff mypy pytest
pip install -e .strucin --help# Scaffold configuration
strucin init --path /path/to/myrepo
# Analyze a local Python repo
strucin scan /path/to/myrepo
strucin analyze /path/to/myrepo
strucin report /path/to/myrepo # writes docs/REPORT.md
strucin explain /path/to/myrepo # writes docs/EXPLAIN.md (template, no key needed)
# Enable LLM-powered narration
export ANTHROPIC_API_KEY="sk-ant-..."
strucin explain /path/to/myrepo # writes docs/EXPLAIN.md
# Semantic search
strucin search "authentication middleware" --path /path/to/myrepo
# Compare two analysis snapshots
strucin diff before.json after.json
# Machine-readable output
strucin analyze /path/to/myrepo --json
# Launch web dashboard
strucin web /path/to/myrepo| Extra | Installs | Enables |
|---|---|---|
pip install strucin[llm] |
anthropic, openai | LLM-powered narration |
pip install strucin[embeddings] |
sentence-transformers | Neural semantic search |
pip install strucin[ai] |
all of the above | Full AI feature set |
pip install strucin[dev] |
pytest, ruff, mypy, coverage | Development tooling |
Scaffolds a .strucin.toml configuration file with commented defaults.
strucin init --path /path/to/repo
strucin init --path /path/to/repo --force # overwrite existingRecursively discovers Python files and writes repository index metadata.
python -m strucin.cli scan /path/to/repoPrimary output:
repo_index.json
Runs AST analysis, builds dependency graph, computes metrics, and detects cycles.
python -m strucin.cli analyze /path/to/repoPrimary outputs:
analysis.jsondependency_graph.json
Generates Markdown architecture report from analysis results.
python -m strucin.cli report /path/to/repoPrimary output:
docs/REPORT.md
Builds or loads semantic index and returns top semantic matches.
python -m strucin.cli search "retry failed payment" --path /path/to/repo --top-k 5Primary output:
semantic_index.json
Generates architecture narration with cache support and metadata output.
python -m strucin.cli explain --path /path/to/repo
python -m strucin.cli explain --path /path/to/repo --refreshPrimary outputs:
docs/EXPLAIN.mdexplain.json.strucin_cache/explain_cache.json
Compares two analysis snapshots and shows what changed: new/resolved cycles, complexity delta, coupling shifts, and LOC changes.
strucin diff before.json after.json
strucin diff before.json after.json --jsonGenerates interactive web dashboard assets and optionally serves locally.
python -m strucin.cli web --path /path/to/repo --out /path/to/repo/.strucin_web
python -m strucin.cli web --path /path/to/repo --serve --host 127.0.0.1 --port 8765Primary outputs:
.strucin_web/index.html.strucin_web/app.js.strucin_web/styles.css.strucin_web/data.json
StrucIn reads .strucin.toml from the target repository root.
[scan]
exclude_dirs = [".git", "__pycache__", "node_modules", "venv", ".venv"]
[search]
top_k = 5
dimensions = 256
[performance]
max_workers = 8
[output]
repo_index = "repo_index.json"
analysis = "analysis.json"
dependency_graph = "dependency_graph.json"
report = "docs/REPORT.md"
semantic_index = "semantic_index.json"
explain_markdown = "docs/EXPLAIN.md"
explain_metadata = "explain.json"Notes:
max_workerscontrols parallel scanning/analysis/semantic indexing- JSON artifacts are written to the target repo root; Markdown reports go to
docs/
| Artifact | Location | Description |
|---|---|---|
repo_index.json |
repo root | File/module map with LOC and size |
analysis.json |
repo root | Static analysis details and dependency graph |
dependency_graph.json |
repo root | Graph nodes/edges for integrations |
semantic_index.json |
repo root | Chunk embeddings and metadata |
explain.json |
repo root | Narration metadata (timestamp/cache key) |
REPORT.md |
docs/ |
Architecture summary and hotspots |
EXPLAIN.md |
docs/ |
Architecture narrative and onboarding guide |
.strucin_web/* |
repo root | Static dashboard files |
Run StrucIn in CI and post architecture reports as PR comments:
- uses: macitch/StrucIn@main
with:
command: report
post-comment: true
fail-on-cycles: falseSee .github/workflows/example-usage.yml for a full example with strict mode
and workflow dispatch support.
Add StrucIn checks to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/macitch/StrucIn
rev: main
hooks:
- id: strucin-cycles # fail on dependency cycles
- id: strucin-complexity # fail on high complexity
args: ['--threshold', '15']Run project checks:
ruff check .
mypy src/strucin
pytest -qGenerate and serve:
python -m strucin.cli web --path . --serve --host 127.0.0.1 --port 8765Open:
http://127.0.0.1:8765/index.html
The examples/ directory contains sample output artifacts generated by running
StrucIn on its own codebase, so you can see what you get before installing.
See SECURITY.md for the security policy, how StrucIn handles your code, and how to report vulnerabilities.