How BizMap works¶
Detector-by-detector detail. Graph format: graph-schema.md. YAML rules: detector-rules.md.
Pipeline¶
- Schema replayer — applies
schema.sql/ migration folders in order (CREATE TABLE IF NOT EXISTS, quoted/schema-qualified pg_dump identifiers,ALTER TABLE ... ADD COLUMN IF NOT EXISTS, drop/add constraints,DO $$blocks) and extractsCREATE TRIGGERplus the tables/columns their plpgsql functions write. Function bodies are re-scanned after the full replay so pg_dumpCREATE FUNCTIONbeforeCREATE TABLEstill records those tables.EXECUTE format('UPDATE %I ...')is dynamictable:unknown. Comments, string literals, DECLARE'd variables, INTO targets, and PL/pgSQL keywords are never table nodes.CREATE VIEW/CREATE MATERIALIZED VIEWbecomeviewnodes withderives_fromedges. AlsoCREATE POLICY,ENABLE ROW LEVEL SECURITY,DROP TABLE(dropped: truewhen still referenced), and Alembicupgrade()chains (schema role, not runtime writers) includingop.executeof views. - Go detector — Echo v4 routes (
group.POST(path, handler)with group prefixes, cross-package consts (includingconst X = shared.Xaliases), factory handlers, and wrappers such aswrap(h.Version)). Method names must be exactlyGET/POST/…/Any/Matchwith a string-like path. SQL is taken from the argument that looks like SQL, so pgxtx.Exec(ctx, sql),database/sqldb.Exec(sql, args…),Query/QueryRow,ExecContext/QueryContext/QueryRowContext, and sqlxGet/Select/NamedExecall match without duplicates. Helpers that take aquery/qstring attribute tables to the caller. Outboundnet/httpNewRequest/NewRequestWithContext,client.Do, andhttp.Get/Post(const, env,fmt.Sprintf, concat,url.PathEscape) becomecalls_http. Dynamic segments ("/items/" + url.PathEscape(id) + "/approve") match/items/:id/approveroutes. Helpers that takepath/methodfrom the caller (getJSON(ctx, path, out)concatenatingc.baseURL + path) compose at the call site. A structbaseURLfield is{base}+path, not a relative fetch. Anygostatement whose target usestime.NewTicker/time.Tick/time.Afterloops or a cron library. Packages are keyed by import path; display names are the directory relative to the scan root. With nogo.mod, import paths fall back to a unique scanned-directory suffix and print a warning. - Python detector — FastAPI/Flask routes (module/imported consts,
+, f-strings,APIRouter/include_routerprefixes, factory helpers such asapp = create_service()including nested helpers (create_service() -> new_app(**kw) -> FastAPI(**kw)) and apps imported from another module). Unresolvable path pieces stay{name}placeholders (unresolved, never truncated). SQLAlchemy Core/ORM usage andtext()/execute()SQL, plus SQL strings held in module dicts (QUERIES["a"]) and callables injected as arguments,deps.run_query/self.run_query, dataclass/NamedTupleCallablefields constructed with kwargs in another module and passed intocreate_app(deps)(closure,app.state, or a typed parameter), and module-level instances (svc = Svc(run_query); svc.go()). Unresolvable typed dispatch isunresolved_calls. HTTP routes require a known FastAPI/Flask app, APIRouter, or Blueprint, or a module-level@name.get("/path")(so@patch("x.x.logger")is not a route). Constructor/annotation dispatch (Drainer(outbox)→self.outbox.settle,store: Store→store.save). Firebase Functions + Firestore collections, including document refs (ref.setaftercollection().document(), including an assignedrefvariable), transactions, and batches. Non-DB calls inside a Firestore write dict (datetime.now()) are nottable:unknown. Celery / RQ / Cloud Tasks / Pub/Sub (enqueue linked to the consumer by URL suffix, a one-hop URL helper, orqueues:) andwhile Trueworkers.supabase.rpc("fn")links to SQL functions. Client URLs keep the env/host origin (os.environ["X_URL"]), not a local variable name.payload.get/ Mapping.getare not HTTP; onlyrequests/httpx/aiohttp/urllibclients and sessions. A constructor/configbase_urlis{base}+path, not a relative fetch. Outbound helpers such as_post(path)that concatenateself.base_url + path(or an httpx/requests session onself) compose at the caller; uncomposed calls keepunresolved_http. SQL dicts reached through a module alias (queries.Q['k'],import pkg.queries as q) and import-timededent/striptransforms resolve;rpc("list")wrappers that dorun_query(Q[name])attribute those tables to the route. SQL dicts derived in another module (Q = {k: _transform(v) for k, v in queries.RAW.items()}) evaluate identity,dedent/strip,.replace/.formatwith constant args (and apply schema renames); unknown transforms keep the raw SQL tables with confidenceinferredand a note.x.request('POST', path)/x.post(path)on a transport whose class is not scanned emitunresolved_http(never silent). - JavaScript / TypeScript detector — Express / Fastify / Hono routes
on a known app/router, including chained factories
(
new Hono().use('*', mw).get('/a', h)), including chained-export routers mounted across files (export const r = new Hono().use(mw).get('/a', h)thenapp.route('/v1/p', r)/ nested.route('/api', b)),.basePath('/v1'), and.route('/x', sub)/app.use('/v1/items', importedRouter)with the mount prefix applied across files. Known HTTP clients (fetch,axios+ instances,ky,ofetch,got,superagent) emit outboundcalls_http;Map/Set/Headers/URLSearchParams/searchParams/config.headersdo not.axios.create({baseURL})/ky/ofetchinstances (exported, factory-built, or passed as a parameter into an object-literal factorymakeApi = (client) => ({ list: () => client.get('/x') })) andrequest(path)wrappers compose the outbound URL; an instance passed into an object-literal factory or a class constructor (new OrdersApi(api)/this.client.get) keeps the caller'sbaseURL(includingimport.meta.env); if a parameter client cannot be composed it isunresolved_http, never dropped. Instances returned by a factory (export function createClient() { return axios.create({baseURL}) },const makeHttp = () => { const inst = axios.create({...}); inst.interceptors.request.use(...); return inst }thenexport const api = createClient()) compose the same way forapi.get('/orders'),api.get<Order[]>('/orders'), and(await api.get(...)).data— never:client/:http. Local wrappersconst get = <T>(url) => api.get<T>(BASE + url)andrequest(method, url, body)that callapi.request({ method, url: \${BASE}${url}` })emit the **call-site** path (get('/orders/' + id)→/orders/:id), notbase:url.tsconfig.json/jsconfig.jsoncompilerOptions.paths(plusbaseUrlandextends) resolve@/→src/; without a config@/still maps tosrc/. A factorycreateApi(baseUrl)used ascreateApi(API_URL)substitutes the call-site argument (import.meta.env.X→). Parameters typedAxiosInstance,Pick/Partialof it,typeof instance, orKyInstanceinherit that instance's base. Chained Hono routes (any length) and statement-style sub-apps (const s = new Hono(); s.get('/x'); app.route('/', s)inside a chained export) keep the composed mount prefix.serve({ fetch: app.fetch })is not aPOST /entrypoint. Relativefetch('/projects')matches only the same repo; a constructor or config base is+pathand may match across repos when the path has 2+ literal segments orservices:maps it. Inline handlers attributesupabase.from('t')to the route..ts/.tsxuse tree-sitter-typescript.pg/postgresquery()SQL and Supabase Edge Functions (serve/Deno.serveinsupabase/functions//index.ts → HTTP/functions/v1/`, with call edges into imported helpers). - Call graph — handler → service → repository using typed locals,
constructors, import aliases, injected func fields
(
Service{ring: notify.Send}), object/interface dispatch (s.Bell.Changed(e),self.outbox.settle(...)→ structural implementers / constructor-assigned types,inferred, withcandidateswhen several). Unscanned/unknown receivers stay unresolved. Reads/writes propagate to HTTP and job entrypoints as table-levelinferrededges;table:unknownstays attached to the function that does the dynamic write and is exposed on entrypoints only asdynamic_table/dynamic_table_unknown(flag/count), never as a reach edge. HTTP clients emitcalls_httpwhen the URL matches a scanned route (same repo, or viaservices:base URLs, env var names, or hostnames). Unmatched client calls printN unresolved HTTP callswith the env/host keys seen and per-reason counts (target_not_scanned,base_unknown,path_dynamic,client_unknown). Eachunresolved_httpentry has areason. Queue produce sites emitenqueuesandtriggersthe matched consumer. - SQL — named columns stay column-level;
SELECT *and column-less INSERT are table-level. FROM-less SELECT (now(),set_config) touches no table. CTE/subquery/LATERAL aliases (l,r,l.x) are never tables. Dynamic table names ("UPDATE "+t+" SET") staytable:unknownon the origin function. Concat/helper holes ({helper(o)}) are not columns. Relations named in FROM/JOIN/INSERT/UPDATE that are not in DDL becomeunresolved_relationnodes (not dropped).pg_catalog.*,information_schema.*,pg_*,storage.*,vault.*, andauth.*are markedexternal. - Registry —
bizmap scan a borbizmap registry merge a.json b.jsonqualifies function/entrypoint/queue ids by repo and re-matches HTTP/queue links from storedhttp_calls. Tables and collections share ids whendatabase:is the same, sowhy orders.statuson the merged graph lists writers and readers from every service. Multi-path scans with a shared--configkeep each repo's own name. Unmatched client calls persist asunresolved_httpin the graph (stderr counts match). - Overrides —
bizmap.yaml(--config, scan root, or git toplevel) fills inwhy, extra edges,excludeglobs,expand_star, plusname,database,services,queues,repos, andconstants(unscanned package const aliases such asPathPrefix: /api/v1orpkg.Name).--exclude GLOBmerges with YAML.--profiletimes each scan phase.
Firebase Functions, callables and Go helpers (0.14)¶
- Firebase Functions (JS/TS) become entrypoints keyed by their deployed
name (
orders-markPaid), followed from the functions entry file throughexports.g = require()/export … from.httpsCallable(fns, 'orders-markPaid')in a web or mobile client links to that function, sowho-writesandtracereach from the client's function to the data the callable writes. - Firestore built doc paths —
`${ORDERS}/${id}`,'notes/' + id, batch / transaction refs and a directdb.doc(path).set()— resolve to their collection; a trigger fires only for its event. - Go helper routes:
e.POST(Prefix+job.Name(), …)inside a helper is expanded per call site, one route per concrete job, and the template route is dropped. - Nested repos and worktrees (a directory with its own
.gitdir or file inside a scanned repo) are not walked, so a stale worktree does not duplicate the graph; they are reported asskipped: nested_repos.
Performance¶
v0.2 keeps the per-function type cache, skips vendor/node_modules during
file discovery, caches go.mod lookup, and walks named AST nodes iteratively.
--profile reports parse / resolve / sql / propagate. Synthetic fixtures
finish in tens of milliseconds; scans of ~150 Go files stay well under 10s.
Fallbacks when a layer cannot be traced¶
- Route literals (JS/TS) — an API-looking string in a function
(
`/orders/${id}`) links to the single backend route it matches (calls_http,inferred,via: route_literal). Rules and exclusions: graph-schema.md. - SQL by reference (Python) — a function that names a SQL constant or SQL
dict entry reads/writes those tables even when an injected executor runs it
(
inferred,via: sql_reference/sql_key). See graph-schema.md.