# sangeeth518/go-e_commerce-clean-arch architecture

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

- Interactive diagram: https://gitdiagram.com/sangeeth518/go-e_commerce-clean-arch
- Repository: https://github.com/sangeeth518/go-e_commerce-clean-arch

## Overview

This repository implements a Go e-commerce API and a separate notification consumer. The main workflow is an authenticated user request routed through Gin to a handler, business use case, and persistence or integration layer. Product capabilities also cover administration, accounts, categories, inventory and images, carts, checkout and orders, invoices, caching, and order notifications. The README provides no capability detail; the graph’s feature coverage comes from the source tree and indexed references. Some unsampled feature connections are omitted where ownership cannot be verified.

Main entry points: [`pkg/api/handler`](https://github.com/sangeeth518/go-e_commerce-clean-arch/tree/master/pkg/api/handler) (API handlers), [`pkg/api/handler/inventory.go`](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/api/handler/inventory.go) (Inventory and images), [`pkg/usecase/order.go`](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/usecase/order.go) (Checkout and orders), [`notification-service/pkg/consumer/consumer.go`](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/notification-service/pkg/consumer/consumer.go) (Event consumer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_api_entry["API bootstrap<br/>[main.go]"]
  node_server["HTTP server<br/>[server.go]"]
  node_routes["Route registration<br/>[user.go]"]
  node_middleware["Auth middleware<br/>[auth.go]"]
  node_handlers["API handlers"]
end

subgraph group_commerce["Commerce workflows"]
  node_accounts["Accounts and admin<br/>[user.go]"]
  node_catalog["Catalog and categories<br/>[category.go]"]
  node_inventory["Inventory and images<br/>[inventory.go]"]
  node_cart["Shopping cart<br/>[cart.go]"]
  node_orders["Checkout and orders<br/>[order.go]"]
end

subgraph group_infra["Data and integrations"]
  node_helper["Shared services<br/>[helper.go]"]
  node_postgres[("PostgreSQL repositories<br/>[order.go]")]
  node_db_setup["Database setup<br/>[db.go]"]
  node_redis_cache[("Redis cache<br/>[redis_cache.go]")]
  node_publisher["Event publisher<br/>[publisher.go]"]
end

subgraph group_notifications["Notifications"]
  node_notification_boot["Consumer bootstrap<br/>[main.go]"]
  node_consumer["Event consumer<br/>[consumer.go]"]
  node_notification_repo[("Notification repository<br/>[notification.go]")]
  node_email["Email service<br/>[email.go]"]
end

node_user(("User"))
node_rabbit["RabbitMQ"]
node_s3[("S3 object storage")]
node_email_provider["Email provider"]

node_user -->|"sends requests"| node_server
node_api_entry -->|"starts"| node_server
node_server -->|"registers routes"| node_routes
node_routes -->|"dispatches"| node_handlers
node_routes -->|"guards routes"| node_middleware
node_handlers -.->|"invokes use cases"| node_accounts
node_handlers -.->|"invokes use cases"| node_catalog
node_handlers -->|"handles inventory"| node_inventory
node_handlers -.->|"invokes use cases"| node_cart
node_handlers -->|"invokes use cases"| node_orders
node_inventory -->|"uses repository"| node_postgres
node_inventory -->|"reads and invalidates"| node_redis_cache
node_inventory -->|"uses image services"| node_helper
node_helper -->|"stores images"| node_s3
node_cart -.->|"uses repository"| node_postgres
node_orders -->|"uses repository"| node_postgres
node_orders -->|"uses shared services"| node_helper
node_orders -->|"publishes events"| node_publisher
node_publisher -->|"publishes messages"| node_rabbit
node_db_setup -.->|"connects database"| node_postgres
node_notification_boot -->|"starts consuming"| node_consumer
node_notification_boot -->|"creates repository"| node_notification_repo
node_notification_boot -->|"creates service"| node_email
node_consumer -.->|"consumes messages"| node_rabbit
node_consumer -->|"uses repository"| node_notification_repo
node_consumer -->|"dispatches email"| node_email
node_email -.->|"sends email"| node_email_provider

click node_api_entry "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/cmd/api/main.go"
click node_server "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/api/server.go"
click node_routes "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/routes/user.go"
click node_middleware "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/api/middleware/auth.go"
click node_handlers "https://github.com/sangeeth518/go-e_commerce-clean-arch/tree/master/pkg/api/handler"
click node_accounts "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/usecase/user.go"
click node_catalog "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/usecase/category.go"
click node_inventory "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/api/handler/inventory.go"
click node_cart "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/usecase/cart.go"
click node_orders "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/usecase/order.go"
click node_helper "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/helper/helper.go"
click node_postgres "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/repository/order.go"
click node_db_setup "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/db/db.go"
click node_redis_cache "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/db/redis_cache.go"
click node_publisher "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/publisher/publisher.go"
click node_notification_boot "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/notification-service/cmd/main.go"
click node_consumer "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/notification-service/pkg/consumer/consumer.go"
click node_notification_repo "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/notification-service/pkg/repository/notification.go"
click node_email "https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/notification-service/pkg/service/email.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_api_entry,node_server,node_routes,node_middleware,node_handlers,node_user toneBlue
class node_accounts,node_catalog,node_inventory,node_cart,node_orders,node_s3 toneAmber
class node_helper,node_postgres,node_db_setup,node_redis_cache,node_publisher toneMint
class node_notification_boot,node_consumer,node_notification_repo,node_email toneRose
class node_rabbit,node_email_provider toneIndigo
```

## Components

### HTTP API

- [API bootstrap](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/cmd/api/main.go): `cmd/api/main.go`
- [HTTP server](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/api/server.go): `pkg/api/server.go`
- [Route registration](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/routes/user.go): `pkg/routes/user.go`
- [Auth middleware](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/api/middleware/auth.go): `pkg/api/middleware/auth.go`
- [API handlers](https://github.com/sangeeth518/go-e_commerce-clean-arch/tree/master/pkg/api/handler): `pkg/api/handler`

### Commerce workflows

- [Accounts and admin](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/usecase/user.go): `pkg/usecase/user.go`
- [Catalog and categories](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/usecase/category.go): `pkg/usecase/category.go`
- [Inventory and images](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/api/handler/inventory.go): `pkg/api/handler/inventory.go`
- [Shopping cart](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/usecase/cart.go): `pkg/usecase/cart.go`
- [Checkout and orders](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/usecase/order.go): `pkg/usecase/order.go`

### Data and integrations

- [Shared services](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/helper/helper.go): `pkg/helper/helper.go`
- [PostgreSQL repositories](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/repository/order.go): `pkg/repository/order.go`
- [Database setup](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/db/db.go): `pkg/db/db.go`
- [Redis cache](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/db/redis_cache.go): `pkg/db/redis_cache.go`
- [Event publisher](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/pkg/publisher/publisher.go): `pkg/publisher/publisher.go`

### Notifications

- [Consumer bootstrap](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/notification-service/cmd/main.go): `notification-service/cmd/main.go`
- [Event consumer](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/notification-service/pkg/consumer/consumer.go): `notification-service/pkg/consumer/consumer.go`
- [Notification repository](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/notification-service/pkg/repository/notification.go): `notification-service/pkg/repository/notification.go`
- [Email service](https://github.com/sangeeth518/go-e_commerce-clean-arch/blob/master/notification-service/pkg/service/email.go): `notification-service/pkg/service/email.go`

### Other components

- **User**
- **RabbitMQ**
- **S3 object storage**
- **Email provider**

## Connections

- User → HTTP server: sends requests
- API bootstrap → HTTP server: starts (evidence: `cmd/api/main.go`)
- HTTP server → Route registration: registers routes (evidence: `pkg/api/server.go`)
- Route registration → API handlers: dispatches (evidence: `pkg/routes/user.go`)
- Route registration → Auth middleware: guards routes (evidence: `pkg/routes/user.go`)
- API handlers → Accounts and admin: invokes use cases
- API handlers → Catalog and categories: invokes use cases
- API handlers → Inventory and images: handles inventory (evidence: `pkg/api/handler/inventory.go`)
- API handlers → Shopping cart: invokes use cases
- API handlers → Checkout and orders: invokes use cases (evidence: `pkg/api/handler/order.go`)
- Inventory and images → PostgreSQL repositories: uses repository
- Inventory and images → Redis cache: reads and invalidates
- Inventory and images → Shared services: uses image services
- Shared services → S3 object storage: stores images (evidence: `pkg/helper/helper.go`)
- Shopping cart → PostgreSQL repositories: uses repository
- Checkout and orders → PostgreSQL repositories: uses repository (evidence: `pkg/usecase/order.go`)
- Checkout and orders → Shared services: uses shared services (evidence: `pkg/usecase/order.go`)
- Checkout and orders → Event publisher: publishes events (evidence: `pkg/usecase/order.go`)
- Event publisher → RabbitMQ: publishes messages (evidence: `pkg/publisher/publisher.go`)
- Database setup → PostgreSQL repositories: connects database
- Consumer bootstrap → Event consumer: starts consuming (evidence: `notification-service/cmd/main.go`)
- Consumer bootstrap → Notification repository: creates repository (evidence: `notification-service/cmd/main.go`)
- Consumer bootstrap → Email service: creates service (evidence: `notification-service/cmd/main.go`)
- Event consumer → RabbitMQ: consumes messages
- Event consumer → Notification repository: uses repository (evidence: `notification-service/pkg/consumer/consumer.go`)
- Event consumer → Email service: dispatches email (evidence: `notification-service/pkg/consumer/consumer.go`)
- Email service → Email provider: sends email
