codemap icon indicating copy to clipboard operation
codemap copied to clipboard

Data-model view: surface schemas/contracts and per-store readers/writers

Open JordanCoin opened this issue 1 month ago • 0 comments

What happened

Running a data-architecture review on a mid-size TypeScript backend, I reached for codemap . first and it did not help with the question I actually had. Two gaps:

  1. Structure output was asset-first. The first ~80 lines of codemap . were the tool's own .codemap/ and .docmap/ cache dirs, a docs folder, and a few MB of CSV/JSON fixtures. The src/ tree never made it into the window I read. Codemap's own cache dirs should be excluded by default, and the structure view should probably lead with the largest code tree rather than walking alphabetically through dotfiles.

  2. No "data model" view. The review needed three things codemap does not surface today, so I fell back to git grep:

    • Where are the schema/contract definitions? (zod schemas, OpenAPI yaml, database rules files, JSON schema dumps.) These are the most important files for understanding a codebase's shape and they are invisible in the tree unless you already know the directory name.
    • For a given named store (a Firestore collection, a table, a queue name, a KV prefix), which files write it and which read it? The string literal is the join key; codemap already parses imports, so parsing collection('x') / from('x') / table('x') style call sites is the same kind of work.
    • Which files write to the same store from more than one layer (server + client repos)? That is the "no single owner" smell and it is exactly what --importers does for modules, just keyed on a store name instead of a file path.

Proposal

  • Default-exclude .codemap/, .docmap/ and other tool caches from the tree.
  • codemap --contracts: list files that define schemas (zod/yup/io-ts/JSON Schema/OpenAPI/GraphQL SDL/Prisma/SQL DDL/Firestore+RLS rules), grouped by kind, with line counts.
  • codemap --stores: inventory of named stores found via well-known call-site patterns, with writer files and reader files per store (writer = call site that also sees set|update|add|insert|put), flagged when writers span more than one package or language.
  • codemap --store <name>: the --importers-style blast-radius view for one store.

Even a heuristic, regex-driven first cut would have replaced about six manual grep rounds in this session. Happy to share the patterns I ended up using if useful.

JordanCoin avatar Oct 06 '26 22:10 JordanCoin