DEV Community

Play Button Pause Button
Kevin Gilpin for AppMap

Posted on • Edited on

How to auto-document the end-to-end code and data flows of your Rails app

In case you missed it, I’m recapping my recent RailsConf 2021 talk in a series of four, short blog posts. Check out Part 1 - We need a better way to communicate and explain our code decisions.

This post recaps the first of the demos I gave as part of my talk. Using AppMap, I walked RailsConf attendees through how to automatically generate documentation and visualizations for end-to-end flows -- right in your code editor.

End-to-end flows help us as developers get the right context. They help us figure out how a given web request uses particular database tables, for example, and they help us find important functions performed by code, such as authentication, authorization, and emailing.

AppMap offers both high-level and low-level views of end-to-end code and data flows. AppMap behaves like a Google Map, providing interactive navigation of the code. You can write analysis code on the AppMap data, and dive into source code and debuggers for further details.

For Ruby, first install the AppMap extension VSCode or the AppMap plugin for RubyMine. Then install the AppMap gem into your Ruby app and configure which source files and dependency gems you want to record. Finally, record AppMap files by recording your code - either using app remote recording, or by running test cases. Unlike static analysis, which only looks at your files on disk, AppMap records your code while it’s running -- meaning it knows exactly what happened at every point and how all the code, services and data stores fit together.

You can watch this portion of my RailsConf talk in the video clip above, which includes a live tour of AppMap using the Rails Sample App. If you want to follow along in the code or look it up later, I’ve created a fork of the Rails Sample App sixth edition. Within that fork is a branch called eager loading. Let us know what you think in the AppMap Discord! Your feedback is really important to us.

Coming up next In Parts 3 and 4 of this blog series, I’m going to recap the remaining demos of my RailsConf talk. Using tools that automatically generate documentation and visualizations of architecture and code design, I’ll be documenting web services and data model details.

Top comments (0)