# shelakeemahesh/swiftcart-backend architecture

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

- Interactive diagram: https://gitdiagram.com/shelakeemahesh/swiftcart-backend
- Repository: https://github.com/shelakeemahesh/swiftcart-backend

## Overview

SwiftCart is a Spring Boot e-commerce backend. Its main workflow is a client request passing through security and REST APIs into domain services, which coordinate catalog/cart/order/payment work and persistence. The README also documents search fallback, Kafka live activity, OAuth/RBAC, AI support, and sentiment analysis. Several service-to-service details and feature implementations are unsampled, so those branches are shown only where documented; source-level call edges are limited to indexed evidence.

Main entry points: [`src/main/java/com/swiftcart/config/SecurityConfig.java`](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/config/SecurityConfig.java) (Security and RBAC), [`src/main/java/com/swiftcart/service/PaymentService.java`](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/PaymentService.java) (Payment processing), [`src/main/java/com/swiftcart/service/AuthService.java`](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/AuthService.java) (Account service), [`src/main/java/com/swiftcart/service/ProductService.java`](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/ProductService.java) (Catalog management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_security["Security and RBAC"]
  node_auth["Authentication"]
  node_oauth["OAuth2 identity"]
  node_commerce_api["Commerce APIs"]
  node_catalog_api["Catalog APIs"]
  node_reviews_api["Reviews API"]
end

subgraph group_commerce["Commerce workflows"]
  node_auth_service["Account service<br/>[AuthService.java]"]
  node_catalog["Catalog management"]
  node_cart["Cart and pricing<br/>[CartService.java]"]
  node_orders["Order lifecycle<br/>[OrderService.java]"]
  node_payments["Payment processing"]
  node_reviews["Reviews and sentiment"]
end

subgraph group_discovery["Discovery and intelligence"]
  node_search["Catalog search<br/>[SearchService.java]"]
  node_chatbot["AI shopping assistant"]
  node_rag["Product RAG"]
end

subgraph group_platform["Data and events"]
  node_mysql[("Relational data")]
  node_redis[("Redis cache")]
  node_elasticsearch[("Elasticsearch")]
  node_kafka["Kafka events"]
end

node_client(("Web/mobile client"))
node_razorpay["Razorpay"]
node_llm["LLM and embeddings"]
node_sms_email["SMS and email"]

node_client -->|"sends requests"| node_security
node_security -->|"routes requests"| node_auth
node_security -->|"routes requests"| node_commerce_api
node_security -->|"routes requests"| node_catalog_api
node_security -->|"routes requests"| node_reviews_api
node_auth -->|"delegates to"| node_auth_service
node_oauth -->|"persists identity"| node_mysql
node_commerce_api -->|"invokes"| node_orders
node_catalog_api -->|"delegates to"| node_catalog
node_reviews_api -.->|"uses analytics"| node_reviews
node_auth_service -->|"reads and writes"| node_mysql
node_auth_service -->|"sends notifications"| node_sms_email
node_catalog -->|"reads and writes"| node_mysql
node_catalog -->|"indexes products"| node_search
node_cart -.->|"reads and writes"| node_mysql
node_orders -->|"persists orders"| node_mysql
node_orders -->|"publishes activity"| node_kafka
node_payments -->|"processes payments"| node_razorpay
node_payments -->|"guards idempotency"| node_redis
node_payments -->|"publishes order events"| node_kafka
node_reviews -.->|"reads reviews"| node_mysql
node_search -->|"searches catalog"| node_elasticsearch
node_search -->|"fallback queries"| node_mysql
node_chatbot -->|"requests recommendations"| node_rag
node_rag -.->|"uses embeddings"| node_llm
node_rag -->|"retrieves catalog"| node_mysql

click node_security "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/config/SecurityConfig.java"
click node_auth "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/controller/AuthController.java"
click node_oauth "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/security/oauth2/CustomOAuth2UserService.java"
click node_commerce_api "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/controller/OrderController.java"
click node_catalog_api "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/controller/ProductController.java"
click node_reviews_api "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/controller/ReviewController.java"
click node_auth_service "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/AuthService.java"
click node_catalog "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/ProductService.java"
click node_cart "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/CartService.java"
click node_orders "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/OrderService.java"
click node_payments "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/PaymentService.java"
click node_reviews "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/sentiment/SentimentAnalyticsService.java"
click node_search "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/SearchService.java"
click node_chatbot "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/ai/AiChatbotService.java"
click node_rag "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/ai/ProductRagService.java"
click node_kafka "https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/kafka/producer/OrderEventProducer.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_security,node_auth,node_oauth,node_commerce_api,node_catalog_api,node_reviews_api,node_client toneBlue
class node_auth_service,node_catalog,node_cart,node_orders,node_payments,node_reviews toneAmber
class node_search,node_chatbot,node_rag toneMint
class node_mysql,node_redis,node_elasticsearch,node_kafka toneRose
class node_razorpay,node_llm,node_sms_email toneIndigo
```

## Components

### API and identity

- [Security and RBAC](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/config/SecurityConfig.java): `src/main/java/com/swiftcart/config/SecurityConfig.java`
- [Authentication](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/controller/AuthController.java): `src/main/java/com/swiftcart/controller/AuthController.java`
- [OAuth2 identity](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/security/oauth2/CustomOAuth2UserService.java): `src/main/java/com/swiftcart/security/oauth2/CustomOAuth2UserService.java`
- [Commerce APIs](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/controller/OrderController.java): `src/main/java/com/swiftcart/controller/OrderController.java`
- [Catalog APIs](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/controller/ProductController.java): `src/main/java/com/swiftcart/controller/ProductController.java`
- [Reviews API](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/controller/ReviewController.java): `src/main/java/com/swiftcart/controller/ReviewController.java`

### Commerce workflows

- [Account service](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/AuthService.java): `src/main/java/com/swiftcart/service/AuthService.java`
- [Catalog management](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/ProductService.java): `src/main/java/com/swiftcart/service/ProductService.java`
- [Cart and pricing](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/CartService.java): `src/main/java/com/swiftcart/service/CartService.java`
- [Order lifecycle](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/OrderService.java): `src/main/java/com/swiftcart/service/OrderService.java`
- [Payment processing](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/PaymentService.java): `src/main/java/com/swiftcart/service/PaymentService.java`
- [Reviews and sentiment](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/sentiment/SentimentAnalyticsService.java): `src/main/java/com/swiftcart/service/sentiment/SentimentAnalyticsService.java`

### Discovery and intelligence

- [Catalog search](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/SearchService.java): `src/main/java/com/swiftcart/service/SearchService.java`
- [AI shopping assistant](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/ai/AiChatbotService.java): `src/main/java/com/swiftcart/service/ai/AiChatbotService.java`
- [Product RAG](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/service/ai/ProductRagService.java): `src/main/java/com/swiftcart/service/ai/ProductRagService.java`

### Data and events

- **Relational data**
- **Redis cache**
- **Elasticsearch**
- [Kafka events](https://github.com/shelakeemahesh/swiftcart-backend/blob/main/src/main/java/com/swiftcart/kafka/producer/OrderEventProducer.java): `src/main/java/com/swiftcart/kafka/producer/OrderEventProducer.java`

### Other components

- **Web/mobile client**
- **Razorpay**
- **LLM and embeddings**
- **SMS and email**

## Connections

- Web/mobile client → Security and RBAC: sends requests (evidence: `README.md`)
- Security and RBAC → Authentication: routes requests (evidence: `README.md`)
- Security and RBAC → Commerce APIs: routes requests (evidence: `README.md`)
- Security and RBAC → Catalog APIs: routes requests (evidence: `README.md`)
- Security and RBAC → Reviews API: routes requests (evidence: `README.md`)
- Authentication → Account service: delegates to (evidence: `README.md`)
- OAuth2 identity → Relational data: persists identity (evidence: `src/main/java/com/swiftcart/security/oauth2/CustomOAuth2UserService.java`)
- Commerce APIs → Order lifecycle: invokes (evidence: `src/main/java/com/swiftcart/controller/OrderController.java`)
- Catalog APIs → Catalog management: delegates to (evidence: `README.md`)
- Reviews API → Reviews and sentiment: uses analytics (evidence: `src/main/java/com/swiftcart/controller/ReviewController.java`)
- Account service → Relational data: reads and writes (evidence: `src/main/java/com/swiftcart/service/AuthService.java`)
- Account service → SMS and email: sends notifications (evidence: `src/main/java/com/swiftcart/service/AuthService.java`)
- Catalog management → Relational data: reads and writes (evidence: `src/main/java/com/swiftcart/service/ProductService.java`)
- Catalog management → Catalog search: indexes products (evidence: `src/main/java/com/swiftcart/service/ProductService.java`)
- Cart and pricing → Relational data: reads and writes (evidence: `README.md`)
- Order lifecycle → Relational data: persists orders (evidence: `src/main/java/com/swiftcart/service/OrderService.java`)
- Order lifecycle → Kafka events: publishes activity (evidence: `README.md`)
- Payment processing → Razorpay: processes payments (evidence: `README.md`)
- Payment processing → Redis cache: guards idempotency (evidence: `README.md`)
- Payment processing → Kafka events: publishes order events (evidence: `src/main/java/com/swiftcart/service/PaymentService.java`)
- Reviews and sentiment → Relational data: reads reviews (evidence: `README.md`)
- Catalog search → Elasticsearch: searches catalog (evidence: `README.md`)
- Catalog search → Relational data: fallback queries (evidence: `README.md`)
- AI shopping assistant → Product RAG: requests recommendations (evidence: `src/main/java/com/swiftcart/service/ai/AiChatbotService.java`)
- Product RAG → LLM and embeddings: uses embeddings (evidence: `README.md`)
- Product RAG → Relational data: retrieves catalog (evidence: `src/main/java/com/swiftcart/service/ai/ProductRagService.java`)
