Laravel Brain is a package that scans your Laravel application and renders an interactive graph of how requests flow through it. Install it, run the scan, and you'll get a visual map of your routes, controllers, services, repositories, models, jobs, events, Artisan commands, scheduled tasks, and broadcast channels—all in one place.

Main features:
- Interactive lifecycle graph — Visualizes every route through controllers, services, models, jobs, and events as an interactive node graph with multiple layouts and dark/light themes.
- AI context export — One-click (or brain:export-context) copies a structured Markdown snapshot of any node's call chain, DB ops, and source snippets for pasting into any LLM.
- AI rules file generation — Generates context/rules files for seven AI coding assistants (Claude Code, Cursor, Windsurf, Copilot, Junie, Aider, AGENTS.md) from your real architecture data.
- Route stress testing — Run concurrent HTTP load tests against any route node with configurable concurrency, headers, and body; see timing percentiles while the graph animates live.
- Watch mode + fat-class detection — Auto-rescans on PHP file changes and flags controllers or services exceeding 300 lines or 10 methods as complexity hotspots.
The graph is served directly through your Laravel app at /_laravel-brain, so there's nothing extra to set up or deploy separately.
Interactive Graph
Each route, controller action, service, model, job, and event appears as a colored node with arrows showing how data moves between them. You can click any node to inspect its details, view the source code inline, or pull up a flowchart of the method's internal logic.
Routes are organized into their own tabs so you can focus on a single endpoint without wading through the whole application at once. You can export graphs as PNG or Mermaid diagrams and choose from several layouts—hierarchical dagre, force-directed, breadth-first, circle, or grid. Dark and light themes are included, and the viewer will flag "fat classes" (controllers or services with more than 300 lines or 10 methods) as a quick sanity check on code health.
AI Context Export
One handy feature is the ability to copy a context snapshot for any node directly to your clipboard. The exported Markdown includes the route, call chain up to three levels deep, complexity hotspots, database operations per node, source snippets, and your full composer.json and package.json dependency lists—formatted to paste straight into an AI coding tool.
You can also generate it from the terminal:
# Full project summaryphp artisan brain:export-context # Focused on a specific routephp artisan brain:export-context --route="GET /users" --budget=4000
The same data is available via the API at GET /_laravel-brain/api/context.
AI Rules Generation
The package can also generate context files for seven AI coding assistants from your scan data:
php artisan brain:generate-rules --target=claude --target=cursor
Each supported tool gets its own rules file, populated with your project's actual architecture, routes, packages, and code health data rather than generic boilerplate.
You can find full installation instructions and the source code on GitHub.