![]() |
Stream Every Click, Learn Every Pattern |
A real-time event-driven e-commerce analytics platform built with React, Express, and Apache Kafka to track user behavior and visualize insights instantly.
Features β’ Tech Stack β’ Getting Started β’ Architecture
KafkaCart is a full-stack learning project that simulates an e-commerce flow and captures user interaction events in real time. The frontend emits structured events (login, product view, cart updates, checkout, and order placement), the backend publishes them to Kafka, and a consumer continuously aggregates analytics for dashboard visualization.
It is designed to help you understand practical event-driven architecture patterns, including producer-consumer flow, stream-based analytics, and near real-time dashboarding.
- Kafka Producer API - Frontend sends events to Express, which publishes to Kafka topic
user-events - Kafka Consumer Aggregation - Continuous consumer updates in-memory analytics state in real time
- Structured Event Schema - Consistent payload shape across login, product, cart, and order workflows
- Topic Partitioning Ready - Topic setup supports multiple partitions for scaling experiments
- Authentication Events -
USER_LOGIN,USER_SIGNUP, andUSER_LOGOUT - Shopping Behavior Events -
PRODUCT_VIEW,ADD_TO_CART,REMOVE_FROM_CART - Checkout & Order Events -
CHECKOUT_STARTED,PAYMENT_METHOD_SELECTED,ORDER_PLACED - Metadata Support - Tracks order totals, payment method, item counts, and product IDs
- Summary Metrics - Total events, signups, logins, orders, revenue, and average order value
- Top Product Insights - Most viewed products from event stream aggregation
- Cart Funnel Metrics - Add-to-cart vs remove-from-cart behavior
- Payment Distribution - Event-based payment method usage stats
- Dockerized Infra - Kafka, Zookeeper, Postgres, and Redis via Docker Compose
- Modern Frontend Stack - React + Vite + Tailwind + Recharts for responsive visualization
- Simple Local Setup - Minimal commands to run full streaming pipeline locally
- Learning-Friendly Codebase - Clear separation of producer, consumer, and analytics endpoints
- Kafka Learning Projects - Understand real-time producer-consumer workflows end to end
- Event-Driven Architecture Demos - Show asynchronous analytics pipeline in interviews and demos
- Behavior Analytics Prototyping - Rapidly test which user actions should be tracked and how
- Dashboarding Practice - Build real-time metrics views from streaming event sources
- System Design Exploration - Experiment with partitions, consumer groups, and scale paths
| Technology | Purpose |
|---|---|
| React 19 | Component-based UI for e-commerce pages and analytics dashboard |
| React Router | Client-side navigation between login, products, cart, checkout, and analytics |
| Tailwind CSS | Utility-first styling for responsive interface |
| Recharts | Data visualization for summary, funnel, and distribution charts |
| Vite | Fast development server and frontend build tool |
| Technology | Purpose |
|---|---|
| Node.js | JavaScript runtime for API and consumer logic |
| Express.js | REST API for event ingestion and analytics endpoints |
| KafkaJS | Kafka client for producer and consumer operations |
| CORS | Cross-origin configuration for frontend-backend communication |
| Technology | Purpose |
|---|---|
| Apache Kafka | Durable event stream for user behavior tracking |
| Zookeeper | Kafka coordination service (local development setup) |
| PostgreSQL | Ready-to-use relational datastore for future persistence expansion |
| Redis | Ready-to-use in-memory store/cache for future optimization |
| Docker Compose | Multi-service orchestration for local environment |
React Client
β
βΌ
Express API
β
βΌ
Kafka Producer
β
βΌ
Kafka Topic: user-events
β
βΌ
Kafka Consumer
β
βΌ
Real-Time Aggregator
β
βββ Analytics API
β
βββ Redis Cache
β
βββ PostgreSQL (future persistence)
Make sure you have the following installed:
- Node.js (v18 or higher recommended)
- npm
- Docker Desktop (for Kafka/Zookeeper/Postgres/Redis)
-
Clone the repository
git clone https://github.com/himadri75/KafkaCart.git cd "KafkaCart"
-
Start infrastructure services
docker compose up -d
-
Setup Backend
cd server npm install -
Create Kafka topic (one-time or when needed)
node createTopic.js
-
Setup Frontend
cd ../client npm install
-
Start the Backend Server
cd server npm startServer will run on
http://localhost:3000 -
Start the Frontend Development Server
cd client npm run devFrontend will run on
http://localhost:5173 -
Open analytics dashboard Navigate to your analytics route
http://localhost:5173/analyticsin the frontend app to view live data updates.
{
"eventId": "uuid",
"eventType": "EVENT_NAME",
"userId": "USER_ID",
"sessionId": "SESSION_ID",
"productId": "PRODUCT_ID",
"timestamp": 1710432000,
"source": "web",
"metadata": {}
}GET /analytics/summaryGET /analytics/top-productsGET /analytics/cartGET /analytics/payments
Himadri Karan
Full Stack Developer & Software Engineer
- π§ Email: [email protected]
- πΌ LinkedIn: linkedin.com/in/himadri516
- π Portfolio: Himadri.me
- π GitHub: github.com/himadri75
Built to explore real-time event streaming with Apache Kafka and modern web technologies.
If this project helped you, consider giving it a β




