You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-8Lines changed: 9 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,22 +4,23 @@ Dapr Store is a sample/reference application showcasing the use of [Dapr](https:
4
4
5
5
[Dapr](https://dapr.io/) is an _"event-driven, portable runtime for building microservices on cloud and edge"_. The intention of this project was to show off many of the capabilities and features of Dapr, but in the context of a real working application. This has influenced the architecture and design decisions, balancing between realism and a simple _"demo-ware"_ showcase.
6
6
7
-
The backend microservices are written in Go (however it's worth nothing that Dapr is language independent), and the frontend is a single-page application (SPA) written in [Vue.js](https://vuejs.org/). All APIs are REST & HTTP based
7
+
The backend microservices are written in Go (however it's worth noting that Dapr is language, framework and platform independent), and the frontend is a single-page application (SPA) written in [Vue.js](https://vuejs.org/). All APIs are REST & HTTP based
8
8
9
9
This repo is a monorepo, containing the source for several discreet but closely linked codebases, one for each component of the project, as described below.
10
10
The ["Go Standard Project Layout"](https://github.com/golang-standards/project-layout) has been used.
11
11
12
12
# Architecture
13
13
14
14
The following diagram shows all the components of the application and main interactions. It also highlights which Dapr API/feature (aka Dapr building block) is used and where.
15
-

15
+
16
+

16
17
17
18
## Dapr Interfaces & Building Blocks
18
19
19
20
The application uses the following [Dapr Building Blocks](https://docs.dapr.io/developing-applications/building-blocks/) and APIs
20
21
21
22
-**Service Invocation** — The API gateway calls the four main microservices using HTTP calls to [Dapr service invocation](https://docs.dapr.io/developing-applications/building-blocks/service-invocation/service-invocation-overview/). This provides retries, mTLS and service discovery.
22
-
-**State** — State is held for users and orders using the [Dapr state management API](https://docs.dapr.io/developing-applications/building-blocks/state-management/state-management-overview/). The state provider used is Redis, however any other provider could be plugged in without any application code changes.
23
+
-**State** — State is held for *users* and *orders* using the [Dapr state management API](https://docs.dapr.io/developing-applications/building-blocks/state-management/state-management-overview/). The state provider used is Redis, however any other provider could be plugged in without any application code changes.
23
24
-**Pub/Sub** — The submission of new orders through the cart service, is decoupled from the order processing via pub/sub messaging and the [Dapr pub/sub messaging API](https://docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-overview/). New orders are placed on a topic as messages, to be collected by the orders service. This allows the orders service to independently scale and separates our reads & writes
24
25
-**Output Bindings** — To communicate with downstream & 3rd party systems, the [Dapr Bindings API](https://docs.dapr.io/developing-applications/building-blocks/bindings/bindings-overview/) is used. This allows the system to carry out tasks such as saving order details into external storage (e.g. Azure Blob) and notify uses with emails via SendGrid
25
26
-**Middleware** — Dapr supports a range of HTTP middleware, for this project traffic rate limiting can enabled on any of the APIs with a single Kubernetes annotation
@@ -80,7 +81,7 @@ This provides a simple user profile service to the Dapr Store. Only registered u
80
81
It is written in Go, source is in `cmd/users` and it exposes the following API routes:
81
82
82
83
```
83
-
/register POST a new user to register them
84
+
/register POST a new user, to register & create them
84
85
/get/{userId} GET the user profile for given user
85
86
/private/get/{userId} GET the user profile for given user. Private endpoints are NOT exposed through the gateway
86
87
/isregistered/{userId} GET the registration status for a given user
@@ -122,7 +123,7 @@ It is written in Go, source is in `cmd/cart` and it exposes the following API ro
122
123
```text
123
124
/setProduct/{userId}/{productId}/{count} PUT a number of products in the cart of given user
124
125
/get/{userId} GET cart for user
125
-
/submit POST submit a cart, and turn it into an 'Order'
126
+
/submit POST submit a cart, and turn it into an 'Order'
126
127
/clear/{userId} PUT clear a user's cart
127
128
```
128
129
@@ -138,13 +139,13 @@ The service is responsible for maintaining shopping carts for each user and pers
138
139
139
140
This is the frontend accessed by users of store and visitors to the site. It is a single-page application (SPA) as such it runs entirely client side in the browser. It was created using the [Vue CLI](https://cli.vuejs.org/) and written in Vue.js
140
141
141
-
It follows the standard SPA pattern of being served via static hosting (the 'frontend host' described below) and all data is fetched via a REST API endpoint. Note. [Vue Router](https://router.vuejs.org/) is used to provide client side routing, as such it needs to be served from a host that is configured to support it.
142
+
It follows the standard SPA pattern of being served via static hosting (the 'frontend host' described below) and all data is fetched from the client browser, via a REST API endpoint. Note. [Vue Router](https://router.vuejs.org/) is used to provide client side routing, as such it needs to be served from a host that is configured to support it.
142
143
143
-
The default API endpoint is `/` and it makes calls to the Dapr invoke API, namely `/v1.0/invoke/{service}` this is routed via the _API gateway_ to the various services.
144
+
The default API endpoint is `/` and it makes calls to the _API gateway_ to invoke the Dapr invoke API, namely `/v1.0/invoke/{service}` this is routed via Dapr from the _API gateway_ to the various services.
144
145
145
146
## 📡 Frontend host
146
147
147
-
A very standard static content server using gorilla/mux. See https://github.com/gorilla/mux#static-files. It simply serves up the static bundled files output from the build process of the frontend, it expects to find these files in `./dist` directory but this is configurable
148
+
A very standard static content server using the [github.com/benc-uk/go-rest-api SPA handler](https://github.com/benc-uk/go-rest-api/blob/main/pkg/static/spa.go). It simply serves up the static bundled files output from the build process of the frontend, it expects to find these files in `./dist` directory but this is configurable.
148
149
149
150
In addition it exposes a simple `/config` endpoint, this is to allow dynamic configuration of the frontend. It passes two env vars `AUTH_CLIENT_ID` and `API_ENDPOINT` from the frontend host to the frontend Vue SPA as a JSON response, which are fetched & read as the app is loaded in the browser.
0 commit comments