Skip to content

muditkalra/Bazaar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›οΈ Bazaar β€” Polyglot Microservices Based E-Commerce Platform

⚑️ Overview

Bazaar is a next-generation, microservices-based e-commerce platform built using multiple frameworks and databases, all orchestrated with a Turborepo monorepo. It demonstrates real-world distributed architecture β€” event-driven communication, polyglot persistence, and framework interoperability.

🧠 The goal: showcase how different technologies (Express, Fastify, Hono, Next.js, Kafka, Stripe, Clerk, etc.) can cohesively form a modular, scalable, event-driven e-commerce system.

πŸ“˜ Data Flow

                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚     Web (Next.js)  β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β–Ό                          β–Ό                           β–Ό                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   
β”‚ Product Svc  │──Kafka──▢│ Order Svc    │──Kafka─ ─▢│ Email Svc      │──Kafka──▢│ Payment Svc     │──Stripe Webhook──▢ Payment Success
β”‚ (Express +   β”‚          β”‚ (Fastify +   β”‚            β”‚ (Worker + Kafkaβ”‚           β”‚ (Hono + Stripe  β”‚
β”‚ PostgreSQL)  β”‚          β”‚ MongoDB)     β”‚            β”‚ Consumers)     β”‚           |  )              |
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β–²                          
       β”‚                          
       β”‚         
       β”‚         
       β”‚  
       β”‚ 
       β”‚  
       β”‚  
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Auth Svc     │──Clerk API──▢ User Authentication
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🧱 Project Structure

bazaar/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ web/               # Next.js storefront (user-facing)
β”‚   β”œβ”€β”€ admin/             # Next.js admin dashboard
β”‚   β”œβ”€β”€ product-service/   # Express + TypeScript + PostgreSQL (via Prisma)
β”‚   β”œβ”€β”€ order-service/     # Fastify + TypeScript + MongoDB (via Mongoose)
β”‚   β”œβ”€β”€ payment-service/   # Hono + TypeScript + Stripe integration
β”‚   β”œβ”€β”€ auth-service/      # Express + TypeScript + Clerk authentication
β”‚   └── email-service/     # Kafka consumers for transactional emails
β”‚
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ kafka/             # Kafka setup (producer/consumer utilities)
β”‚   β”œβ”€β”€ product-db/        # Prisma + NeonDB client
β”‚   β”œβ”€β”€ order-db/          # Mongoose + MongoDB connection
β”‚   └── types/             # Shared TypeScript types across services
β”‚
└── turbo.json

βš™οΈ Services Overview

Service Framework Database Description
πŸ›’ Product Service Express PostgreSQL (via Prisma) Manages products, CRUD ops, and publishes Kafka events
πŸ“¦ Order Service Fastify MongoDB (via Mongoose) Handles order creation/retrieval, consumes & emits Kafka events
πŸ’³ Payment Service Hono β€” Integrates with Stripe APIs and webhooks for payment flow
πŸ‘€ Auth Service Express Clerk Manages user retrieval and authentication
βœ‰οΈ Email Service Node (Kafka Worker) β€” Subscribes to user.created & order.created for emails

🌍 Frontend Applications

App Framework Purpose
πŸͺ Web App Next.js Customer-facing storefront (products, checkout, etc.)
πŸ§‘β€πŸ’Ό Admin Panel Next.js Dashboard to manage products, orders, and payments

πŸ“¦ Shared Packages

Package Purpose
🧭 kafka Central Kafka setup and utilities
🧩 product-db Prisma + NeonDB connection for product data
🧱 order-db MongoDB connection and Mongoose models
🧾 types Shared TypeScript types between services

🧠 Design Philosophy

  • 🧩 Polyglot Microservices: Each service uses a unique framework and database.
  • ⚑ Event-Driven Architecture: Kafka enables async communication and decoupling.
  • 🧰 Turborepo Monorepo: Enables isolated builds and shared dependency management.
  • πŸ”’ Decoupled Auth: Clerk ensures secure authentication across apps.
  • πŸ’³ Modern Payments: Stripe webhook for checkout.session.completed event.

🧰 Local Development

# Clone the repo
git clone https://github.com/muditkalra/microservices-ecommerce.git
cd microservices-ecommerce

# Install dependencies
pnpm install

# Start Kafka  (via Docker Compose)
cd packages/kafka
docker compose up -d

# Run a specific service (example: product-service)
pnpm --filter product-service dev

# Or run all apps & services
pnpm run dev

⚠️ Configure .env files for each app (Stripe, Clerk, databases, etc.) before running.

πŸ“ˆ Future Roadmap

  • API Gateway / GraphQL BFF
  • Redis caching layer
  • gRPC inter-service communication
  • Prometheus + Grafana monitoring
  • CI/CD with GitHub Actions
  • Background worker optimizations

βš™οΈ Tech Stack Summary

Layer Technologies
Frontend Next.js (App Router, TypeScript)
Backend Express, Fastify, Hono
Databases PostgreSQL (Prisma), MongoDB (Mongoose), NeonDB
Auth Clerk
Payments Stripe
Messaging Kafka
Repo Management Turborepo + PNPM
Language TypeScript
Infrastructure Docker Compose (WIP)

πŸ’‘ Key Learnings Showcased

βœ… Real-world microservices communication using Kafka
βœ… Handling different databases per service (polyglot persistence)
βœ… Clean service isolation via Turborepo
βœ… Seamless third-party API integration (Stripe, Clerk)
βœ… Event-driven flow with async reliability

πŸ‘¨β€πŸ’» Author

Mudit Kalra
Fullstack & Systems Design Enthusiast
Building scalable distributed systems with Node.js, Kafka, and Next.js

🌟 Project Status

🚧 In active development β€” evolving toward a fully distributed, event-driven e-commerce ecosystem.
⭐ Star this repo if you find the architecture inspiring!

About

Ecommerce Platform built on microservices and event-driven architecture, with services written in express, fastify and hono. Client facing and admin dashboard built using Next.js

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors