Skip to content
Empire Builder KitDocumentation
v1 Documentation

Find your next step.

Search the complete documentation, including code examples.

    Full-text search↑ ↓ navigate Enter open
    Browse documentation
    DocsCore concepts

    Persistence

    A generated Slice stores its data in DynamoDB. SQL is an explicit, additive choice you make for a Slice when a feature needs relational constraints or joins.

    On this page
    1. DynamoDB first
    2. Optional SQL

    DynamoDB first

    Every Slice starts with three data files. data/persistence.json declares which stores the Slice uses. data/key-value.ts gives the Slice a key-value store built on the runtime package. data/records.ts is a seeded example of product records that you replace with your own.

    DynamoDB is the default because it has no cluster to size and no network to place it in. A Slice that only needs to read and write items by key is complete without anything else.

    Architecture plate / persistence

    Start on DynamoDB. Add SQL when a feature needs it.

    Choose a store from the feature's access patternsA feature's access patterns determine persistence. DynamoDB is the default for a generated Slice. SQL is an explicit choice for relational constraints, joins, or other concrete relational needs; the sql generator adds it, and the Foundation provisions Aurora PostgreSQL only then. No transaction spans DynamoDB and PostgreSQL.PERSISTENCE CHOICEFeature access patternsQueries · invariants · data lifecycleDefault application journeyRelational constraints or joinsDEFAULTDynamoDBSlice-owned key-value store and recordsIN EVERY SLICEdata/key-value.ts · data/records.tsADDED WITH THE SQL GENERATORAurora PostgreSQLFoundation VPC and Aurora · Slice schemaADDED TO THE SLICEdrizzle-orm · pg · rds-signerNo database to keep runningProvisioned only when declaredAdding SQL keeps existing DynamoDB data. No transaction spans both.

    Choose Detail to inspect the labels. Download the SVG to keep or share this diagram.

    SQL is additive. It does not move existing DynamoDB data, and no transaction spans both stores.

    A Slice starts on the left. The right side exists only after you add SQL.

    Optional SQL

    When a feature needs integrity constraints, joins or reporting queries, run the sql generator for that Slice. It adds drizzle-orm, pg and @aws-sdk/rds-signer to the Slice and declares SQL in data/persistence.json. The Foundation then provisions a VPC and Aurora PostgreSQL for the stage.

    See Add SQL for the steps.