How lukasaldivia/maat-ts works
Project Type and Purpose
• Maat-ts is a modular TypeScript library (not a full-stack app).
• It exposes a fluent API for:
• Defining tables (TableFactory → Table)
• Building queries with filters (FilterFactory, FilterCollection, various Filter classes)
• Executing CRUD/search operations via a pluggable SQL adapter (Queryable)
• Creating aggregate functions (AggregateFunction).
File Structure
• Top-level “src” modules:
• AggregateFunction
• Filter (core + Factory + variations)
• Model
• Table (core + Factory)
• vendor (utility code)
• Key factories (TableFactory, FilterFactory) generate domain objects.
• Model ties a Table and a Queryable together to perform operations.
• No server, UI, or persistence layer is bundled—only the library API and its internals.
Core Components and Their Relationships
a. Table & TableFactory
• TableFactory.create() ⇒ Table<C, PK>
• Table encapsulates table name, columns, PK.
b. Model & Queryable
• new Model(table, connection)
• CRUD and search methods delegate to connection.query(...).
c. Filter System
• FilterFactory.build(options) ⇒ Filter
• FilterCollection accumulates Filters via appendFilter()
• Variations (DateFilter, NumberFilter, TextFilter, etc.) implement specific operators.
d. AggregateFunction
• AggregateFunction.from(table) ⇒ object with .count(), .sum(), etc.
e. Vendor utilities
• e.g. getAccumulated used internally by FilterCollection or Model.
Architectural Patterns
• Factory Pattern: TableFactory, FilterFactory
• Fluent/Builder: FilterCollection.appendFilter(), chainable query options
• Strategy/Polymorphism: Filter variations encapsulate different SQL operators
• Dependency Injection: Model receives a Queryable adapter