Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Catalog System

The catalog is an in-memory SQLite database that indexes Mendix project metadata for fast querying, full-text search, and cross-reference navigation.

Purpose

Reading a Mendix project requires parsing BSON documents from the MPR file. The catalog pre-processes this data into relational tables, enabling:

  • SQL queries against project metadata (SELECT ... FROM CATALOG.ENTITIES)
  • Full-text search across all strings and source (SEARCH 'keyword')
  • Cross-reference tracking (callers, callees, references, impact analysis)
  • Lint rule evaluation (Starlark rules query catalog tables)

Building the Catalog

The catalog is populated by the REFRESH CATALOG command:

-- Quick refresh: basic tables (modules, entities, microflows, pages, etc.)
REFRESH CATALOG;

-- Full refresh: adds cross-references, widgets, and source tables
REFRESH CATALOG FULL;

The full refresh is required for:

  • SHOW CALLERS / SHOW CALLEES / SHOW REFERENCES / SHOW IMPACT
  • SHOW WIDGETS / UPDATE WIDGETS
  • SELECT ... FROM CATALOG.REFS
  • SELECT ... FROM CATALOG.SOURCE

Querying the Catalog

Use standard SQL syntax with the CATALOG. prefix:

-- Find large microflows
SELECT Name, ActivityCount
FROM CATALOG.MICROFLOWS
WHERE ActivityCount > 10
ORDER BY ActivityCount DESC;

-- Find all entity usages
SELECT SourceName, RefKind, TargetName
FROM CATALOG.REFS
WHERE TargetName = 'MyModule.Customer';

-- Search the strings table
SELECT * FROM CATALOG.STRINGS
WHERE strings MATCH 'error'
LIMIT 10;

Available Tables

TableContentsPopulated By
MODULESModule names and IDsREFRESH CATALOG
ENTITIESEntity names, persistence, attribute countsREFRESH CATALOG
MICROFLOWSMicroflow names, activity counts, parametersREFRESH CATALOG
NANOFLOWSNanoflow names and metadataREFRESH CATALOG
PAGESPage names, layouts, URLsREFRESH CATALOG
SNIPPETSSnippet namesREFRESH CATALOG
ENUMERATIONSEnumeration names and value countsREFRESH CATALOG
WORKFLOWSWorkflow names and activity countsREFRESH CATALOG
ACTIVITIESIndividual microflow activitiesREFRESH CATALOG FULL
WIDGETSWidget instances across all pagesREFRESH CATALOG FULL
REFSCross-references between documentsREFRESH CATALOG FULL
PERMISSIONSSecurity permissions (entity access, microflow access)REFRESH CATALOG FULL
STRINGSFTS5 full-text search indexREFRESH CATALOG FULL
SOURCEMDL source text for all documentsREFRESH CATALOG FULL

Implementation

The catalog is implemented in mdl/catalog/catalog.go. It:

  1. Creates an in-memory SQLite database
  2. Iterates all modules and documents in the project
  3. Inserts rows into the appropriate tables
  4. Builds FTS5 indexes for full-text search
  5. Builds the reference graph for cross-reference queries

The catalog lives for the duration of the mxcli session and is discarded on exit.