# shanjay-k/shan-mart architecture

> Architecture diagram of the GitHub repository shanjay-k/shan-mart, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shanjay-k/shan-mart
- Repository: https://github.com/shanjay-k/shan-mart

## Overview

SHAN MART is a Servlet-based marketplace for buyers, sellers, and admins. Users browse/search listings, manage carts and wishlists, check out, track orders, and review products; sellers manage listings and incoming orders, while admins audit and moderate. Controllers handle HTTP workflows, with services for authentication and commerce rules and DAOs for persistence. The README documents additional dashboard and profile capabilities. Source excerpts show service-to-DAO and chat-provider calls; several controller routes and broader wiring are documented but their implementations were not sampled.

Main entry points: [`src/main/java/com/shanjay/mart/service/ShopService.java`](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/service/ShopService.java) (Commerce rules), [`src/main/java/com/shanjay/mart/service/chat/ChatService.java`](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/service/chat/ChatService.java) (Chat handling), [`src/main/java/com/shanjay/mart/controller/ShopServlet.java`](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/ShopServlet.java) (Catalog and listings), [`src/main/java/com/shanjay/mart/service/AuthService.java`](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/service/AuthService.java) (Authentication rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web workflows"]
  node_encoding["Request encoding"]
  node_authfilter["Access control<br/>[AuthFilter.java]"]
  node_catalog["Catalog and listings<br/>[ShopServlet.java]"]
  node_product["Product details"]
  node_cart["Cart workflow<br/>[CartServlet.java]"]
  node_checkout["Checkout"]
  node_orders["Order tracking<br/>[OrdersServlet.java]"]
  node_reviews["Product reviews<br/>[ReviewServlet.java]"]
  node_wishlist["Wishlist portal"]
  node_dashboard["Role dashboards"]
  node_profile["Account profile"]
end

subgraph group_commerce["Commerce services"]
  node_shopservice["Commerce rules<br/>[ShopService.java]"]
end

subgraph group_identity["Identity and access"]
  node_authroutes["Login and registration<br/>[LoginServlet.java]"]
  node_logout["Logout<br/>[LogoutServlet.java]"]
  node_authservice["Authentication rules<br/>[AuthService.java]"]
end

subgraph group_persistence["Marketplace persistence"]
  node_userdao["User records<br/>[UserDAO.java]"]
  node_productdao["Product records<br/>[ProductDAO.java]"]
  node_cartdao["Cart records<br/>[CartDAO.java]"]
  node_orderdao["Order records<br/>[OrderDAO.java]"]
  node_reviewdao["Review records<br/>[ReviewDAO.java]"]
  node_wishlistdao["Wishlist records<br/>[WishlistDAO.java]"]
  node_database[("H2 marketplace data")]
end

subgraph group_assistant["AI assistant"]
  node_chatservlet["Chat endpoint<br/>[ChatServlet.java]"]
  node_chatservice["Chat handling<br/>[ChatService.java]"]
  node_gemini["Gemini provider"]
  node_mock["Mock fallback"]
end

node_browser(("Marketplace users"))
node_ai(("Gemini service"))

node_browser -->|"sends HTTP"| node_encoding
node_encoding -.->|"passes requests"| node_authfilter
node_authfilter -.->|"routes requests"| node_catalog
node_browser -.->|"browses listings"| node_catalog
node_browser -.->|"opens product"| node_product
node_browser -.->|"manages cart"| node_cart
node_browser -->|"submits order"| node_checkout
node_checkout -->|"calls checkout"| node_shopservice
node_shopservice -->|"reads cart"| node_cartdao
node_shopservice -->|"creates order"| node_orderdao
node_shopservice -->|"clears cart"| node_cartdao
node_browser -.->|"tracks orders"| node_orders
node_browser -.->|"submits reviews"| node_reviews
node_browser -.->|"saves products"| node_wishlist
node_browser -.->|"views dashboard"| node_dashboard
node_browser -.->|"updates profile"| node_profile
node_browser -.->|"signs in"| node_authroutes
node_authroutes -.->|"authenticates"| node_authservice
node_authservice -->|"reads and writes"| node_userdao
node_browser -.->|"signs out"| node_logout
node_browser -.->|"asks assistant"| node_chatservlet
node_chatservlet -->|"processes message"| node_chatservice
node_chatservice -->|"queries primary"| node_gemini
node_chatservice -->|"falls back"| node_mock
node_gemini -.->|"sends prompt"| node_ai
node_catalog -.->|"searches listings"| node_productdao
node_product -.->|"uses commerce rules"| node_shopservice
node_cart -.->|"manages cart"| node_shopservice
node_wishlist -.->|"manages wishlist"| node_shopservice
node_reviews -.->|"validates review"| node_shopservice
node_dashboard -.->|"loads statistics"| node_shopservice
node_profile -.->|"updates account"| node_authservice
node_shopservice -->|"manages products"| node_productdao
node_shopservice -->|"manages wishlist"| node_wishlistdao
node_shopservice -->|"stores reviews"| node_reviewdao
node_cartdao -.->|"reads and writes"| node_database
node_orderdao -.->|"transacts orders"| node_database
node_productdao -.->|"reads and writes"| node_database
node_userdao -.->|"reads and writes"| node_database
node_reviewdao -.->|"reads and writes"| node_database
node_wishlistdao -.->|"reads and writes"| node_database

click node_encoding "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/filter/EncodingFilter.java"
click node_authfilter "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/filter/AuthFilter.java"
click node_catalog "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/ShopServlet.java"
click node_product "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/ProductServlet.java"
click node_cart "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/CartServlet.java"
click node_checkout "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/CheckoutServlet.java"
click node_orders "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/OrdersServlet.java"
click node_reviews "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/ReviewServlet.java"
click node_wishlist "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/WishlistServlet.java"
click node_dashboard "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/DashboardServlet.java"
click node_profile "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/ProfileServlet.java"
click node_authroutes "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/LoginServlet.java"
click node_logout "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/LogoutServlet.java"
click node_authservice "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/service/AuthService.java"
click node_shopservice "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/service/ShopService.java"
click node_userdao "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/dao/UserDAO.java"
click node_productdao "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/dao/ProductDAO.java"
click node_cartdao "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/dao/CartDAO.java"
click node_orderdao "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/dao/OrderDAO.java"
click node_reviewdao "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/dao/ReviewDAO.java"
click node_wishlistdao "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/dao/WishlistDAO.java"
click node_chatservlet "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/ChatServlet.java"
click node_chatservice "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/service/chat/ChatService.java"
click node_gemini "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/service/chat/GeminiChatProvider.java"
click node_mock "https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/service/chat/MockChatProvider.java"

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_encoding,node_authfilter,node_catalog,node_product,node_cart,node_checkout,node_orders,node_reviews,node_wishlist,node_dashboard,node_profile,node_browser toneBlue
class node_shopservice toneAmber
class node_authroutes,node_logout,node_authservice toneMint
class node_userdao,node_productdao,node_cartdao,node_orderdao,node_reviewdao,node_wishlistdao,node_database toneRose
class node_chatservlet,node_chatservice,node_gemini,node_mock,node_ai toneIndigo
```

## Components

### Web workflows

- [Request encoding](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/filter/EncodingFilter.java): `src/main/java/com/shanjay/mart/filter/EncodingFilter.java`
- [Access control](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/filter/AuthFilter.java): `src/main/java/com/shanjay/mart/filter/AuthFilter.java`
- [Catalog and listings](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/ShopServlet.java): `src/main/java/com/shanjay/mart/controller/ShopServlet.java`
- [Product details](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/ProductServlet.java): `src/main/java/com/shanjay/mart/controller/ProductServlet.java`
- [Cart workflow](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/CartServlet.java): `src/main/java/com/shanjay/mart/controller/CartServlet.java`
- [Checkout](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/CheckoutServlet.java): `src/main/java/com/shanjay/mart/controller/CheckoutServlet.java`
- [Order tracking](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/OrdersServlet.java): `src/main/java/com/shanjay/mart/controller/OrdersServlet.java`
- [Product reviews](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/ReviewServlet.java): `src/main/java/com/shanjay/mart/controller/ReviewServlet.java`
- [Wishlist portal](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/WishlistServlet.java): `src/main/java/com/shanjay/mart/controller/WishlistServlet.java`
- [Role dashboards](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/DashboardServlet.java): `src/main/java/com/shanjay/mart/controller/DashboardServlet.java`
- [Account profile](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/ProfileServlet.java): `src/main/java/com/shanjay/mart/controller/ProfileServlet.java`

### Commerce services

- [Commerce rules](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/service/ShopService.java): `src/main/java/com/shanjay/mart/service/ShopService.java`

### Identity and access

- [Login and registration](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/LoginServlet.java): `src/main/java/com/shanjay/mart/controller/LoginServlet.java`
- [Logout](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/LogoutServlet.java): `src/main/java/com/shanjay/mart/controller/LogoutServlet.java`
- [Authentication rules](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/service/AuthService.java): `src/main/java/com/shanjay/mart/service/AuthService.java`

### Marketplace persistence

- [User records](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/dao/UserDAO.java): `src/main/java/com/shanjay/mart/dao/UserDAO.java`
- [Product records](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/dao/ProductDAO.java): `src/main/java/com/shanjay/mart/dao/ProductDAO.java`
- [Cart records](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/dao/CartDAO.java): `src/main/java/com/shanjay/mart/dao/CartDAO.java`
- [Order records](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/dao/OrderDAO.java): `src/main/java/com/shanjay/mart/dao/OrderDAO.java`
- [Review records](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/dao/ReviewDAO.java): `src/main/java/com/shanjay/mart/dao/ReviewDAO.java`
- [Wishlist records](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/dao/WishlistDAO.java): `src/main/java/com/shanjay/mart/dao/WishlistDAO.java`
- **H2 marketplace data**

### AI assistant

- [Chat endpoint](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/controller/ChatServlet.java): `src/main/java/com/shanjay/mart/controller/ChatServlet.java`
- [Chat handling](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/service/chat/ChatService.java): `src/main/java/com/shanjay/mart/service/chat/ChatService.java`
- [Gemini provider](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/service/chat/GeminiChatProvider.java): `src/main/java/com/shanjay/mart/service/chat/GeminiChatProvider.java`
- [Mock fallback](https://github.com/shanjay-k/shan-mart/blob/main/src/main/java/com/shanjay/mart/service/chat/MockChatProvider.java): `src/main/java/com/shanjay/mart/service/chat/MockChatProvider.java`

### Other components

- **Marketplace users**
- **Gemini service**

## Connections

- Marketplace users → Request encoding: sends HTTP
- Request encoding → Access control: passes requests
- Access control → Catalog and listings: routes requests
- Marketplace users → Catalog and listings: browses listings
- Marketplace users → Product details: opens product
- Marketplace users → Cart workflow: manages cart
- Marketplace users → Checkout: submits order
- Checkout → Commerce rules: calls checkout (evidence: `src/main/java/com/shanjay/mart/controller/CheckoutServlet.java`)
- Commerce rules → Cart records: reads cart (evidence: `src/main/java/com/shanjay/mart/service/ShopService.java`)
- Commerce rules → Order records: creates order (evidence: `src/main/java/com/shanjay/mart/service/ShopService.java`)
- Commerce rules → Cart records: clears cart (evidence: `src/main/java/com/shanjay/mart/service/ShopService.java`)
- Marketplace users → Order tracking: tracks orders
- Marketplace users → Product reviews: submits reviews
- Marketplace users → Wishlist portal: saves products
- Marketplace users → Role dashboards: views dashboard
- Marketplace users → Account profile: updates profile
- Marketplace users → Login and registration: signs in
- Login and registration → Authentication rules: authenticates (evidence: `src/main/java/com/shanjay/mart/service/AuthService.java`)
- Authentication rules → User records: reads and writes (evidence: `src/main/java/com/shanjay/mart/service/AuthService.java`)
- Marketplace users → Logout: signs out
- Marketplace users → Chat endpoint: asks assistant
- Chat endpoint → Chat handling: processes message (evidence: `src/main/java/com/shanjay/mart/controller/ChatServlet.java`)
- Chat handling → Gemini provider: queries primary (evidence: `src/main/java/com/shanjay/mart/service/chat/ChatService.java`)
- Chat handling → Mock fallback: falls back (evidence: `src/main/java/com/shanjay/mart/service/chat/ChatService.java`)
- Gemini provider → Gemini service: sends prompt
- Catalog and listings → Product records: searches listings (evidence: `src/main/java/com/shanjay/mart/controller/ShopServlet.java`)
- Product details → Commerce rules: uses commerce rules (evidence: `src/main/java/com/shanjay/mart/controller/ProductServlet.java`)
- Cart workflow → Commerce rules: manages cart (evidence: `src/main/java/com/shanjay/mart/controller/CartServlet.java`)
- Wishlist portal → Commerce rules: manages wishlist (evidence: `src/main/java/com/shanjay/mart/controller/WishlistServlet.java`)
- Product reviews → Commerce rules: validates review (evidence: `src/main/java/com/shanjay/mart/controller/ReviewServlet.java`)
- Role dashboards → Commerce rules: loads statistics (evidence: `src/main/java/com/shanjay/mart/controller/DashboardServlet.java`)
- Account profile → Authentication rules: updates account (evidence: `src/main/java/com/shanjay/mart/controller/ProfileServlet.java`)
- Commerce rules → Product records: manages products (evidence: `src/main/java/com/shanjay/mart/service/ShopService.java`)
- Commerce rules → Wishlist records: manages wishlist (evidence: `src/main/java/com/shanjay/mart/service/ShopService.java`)
- Commerce rules → Review records: stores reviews (evidence: `src/main/java/com/shanjay/mart/service/ShopService.java`)
- Cart records → H2 marketplace data: reads and writes
- Order records → H2 marketplace data: transacts orders
- Product records → H2 marketplace data: reads and writes
- User records → H2 marketplace data: reads and writes
- Review records → H2 marketplace data: reads and writes
- Wishlist records → H2 marketplace data: reads and writes
