Skip to main content
PreparationZone Logo
PrepZone

Polyglot Persistence

Postgres for orders, Redis for sessions, Elasticsearch for search — one platform, many engines.

Pass checkpoint below

Why this matters

  • VaultCommerce's checkout, search, cache, and analytics layers have incompatible requirements; one database cannot serve them all without painful compromises.
  • Production engineers debug consistency boundaries daily — knowing which store is source of truth prevents double-charge bugs.
  • Interviews reward coherent multi-store designs with clear sync paths, not buzzword salads.
SQL (Postgres)
ACID transactions
Complex joins
Fixed schema
NoSQL
Flexible schema
Horizontal scale
Specialised access
Structured relations with joins favour SQL. Flexible schema and horizontal scale favour NoSQL.

VaultCommerce data plane

Store map and ownership

  • Postgres — users, orders, payments, inventory ledger (source of truth).
  • MongoDB — product catalog with nested variants and marketing content.
  • Redis — sessions, shopping carts, rate limits, hot product snapshots.
  • Elasticsearch — full-text product search, autocomplete, faceted browse.
  • Cassandra — clickstream, order-status events, analytics ingestion.
  • Neo4j — recommendation graph and fraud relationship queries.

Source of truth and derived views

Every piece of data has one authoritative home. VaultCommerce never treats Elasticsearch as the inventory system — search indexes are rebuildable projections from Postgres and MongoDB.

Java
// Order placement — single transactional boundary
@Transactional
public Order placeOrder(PlaceOrderCommand cmd) {
    inventoryService.reserve(cmd.items());      // Postgres
    paymentService.charge(cmd.payment());       // Postgres
    Order order = orderRepo.save(cmd.toOrder()); // Postgres
    eventPublisher.publish(new OrderPlaced(order)); // async fan-out
    return order;
}

Downstream consumers update Redis cart eviction, Cassandra event logs, and Elasticsearch "sold count" facets — eventually, and idempotently.

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 2 sections

  • Sync strategies
  • Consistency across boundaries

Test yourself

Answer these before moving on — recall is what makes it stick.