How baidaneayoub/ecommerce-realtime-analytics works
This repository combines a luxury perfume storefront with an event-analytics ecosystem. A customer browses products, authenticates, adds items to a cart, or submits a review; the frontend sends product and user requests to Django and tracks interactions as events. Django produces events for Kafka, which Spark processes and enriches for analytics storage. Separate documented capabilities include Locust journey simulation, multilingual sentiment analysis, Elasticsearch loading, machine-learning experiments, and an analytics dashboard. Several backend and ML connections are documented rather than shown in sampled implementation code.
Main entry points: store Django API · App.jsx Storefront App · Home.jsx Product Browsing · Login.jsx Membership Login
Components 25
Storefront
- Storefront App
0-site-ecommerce/frontend-react/src/App.jsx - Product Browsing
0-site-ecommerce/frontend-react/src/pages/Home.jsx - Membership Login
0-site-ecommerce/frontend-react/src/components/Login.jsx - Cart UI
0-site-ecommerce/frontend-react/src/components/Cart.jsx - Cart State
0-site-ecommerce/frontend-react/src/context/CartContext.jsx - User State
0-site-ecommerce/frontend-react/src/context/UserContext.jsx - Event Tracker
0-site-ecommerce/frontend-react/src/hooks/useTracker.js
Commerce Backend
- Django API
0-site-ecommerce/backend-django/store - Event Endpoint
0-site-ecommerce/backend-django/store/views.py - Kafka Producer
0-site-ecommerce/backend-django/store/kafka_producer.py - Commerce Models
0-site-ecommerce/backend-django/store/models.py - MongoDB Access
0-site-ecommerce/backend-django/store/mongo.py - Dashboard API
0-site-ecommerce/backend-django/store/views_dashboard.py
Event Analytics
- Journey Simulator
1-data-simulation/locustfile.py - Data Generators
1-data-simulation - Kafka
- Spark Streaming
3-spark-processing/spark_streaming.py - Sentiment Analysis
3-spark-processing/nlp_sentiment.py - NLP Index Loader
4-bases-nosql/load_nlp_to_es.py - Elasticsearch
Machine Learning
- Purchase Model Training
5-machine-learning/a_pre_training/train_purchase_model.py - Inference API
5-machine-learning/b_streaming_inference/predictor_api.py - Model Comparison
5-machine-learning/c_comparative_study/app.py
Monitoring
- Analytics Dashboard
6-dashboard-alertes/react-dashboard/src/App.jsx
Other components
- Shopper
Connections 31
- Shopper → Storefront App: uses
README.md - Storefront App → Product Browsing: routes to
0-site-ecommerce/frontend-react/src/App.jsx - Storefront App → Membership Login: routes to
0-site-ecommerce/frontend-react/src/App.jsx - Storefront App → Cart State: provides state
0-site-ecommerce/frontend-react/src/App.jsx - Storefront App → User State: provides state
0-site-ecommerce/frontend-react/src/App.jsx - Product Browsing → Cart UI: renders
0-site-ecommerce/frontend-react/src/pages/Home.jsx - Product Browsing → Cart State: uses
0-site-ecommerce/frontend-react/src/pages/Home.jsx - Product Browsing → Event Tracker: tracks events
0-site-ecommerce/frontend-react/src/pages/Home.jsx - Cart UI → Cart State: uses
0-site-ecommerce/frontend-react/src/components/Cart.jsx - Cart State → Event Tracker: tracks cart events
0-site-ecommerce/frontend-react/src/context/CartContext.jsx - Membership Login → User State: updates login
0-site-ecommerce/frontend-react/src/components/Login.jsx - Membership Login → Event Tracker: tracks login
0-site-ecommerce/frontend-react/src/components/Login.jsx - Product Browsing → Django API: fetches products
0-site-ecommerce/frontend-react/src/pages/Home.jsx - Membership Login → Django API: authenticates
0-site-ecommerce/frontend-react/src/components/Login.jsx - Event Tracker → Event Endpoint: posts events
0-site-ecommerce/frontend-react/src/hooks/useTracker.js - Django API → Commerce Models: serves commerce data
0-site-ecommerce/backend-django/store/management/commands/seed_db.py - Django API → MongoDB Access: reads and writes
0-site-ecommerce/backend-django/store/apps.py - Django API → Event Endpoint: routes events
- Event Endpoint → Kafka Producer: publishes events
- Kafka Producer → Kafka: sends events
README.md - Journey Simulator → Django API: simulates journeys
README.md - Data Generators → Journey Simulator: provides scenarios
- Kafka → Spark Streaming: streams events
README.md - Spark Streaming → Sentiment Analysis: uses analysis
3-spark-processing/spark_streaming.py - Spark Streaming → MongoDB Access: stores analytics
README.md - NLP Index Loader → Sentiment Analysis: imports NLP logic
- Sentiment Analysis → Elasticsearch: indexes documents
3-spark-processing/nlp_sentiment.py - Purchase Model Training → Inference API: supplies model
- Analytics Dashboard → Dashboard API: fetches analytics
6-dashboard-alertes/react-dashboard/src/App.jsx - Dashboard API → MongoDB Access: queries analytics
0-site-ecommerce/backend-django/store/views_dashboard.py - Model Comparison → Purchase Model Training: compares models