MCPcopy Index your code
hub / github.com/dhij/ecomm

github.com/dhij/ecomm @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
475 symbols 809 edges 20 files 23 documented · 5%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Ecomm Microservice

This is an ecomm microservice that consists of ecomm-api, ecomm-grpc, and an ecomm-notification microservices.

This repo is a WIP and consists of a series of tutorials available on Youtube:

Ecomm Architecture

Ecomm Architecture

Run the gRPC and API Microservices

Database Setup

docker pull mysql:8.4
docker run --name ecomm-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -d mysql:8.4

Pull and run the mysql image in a detached mode (-d) with port-forwarding and an environment variable.

docker exec -i ecomm-mysql mysql -uroot -ppassword <<< "CREATE DATABASE ecomm;"

Make the CREATE DATABASE query in the mysql container with docker exec.

docker run -it --rm --network host --volume ./db:/db migrate/migrate:v4.17.0 -path=/db/migrations -database "mysql://root:password@tcp(localhost:3306)/ecomm" up

Apply the migration files in db/migrations by running the golang-migrate image with the up command.

Run the Go Apps

go run cmd/ecomm-grpc/main.go
go run cmd/ecomm-api/main.go

How Notification Queue Works

Notification Queue 1

When an admin creates an order, a new notification event for the "pending" status of an order is enqueued into the notification_events_queue table. A notification event is also enqueued for every update of the order status, since we want to send an email notification for every update.the

Notification Queue 2

We have a separate notification_states table to maintain the state of the notification events even after the event has been deleted/dequeued from the notification_events_queue. The state of an event represents whether the notification email is "not sent", "sent", or "failed". Please note that the state of the notification event is what makes this ecomm notification database queue stateful and the "status" of an order has nothing to do with the statefulness.

Notification Queue 3

The ecomm-notification microservice will list these notification events from the database queue (ordered in the created_at timestamp of the events) and attempt to send an email notification for each of them. An attempt to send a notification email may succeed or fail. We have three possible scenarios for this as a failure case can split up into two different cases.

  1. Upon success, we delete/dequeue the event from the notifications queue and update the record in the notification states table to sent.
  2. Upon failure:
  3. If the number of attempts is less than the maximum number of attempts we have defined (ex. 3), we update the attempt count of the notification event in the database queue. The notification event will remain in the queue and processed in the following round.
  4. If the number of attempts has exceeded the maximum number of attempts allowed, we delete/dequeue the event from the notifications queue and update the record in the notification states table to failed.

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

NewMySQLStorer
called by 10
ecomm-grpc/storer/storer_mysql.go
CreateProduct
called by 4
ecomm-grpc/storer/storer_mysql.go
CreateOrder
called by 4
ecomm-grpc/storer/storer_mysql.go
execTx
called by 4
ecomm-grpc/storer/storer_mysql.go
toPBProductRes
called by 4
ecomm-grpc/server/mapping.go
toPBOrderRes
called by 4
ecomm-grpc/server/mapping.go
toPBUserRes
called by 4
ecomm-grpc/server/mapping.go
GetAuthMiddlewareFunc
called by 4
ecomm-api/handler/middleware.go

Shape

Method 336
Function 82
Struct 48
TypeAlias 6
Interface 3

Languages

Go100%

Modules by API surface

ecomm-grpc/pb/api.pb.go201 symbols
ecomm-grpc/pb/api_grpc.pb.go115 symbols
ecomm-grpc/storer/storer_mysql.go34 symbols
ecomm-grpc/server/server.go23 symbols
ecomm-api/handler/handler.go20 symbols
ecomm-grpc/server/mapping.go12 symbols
ecomm-api/handler/types.go12 symbols
ecomm-grpc/storer/types.go10 symbols
ecomm-grpc/storer/storer_mysql_test.go10 symbols
ecomm-api/handler/mapping.go10 symbols
ecomm-notification/server/server.go7 symbols
token/jwt_maker.go4 symbols

Datastores touched

(mysql)Database · 1 repos
ecommDatabase · 1 repos

For agents

$ claude mcp add ecomm \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact