Giter Site home page Giter Site logo

nphattai / intelli-mall Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lordmoma/intelli-mall

0.0 0.0 0.0 3.66 MB

A distributed system that simulates a retail experience coupled with some futuristic shopping robots.

License: MIT License

Shell 0.99% JavaScript 0.64% Go 60.44% PowerShell 0.05% CSS 19.10% Makefile 0.36% HTML 12.20% HCL 5.78% Dockerfile 0.25% Gherkin 0.19%

intelli-mall's Introduction

Intelli-Mall

High-level view of the components

Intelli-Mall Architecture

Intelli-Mall AWS Architecture

Intelli-Mall AWS Architecture

How to start the application

Starting the monolith:

docker compose --profile monolith up

Starting the microservices

docker compose --profile microservices up  

Note: my local machine is Mac M2 ARM64, be sure to locate the docker image with the tag version compatible with your machine architecture.

How to generate .pb.go files for the microservices

let's take baskets microservice for example, once you have your .proto files like api.proto and events.proto specified in basketspb folder:

cd baskets && go generate

buf generate inside the generate.go file will generate based on what is configured in the buf.gen.yaml file.

Note: mockery tool in the Makefile @go install github.com/vektra/mockery/v2@latest will generate files starting with mock_ that contains a mock implementation of the BasketServiceClient interface defined in the basketspb package. The mock implementation allows you to test your code in isolation from the real implementation of the BasketServiceClient interface, making it easier to test and debug your code.

For more info on using buf, please go to buf tutorial

Docker Compose with either a monolith or microservices

Screenshot of Intelli-Mall

Swagger UI

Screenshot of Intelli-Mall

The monitoring services

Screenshot of Intelli-Mall

Use /cmd/busywork to simulate several users making requests to perform several different activities:

cd cmd/busywork
go run .

Busywork Output

07:55:36.221473 [Client 1] is considering adding new inventory
07:55:36.687106 [Client 3] is considering registering a new account
07:55:37.281486 [Client 1] is adding "Refined Wooden Computer" for $6.76
07:55:38.797600 [Client 1] is adding "Oriental Granite Keyboard" for $8.81
07:55:39.115718 [Client 2] is considering registering a new account
07:55:40.790283 [Client 1] is adding "Unbranded Steel Chair" for $8.65
07:55:40.797666 [Client 1] is done adding new inventory
07:55:42.595664 [Client 4] is considering adding new inventory
07:55:43.460873 [Client 4] is adding "Rustic Rubber Fish" for $9.26
07:55:44.069827 [Client 4] is adding "Licensed Frozen Pants" for $11.21
07:55:45.709748 [Client 5] is considering browsing for new things
07:55:45.721676 [Client 4] is adding "Practical Metal Towels" for $6.27
07:55:45.729938 [Client 4] is done adding new inventory
07:55:46.598130 [Client 3] is considering adding new inventory
07:55:47.884613 [Client 5] is browsing the items from "William Connelly"
07:55:48.285565 [Client 3] is adding "Incredible Granite Chips" for $10.04
07:55:49.448966 [Client 3] is adding "Handmade Bronze Chicken" for $6.83
07:55:49.651385 [Client 5] might buy 3 "Rustic Concrete Pants" for $7.37 each
07:55:50.290852 [Client 5] thinks $22.11 is too much
07:55:50.297213 [Client 5] Quitting time
07:55:50.394300 [Client 3] is adding "Intelligent Rubber Shirt" for $10.36
07:55:50.400688 [Client 3] is done adding new inventory
07:55:50.400713 [Client 3] Quitting time
07:55:50 busywork shutdown

You can increase the number of clients by passing in the -clients=n flag, with an upper limit of 25.

The Jaeger UI for tracing

Open http:// localhost:8081 in your browser to open Jaeger.

Screenshot of Intelli-Mall

Traces that involved the baskets service

Screenshot of the Jaeger UI for tracing

Viewing the monitoring data

Screenshot of the Jaeger UI for tracing

Clicking on one of the rows in the graph will provide you with additional details.

The Prometheus UI

We also have the metrics to check out in Prometheus at http://localhost:9090

Screenshot of received messages counts for the cosec service

Searching for the received messages counts for the cosec service

Screenshot of received messages counts for the cosec service

Grafana UI for more compelling intepretation - Intelli Mall App Dashboard

Opening localhost:3000/ and then browsing for dashboards will show the two dashboards that are installed under the intellimall folder.

Screenshot of OpenTelemetry Collector dashboard

How much activity you see in the dashboard will depend on how many clients you have running in the busywork application and the random interactions that the clients are performing.

OpenTelemetry Collector dashboard

Screenshot of OpenTelemetry Collector dashboard

Details about how much work the collector is doing.

How does Terminal reflect the events:

grafana        | logger=context traceID=00000000000000000000000000000000 userId=0 orgId=1 uname= t=2023-09-20T12:06:26.480212513Z level=info msg="Request Completed" method=POST path=/api/ds/query status=400 remote_addr=172.18.0.1 time_ms=21 duration=21.768709ms size=99 referer="http://localhost:3000/d/Pc9ixd4Vk/application?orgId=1&refresh=30s" traceID=00000000000000000000000000000000
collector      | 2023-09-20T12:13:41.244Z       info    TracesExporter  {"kind": "exporter", "data_type": "traces", "name": "logging", "#spans": 2}
grafana        | logger=live t=2023-09-20T12:18:33.088289544Z level=info msg="Initialized channel handler" channel=grafana/dashboard/uid/BKf2sowmj address=grafana/dashboard/uid/BKf2sowmj
prometheus     | ts=2023-09-20T13:04:51.975Z caller=compact.go:519 level=info component=tsdb msg="write block" mint=1695204291419 maxt=1695211200000 ulid=01HASB306VTMA1K6NRP5ZCCEQ3 duration=44.237792ms

Business logic flow

read after write

read after write

transactions

transactions

notification ordering

notification ordering

adding items

adding items

async pay invoice

async pay invoice

create order with domain events

create order with domain events

intelli-mall's People

Contributors

lordmoma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.