How akene-uzezi/ecommerce-microservice works
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: main.go Gateway server · proto Protobuf contracts · token.go Auth service · auth_handler.go Auth routes
Components 24
HTTP gateway
- Gateway server
gateway/cmd/main.go - Auth routes
gateway/internal/handler/auth_handler.go - Order routes
gateway/internal/handler/handler.go - Product routes
gateway/internal/handler/products_handler.go - Payment routes
gateway/internal/handler/payments.go - Stock routes
gateway/internal/handler/stock.go - JWT middleware
gateway/internal/middleware/auth.go
Domain services
- Auth service
auth/internal/handler/token.go - User operations
auth/internal/handler/users.go - Password hashing
auth/internal/util/bcrypt.go - Order operations
orders/internal/handler/grpc.go - Product catalog
products/internal/handler/grpc.go - Payment processing
payments/internal/handler/grpc.go - Stock operations
stock/internal/handler/grpc.go
Persistence
- User data access
auth/internal/db/users.go - Auth database
- Order data access
orders/internal/db/orders.go - Orders database
- Product data access
products/internal/db/products.go - Products database
- Stock data access
stock/internal/db/db.go - Stock database
RPC contracts
- Protobuf contracts
api/proto
Other components
- API client
Connections 29
- API client → Gateway server: HTTP/JSON
README.md - Gateway server → Auth routes: registers routes
- Gateway server → Order routes: registers routes
README.md - Gateway server → Product routes: registers routes
README.md - Gateway server → Payment routes: registers routes
README.md - Gateway server → Stock routes: registers routes
README.md - Auth routes → Auth service: calls gRPC
gateway/internal/handler/auth_handler.go - Order routes → Order operations: calls gRPC
gateway/internal/handler/handler.go - Product routes → Product catalog: calls gRPC
gateway/internal/handler/products_handler.go - Payment routes → Payment processing: calls gRPC
README.md - Stock routes → Stock operations: calls gRPC
README.md - Auth routes → JWT middleware: protects search
gateway/internal/handler/auth_handler.go - Product routes → JWT middleware: protects routes
gateway/internal/handler/products_handler.go - Order routes → JWT middleware: protects orders
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
README.md - Order operations → Order data access: uses data access
- Order data access → Orders database: reads/writes
README.md - Product catalog → Product data access: uses data access
- Product data access → Products database: reads/writes
README.md - Stock operations → Stock data access: uses data access
- Stock data access → Stock database: reads/writes
README.md - Protobuf contracts → Auth service: defines RPC
README.md - Protobuf contracts → Order operations: defines RPC
README.md - Protobuf contracts → Product catalog: defines RPC
README.md - Protobuf contracts → Payment processing: defines RPC
README.md - Protobuf contracts → Stock operations: defines RPC
README.md