Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand documentation #75

Merged
merged 33 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9921366
revised the README to remove the part about the application being und…
tomwheeler Jul 9, 2024
3dfcaaf
removed extra space that was being rendered as a linebreak in GitHub
tomwheeler Jul 9, 2024
dc228b7
mention maintenance mode
tomwheeler Jul 9, 2024
749cb27
moving sequence diagram to TRD document and reusing the overview.md f…
tomwheeler Jul 9, 2024
dd39b6f
expanding the project documentation
tomwheeler Jul 13, 2024
a98b755
Changed 'The' to 'An' so it applies to order management systems in ge…
tomwheeler Jul 13, 2024
98c0a6d
normalized spaces
tomwheeler Jul 13, 2024
eeef4fe
simplified sentence
tomwheeler Jul 13, 2024
535c9df
fix some typos
tomwheeler Jul 13, 2024
321f150
Changed title to remove "basic" since that lacked context here
tomwheeler Jul 13, 2024
9310af2
removed duplicate word
tomwheeler Jul 13, 2024
f57c541
fixed typo
tomwheeler Jul 15, 2024
cbec917
clarified from which directory the command should be run
tomwheeler Jul 15, 2024
51c71fb
added Paul's suggestion to verify service startup by using the Web UI
tomwheeler Jul 15, 2024
25260cf
Revised phrasing about running multiple Workers, per Paul's suggestion.
tomwheeler Jul 15, 2024
f43ce9d
Clarified that we're discussing specific Worker instances, not Worker…
tomwheeler Jul 15, 2024
1489713
added sentence about distribution of load, as per Paul's suggestion.
tomwheeler Jul 15, 2024
133da45
incorporated some feedback from Paul's review
tomwheeler Jul 15, 2024
46a02b6
Slight revision based on review feedback
tomwheeler Jul 15, 2024
93f0935
fixed typo (it's -> its)
tomwheeler Jul 15, 2024
1b0eeaf
formatted with line breaks for easier editing in the terminal; also m…
tomwheeler Jul 15, 2024
dfe6540
fix typo (missing "i" in "services")
tomwheeler Jul 16, 2024
f65c7d2
changed spelling
tomwheeler Jul 16, 2024
980c4bd
fix typo
tomwheeler Jul 16, 2024
9f99c9f
incorporated some suggestions from Paul's review
tomwheeler Jul 16, 2024
14f37b6
enlarged Web UI image and renamed the file
tomwheeler Jul 16, 2024
1d39713
improved grammar
tomwheeler Jul 16, 2024
8a32338
renamed high-level overview diagram, resized it, and made it a little…
tomwheeler Jul 16, 2024
7ab3b9d
updated Namespace display
tomwheeler Jul 16, 2024
811d49c
renamed and resized images related to data converter explanation
tomwheeler Jul 16, 2024
4fded93
scaled image
tomwheeler Jul 16, 2024
fff0210
scaled images and added depiction of data converter
tomwheeler Jul 16, 2024
043e308
added some headings to break up the long passages of text
tomwheeler Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ system with Temporal. You can run this application locally
the Temporal Service can be local, a remote self-hosted deployment,
or Temporal Cloud.

NOTE: This application is under development and we're working to
expand the documentation before we officially announce it.

## Quickstart
We recommend that you begin by reading the [documentation](docs/README.md),
which will explain the features of the application and aspects
Expand All @@ -30,23 +27,21 @@ Run the following command in your terminal:
temporal server start-dev --ui-port 8080 --db-filename temporal-persistence.db
```

This command uses the `--db-filename` option so that the development
server will persist its data to a file instead of memory, thus making
it available during later sessions. The file will be created if it
does not already exist.
The Temporal Service manages application state by assigning tasks
related to each execution and tracking the completion of those tasks.
The detailed history it maintains for each execution enables the
application to recover from a crash by reconstructing its pre-crash
state and resuming the execution.

### Start the Worker
### Start the Workers
Run the following command in another terminal:

```command
go run ./cmd/oms worker
```

Although one Worker is sufficient for local development, Temporal
recommends running multiple Workers in production since this can
improve both the scalability and availability of an application.
You can repeat this step to launch as many additional Workers as
you like.
The Workers run the Workflow and Activity functions that handle
various aspects of order processing.

### Start the API Servers
Run the following command in another terminal:
Expand Down Expand Up @@ -80,8 +75,8 @@ You will then be able to access the OMS web application at
<http://localhost:5173/> and the Temporal Web UI at
<http://localhost:8080/>. In the OMS web application, select
the **User** role, and then submit an order (we recommend
choosing order #1 to start). Next, return to the main page of
the web application, select the **Courier** role, locate
choosing order #1 to start). Next, return to the main page
of the web application, select the **Courier** role, locate
the shipments corresponding to your order, and then click
the **Dispatch** and **Deliver** buttons to complete the
process. As you proceed with each of these steps, be sure
Expand Down
32 changes: 29 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,33 @@
![OMS logo](images/oms-logo.png)

The documentation for the Order Management System reference application
is split up into multiple sections:
is organized into multiple sections:

## Understanding the OMS
* [Overview](overview.md):
Provides a brief high-level overview of the OMS
* [Product Requirements](product-requirements.md):
Describes what the OMS does
* [Technical Description](technical-description.md):
Describes the design and implementation of the OMS

## Running the OMS
* [Run: Basic](run-basic.md):
Provides step-by-step instructions for running the
application locally and using a local Temporal Service.
<!--
* [Run: Temporal Cloud](run-temporal-cloud.md):
TODO Provides step-by-step instructions for running the
application locally and using the Temporal Service provided
by Temporal Cloud.
* [Run: Codec Server](run-codec-server.md):
TODO Provides step-by-step instructions for running the
application and Temporal Service locally, with a Data
Converter to encrypt confidential information and a
Codec Server that enables you to view decrypted data
in the Temporal Web UI.
-->

## Deploying the OMS
* [Deploying to Kubernetes](deploy-on-k8s.md)

* [Product Requirements](product-requirements.md) - describes what the OMS does
* (Other content is forthcoming, including detailed instructions for running and deploying the application, plus commentary on the design)
Binary file added docs/images/communication-1020w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/oms-architecture-scaled-1200w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/web-ui-example-1020w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/with-data-converter-650w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/without-data-converter-650w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
120 changes: 95 additions & 25 deletions docs/overview.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,95 @@
# System Overview

```mermaid
sequenceDiagram
participant Customer
participant Order
participant Inventory
participant Billing
participant Shipment
participant Courier

Customer->>Order: place order
Order->>Inventory: fulfill order
Order->>Billing: create invoice
Order->>Billing: charge customer
Order->>Shipment: create shipment
Shipment->>Courier: book shipment
Courier->>Shipment: shipment booked
Shipment->>Customer: shipment booked
Courier->>Shipment: shipment dispatched
Shipment->>Customer: shipment dispatched
Courier->>Shipment: shipment delivered
Shipment->>Customer: shipment delivered
Order->>Customer: order complete
```
# About the Order Management System

The Order Management System (OMS) reference application illustrates a
common use case for Temporal: processing product orders from customers.

## OMS Overview

An OMS is inherently a back-end system, but we provide a basic web
application that offers a convenient way to interact with it. It is
also possible to interact with it using APIs provided by the OMS or
through the `temporal` command-line tool.

The following diagram illustrates the high-level interaction that
takes place when a user submits an order through the web application:

![OMS high-level overview diagram](images/high-level-overview-diagram-900w.png "OMS high-level overview diagram")

Notice that each item is only connected to the items adjacent to it.
The user does not interact with either the OMS or the Temporal
Service. Likewise, the web application does not use any Temporal
libraries or tools; it only calls APIs provided by the OMS. This
design increases both security and flexibility.

## Order Processing Overview
The input to the OMS is an order, which has a unique identifier, is
associated with a customer, and specifies a list of SKUs (products)
along with the quantities.

Upon receiving an order, the OMS launches a Workflow to orchestrate
all of the steps required to process it. This includes claiming the
items from inventory, generating invoices and charging the customer
for each shipment, and booking couriers who pick them up from the
warehouse and deliver them to the customers. This Workflow ends when
all shipments have been delivered or when canceled by the business or
customer.


## Benefits of Using the Temporal Platform

### Reliability
The application gains reliability from the support provided by the
Temporal Service, which automatically manages application state and
allows the system to withstand failure conditions. Once the OMS
receives an order, that order will be processed, no matter what.

If the application makes a call to a microservice that’s experiencing
an outage, for example, that call will be retried according to a
configurable policy. When the microservice comes back online, the call
will succeed on the next retry attempt and further processing will
follow.

If the application terminates unexpectedly while processing is
underway, the application can automatically reconstruct the
pre-termination state and resume where it left off, as if the problem
never happened at all. You can even resume that execution on another
machine, which allows the application to overcome hardware failures.

### Scalability
You can increase throughput—enabling the system to handle more orders
concurrently—by running additional instances of the application.
Although Temporal applications can run on bare metal or virtual
machines, many users deploy them in containers managed through
Kubernetes, and use metrics provided by the Temporal Service to
scale them up or down in response to changing demand.

### Availability
Each additional instance contributes to the application's
availability. If one of those instances crashes, another running
instance will automatically take over processing from where the
previous one left off.

Any instance can automatically take over processing for one that fails
(for example, due to a hardware crash).

### Developer Productivity
Although often initially overlooked, developers who begin using
Temporal soon realize that they're much more productive. They
spend less time writing code to handle failure scenarios, which
frees them up to focus on the business logic and ship features
faster.

The productivity boost is also evident in production. The Temporal
Service maintains a complete Event History for every execution. Its
corresponding Web UI provides a convenient way to view the timeline
and details of these Events, both for orders in progress as well as
those that have already completed. The result is immediate insight
into the status of every order processed.

![Screenshot of an Order Workflow in Temporal Web UI](images/web-ui-example-1020w.png "Screenshot of an Order Workflow in Temporal Web UI")

In fact, a developer can download the Event History for any execution
and replay it in a debugger, making it possible to [reproduce and fix
elusive bugs](https://www.youtube.com/watch?v=fN5bIL7wc5M) in your
application code. And once it is fixed, you can use that history file
in an automated test and be confident that there are no regressions.
7 changes: 6 additions & 1 deletion docs/product-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


## Vision
The Order Management System (OMS) is a mission-critical system for
An Order Management System (OMS) is a mission-critical system for
processing product orders.

Reliability is essential, since failure to process individual orders
Expand Down Expand Up @@ -94,9 +94,14 @@ click the "Deliver" button. These interactions update the current status
of each shipment and are immediately visible to customers and support
staff.


### Manager Interaction
As previously described, the store manager has the ability to combat
fraud by setting a global limit on the total charges (expressed in
cents) that each customer is allowed. This is set to 0 by default,
meaning that there is no limit. The manager can increase, decrease,
or reset this limit at any time.

Additionally, the manager can enable a maintenance mode in this
fraud detection system. When this is enabled, no new charges are
allowed, regardless of amount.
93 changes: 93 additions & 0 deletions docs/run-basic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Running the OMS Locally

Follow these instructions to run the OMS locally, using the
Temporal Service provided that the `temporal` command. This
tomwheeler marked this conversation as resolved.
Show resolved Hide resolved
is an expanded version of the instructions found in the
_Quickstart_ section of the top-level README file.


### Start the Temporal Service

Run the following command in your terminal to start the Temporal
tomwheeler marked this conversation as resolved.
Show resolved Hide resolved
Service:

```command
temporal server start-dev \
--ui-port 8080 \
--db-filename temporal-persistence.db
```

The `temporal` CLI provides a convenient way of running a
Temporal Service locally for development purposes. By default,
it provides a Web UI on port 8233 and persists data to an
ephemeral in-memory database. The options in this command
change the Web UI port to 8080 and instructs the Temporal
Service to persist its data to a file so that it will be
available in subsequent sessions. This file will be created
if it does not exist.

tomwheeler marked this conversation as resolved.
Show resolved Hide resolved

### Start the Worker

Run the following command in another terminal to start the Workers:

```command
go run ./cmd/oms worker
```

The Workers run the Workflow and Activity code used to implement the
tomwheeler marked this conversation as resolved.
Show resolved Hide resolved
OMS. Although one Worker is sufficient for local development, Temporal
tomwheeler marked this conversation as resolved.
Show resolved Hide resolved
recommends running multiple Workers in production since this can improve
tomwheeler marked this conversation as resolved.
Show resolved Hide resolved
both the scalability and availability of an application. You can repeat
this step to launch as many additional Workers as you like.
tomwheeler marked this conversation as resolved.
Show resolved Hide resolved


### Start the API Servers

Run the following command in another terminal to start the API Servers:

```command
go run ./cmd/oms api
```

The API Servers provide REST APIs that the web application uses to
interact with the OMS.


### Run the Web Application
You will need to clone the code for the web application, which is
maintained in the [reference-app-orders-web](https://github.com/temporalio/reference-app-orders-web)
repository:

```command
cd ..
git clone https://github.com/temporalio/reference-app-orders-web.git
```
tomwheeler marked this conversation as resolved.
Show resolved Hide resolved

You will then need to run the following commands to start it:

```command
cd reference-app-orders-web
pnpm install
pnpm dev
```

<!--
TODO: expand this section to cover more advanced cases
and then move it to a separate document (with a
demo video) that can be referenced by the other
instructions for running it.
-->

You will then be able to access the OMS web application at
<http://localhost:5173/> and the Temporal Web UI at
<http://localhost:8080/>. In the OMS web application, select
tomwheeler marked this conversation as resolved.
Show resolved Hide resolved
the **User** role, and then submit an order (we recommend
choosing order #1 to start). Next, return to the main page of
the web application, select the **Courier** role, locate
the shipments corresponding to your order, and then click
the **Dispatch** and **Deliver** buttons to complete the
process. As you proceed with each of these steps, be sure
to refresh the Temporal Web UI so that you can see the
Workflows created and updated as a result.

Loading