# guneshsiripuram/swara architecture

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

- Interactive diagram: https://gitdiagram.com/guneshsiripuram/swara
- Repository: https://github.com/guneshsiripuram/swara

## Overview

SwaRa is a jewellery and saree storefront with customer accounts, checkout, payments, and administrative product and site-asset management. The main customer journey is browsing or searching the catalogue, preparing a cart, validating checkout details and totals, creating an order, then paying through Razorpay; account pages also expose orders, addresses, and wishlists. The graph groups these product areas and the shared persistence/authentication layer. The README is only the Next.js starter template, and sampled excerpts do not establish every UI-to-route connection, so uncertain wiring is omitted.

Main entry points: [`src/lib/db/index.ts`](https://github.com/guneshsiripuram/swara/blob/master/src/lib/db/index.ts) (Application database), [`src/app/api/user/addresses/route.ts`](https://github.com/guneshsiripuram/swara/blob/master/src/app/api/user/addresses/route.ts) (Address management), [`src/app/checkout/CheckoutPageClient.tsx`](https://github.com/guneshsiripuram/swara/blob/master/src/app/checkout/CheckoutPageClient.tsx) (Checkout), [`src/app/api/orders/route.ts`](https://github.com/guneshsiripuram/swara/blob/master/src/app/api/orders/route.ts) (Order handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront and catalogue"]
  node_storefront_ui["Storefront pages<br/>[page.tsx]"]
  node_collection_ui["Collections<br/>[CollectionPage.tsx]"]
  node_product_ui["Product detail<br/>[page.tsx]"]
  node_search_ui["Product search"]
  node_catalog_api["Catalogue API<br/>[route.ts]"]
  node_catalog_service["Catalogue service<br/>[server.ts]"]
end

subgraph group_customer["Customer account"]
  node_account_ui["Account pages<br/>[page.tsx]"]
  node_auth_api["Authentication API<br/>[route.ts]"]
  node_addresses_api["Address management<br/>[route.ts]"]
  node_cart_api["Cart API<br/>[route.ts]"]
  node_wishlist_api["Wishlist API<br/>[route.ts]"]
end

subgraph group_commerce["Checkout and orders"]
  node_cart_ui["Cart<br/>[CartPageClient.tsx]"]
  node_checkout_ui["Checkout"]
  node_checkout_validate["Checkout validation<br/>[route.ts]"]
  node_orders_api["Order handling<br/>[route.ts]"]
  node_payment_api["Order payment<br/>[route.ts]"]
  node_payment_webhook["Payment webhook<br/>[route.ts]"]
end

subgraph group_admin["Store administration"]
  node_admin_ui["Admin catalogue<br/>[page.tsx]"]
  node_admin_products_api["Product administration<br/>[route.ts]"]
  node_site_assets_api["Site asset management<br/>[route.ts]"]
end

subgraph group_platform["Shared services"]
  node_contact_api["Contact enquiries<br/>[route.ts]"]
  node_email_service["Email delivery<br/>[index.ts]"]
  node_database[("Application database<br/>[index.ts]")]
  node_transactions["Transaction layer<br/>[transaction.ts]"]
  node_auth_service["Session and roles<br/>[helpers.ts]"]
end

node_shopper(("Shopper"))
node_razorpay["Razorpay"]
node_blob_storage[("Image blob storage")]

node_shopper -->|"browses"| node_storefront_ui
node_shopper -->|"browses"| node_collection_ui
node_shopper -->|"searches"| node_search_ui
node_search_ui -->|"requests results"| node_catalog_api
node_catalog_api -->|"queries catalogue"| node_catalog_service
node_catalog_service -->|"reads products"| node_database
node_shopper -->|"manages cart"| node_cart_ui
node_shopper -->|"checks out"| node_checkout_ui
node_checkout_ui -->|"validates cart"| node_checkout_validate
node_checkout_validate -->|"reads products"| node_database
node_checkout_ui -->|"creates order"| node_orders_api
node_orders_api -->|"reads and writes orders"| node_database
node_orders_api -->|"runs atomic work"| node_transactions
node_transactions -->|"executes transaction"| node_database
node_shopper -->|"initiates payment"| node_payment_api
node_payment_api -->|"creates or fetches payment"| node_razorpay
node_payment_api -->|"claims order"| node_database
node_razorpay -->|"sends events"| node_payment_webhook
node_payment_webhook -->|"updates payment status"| node_database
node_shopper -->|"views account"| node_account_ui
node_account_ui -->|"checks session"| node_auth_api
node_auth_api -->|"resolves identity"| node_auth_service
node_shopper -->|"manages addresses"| node_addresses_api
node_addresses_api -->|"resolves identity"| node_auth_service
node_addresses_api -->|"reads and writes addresses"| node_database
node_cart_api -->|"reads and writes cart"| node_database
node_wishlist_api -->|"reads and writes wishlist"| node_database
node_admin_ui -->|"manages products"| node_admin_products_api
node_admin_products_api -->|"reads and writes products"| node_database
node_admin_ui -->|"manages assets"| node_site_assets_api
node_site_assets_api -->|"reads and writes assets"| node_database
node_site_assets_api -->|"deletes unused images"| node_blob_storage
node_shopper -->|"submits enquiry"| node_contact_api
node_contact_api -->|"sends enquiry"| node_email_service

click node_storefront_ui "https://github.com/guneshsiripuram/swara/blob/master/src/app/page.tsx"
click node_collection_ui "https://github.com/guneshsiripuram/swara/blob/master/src/components/product/CollectionPage.tsx"
click node_product_ui "https://github.com/guneshsiripuram/swara/blob/master/src/app/product/%5Bslug%5D/page.tsx"
click node_search_ui "https://github.com/guneshsiripuram/swara/blob/master/src/app/search/SearchPageClient.tsx"
click node_catalog_api "https://github.com/guneshsiripuram/swara/blob/master/src/app/api/catalog/search/route.ts"
click node_catalog_service "https://github.com/guneshsiripuram/swara/blob/master/src/lib/catalog/server.ts"
click node_cart_ui "https://github.com/guneshsiripuram/swara/blob/master/src/app/cart/CartPageClient.tsx"
click node_checkout_ui "https://github.com/guneshsiripuram/swara/blob/master/src/app/checkout/CheckoutPageClient.tsx"
click node_checkout_validate "https://github.com/guneshsiripuram/swara/blob/master/src/app/api/checkout/validate/route.ts"
click node_orders_api "https://github.com/guneshsiripuram/swara/blob/master/src/app/api/orders/route.ts"
click node_payment_api "https://github.com/guneshsiripuram/swara/blob/master/src/app/api/orders/%5Bid%5D/pay/route.ts"
click node_payment_webhook "https://github.com/guneshsiripuram/swara/blob/master/src/app/api/webhooks/razorpay/route.ts"
click node_account_ui "https://github.com/guneshsiripuram/swara/blob/master/src/app/account/page.tsx"
click node_auth_api "https://github.com/guneshsiripuram/swara/blob/master/src/app/api/auth/me/route.ts"
click node_addresses_api "https://github.com/guneshsiripuram/swara/blob/master/src/app/api/user/addresses/route.ts"
click node_cart_api "https://github.com/guneshsiripuram/swara/blob/master/src/app/api/user/cart/route.ts"
click node_wishlist_api "https://github.com/guneshsiripuram/swara/blob/master/src/app/api/user/wishlist/route.ts"
click node_admin_ui "https://github.com/guneshsiripuram/swara/blob/master/src/app/admin/catalogue/page.tsx"
click node_admin_products_api "https://github.com/guneshsiripuram/swara/blob/master/src/app/api/admin/catalogue/products/route.ts"
click node_site_assets_api "https://github.com/guneshsiripuram/swara/blob/master/src/app/api/admin/site-assets/route.ts"
click node_contact_api "https://github.com/guneshsiripuram/swara/blob/master/src/app/api/contact/route.ts"
click node_email_service "https://github.com/guneshsiripuram/swara/blob/master/src/lib/email/index.ts"
click node_database "https://github.com/guneshsiripuram/swara/blob/master/src/lib/db/index.ts"
click node_transactions "https://github.com/guneshsiripuram/swara/blob/master/src/lib/db/transaction.ts"
click node_auth_service "https://github.com/guneshsiripuram/swara/blob/master/src/lib/auth/helpers.ts"

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_storefront_ui,node_collection_ui,node_product_ui,node_search_ui,node_catalog_api,node_catalog_service toneBlue
class node_account_ui,node_auth_api,node_addresses_api,node_cart_api,node_wishlist_api,node_blob_storage toneAmber
class node_cart_ui,node_checkout_ui,node_checkout_validate,node_orders_api,node_payment_api,node_payment_webhook toneMint
class node_admin_ui,node_admin_products_api,node_site_assets_api toneRose
class node_contact_api,node_email_service,node_database,node_transactions,node_auth_service,node_shopper,node_razorpay toneIndigo
```

## Components

### Storefront and catalogue

- [Storefront pages](https://github.com/guneshsiripuram/swara/blob/master/src/app/page.tsx): `src/app/page.tsx`
- [Collections](https://github.com/guneshsiripuram/swara/blob/master/src/components/product/CollectionPage.tsx): `src/components/product/CollectionPage.tsx`
- [Product detail](https://github.com/guneshsiripuram/swara/blob/master/src/app/product/%5Bslug%5D/page.tsx): `src/app/product/[slug]/page.tsx`
- [Product search](https://github.com/guneshsiripuram/swara/blob/master/src/app/search/SearchPageClient.tsx): `src/app/search/SearchPageClient.tsx`
- [Catalogue API](https://github.com/guneshsiripuram/swara/blob/master/src/app/api/catalog/search/route.ts): `src/app/api/catalog/search/route.ts`
- [Catalogue service](https://github.com/guneshsiripuram/swara/blob/master/src/lib/catalog/server.ts): `src/lib/catalog/server.ts`

### Customer account

- [Account pages](https://github.com/guneshsiripuram/swara/blob/master/src/app/account/page.tsx): `src/app/account/page.tsx`
- [Authentication API](https://github.com/guneshsiripuram/swara/blob/master/src/app/api/auth/me/route.ts): `src/app/api/auth/me/route.ts`
- [Address management](https://github.com/guneshsiripuram/swara/blob/master/src/app/api/user/addresses/route.ts): `src/app/api/user/addresses/route.ts`
- [Cart API](https://github.com/guneshsiripuram/swara/blob/master/src/app/api/user/cart/route.ts): `src/app/api/user/cart/route.ts`
- [Wishlist API](https://github.com/guneshsiripuram/swara/blob/master/src/app/api/user/wishlist/route.ts): `src/app/api/user/wishlist/route.ts`

### Checkout and orders

- [Cart](https://github.com/guneshsiripuram/swara/blob/master/src/app/cart/CartPageClient.tsx): `src/app/cart/CartPageClient.tsx`
- [Checkout](https://github.com/guneshsiripuram/swara/blob/master/src/app/checkout/CheckoutPageClient.tsx): `src/app/checkout/CheckoutPageClient.tsx`
- [Checkout validation](https://github.com/guneshsiripuram/swara/blob/master/src/app/api/checkout/validate/route.ts): `src/app/api/checkout/validate/route.ts`
- [Order handling](https://github.com/guneshsiripuram/swara/blob/master/src/app/api/orders/route.ts): `src/app/api/orders/route.ts`
- [Order payment](https://github.com/guneshsiripuram/swara/blob/master/src/app/api/orders/%5Bid%5D/pay/route.ts): `src/app/api/orders/[id]/pay/route.ts`
- [Payment webhook](https://github.com/guneshsiripuram/swara/blob/master/src/app/api/webhooks/razorpay/route.ts): `src/app/api/webhooks/razorpay/route.ts`

### Store administration

- [Admin catalogue](https://github.com/guneshsiripuram/swara/blob/master/src/app/admin/catalogue/page.tsx): `src/app/admin/catalogue/page.tsx`
- [Product administration](https://github.com/guneshsiripuram/swara/blob/master/src/app/api/admin/catalogue/products/route.ts): `src/app/api/admin/catalogue/products/route.ts`
- [Site asset management](https://github.com/guneshsiripuram/swara/blob/master/src/app/api/admin/site-assets/route.ts): `src/app/api/admin/site-assets/route.ts`

### Shared services

- [Contact enquiries](https://github.com/guneshsiripuram/swara/blob/master/src/app/api/contact/route.ts): `src/app/api/contact/route.ts`
- [Email delivery](https://github.com/guneshsiripuram/swara/blob/master/src/lib/email/index.ts): `src/lib/email/index.ts`
- [Application database](https://github.com/guneshsiripuram/swara/blob/master/src/lib/db/index.ts): `src/lib/db/index.ts`
- [Transaction layer](https://github.com/guneshsiripuram/swara/blob/master/src/lib/db/transaction.ts): `src/lib/db/transaction.ts`
- [Session and roles](https://github.com/guneshsiripuram/swara/blob/master/src/lib/auth/helpers.ts): `src/lib/auth/helpers.ts`

### Other components

- **Shopper**
- **Razorpay**
- **Image blob storage**

## Connections

- Shopper → Storefront pages: browses
- Shopper → Collections: browses
- Shopper → Product search: searches
- Product search → Catalogue API: requests results
- Catalogue API → Catalogue service: queries catalogue
- Catalogue service → Application database: reads products
- Shopper → Cart: manages cart
- Shopper → Checkout: checks out
- Checkout → Checkout validation: validates cart
- Checkout validation → Application database: reads products
- Checkout → Order handling: creates order
- Order handling → Application database: reads and writes orders
- Order handling → Transaction layer: runs atomic work
- Transaction layer → Application database: executes transaction
- Shopper → Order payment: initiates payment
- Order payment → Razorpay: creates or fetches payment
- Order payment → Application database: claims order
- Razorpay → Payment webhook: sends events
- Payment webhook → Application database: updates payment status
- Shopper → Account pages: views account
- Account pages → Authentication API: checks session
- Authentication API → Session and roles: resolves identity
- Shopper → Address management: manages addresses
- Address management → Session and roles: resolves identity
- Address management → Application database: reads and writes addresses
- Cart API → Application database: reads and writes cart
- Wishlist API → Application database: reads and writes wishlist
- Admin catalogue → Product administration: manages products
- Product administration → Application database: reads and writes products
- Admin catalogue → Site asset management: manages assets
- Site asset management → Application database: reads and writes assets
- Site asset management → Image blob storage: deletes unused images
- Shopper → Contact enquiries: submits enquiry
- Contact enquiries → Email delivery: sends enquiry
