A program database for Elixir codebases.
Fathom compiles a project under a compiler tracer and writes what the compiler resolved into SQLite: definitions, calls, module dependencies, behaviours, protocols, Ecto schemas, Phoenix routes, and the sites where dispatch is dynamic enough that the call graph stops being complete.
Most use goes through the Mix tasks:
mix fathom.install # wire the database into AGENTS.md
mix fathom.build # compile under the tracer and write the database
mix fathom.query # run a read-only queryThis module is for reading the database from Elixir, which is mainly useful for building linters on top of it.
Pieces
Fathom.Tracer— the compiler tracer, and what each event contributesFathom.Dynamic— finds dispatch the tracer structurally cannot seeFathom.Introspect— post-compile reflection, including frameworksFathom.Schema— the database schema, and why it is shaped that wayFathom.Store— the SQLite writerFathom.Guide— the agent-facing documentation generated by the installer
Summary
Functions
The conventional location of the database.
Asserts that a query returns no rows, which is how architecture rules are written.
Runs a read-only query and returns {:ok, columns, rows}.
Runs a query and returns its rows as maps keyed by column name.
Functions
The conventional location of the database.
Asserts that a query returns no rows, which is how architecture rules are written.
Returns :ok, or {:error, rows} with the violations.
Fathom.forbid("""
SELECT caller, file, line FROM calls
WHERE caller_module LIKE 'MyAppWeb.%' AND callee_module LIKE '%.Repo'
""")
Runs a read-only query and returns {:ok, columns, rows}.
The connection is opened read-only, so a statement that tries to write fails at SQLite rather than relying on anything here to inspect the SQL.
iex> Fathom.query("SELECT mfa FROM functions WHERE name = ?", ["create_user"])
Runs a query and returns its rows as maps keyed by column name.
Raises if the query fails.