Skip to content

A clean, production-style example of building a scalable marketplace search system using PostgreSQL as the source of truth, MeiliSearch for full-text indexing, and Node.js for the API and sync worker.

Notifications You must be signed in to change notification settings

nivedhapalani96/marketplace-search-meilisearch-postgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Marketplace Search with PostgreSQL + MeiliSearch

This repository contains a minimal example of a marketplace-style search architecture using:

  • PostgreSQL as the source of truth
  • MeiliSearch as the search engine
  • Node.js (Express) as the API layer
  • A background worker to keep the search index in sync using Postgres LISTEN/NOTIFY

It accompanies the article: "How to Design a Scalable Marketplace Search Architecture Using MeiliSearch and PostgreSQL"

Prerequisites

  • Node.js (v18+ recommended)
  • Docker and docker-compose

Getting Started

  1. Clone the repository:

    git clone https://github.com/your-username/marketplace-search-meilisearch-postgres.git
    cd marketplace-search-meilisearch-postgres
  2. Copy the environment file:

    cp .env.example .env
  3. Start Postgres and MeiliSearch:

    docker-compose up -d
  4. Initialize the database:

    cat sql/schema.sql | docker exec -i marketplace_postgres psql -U postgres -d marketplace
    cat sql/seed.sql   | docker exec -i marketplace_postgres psql -U postgres -d marketplace
  5. Install dependencies:

    npm install
  6. Start the worker in one terminal:

    npm run worker
  7. Start the API server in another terminal:

    npm run dev
  8. Test the API:

    • Health check:

      curl http://localhost:3000/health
    • Search (example):

      curl "http://localhost:3000/search?q=saree&city=Hyderabad"

Notes

  • All writes go to PostgreSQL. The worker listens for changes and updates MeiliSearch.
  • MeiliSearch is treated purely as a search index, not a primary store.
  • This is a minimal example intended for learning and demonstration; in production, you would add authentication, stricter validation, logging, metrics, and better error handling.

Maintained by: Nivedha Palani GitHub: https://github.com/nivedhapalani96

About

A clean, production-style example of building a scalable marketplace search system using PostgreSQL as the source of truth, MeiliSearch for full-text indexing, and Node.js for the API and sync worker.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published