You've got a great start on your README! Here's a revised version that incorporates standard README best practices for clarity, structure, and engagement.
# 🛍️ Typesense Product Search App
This is a full-stack product search application built with **React** for the frontend and **Typesense** powering the backend search capabilities. It offers a robust and instant search experience for products.
---
## ✨ Features
* **Full-Text Search:** Instantly search through your product catalog.
* **Faceted Filters:** Refine search results by product **tags** and **collections**.
* **Pagination:** Navigate through large result sets with ease.
* **Instant Results with Debounce:** Get real-time search suggestions with a 200ms debounce to optimize performance.
* **Live-Updating Filters:** Facets dynamically update based on the current search query, providing relevant filtering options.
---
## 🚀 Getting Started
To get this application up and running, ensure you have the following prerequisites installed:
* **Node.js**: Version 16+ is recommended.
* **npm**: Node package manager, typically installed with Node.js.
* **Docker**: Required to run the Typesense search engine.
---
## 🧠 Project Structure
```bash
.
├── backend/
│ ├── src/
│ │ ├── index.js # Express server with /search endpoint
│ │ ├── index-catalog.ts # Script for indexing
│ │ ├── catalog.fixed.jsonl # Product data for indexing
│ ├── package.json
│ └── ...
├── frontend/
│ ├── src/
│ │ └── App.tsx # Main React App
│ ├── public/
│ ├── package.json
│ └── ...
├── .gitignore
├── README.md
└── ...
Follow these steps to set up and run the application locally:
-
Clone the repository:
git clone [https://github.com/moshe19909090/typesense-search-app.git](https://github.com/moshe19909090/typesense-search-app.git) cd typesense-search-app -
Start Typesense using Docker: Navigate into the
backenddirectory and run the Docker command. This will start a Typesense instance accessible on port8108.cd backend docker run -p 8108:8108 -v$(pwd)/typesense-data:/data typesense/typesense:0.25.1 \ --data-dir /data --api-key=xyz --listen-port 8108 --enable-cors
-
Install backend dependencies:
npm install
-
Index product data: Run the indexing script to upload the sample
catalog.fixed.jsonldata into your running Typesense instance. You should see logs confirming successful indexing.npm run index
-
Run the backend server:
npm run dev
This will start the Express server, which provides the
/searchendpoint for the frontend.
Once the backend and Typesense are running, you can start the React frontend:
-
Open a new terminal and navigate to the
frontenddirectory:cd frontend -
Install frontend dependencies:
npm install
-
Run the React application:
npm start
The application will open in your browser at
http://localhost:3000.
- Typing in the search box triggers a 200ms debounce for live, instant search results.
- Tags and Collections facets dynamically update based on the current search query, ensuring only relevant filters are displayed.
- You can click on filter chips to apply filters and use the "Clear Filters" option to reset your search.
- React: A JavaScript library for building user interfaces.
- Axios: A promise-based HTTP client for making API requests.
- Express: A fast, unopinionated, minimalist web framework for Node.js.
- Typesense: A fast, open source, typo-tolerant search engine.
- dotenv (optional): For loading environment variables from a
.envfile.