Buyzaar

Built with

React 19TypeScriptViteTailwind CSSShadcn UIRedux ToolkitTanStack QueryPythonFastAPIPostgreSQLpgvectorRedisInngestLangChainHugging FaceGroq LLMNginxDockerCashfreeCloudinary

🌟 Buyzaar — Distributed Microservices E-Commerce Platform with RAG AI

A high-performance, distributed microservices e-commerce platform featuring an AI shopping assistant powered by RAG, pgvector, and Groq LLM.

MicroservicesMicroservices FastAPIFastAPI ReactReact pgvectorpgvector Groq AIGroq AI RedisRedis DockerDocker


📌 Project Overview

Buyzaar is an enterprise-grade, distributed microservices e-commerce system built to demonstrate scalable cloud architecture, domain-driven decoupling, and practical Generative AI integration.

Unlike traditional monolithic applications, Buyzaar is designed with a strict database-per-service pattern across seven independent backend microservices. It features an Nginx API Gateway, a Redis caching tier implementing the Cache-Aside pattern, asynchronous event-driven pipelines via Inngest, and an integrated Retrieval-Augmented Generation (RAG) Recommendation Service that allows shoppers to discover products conversationally using natural language and budget constraints.


🛠️ Technology Stack

text
React 19, TypeScript, Vite, Tailwind CSS v4, Shadcn UI, Radix UI, Redux Toolkit, TanStack Query, Python, FastAPI, Uvicorn, SQLAlchemy, Alembic, PostgreSQL (Neon), pgvector, Redis, Inngest, LangChain, Hugging Face, Groq LLM, Nginx, Docker, Docker Compose, Cashfree Payment Gateway, Cloudinary, JWT Authentication

Categorized Breakdown

DomainTechnologies
Frontend & UIReact 19, TypeScript, Vite, Tailwind CSS v4, Shadcn UI, Radix UI, Redux Toolkit, TanStack Query, Axios, Lucide Icons
Backend MicroservicesPython 3.11+, FastAPI, Uvicorn, Pydantic, SQLAlchemy ORM, Alembic Migrations, HTTPX
AI, RAG & Vector SearchGroq AI (llama-3.1-8b-instant), LangChain, Hugging Face (sentence-transformers/all-MiniLM-L6-v2), pgvector (PostgreSQL), Inngest
Databases & CachingNeon Serverless PostgreSQL (Database-per-Service), Redis (Cache-Aside pattern)
Gateway & SecurityNginx API Gateway, JWT Authentication (HS256 via HttpOnly Secure Cookies), SHA256 HMAC Webhook Verification
Third-Party IntegrationsCashfree Sandbox Payment Gateway, Cloudinary CDN (Image Management)
DevOps & ContainerizationDocker, Docker Compose, Multi-stage builds

🏗️ System Architecture

Buyzaar decouples domain boundaries into seven autonomous microservices, orchestrated through a centralized reverse proxy gateway and backed by independent serverless databases.

Loading diagram...

🤖 AI Shopping Assistant & RAG Pipeline

Buyzaar includes a conversational shopping assistant that goes beyond naive keyword search. It converts user queries into dense 384-dimensional vector embeddings, conducts cosine similarity searches within PostgreSQL via pgvector, and applies dynamic price filters before synthesizing responses through Groq's high-speed inference engine.

Loading diagram...

RAG Architecture Highlights:

  • Vector Model: sentence-transformers/all-MiniLM-L6-v2 produces compact, high-efficiency 384-dimensional vectors.
  • Hybrid Budget Filtering: Natural language parsing extracts budgetary caps (e.g., "under ₹15,000", "below 500") and applies SQL-level WHERE price <= :budget conditions to vector matches, eliminating hallucinated out-of-budget recommendations.
  • LLM Fallback Cascade: Primary inference powered by llama-3.1-8b-instant with automatic fallback to llama-3.3-70b-versatile and gemma2-9b-it if rate limits or latency thresholds are hit.
  • Real-time Event Synchronization: Product catalog mutations in the Product Service dispatch product.created, product.updated, and product.deleted events through Inngest, triggering immediate vector updates in pgvector without manual administrative intervention.
  • Out-of-Catalog Guardrails: Automatically identifies off-topic or out-of-catalog inquiries and renders an alert banner to preserve conversational relevance.

💳 Checkout & Cryptographic Payment Flow

Payment security is enforced using a webhook-based verification flow with Cashfree Payment Gateway and SHA256 HMAC cryptographic signature validation.

Loading diagram...

🔑 Key Engineering & Architectural Highlights

1. Database-Per-Service Pattern

Each domain microservice owns its schema in Neon Serverless PostgreSQL. No microservice ever executes queries directly against another service's database. Cross-service data requirements are satisfied through authenticated REST endpoints and asynchronous event triggers.

2. High-Performance Redis Caching (Cache-Aside)

  • Product Catalog: Caches frequent catalog listings and category filters, evicting cache entries on inventory updates.
  • Shopping Carts: Rapid read/write memory store for active user baskets, reducing round-trips to the persistent relational database during cart operations.
  • RAG Semantic Caching: Identical recommendation inquiries leverage cached responses to avoid redundant embedding generations and LLM API round-trips.

3. Stateless Cookie-Based JWT Security

  • Authentication: User Service issues an access_token stored in an HttpOnly, Secure, SameSite=None cookie.
  • Zero-Bottleneck Verification: Services verify user claims locally using a shared cryptographic secret without sending synchronous validation requests back to the User Service.
  • Role-Based Access Control (RBAC): Enforces distinct access tiers (USER vs ADMIN) for operations such as vector re-indexing and product catalog management.

4. Resilient Nginx API Gateway

Acts as a unified reverse proxy shielding internal microservices from external exposure. Handles TLS termination, centralizes CORS headers, and dynamically routes path prefixes to corresponding internal container ports.


🧩 Microservices Breakdown

ServicePortDatabasePrimary Responsibility
Nginx API Gateway80, 443—Single public gateway; reverse proxying; routing; CORS headers.
User Service8000Postgres (Users)User registration, login, BCrypt password hashing, JWT creation, profile avatar management.
Product Service8000Postgres (Products)Catalog CRUD, brand/category filtering, image uploads (Cloudinary), Redis caching, Inngest event publishing.
Cart Service8000Postgres (Carts)Cart management, item quantity bounds checks, pricing sync, Redis cart caching.
Review Service8000Postgres (Reviews)Rating submission, review aggregation, average score computation, Redis review cache invalidation.
Order Service8000Postgres (Orders)Checkout orchestration, server-side price verification, order state machine (pending ➔ processing ➔ shipped).
Payment Service5000Postgres (Payments)Cashfree session creation, webhook ingestion, SHA256 HMAC verification, downstream order & cart updates.
Recommendation Service8003Postgres + pgvector384D HuggingFace vector embedding, cosine similarity search, budget filtering, Groq AI RAG chat, admin vector sync console.