# akene-uzezi/ecommerce-microservice architecture

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

- Interactive diagram: https://gitdiagram.com/akene-uzezi/ecommerce-microservice
- Repository: https://github.com/akene-uzezi/ecommerce-microservice

## Overview

This is a Go ecommerce microservices platform. The principal flow is client HTTP/JSON traffic into the gateway, where route handlers authenticate protected requests and translate them into gRPC calls; service handlers implement auth, orders, products, payments, and stock operations, with four services persisting to PostgreSQL. README-documented capabilities include user registration/login and token verification, product catalog operations, order operations, stock checks/reservation, and mock payment processing. Some service-to-database and gateway routes are documented rather than shown in sampled source.

Main entry points: [`gateway/cmd/main.go`](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/cmd/main.go) (Gateway server), [`api/proto`](https://github.com/akene-uzezi/ecommerce-microservice/tree/main/api/proto) (Protobuf contracts), [`auth/internal/handler/token.go`](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/auth/internal/handler/token.go) (Auth service), [`gateway/internal/handler/auth_handler.go`](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/internal/handler/auth_handler.go) (Auth routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["HTTP gateway"]
  node_gateway_server["Gateway server<br/>[main.go]"]
  node_auth_routes["Auth routes<br/>[auth_handler.go]"]
  node_order_routes["Order routes<br/>[handler.go]"]
  node_product_routes["Product routes"]
  node_payment_routes["Payment routes<br/>[payments.go]"]
  node_stock_routes["Stock routes<br/>[stock.go]"]
  node_jwt_middleware["JWT middleware<br/>[auth.go]"]
end

subgraph group_services["Domain services"]
  node_auth_service["Auth service<br/>[token.go]"]
  node_auth_users["User operations<br/>[users.go]"]
  node_auth_passwords["Password hashing<br/>[bcrypt.go]"]
  node_orders_service["Order operations<br/>[grpc.go]"]
  node_products_service["Product catalog<br/>[grpc.go]"]
  node_payments_service["Payment processing<br/>[grpc.go]"]
  node_stock_service["Stock operations<br/>[grpc.go]"]
end

subgraph group_storage["Persistence"]
  node_auth_db_layer["User data access<br/>[users.go]"]
  node_auth_db[("Auth database")]
  node_orders_db_layer["Order data access<br/>[orders.go]"]
  node_orders_db[("Orders database")]
  node_products_db_layer["Product data access<br/>[products.go]"]
  node_products_db[("Products database")]
  node_stock_db_layer["Stock data access<br/>[db.go]"]
  node_stock_db[("Stock database")]
end

subgraph group_contracts["RPC contracts"]
  node_rpc_contracts["Protobuf contracts"]
end

node_client(("API client"))

node_client -->|"HTTP/JSON"| node_gateway_server
node_gateway_server -->|"registers routes"| node_auth_routes
node_gateway_server -->|"registers routes"| node_order_routes
node_gateway_server -->|"registers routes"| node_product_routes
node_gateway_server -->|"registers routes"| node_payment_routes
node_gateway_server -->|"registers routes"| node_stock_routes
node_auth_routes -->|"calls gRPC"| node_auth_service
node_order_routes -->|"calls gRPC"| node_orders_service
node_product_routes -->|"calls gRPC"| node_products_service
node_payment_routes -->|"calls gRPC"| node_payments_service
node_stock_routes -->|"calls gRPC"| node_stock_service
node_auth_routes -->|"protects search"| node_jwt_middleware
node_product_routes -->|"protects routes"| node_jwt_middleware
node_order_routes -->|"protects orders"| node_jwt_middleware
node_auth_service -.->|"serves user ops"| node_auth_users
node_auth_service -.->|"uses hashing"| node_auth_passwords
node_auth_users -.->|"stores users"| node_auth_db_layer
node_auth_db_layer -->|"reads/writes"| node_auth_db
node_orders_service -.->|"uses data access"| node_orders_db_layer
node_orders_db_layer -->|"reads/writes"| node_orders_db
node_products_service -.->|"uses data access"| node_products_db_layer
node_products_db_layer -->|"reads/writes"| node_products_db
node_stock_service -.->|"uses data access"| node_stock_db_layer
node_stock_db_layer -->|"reads/writes"| node_stock_db
node_rpc_contracts -->|"defines RPC"| node_auth_service
node_rpc_contracts -->|"defines RPC"| node_orders_service
node_rpc_contracts -->|"defines RPC"| node_products_service
node_rpc_contracts -->|"defines RPC"| node_payments_service
node_rpc_contracts -->|"defines RPC"| node_stock_service

click node_gateway_server "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/cmd/main.go"
click node_auth_routes "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/internal/handler/auth_handler.go"
click node_order_routes "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/internal/handler/handler.go"
click node_product_routes "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/internal/handler/products_handler.go"
click node_payment_routes "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/internal/handler/payments.go"
click node_stock_routes "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/internal/handler/stock.go"
click node_jwt_middleware "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/internal/middleware/auth.go"
click node_auth_service "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/auth/internal/handler/token.go"
click node_auth_users "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/auth/internal/handler/users.go"
click node_auth_passwords "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/auth/internal/util/bcrypt.go"
click node_orders_service "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/orders/internal/handler/grpc.go"
click node_products_service "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/products/internal/handler/grpc.go"
click node_payments_service "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/payments/internal/handler/grpc.go"
click node_stock_service "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/stock/internal/handler/grpc.go"
click node_auth_db_layer "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/auth/internal/db/users.go"
click node_orders_db_layer "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/orders/internal/db/orders.go"
click node_products_db_layer "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/products/internal/db/products.go"
click node_stock_db_layer "https://github.com/akene-uzezi/ecommerce-microservice/blob/main/stock/internal/db/db.go"
click node_rpc_contracts "https://github.com/akene-uzezi/ecommerce-microservice/tree/main/api/proto"

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_gateway_server,node_auth_routes,node_order_routes,node_product_routes,node_payment_routes,node_stock_routes,node_jwt_middleware,node_client toneBlue
class node_auth_service,node_auth_users,node_auth_passwords,node_orders_service,node_products_service,node_payments_service,node_stock_service toneAmber
class node_auth_db_layer,node_auth_db,node_orders_db_layer,node_orders_db,node_products_db_layer,node_products_db,node_stock_db_layer,node_stock_db toneMint
class node_rpc_contracts toneRose
```

## Components

### HTTP gateway

- [Gateway server](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/cmd/main.go): `gateway/cmd/main.go`
- [Auth routes](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/internal/handler/auth_handler.go): `gateway/internal/handler/auth_handler.go`
- [Order routes](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/internal/handler/handler.go): `gateway/internal/handler/handler.go`
- [Product routes](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/internal/handler/products_handler.go): `gateway/internal/handler/products_handler.go`
- [Payment routes](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/internal/handler/payments.go): `gateway/internal/handler/payments.go`
- [Stock routes](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/internal/handler/stock.go): `gateway/internal/handler/stock.go`
- [JWT middleware](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/gateway/internal/middleware/auth.go): `gateway/internal/middleware/auth.go`

### Domain services

- [Auth service](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/auth/internal/handler/token.go): `auth/internal/handler/token.go`
- [User operations](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/auth/internal/handler/users.go): `auth/internal/handler/users.go`
- [Password hashing](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/auth/internal/util/bcrypt.go): `auth/internal/util/bcrypt.go`
- [Order operations](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/orders/internal/handler/grpc.go): `orders/internal/handler/grpc.go`
- [Product catalog](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/products/internal/handler/grpc.go): `products/internal/handler/grpc.go`
- [Payment processing](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/payments/internal/handler/grpc.go): `payments/internal/handler/grpc.go`
- [Stock operations](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/stock/internal/handler/grpc.go): `stock/internal/handler/grpc.go`

### Persistence

- [User data access](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/auth/internal/db/users.go): `auth/internal/db/users.go`
- **Auth database**
- [Order data access](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/orders/internal/db/orders.go): `orders/internal/db/orders.go`
- **Orders database**
- [Product data access](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/products/internal/db/products.go): `products/internal/db/products.go`
- **Products database**
- [Stock data access](https://github.com/akene-uzezi/ecommerce-microservice/blob/main/stock/internal/db/db.go): `stock/internal/db/db.go`
- **Stock database**

### RPC contracts

- [Protobuf contracts](https://github.com/akene-uzezi/ecommerce-microservice/tree/main/api/proto): `api/proto`

### Other components

- **API client**

## Connections

- API client → Gateway server: HTTP/JSON (evidence: `README.md`)
- Gateway server → Auth routes: registers routes
- Gateway server → Order routes: registers routes (evidence: `README.md`)
- Gateway server → Product routes: registers routes (evidence: `README.md`)
- Gateway server → Payment routes: registers routes (evidence: `README.md`)
- Gateway server → Stock routes: registers routes (evidence: `README.md`)
- Auth routes → Auth service: calls gRPC (evidence: `gateway/internal/handler/auth_handler.go`)
- Order routes → Order operations: calls gRPC (evidence: `gateway/internal/handler/handler.go`)
- Product routes → Product catalog: calls gRPC (evidence: `gateway/internal/handler/products_handler.go`)
- Payment routes → Payment processing: calls gRPC (evidence: `README.md`)
- Stock routes → Stock operations: calls gRPC (evidence: `README.md`)
- Auth routes → JWT middleware: protects search (evidence: `gateway/internal/handler/auth_handler.go`)
- Product routes → JWT middleware: protects routes (evidence: `gateway/internal/handler/products_handler.go`)
- Order routes → JWT middleware: protects orders (evidence: `gateway/internal/handler/handler.go`)
- Auth service → User operations: serves user ops
- Auth service → Password hashing: uses hashing
- User operations → User data access: stores users
- User data access → Auth database: reads/writes (evidence: `README.md`)
- Order operations → Order data access: uses data access
- Order data access → Orders database: reads/writes (evidence: `README.md`)
- Product catalog → Product data access: uses data access
- Product data access → Products database: reads/writes (evidence: `README.md`)
- Stock operations → Stock data access: uses data access
- Stock data access → Stock database: reads/writes (evidence: `README.md`)
- Protobuf contracts → Auth service: defines RPC (evidence: `README.md`)
- Protobuf contracts → Order operations: defines RPC (evidence: `README.md`)
- Protobuf contracts → Product catalog: defines RPC (evidence: `README.md`)
- Protobuf contracts → Payment processing: defines RPC (evidence: `README.md`)
- Protobuf contracts → Stock operations: defines RPC (evidence: `README.md`)
