# preethi-karuna06/thoori-cosmetics architecture

> Architecture diagram of the GitHub repository preethi-karuna06/thoori-cosmetics, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/preethi-karuna06/thoori-cosmetics
- Repository: https://github.com/preethi-karuna06/thoori-cosmetics

## Overview

Thoori is a skincare e-commerce platform whose customer journey runs from browsing products and completing a skin quiz to personalized recommendations, cart/checkout, payment, order tracking, and reviews. A parallel AI-chat workflow retrieves product candidates and generates explanations; admins manage products, orders, users, reviews, and analytics. The graph includes the API, domain controllers, and persistence/integration layer. Several UI and backend subsystems are documented but unsampled, so their links are shown only where the README or source index supports them.

Main entry points: [`backend/server.js`](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/server.js) (Express API), [`frontend/src/services/api.js`](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/services/api.js) (API client), [`frontend/src/App.jsx`](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/App.jsx) (Web app routes), [`backend/models/Product.js`](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/models/Product.js) (Product model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Customer web app"]
  node_webapp["Web app routes<br/>[App.jsx]"]
  node_authui["Auth state<br/>[AuthContext.jsx]"]
  node_cartui["Cart state<br/>[CartContext.jsx]"]
  node_productui["Product browsing<br/>[HomePage.jsx]"]
  node_productcard["Product card<br/>[ProductCard.jsx]"]
  node_shopui["Shop and detail"]
  node_quizui["Skin quiz<br/>[QuizPage.jsx]"]
  node_recommendui["Recommendations"]
  node_checkoutui["Checkout and orders<br/>[CheckoutPage.jsx]"]
  node_chatui["Chat experience<br/>[ChatBot.jsx]"]
  node_adminui["Admin console"]
end

subgraph group_api["API and identity"]
  node_apiclient["API client<br/>[api.js]"]
  node_server["Express API<br/>[server.js]"]
  node_auth["Authentication<br/>[auth.controller.js]"]
  node_guard["JWT access control<br/>[auth.middleware.js]"]
end

subgraph group_commerce["Commerce domains"]
  node_catalog["Product catalog"]
  node_cart["Cart and wishlist<br/>[cart.controller.js]"]
  node_orders["Order and payment"]
  node_reviews["Reviews"]
  node_adminops["Admin operations"]
end

subgraph group_personalization["Skincare AI"]
  node_quiz["Quiz scoring<br/>[quiz.controller.js]"]
  node_chat["RAG chatbot<br/>[chat.controller.js]"]
  node_vector["Vector retrieval<br/>[vector.service.js]"]
end

subgraph group_data["Persistence and integrations"]
  node_mongo[("MongoDB models<br/>[index.js]")]
  node_productmodel[("Product model<br/>[Product.js]")]
  node_ordermodel[("Order model<br/>[Order.js]")]
  node_usermodel[("User model<br/>[User.js]")]
  node_qdrant[("Qdrant")]
  node_gemini["Gemini embeddings"]
  node_llm["Chat LLM"]
  node_razorpay["Razorpay"]
  node_cloudinary["Cloudinary"]
end

node_customer(("Customer"))
node_admin(("Administrator"))

node_customer -->|"uses"| node_webapp
node_admin -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_productui
node_webapp -->|"routes to"| node_shopui
node_webapp -->|"routes to"| node_quizui
node_webapp -->|"routes to"| node_checkoutui
node_webapp -->|"routes to"| node_adminui
node_webapp -->|"checks access"| node_authui
node_productui -->|"renders"| node_productcard
node_productui -->|"requests catalog"| node_apiclient
node_shopui -->|"requests product"| node_apiclient
node_shopui -->|"updates cart"| node_cartui
node_authui -->|"authenticates via"| node_apiclient
node_cartui -->|"requests cart"| node_apiclient
node_quizui -->|"submits quiz"| node_apiclient
node_recommendui -->|"fetches results"| node_apiclient
node_checkoutui -->|"submits order"| node_apiclient
node_chatui -->|"sends messages"| node_apiclient
node_adminui -->|"requests admin data"| node_apiclient
node_apiclient -->|"calls API"| node_server
node_server -->|"routes auth"| node_auth
node_server -->|"routes products"| node_catalog
node_server -->|"routes cart"| node_cart
node_server -->|"routes orders"| node_orders
node_server -->|"routes quiz"| node_quiz
node_server -->|"routes reviews"| node_reviews
node_server -->|"routes chat"| node_chat
node_server -->|"routes admin"| node_adminops
node_catalog -->|"reads and updates"| node_productmodel
node_catalog -->|"indexes products"| node_vector
node_cart -->|"reads and writes"| node_mongo
node_cart -->|"reads product"| node_productmodel
node_orders -->|"creates and updates"| node_ordermodel
node_orders -->|"reads and clears cart"| node_mongo
node_orders -->|"adjusts stock"| node_productmodel
node_orders -->|"creates payment"| node_razorpay
node_reviews -->|"checks delivery"| node_ordermodel
node_reviews -->|"updates rating"| node_productmodel
node_reviews -->|"stores reviews"| node_mongo
node_adminops -->|"manages users"| node_usermodel
node_adminops -->|"manages catalog"| node_productmodel
node_adminops -->|"reads orders"| node_ordermodel
node_quiz -->|"scores products"| node_productmodel
node_quiz -->|"reads profile"| node_usermodel
node_quiz -->|"stores results"| node_mongo
node_chat -->|"searches products"| node_vector
node_chat -->|"loads candidates"| node_productmodel
node_chat -->|"loads profile and history"| node_mongo

click node_webapp "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/App.jsx"
click node_authui "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/context/AuthContext.jsx"
click node_cartui "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/context/CartContext.jsx"
click node_productui "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/pages/HomePage.jsx"
click node_productcard "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/components/product/ProductCard.jsx"
click node_shopui "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/pages/shop/ProductDetailPage.jsx"
click node_quizui "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/pages/QuizPage.jsx"
click node_recommendui "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/pages/RecommendationsPage.jsx"
click node_checkoutui "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/pages/shop/CheckoutPage.jsx"
click node_chatui "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/components/chat/ChatBot.jsx"
click node_adminui "https://github.com/preethi-karuna06/thoori-cosmetics/tree/main/frontend/src/pages/admin"
click node_apiclient "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/services/api.js"
click node_server "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/server.js"
click node_auth "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/auth.controller.js"
click node_guard "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/middleware/auth.middleware.js"
click node_catalog "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/product.controller.js"
click node_cart "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/cart.controller.js"
click node_orders "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/order.controller.js"
click node_reviews "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/review.controller.js"
click node_adminops "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/admin.controller.js"
click node_quiz "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/quiz.controller.js"
click node_chat "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/chat.controller.js"
click node_vector "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/services/vector.service.js"
click node_mongo "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/models/index.js"
click node_productmodel "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/models/Product.js"
click node_ordermodel "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/models/Order.js"
click node_usermodel "https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/models/User.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapp,node_authui,node_cartui,node_productui,node_productcard,node_shopui,node_quizui,node_recommendui,node_checkoutui,node_chatui,node_adminui toneBlue
class node_apiclient,node_server,node_auth,node_guard toneAmber
class node_catalog,node_cart,node_orders,node_reviews,node_adminops toneMint
class node_quiz,node_chat,node_vector toneRose
class node_mongo,node_productmodel,node_ordermodel,node_usermodel,node_qdrant,node_gemini,node_llm,node_razorpay,node_cloudinary,node_customer,node_admin toneIndigo
```

## Components

### Customer web app

- [Web app routes](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth state](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Cart state](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/context/CartContext.jsx): `frontend/src/context/CartContext.jsx`
- [Product browsing](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/pages/HomePage.jsx): `frontend/src/pages/HomePage.jsx`
- [Product card](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/components/product/ProductCard.jsx): `frontend/src/components/product/ProductCard.jsx`
- [Shop and detail](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/pages/shop/ProductDetailPage.jsx): `frontend/src/pages/shop/ProductDetailPage.jsx`
- [Skin quiz](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/pages/QuizPage.jsx): `frontend/src/pages/QuizPage.jsx`
- [Recommendations](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/pages/RecommendationsPage.jsx): `frontend/src/pages/RecommendationsPage.jsx`
- [Checkout and orders](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/pages/shop/CheckoutPage.jsx): `frontend/src/pages/shop/CheckoutPage.jsx`
- [Chat experience](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/components/chat/ChatBot.jsx): `frontend/src/components/chat/ChatBot.jsx`
- [Admin console](https://github.com/preethi-karuna06/thoori-cosmetics/tree/main/frontend/src/pages/admin): `frontend/src/pages/admin`

### API and identity

- [API client](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Express API](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/server.js): `backend/server.js`
- [Authentication](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/auth.controller.js): `backend/controllers/auth.controller.js`
- [JWT access control](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/middleware/auth.middleware.js): `backend/middleware/auth.middleware.js`

### Commerce domains

- [Product catalog](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/product.controller.js): `backend/controllers/product.controller.js`
- [Cart and wishlist](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/cart.controller.js): `backend/controllers/cart.controller.js`
- [Order and payment](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/order.controller.js): `backend/controllers/order.controller.js`
- [Reviews](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/review.controller.js): `backend/controllers/review.controller.js`
- [Admin operations](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/admin.controller.js): `backend/controllers/admin.controller.js`

### Skincare AI

- [Quiz scoring](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/quiz.controller.js): `backend/controllers/quiz.controller.js`
- [RAG chatbot](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/controllers/chat.controller.js): `backend/controllers/chat.controller.js`
- [Vector retrieval](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/services/vector.service.js): `backend/services/vector.service.js`

### Persistence and integrations

- [MongoDB models](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/models/index.js): `backend/models/index.js`
- [Product model](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/models/Product.js): `backend/models/Product.js`
- [Order model](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/models/Order.js): `backend/models/Order.js`
- [User model](https://github.com/preethi-karuna06/thoori-cosmetics/blob/main/backend/models/User.js): `backend/models/User.js`
- **Qdrant**
- **Gemini embeddings**
- **Chat LLM**
- **Razorpay**
- **Cloudinary**

### Other components

- **Customer**
- **Administrator**

## Connections

- Customer → Web app routes: uses
- Administrator → Web app routes: uses
- Web app routes → Product browsing: routes to (evidence: `frontend/src/App.jsx`)
- Web app routes → Shop and detail: routes to (evidence: `frontend/src/App.jsx`)
- Web app routes → Skin quiz: routes to (evidence: `frontend/src/App.jsx`)
- Web app routes → Checkout and orders: routes to (evidence: `frontend/src/App.jsx`)
- Web app routes → Admin console: routes to (evidence: `frontend/src/App.jsx`)
- Web app routes → Auth state: checks access (evidence: `frontend/src/App.jsx`)
- Product browsing → Product card: renders (evidence: `frontend/src/pages/HomePage.jsx`)
- Product browsing → API client: requests catalog (evidence: `frontend/src/pages/HomePage.jsx`)
- Shop and detail → API client: requests product (evidence: `frontend/src/pages/shop/ProductDetailPage.jsx`)
- Shop and detail → Cart state: updates cart (evidence: `frontend/src/pages/shop/ProductDetailPage.jsx`)
- Auth state → API client: authenticates via (evidence: `frontend/src/context/AuthContext.jsx`)
- Cart state → API client: requests cart (evidence: `frontend/src/context/CartContext.jsx`)
- Skin quiz → API client: submits quiz
- Recommendations → API client: fetches results
- Checkout and orders → API client: submits order
- Chat experience → API client: sends messages
- Admin console → API client: requests admin data (evidence: `frontend/src/pages/admin/AdminReviews.jsx`)
- API client → Express API: calls API
- Express API → Authentication: routes auth (evidence: `backend/server.js`)
- Express API → Product catalog: routes products (evidence: `backend/server.js`)
- Express API → Cart and wishlist: routes cart (evidence: `backend/server.js`)
- Express API → Order and payment: routes orders (evidence: `backend/server.js`)
- Express API → Quiz scoring: routes quiz (evidence: `backend/server.js`)
- Express API → Reviews: routes reviews (evidence: `backend/server.js`)
- Express API → RAG chatbot: routes chat (evidence: `backend/server.js`)
- Express API → Admin operations: routes admin (evidence: `backend/server.js`)
- Product catalog → Product model: reads and updates (evidence: `backend/controllers/product.controller.js`)
- Product catalog → Vector retrieval: indexes products (evidence: `backend/controllers/product.controller.js`)
- Cart and wishlist → MongoDB models: reads and writes (evidence: `backend/controllers/cart.controller.js`)
- Cart and wishlist → Product model: reads product (evidence: `backend/controllers/cart.controller.js`)
- Order and payment → Order model: creates and updates (evidence: `backend/controllers/order.controller.js`)
- Order and payment → MongoDB models: reads and clears cart (evidence: `backend/controllers/order.controller.js`)
- Order and payment → Product model: adjusts stock (evidence: `backend/controllers/order.controller.js`)
- Order and payment → Razorpay: creates payment (evidence: `backend/controllers/order.controller.js`)
- Reviews → Order model: checks delivery (evidence: `backend/controllers/review.controller.js`)
- Reviews → Product model: updates rating (evidence: `backend/controllers/review.controller.js`)
- Reviews → MongoDB models: stores reviews (evidence: `backend/controllers/review.controller.js`)
- Admin operations → User model: manages users (evidence: `backend/controllers/admin.controller.js`)
- Admin operations → Product model: manages catalog (evidence: `backend/controllers/admin.controller.js`)
- Admin operations → Order model: reads orders (evidence: `backend/controllers/admin.controller.js`)
- Quiz scoring → Product model: scores products (evidence: `backend/controllers/quiz.controller.js`)
- Quiz scoring → User model: reads profile (evidence: `backend/controllers/quiz.controller.js`)
- Quiz scoring → MongoDB models: stores results (evidence: `backend/models/index.js`)
- RAG chatbot → Vector retrieval: searches products (evidence: `backend/controllers/chat.controller.js`)
- RAG chatbot → Product model: loads candidates (evidence: `backend/controllers/chat.controller.js`)
- RAG chatbot → MongoDB models: loads profile and history (evidence: `backend/controllers/chat.controller.js`)
