How 1ayazahmed/ai-powered-ecommerce works
Project type and purpose
• This is a full-stack MERN (MongoDB, Express, React, Node.js) e-commerce application, augmented with a suite of Python-based AI micro-services for chatbots, recommendations, predictive analytics, sentiment analysis and product description generation.
File structure
• Top level:
• ai/ → Python AI micro-services
• backend/ → Node.js/Express REST API
• frontend/ → React/Redux single-page application
• uploads/ → Persistent file store for product images
• backend/ follows an MVC-style broken out into config, models, controllers, routes, middlewares and services.
• frontend/ uses Vite, tailwind, React components, pages, a Redux-toolkit setup for state and RTK Query for API calls.
• Python services each implement a distinct AI capability and have their own requirements.txt and tests.
README
• Minimal, confirms the MERN e-commerce store identity.
• Client (React SPA)
• API Gateway / Node.js Server (Express)
• Python AI Micro-services cluster
• MongoDB Database
• File Storage (uploads folder or S3)
• External Services (e.g., Payment Gateway, Email/SMS)
b. Relationships & data flows
1. User interacts with React SPA → issues HTTPS requests to Express API
2. Express Authentication middleware validates JWT (authMiddleware)
3. Express routes dispatch to controllers → business logic in services → MongoDB via Mongoose models
4. For AI features, Express invokes corresponding Python micro-service (e.g., HTTP request on localhost:5000/chatbot)
5. Python service processes input, optionally reads/writes to a lightweight store or returns JSON → Express returns result to SPA
6. File uploads (product images) go through multerMiddleware → persisted under /uploads → paths saved in MongoDB
7. Background scripts (cleanupProductImages.js, updateProductImage.js) run as cron jobs or Node scripts against MongoDB/files
8. Redux/RTK Query on the client caches API responses, updates UI
c. Architectural patterns & design principles
• Separation of concerns: MVC on backend, micro-services for AI, clear frontend-backend boundary
• Stateless RESTful API + JWT auth
• Single-page Application with centralized state management (Redux)
• Micro-services for scalability of AI workloads
• Modular file-based routing in Express and React (pages/components)
d. Key technologies & libraries
• Frontend: React, Redux Toolkit, RTK Query, Vite, Tailwind CSS
• Backend: Node.js, Express, Mongoose, Multer, JWT, asyncHandler, cors
• Python AI: Flask/FastAPI (or similar), scikit-learn/tensorflow, NLTK/spacy
• Database: MongoDB Atlas (or self-hosted)
• Storage: Local filesystem or AWS S3 for uploads
• DevOps: npm scripts, Vite config, dotenv, .env files
Detailed capture of essential elements
• Your backend folder breakdown as sub-components: AuthMiddleware, CategoryController → CategoryService → categoryModel
• Python services as independent modules each with their own container/port
• Redux RTK Query slices hitting their corresponding /api/* endpoints