# vidhyashekar/cloudcart architecture

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

- Interactive diagram: https://gitdiagram.com/vidhyashekar/cloudcart
- Repository: https://github.com/vidhyashekar/cloudcart

## Overview

CloudCart is a microservices e-commerce backend. The principal flow is a client creating an order: the order service validates products and reserves stock through the product-service client, persists the order, then publishes an order-created event for the notification consumer. Separate auth and product APIs support identity and catalog/stock management. The excerpts show the order orchestration and service wiring; cross-service HTTP and broker delivery are represented only where documented or marked unverified, since those implementations are not fully excerpted.

Main entry points: [`services/auth-service/internal/app/app.go`](https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/app/app.go) (Auth App), [`services/order-service/internal/app/app.go`](https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/app/app.go) (Order App), [`services/product-service/internal/app/app.go`](https://github.com/vidhyashekar/cloudcart/blob/main/services/product-service/internal/app/app.go) (Product App), [`services/order-service/internal/service/order_service.go`](https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/service/order_service.go) (Order Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity"]
  node_auth_app["Auth App<br/>[app.go]"]
  node_auth_routes["Auth Routes<br/>[router.go]"]
  node_auth_handler["Auth Handler<br/>[auth_handler.go]"]
  node_auth_service["Auth Service<br/>[auth_service.go]"]
  node_jwt["JWT Manager<br/>[jwt.go]"]
  node_user_repo["User Repository"]
  node_auth_db[("Auth Database<br/>[database.go]")]
end

subgraph group_catalog["Product Catalog"]
  node_product_app["Product App<br/>[app.go]"]
  node_product_routes["Product Routes<br/>[router.go]"]
  node_product_handler["Product Handler<br/>[product_handler.go]"]
  node_product_service["Product Service<br/>[product_service.go]"]
  node_product_repo["Product Repository"]
  node_product_db[("Product Database<br/>[database.go]")]
end

subgraph group_orders["Order Processing"]
  node_order_app["Order App<br/>[app.go]"]
  node_order_routes["Order Routes<br/>[router.go]"]
  node_order_handler["Order Handler<br/>[order_handler.go]"]
  node_order_service["Order Service<br/>[order_service.go]"]
  node_product_client["Product Client"]
  node_order_repo["Order Repository"]
  node_order_db[("Order Database<br/>[database.go]")]
end

subgraph group_notify["Notifications"]
  node_notification_consumer["Event Consumer<br/>[consumer.go]"]
  node_notification_service["Notification Service"]
end

node_client(("API Client"))
node_event_broker["Kafka Broker"]

node_client -.->|"sends requests"| node_auth_routes
node_auth_app -->|"connects and migrates"| node_auth_db
node_auth_app -->|"constructs"| node_user_repo
node_auth_app -->|"constructs"| node_jwt
node_auth_app -->|"constructs"| node_auth_service
node_auth_app -->|"constructs"| node_auth_handler
node_auth_app -->|"registers routes"| node_auth_routes
node_auth_routes -->|"routes to"| node_auth_handler
node_auth_handler -->|"calls"| node_auth_service
node_auth_service -->|"reads and writes"| node_user_repo
node_auth_service -->|"generates tokens"| node_jwt
node_client -.->|"sends requests"| node_product_routes
node_product_app -->|"connects and migrates"| node_product_db
node_product_app -->|"constructs"| node_product_repo
node_product_app -->|"constructs"| node_product_service
node_product_app -->|"constructs"| node_product_handler
node_product_app -->|"registers routes"| node_product_routes
node_product_routes -->|"routes to"| node_product_handler
node_product_handler -->|"calls"| node_product_service
node_product_service -->|"queries and updates"| node_product_repo
node_client -.->|"sends requests"| node_order_routes
node_order_app -->|"connects and migrates"| node_order_db
node_order_app -->|"constructs"| node_order_repo
node_order_app -->|"constructs"| node_product_client
node_order_app -->|"constructs"| node_order_service
node_order_app -->|"constructs"| node_order_handler
node_order_app -->|"registers routes"| node_order_routes
node_order_routes -->|"routes to"| node_order_handler
node_order_handler -->|"calls"| node_order_service
node_order_service -->|"gets product and adjusts stock"| node_product_client
node_order_service -->|"creates and queries orders"| node_order_repo
node_product_client -.->|"calls product API"| node_product_routes
node_order_service -->|"publishes order event"| node_event_broker
node_event_broker -.->|"delivers event"| node_notification_consumer
node_notification_consumer -->|"handles event"| node_notification_service

click node_auth_app "https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/app/app.go"
click node_auth_routes "https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/router/router.go"
click node_auth_handler "https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/handler/auth_handler.go"
click node_auth_service "https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/service/auth_service.go"
click node_jwt "https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/auth/jwt.go"
click node_user_repo "https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/repository/user_repository_impl.go"
click node_auth_db "https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/database/database.go"
click node_product_app "https://github.com/vidhyashekar/cloudcart/blob/main/services/product-service/internal/app/app.go"
click node_product_routes "https://github.com/vidhyashekar/cloudcart/blob/main/services/product-service/internal/router/router.go"
click node_product_handler "https://github.com/vidhyashekar/cloudcart/blob/main/services/product-service/internal/handler/product_handler.go"
click node_product_service "https://github.com/vidhyashekar/cloudcart/blob/main/services/product-service/internal/service/product_service.go"
click node_product_repo "https://github.com/vidhyashekar/cloudcart/blob/main/services/product-service/internal/repository/product_repository_impl.go"
click node_product_db "https://github.com/vidhyashekar/cloudcart/blob/main/services/product-service/internal/database/database.go"
click node_order_app "https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/app/app.go"
click node_order_routes "https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/router/router.go"
click node_order_handler "https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/handler/order_handler.go"
click node_order_service "https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/service/order_service.go"
click node_product_client "https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/client/product_client_impl.go"
click node_order_repo "https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/repository/order_repository_impl.go"
click node_order_db "https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/database/database.go"
click node_notification_consumer "https://github.com/vidhyashekar/cloudcart/blob/main/services/notification-service/internal/kafka/consumer.go"
click node_notification_service "https://github.com/vidhyashekar/cloudcart/blob/main/services/notification-service/internal/service/notification_service.go"

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_auth_app,node_auth_routes,node_auth_handler,node_auth_service,node_jwt,node_user_repo,node_auth_db,node_client toneBlue
class node_product_app,node_product_routes,node_product_handler,node_product_service,node_product_repo,node_product_db toneAmber
class node_order_app,node_order_routes,node_order_handler,node_order_service,node_product_client,node_order_repo,node_order_db toneMint
class node_notification_consumer,node_notification_service toneRose
class node_event_broker toneIndigo
```

## Components

### Identity

- [Auth App](https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/app/app.go): `services/auth-service/internal/app/app.go`
- [Auth Routes](https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/router/router.go): `services/auth-service/internal/router/router.go`
- [Auth Handler](https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/handler/auth_handler.go): `services/auth-service/internal/handler/auth_handler.go`
- [Auth Service](https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/service/auth_service.go): `services/auth-service/internal/service/auth_service.go`
- [JWT Manager](https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/auth/jwt.go): `services/auth-service/internal/auth/jwt.go`
- [User Repository](https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/repository/user_repository_impl.go): `services/auth-service/internal/repository/user_repository_impl.go`
- [Auth Database](https://github.com/vidhyashekar/cloudcart/blob/main/services/auth-service/internal/database/database.go): `services/auth-service/internal/database/database.go`

### Product Catalog

- [Product App](https://github.com/vidhyashekar/cloudcart/blob/main/services/product-service/internal/app/app.go): `services/product-service/internal/app/app.go`
- [Product Routes](https://github.com/vidhyashekar/cloudcart/blob/main/services/product-service/internal/router/router.go): `services/product-service/internal/router/router.go`
- [Product Handler](https://github.com/vidhyashekar/cloudcart/blob/main/services/product-service/internal/handler/product_handler.go): `services/product-service/internal/handler/product_handler.go`
- [Product Service](https://github.com/vidhyashekar/cloudcart/blob/main/services/product-service/internal/service/product_service.go): `services/product-service/internal/service/product_service.go`
- [Product Repository](https://github.com/vidhyashekar/cloudcart/blob/main/services/product-service/internal/repository/product_repository_impl.go): `services/product-service/internal/repository/product_repository_impl.go`
- [Product Database](https://github.com/vidhyashekar/cloudcart/blob/main/services/product-service/internal/database/database.go): `services/product-service/internal/database/database.go`

### Order Processing

- [Order App](https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/app/app.go): `services/order-service/internal/app/app.go`
- [Order Routes](https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/router/router.go): `services/order-service/internal/router/router.go`
- [Order Handler](https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/handler/order_handler.go): `services/order-service/internal/handler/order_handler.go`
- [Order Service](https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/service/order_service.go): `services/order-service/internal/service/order_service.go`
- [Product Client](https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/client/product_client_impl.go): `services/order-service/internal/client/product_client_impl.go`
- [Order Repository](https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/repository/order_repository_impl.go): `services/order-service/internal/repository/order_repository_impl.go`
- [Order Database](https://github.com/vidhyashekar/cloudcart/blob/main/services/order-service/internal/database/database.go): `services/order-service/internal/database/database.go`

### Notifications

- [Event Consumer](https://github.com/vidhyashekar/cloudcart/blob/main/services/notification-service/internal/kafka/consumer.go): `services/notification-service/internal/kafka/consumer.go`
- [Notification Service](https://github.com/vidhyashekar/cloudcart/blob/main/services/notification-service/internal/service/notification_service.go): `services/notification-service/internal/service/notification_service.go`

### Other components

- **API Client**
- **Kafka Broker**

## Connections

- API Client → Auth Routes: sends requests
- Auth App → Auth Database: connects and migrates (evidence: `services/auth-service/internal/app/app.go`)
- Auth App → User Repository: constructs (evidence: `services/auth-service/internal/app/app.go`)
- Auth App → JWT Manager: constructs (evidence: `services/auth-service/internal/app/app.go`)
- Auth App → Auth Service: constructs (evidence: `services/auth-service/internal/app/app.go`)
- Auth App → Auth Handler: constructs (evidence: `services/auth-service/internal/app/app.go`)
- Auth App → Auth Routes: registers routes (evidence: `services/auth-service/internal/app/app.go`)
- Auth Routes → Auth Handler: routes to (evidence: `services/auth-service/internal/router/router.go`)
- Auth Handler → Auth Service: calls (evidence: `services/auth-service/internal/handler/auth_handler.go`)
- Auth Service → User Repository: reads and writes (evidence: `services/auth-service/internal/service/auth_service.go`)
- Auth Service → JWT Manager: generates tokens (evidence: `services/auth-service/internal/service/auth_service.go`)
- API Client → Product Routes: sends requests
- Product App → Product Database: connects and migrates (evidence: `services/product-service/internal/app/app.go`)
- Product App → Product Repository: constructs (evidence: `services/product-service/internal/app/app.go`)
- Product App → Product Service: constructs (evidence: `services/product-service/internal/app/app.go`)
- Product App → Product Handler: constructs (evidence: `services/product-service/internal/app/app.go`)
- Product App → Product Routes: registers routes (evidence: `services/product-service/internal/app/app.go`)
- Product Routes → Product Handler: routes to (evidence: `services/product-service/internal/router/router.go`)
- Product Handler → Product Service: calls (evidence: `services/product-service/internal/handler/product_handler.go`)
- Product Service → Product Repository: queries and updates (evidence: `services/product-service/internal/service/product_service.go`)
- API Client → Order Routes: sends requests
- Order App → Order Database: connects and migrates (evidence: `services/order-service/internal/app/app.go`)
- Order App → Order Repository: constructs (evidence: `services/order-service/internal/app/app.go`)
- Order App → Product Client: constructs (evidence: `services/order-service/internal/app/app.go`)
- Order App → Order Service: constructs (evidence: `services/order-service/internal/app/app.go`)
- Order App → Order Handler: constructs (evidence: `services/order-service/internal/app/app.go`)
- Order App → Order Routes: registers routes (evidence: `services/order-service/internal/app/app.go`)
- Order Routes → Order Handler: routes to (evidence: `services/order-service/internal/router/router.go`)
- Order Handler → Order Service: calls (evidence: `services/order-service/internal/handler/order_handler.go`)
- Order Service → Product Client: gets product and adjusts stock (evidence: `services/order-service/internal/service/order_service.go`)
- Order Service → Order Repository: creates and queries orders (evidence: `services/order-service/internal/service/order_service.go`)
- Product Client → Product Routes: calls product API
- Order Service → Kafka Broker: publishes order event (evidence: `services/order-service/internal/service/order_service.go`)
- Kafka Broker → Event Consumer: delivers event
- Event Consumer → Notification Service: handles event (evidence: `services/notification-service/internal/kafka/consumer.go`)
