From dc43eece4f9b49e50eaa8ef0c244c2616f10434b Mon Sep 17 00:00:00 2001 From: Robert Mitchell Date: Wed, 7 Aug 2024 13:38:32 -0700 Subject: [PATCH] Create architecture diagram for the `trigger-code-reference` (#2334) * use json array form to solve buildx warning about shell interpretation and OS signal handling * move description -> README; container build/tests passed locally * add tcr arc diagram --- containers/trigger-code-reference/Dockerfile | 4 +- .../{description.md => README.md} | 48 +++++++++++++++++-- containers/trigger-code-reference/app/main.py | 2 +- 3 files changed, 46 insertions(+), 8 deletions(-) rename containers/trigger-code-reference/{description.md => README.md} (62%) diff --git a/containers/trigger-code-reference/Dockerfile b/containers/trigger-code-reference/Dockerfile index bbdbecf32d..678de9c6a1 100644 --- a/containers/trigger-code-reference/Dockerfile +++ b/containers/trigger-code-reference/Dockerfile @@ -8,7 +8,7 @@ RUN pip install -r requirements.txt COPY ./app /code/app COPY ./assets /code/assets COPY ./seed-scripts /code/seed-scripts -COPY ./description.md /code/description.md +COPY ./README.md /code/README.md EXPOSE 8080 -CMD uvicorn app.main:app --host 0.0.0.0 --port 8080 \ No newline at end of file +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"] diff --git a/containers/trigger-code-reference/description.md b/containers/trigger-code-reference/README.md similarity index 62% rename from containers/trigger-code-reference/description.md rename to containers/trigger-code-reference/README.md index 5cfbf521de..e410cc0ca3 100644 --- a/containers/trigger-code-reference/description.md +++ b/containers/trigger-code-reference/README.md @@ -1,4 +1,4 @@ -## Getting Started with the DIBBs Trigger Code Reference Service +## Getting Started with the DIBBs Trigger Code Reference Service ### Introduction @@ -6,13 +6,13 @@ The DIBBs Trigger Code Reference (TCR) service offers a REST API devoted to quer ### Running the Trigger Code Reference Service -You can run the TCR using Docker. another OCI container runtime (e.g., Podman), or directly from the Python source code. +You can run the TCR using Docker. another OCI container runtime (e.g., Podman), or directly from the Python source code. #### Running with Docker (Recommended) To run the trigger code reference with Docker, follow these steps. -1. Confirm that you have Docker installed by running docker -v. If you don't see a response similar to what's shown below, follow [these instructions](https://docs.docker.com/get-docker/) to install Docker. +1. Confirm that you have Docker installed by running docker -v. If you don't see a response similar to what's shown below, follow [these instructions](https://docs.docker.com/get-docker/) to install Docker. ``` ❯ docker -v @@ -26,7 +26,7 @@ Congratulations, the TCR should now be running on `localhost:8080`! #### Running from Python Source Code -We recommend running the TCR from a container, but if that isn't feasible for a given use case, you can also run the service directly from Python using the steps below. +We recommend running the TCR from a container, but if that isn't feasible for a given use case, you can also run the service directly from Python using the steps below. 1. Ensure that both Git and Python 3.10 or higher are installed. 2. Clone the PHDI repository with `git clone https://github.com/CDCgov/phdi`. @@ -47,4 +47,42 @@ To build the Docker image for the trigger code reference from source instead of ### The API -When viewing these docs from the `/redoc` endpoint on a running instance of the TCR or the DIBBs website, detailed documentation on the API will be available below. +When viewing these docs from the `/redoc` endpoint on a running instance of the TCR or the DIBBs website, detailed documentation on the API will be available below. + +### Architecture Diagram + +```mermaid +flowchart LR + +subgraph requests["Requests"] + direction TB + subgraph GET["fas:fa-download GET"] + hc["/\n(Health Check)"] + getValueSets["/get-value-sets\n(Get Value Sets for Condition)"] + end + subgraph POST["fas:fa-upload POST"] + stampConditionExtensions["/stamp-condition-extensions\n(Stamp Condition Extensions)"] + end +end + +subgraph service[REST API Service] + direction TB + subgraph container["fab:fa-docker container"] + tcr["fab:fa-python trigger-code-reference
HTTP:8080/
"] + db["fas:fa-database SQLite DB"] + end +end + +subgraph response["Responses"] + subgraph JSON["fa:fa-file-alt JSON"] + rsp-hc["fa:fa-file-code OK fa:fa-thumbs-up"] + rsp-getValueSets["fa:fa-file-code Value Sets"] + rsp-stampConditionExtensions["fa:fa-file-code Stamped Bundle"] + end +end + +hc -.-> tcr -.-> rsp-hc +getValueSets -.-> tcr -.-> rsp-getValueSets +stampConditionExtensions ==> tcr ==> rsp-stampConditionExtensions +tcr --> db +``` diff --git a/containers/trigger-code-reference/app/main.py b/containers/trigger-code-reference/app/main.py index 33b3d13502..6bcb33cc8d 100644 --- a/containers/trigger-code-reference/app/main.py +++ b/containers/trigger-code-reference/app/main.py @@ -26,7 +26,7 @@ app = BaseService( service_name="Trigger Code Reference", service_path="/trigger-code-reference", - description_path=Path(__file__).parent.parent / "description.md", + description_path=Path(__file__).parent.parent / "README.md", openapi_url="/trigger-code-reference/openapi.json", ).start()