u/creatorpiyush

▲ 3 r/FlutterFlow+1 crossposts

Made a CLI that fails CI when someone imports data/ from presentation/, looking for feedback

Hi all, I'm the author of arch_guard, an open-source (MIT) CLI + analyzer plugin for Dart/Flutter.

The problem: we agree on Clean Architecture / Bloc / feature-first at the start, and a few months later widgets import repository implementations directly and features import each other. The analyzer and tests don't catch it.

What arch_guard does:

  • Layer rules with presets for clean_architecture, riverpod, bloc and feature_first. dart run arch_guard init detects which fits your folders and writes the config.
  • Forbidden packages per layer, e.g. domain may not import flutter or dart:io.
  • Circular dependency detection (Tarjan's SCC) that names the one import to remove to break each cycle, plus --explain <file>.
  • IDE warnings with quick fixes via the arch_guard_lint analyzer plugin: the bad import gets underlined as you type, with "Remove this import" / "Allow layer X to import Y".
  • Baselines: record existing problems once, and CI fails only on new ones. --since origin/main limits a PR's report to files it changed. This is what makes it usable on an app that's been around for years.
  • expectArchitecture() to run the same checks in flutter test.
  • GitHub Action that comments on PRs, SARIF for Code Scanning, pre-commit hook.
  • Interactive HTML dependency graph (offline), Mermaid, DOT, JSON.
  • Works with Dart workspaces / Melos monorepos, with rules for which packages may depend on which.
dart pub add --dev arch_guard
dart run arch_guard init
dart run arch_guard

[screenshot / GIF]

Docs: https://creatorpiyush.github.io/arch_guard/ pub.dev: https://pub.dev/packages/arch_guard GitHub: https://github.com/creatorpiyush/arch_guard

Two questions for you:

  1. What folder structure does your team use? I'd like to know which presets are missing.
  2. For those who try the IDE plugin: which quick fix would you want next?
reddit.com
u/creatorpiyush — 4 days ago