🌟 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.
Microservices
FastAPI
React
pgvector
Groq AI
Redis
Docker
📌 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
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 AuthenticationCategorized Breakdown
| Domain | Technologies |
|---|---|
| Frontend & UI | React 19, TypeScript, Vite, Tailwind CSS v4, Shadcn UI, Radix UI, Redux Toolkit, TanStack Query, Axios, Lucide Icons |
| Backend Microservices | Python 3.11+, FastAPI, Uvicorn, Pydantic, SQLAlchemy ORM, Alembic Migrations, HTTPX |
| AI, RAG & Vector Search | Groq AI (llama-3.1-8b-instant), LangChain, Hugging Face (sentence-transformers/all-MiniLM-L6-v2), pgvector (PostgreSQL), Inngest |
| Databases & Caching | Neon Serverless PostgreSQL (Database-per-Service), Redis (Cache-Aside pattern) |
| Gateway & Security | Nginx API Gateway, JWT Authentication (HS256 via HttpOnly Secure Cookies), SHA256 HMAC Webhook Verification |
| Third-Party Integrations | Cashfree Sandbox Payment Gateway, Cloudinary CDN (Image Management) |
| DevOps & Containerization | Docker, 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-v2produces 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 <= :budgetconditions to vector matches, eliminating hallucinated out-of-budget recommendations. - LLM Fallback Cascade: Primary inference powered by
llama-3.1-8b-instantwith automatic fallback tollama-3.3-70b-versatileandgemma2-9b-itif rate limits or latency thresholds are hit. - Real-time Event Synchronization: Product catalog mutations in the Product Service dispatch
product.created,product.updated, andproduct.deletedevents 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_tokenstored in anHttpOnly,Secure,SameSite=Nonecookie. - 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 (
USERvsADMIN) 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
| Service | Port | Database | Primary Responsibility |
|---|---|---|---|
| Nginx API Gateway | 80, 443 | — | Single public gateway; reverse proxying; routing; CORS headers. |
| User Service | 8000 | Postgres (Users) | User registration, login, BCrypt password hashing, JWT creation, profile avatar management. |
| Product Service | 8000 | Postgres (Products) | Catalog CRUD, brand/category filtering, image uploads (Cloudinary), Redis caching, Inngest event publishing. |
| Cart Service | 8000 | Postgres (Carts) | Cart management, item quantity bounds checks, pricing sync, Redis cart caching. |
| Review Service | 8000 | Postgres (Reviews) | Rating submission, review aggregation, average score computation, Redis review cache invalidation. |
| Order Service | 8000 | Postgres (Orders) | Checkout orchestration, server-side price verification, order state machine (pending ➔ processing ➔ shipped). |
| Payment Service | 5000 | Postgres (Payments) | Cashfree session creation, webhook ingestion, SHA256 HMAC verification, downstream order & cart updates. |
| Recommendation Service | 8003 | Postgres + pgvector | 384D HuggingFace vector embedding, cosine similarity search, budget filtering, Groq AI RAG chat, admin vector sync console. |
