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"
- Node.js (v18+ recommended)
- Docker and docker-compose
-
Clone the repository:
git clone https://github.com/your-username/marketplace-search-meilisearch-postgres.git cd marketplace-search-meilisearch-postgres -
Copy the environment file:
cp .env.example .env
-
Start Postgres and MeiliSearch:
docker-compose up -d
-
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
-
Install dependencies:
npm install
-
Start the worker in one terminal:
npm run worker
-
Start the API server in another terminal:
npm run dev
-
Test the API:
-
Health check:
curl http://localhost:3000/health
-
Search (example):
curl "http://localhost:3000/search?q=saree&city=Hyderabad"
-
- 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