# zrn2003/avyana-fashion-store-backend architecture

> Architecture diagram of the GitHub repository zrn2003/avyana-fashion-store-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/zrn2003/avyana-fashion-store-backend
- Repository: https://github.com/zrn2003/avyana-fashion-store-backend

## Overview

Avyana Craft is an e-commerce backend API. Customers authenticate, browse the catalog and store settings, place and track orders, and complete payment; admins manage catalog, fulfillment, settings, and media. The graph distinguishes route/controller dispatch from service-level work and includes the persistence and middleware layers. The README documents capabilities such as inventory-safe transactions, Razorpay verification, and Cloudflare R2 uploads; some implementation details are unsampled, so those relationships are shown only where documented or indexed.

Main entry points: [`src/index.ts`](https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/index.ts) (Express API), [`prisma/schema.prisma`](https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/prisma/schema.prisma) (PostgreSQL), [`src/modules/auth/auth.service.ts`](https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/modules/auth/auth.service.ts) (Auth Service), [`src/modules/orders`](https://github.com/zrn2003/avyana-fashion-store-backend/tree/main/src/modules/orders) (Order Lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["API Runtime"]
  node_api["Express API<br/>[index.ts]"]
  node_middleware["Request Middleware"]
  node_health["Health Probe<br/>[index.ts]"]
end

subgraph group_identity["Identity"]
  node_auth_routes["Auth Routes<br/>[auth.routes.ts]"]
  node_auth_controller["Auth Controller<br/>[auth.controller.ts]"]
  node_auth_service["Auth Service<br/>[auth.service.ts]"]
  node_auth_schema["Auth Validation<br/>[auth.schema.ts]"]
end

subgraph group_store["Storefront"]
  node_catalog["Catalog Products"]
  node_settings["Store Settings"]
end

subgraph group_commerce["Commerce Operations"]
  node_orders["Order Lifecycle"]
  node_order_schema["Order Validation<br/>[order.schema.ts]"]
  node_payments["Payment Processing"]
  node_media["Media Assets"]
  node_mcp["Store MCP Server"]
end

subgraph group_platform["Platform Services"]
  node_database[("PostgreSQL<br/>[schema.prisma]")]
  node_prisma_client["Prisma Client<br/>[prisma.ts]"]
  node_env["Runtime Configuration<br/>[env.ts]"]
end

node_client(("Storefront / Admin"))
node_google{{"Google / Firebase Auth"}}
node_razorpay{{"Razorpay"}}
node_r2{{"Cloudflare R2"}}

node_client -->|"sends requests"| node_api
node_api -->|"mounts routes"| node_auth_routes
node_api -->|"mounts routes"| node_catalog
node_api -->|"mounts routes"| node_orders
node_api -->|"mounts routes"| node_media
node_api -->|"mounts routes"| node_settings
node_api -->|"mounts routes"| node_payments
node_api -->|"applies"| node_middleware
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_routes -->|"validates with"| node_auth_schema
node_auth_controller -->|"calls"| node_auth_service
node_auth_service -->|"reads and writes"| node_prisma_client
node_auth_service -->|"verifies identity"| node_google
node_catalog -->|"reads and writes"| node_database
node_settings -->|"reads and writes"| node_database
node_orders -->|"validates with"| node_order_schema
node_orders -->|"calls payment service"| node_payments
node_orders -->|"places and tracks"| node_database
node_payments -->|"verifies payments"| node_razorpay
node_media -->|"registers assets"| node_database
node_media -->|"uploads assets"| node_r2
node_mcp -->|"queries store data"| node_database
node_prisma_client -->|"connects to"| node_database
node_middleware -->|"reads limits and secrets"| node_env
node_auth_service -->|"reads auth settings"| node_env
node_health -->|"probes health"| node_database

click node_api "https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/index.ts"
click node_middleware "https://github.com/zrn2003/avyana-fashion-store-backend/tree/main/src/middleware"
click node_auth_routes "https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/modules/auth/auth.routes.ts"
click node_auth_controller "https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/modules/auth/auth.controller.ts"
click node_auth_service "https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/modules/auth/auth.service.ts"
click node_auth_schema "https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/modules/auth/auth.schema.ts"
click node_catalog "https://github.com/zrn2003/avyana-fashion-store-backend/tree/main/src/modules/products"
click node_settings "https://github.com/zrn2003/avyana-fashion-store-backend/tree/main/src/modules/settings"
click node_orders "https://github.com/zrn2003/avyana-fashion-store-backend/tree/main/src/modules/orders"
click node_order_schema "https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/modules/orders/order.schema.ts"
click node_payments "https://github.com/zrn2003/avyana-fashion-store-backend/tree/main/src/modules/payments"
click node_media "https://github.com/zrn2003/avyana-fashion-store-backend/tree/main/src/modules/media"
click node_mcp "https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/mcp/store-mcp-server.ts"
click node_database "https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/prisma/schema.prisma"
click node_prisma_client "https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/config/prisma.ts"
click node_env "https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/config/env.ts"
click node_health "https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/index.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_api,node_middleware,node_health toneBlue
class node_auth_routes,node_auth_controller,node_auth_service,node_auth_schema toneAmber
class node_catalog,node_settings toneMint
class node_orders,node_order_schema,node_payments,node_media,node_mcp toneRose
class node_database,node_prisma_client,node_env,node_client,node_google,node_razorpay,node_r2 toneIndigo
```

## Components

### API Runtime

- [Express API](https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/index.ts): `src/index.ts`
- [Request Middleware](https://github.com/zrn2003/avyana-fashion-store-backend/tree/main/src/middleware): `src/middleware`
- [Health Probe](https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/index.ts): `src/index.ts`

### Identity

- [Auth Routes](https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/modules/auth/auth.routes.ts): `src/modules/auth/auth.routes.ts`
- [Auth Controller](https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/modules/auth/auth.controller.ts): `src/modules/auth/auth.controller.ts`
- [Auth Service](https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/modules/auth/auth.service.ts): `src/modules/auth/auth.service.ts`
- [Auth Validation](https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/modules/auth/auth.schema.ts): `src/modules/auth/auth.schema.ts`

### Storefront

- [Catalog Products](https://github.com/zrn2003/avyana-fashion-store-backend/tree/main/src/modules/products): `src/modules/products`
- [Store Settings](https://github.com/zrn2003/avyana-fashion-store-backend/tree/main/src/modules/settings): `src/modules/settings`

### Commerce Operations

- [Order Lifecycle](https://github.com/zrn2003/avyana-fashion-store-backend/tree/main/src/modules/orders): `src/modules/orders`
- [Order Validation](https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/modules/orders/order.schema.ts): `src/modules/orders/order.schema.ts`
- [Payment Processing](https://github.com/zrn2003/avyana-fashion-store-backend/tree/main/src/modules/payments): `src/modules/payments`
- [Media Assets](https://github.com/zrn2003/avyana-fashion-store-backend/tree/main/src/modules/media): `src/modules/media`
- [Store MCP Server](https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/mcp/store-mcp-server.ts): `src/mcp/store-mcp-server.ts`

### Platform Services

- [PostgreSQL](https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/prisma/schema.prisma): `prisma/schema.prisma`
- [Prisma Client](https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/config/prisma.ts): `src/config/prisma.ts`
- [Runtime Configuration](https://github.com/zrn2003/avyana-fashion-store-backend/blob/main/src/config/env.ts): `src/config/env.ts`

### Other components

- **Storefront / Admin**
- **Google / Firebase Auth**
- **Razorpay**
- **Cloudflare R2**

## Connections

- Storefront / Admin → Express API: sends requests (evidence: `README.md`)
- Express API → Auth Routes: mounts routes (evidence: `src/index.ts`)
- Express API → Catalog Products: mounts routes (evidence: `src/index.ts`)
- Express API → Order Lifecycle: mounts routes (evidence: `src/index.ts`)
- Express API → Media Assets: mounts routes (evidence: `src/index.ts`)
- Express API → Store Settings: mounts routes (evidence: `src/index.ts`)
- Express API → Payment Processing: mounts routes (evidence: `src/index.ts`)
- Express API → Request Middleware: applies (evidence: `src/index.ts`)
- Auth Routes → Auth Controller: dispatches (evidence: `src/modules/auth/auth.routes.ts`)
- Auth Routes → Auth Validation: validates with (evidence: `src/modules/auth/auth.routes.ts`)
- Auth Controller → Auth Service: calls (evidence: `src/modules/auth/auth.controller.ts`)
- Auth Service → Prisma Client: reads and writes (evidence: `src/modules/auth/auth.service.ts`)
- Auth Service → Google / Firebase Auth: verifies identity (evidence: `src/modules/auth/auth.service.ts`)
- Catalog Products → PostgreSQL: reads and writes (evidence: `src/modules/products/product.service.ts`)
- Store Settings → PostgreSQL: reads and writes (evidence: `src/modules/settings/settings.service.ts`)
- Order Lifecycle → Order Validation: validates with (evidence: `src/modules/orders/order.routes.ts`)
- Order Lifecycle → Payment Processing: calls payment service (evidence: `src/modules/orders/order.service.ts`)
- Order Lifecycle → PostgreSQL: places and tracks (evidence: `README.md`)
- Payment Processing → Razorpay: verifies payments (evidence: `README.md`)
- Media Assets → PostgreSQL: registers assets (evidence: `src/modules/media/media.service.ts`)
- Media Assets → Cloudflare R2: uploads assets (evidence: `README.md`)
- Store MCP Server → PostgreSQL: queries store data (evidence: `src/mcp/store-mcp-server.ts`)
- Prisma Client → PostgreSQL: connects to (evidence: `src/config/prisma.ts`)
- Request Middleware → Runtime Configuration: reads limits and secrets (evidence: `src/middleware/rateLimit.middleware.ts`)
- Auth Service → Runtime Configuration: reads auth settings (evidence: `src/modules/auth/auth.service.ts`)
- Health Probe → PostgreSQL: probes health (evidence: `README.md`)
