Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 73fca98

Browse files
jyecuschdavemooreuws
authored andcommitted
update ws and sql sequences
1 parent ab58233 commit 73fca98

File tree

3 files changed

+89
-35
lines changed

3 files changed

+89
-35
lines changed

docs/architecture/apis.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ sequenceDiagram
113113
Nitric->>Nitric: Generate OpenAPI Spec
114114
Nitric->>Provider: Forward Nitric Spec
115115
Provider->>IAC: Provision API Gateway
116+
Provider->>IAC: Provision IAM
116117
```
117118

118119
### Runtime Sequence

docs/architecture/sql.mdx

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,46 @@ classDef edgeLabel line-height:2;
5252

5353
</details>
5454

55-
## 2. Sequence Diagram (Level 2)
55+
## 2. Sequence
56+
57+
### Build Sequence
58+
59+
Below is the sequence of events that occur when a developer registers a SQL database with Nitric.
60+
61+
```mermaid
62+
sequenceDiagram
63+
participant Worker as App Worker(s)
64+
participant SDK as Nitric SDK
65+
participant Nitric as Nitric CLI
66+
participant Provider as Nitric Provider <br> (plugin)
67+
participant IAC as IaC <br> (e.g. Terraform)
68+
69+
Worker->>SDK: Register SQL Database
70+
SDK->>Nitric: Register SQL Database
71+
72+
Nitric->>Provider: Forward Nitric Spec
73+
Provider->>IAC: Provision Database Cluster
74+
Provider->>IAC: Provision Database Instance
75+
Provider->>IAC: Provision IAM
76+
```
77+
78+
### Runtime Sequence
79+
80+
Below is the runtime flow of a database operation in a Nitric application, using the Nitric SDK. The SDK provides access to the connection details for the SQL database. All database operations are performed as usual, without any additional Nitric-specific steps.
5681

5782
```mermaid
5883
sequenceDiagram
59-
participant Client as Client
60-
participant NitricSDK as Nitric SDK
61-
participant NitricRuntime as Nitric Runtime
62-
participant SQLDatabase as SQL Database (e.g., PostgreSQL, MySQL)
63-
64-
Client->>NitricSDK: Perform SQL operation (e.g., query, insert, update)
65-
NitricSDK->>NitricRuntime: Forward SQL API call
66-
NitricRuntime->>SQLDatabase: Execute SQL operation
67-
68-
alt Successful Operation
69-
SQLDatabase-->>NitricRuntime: Return result (e.g., query data or success status)
70-
NitricRuntime-->>NitricSDK: Return result
71-
NitricSDK-->>Client: Return result to client
72-
else Failure
73-
SQLDatabase-->>NitricRuntime: Return error
74-
NitricRuntime-->>NitricSDK: Forward error
75-
NitricSDK-->>Client: Return error response
76-
end
84+
participant Client as App Code
85+
participant SDK as Nitric SDK
86+
participant Nitric as Nitric Runtime <br> (plugin)
87+
participant CloudAPI as Cloud DMBS <br> (e.g. AWS RDS)
88+
89+
Client->>SDK: connectionString()
90+
SDK->>Nitric: Forward Request
91+
Nitric->>Nitric: Convert Request
92+
Nitric->>CloudAPI: Retrieve Connection String
93+
94+
Client->>CloudAPI: Execute SQL Query
7795
```
7896

7997
## 3. Component

docs/architecture/websockets.mdx

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,31 +47,66 @@ classDef edgeLabel line-height:2;
4747

4848
## 2. Sequence
4949

50+
### Build Sequence
51+
52+
Here is the sequence of events that occur when a developer registers an Websocket API with Nitric, including the registration of handlers for connection, message, and disconnection events.
53+
54+
```mermaid
55+
sequenceDiagram
56+
participant Worker as App Worker(s)
57+
participant SDK as Nitric SDK
58+
participant Nitric as Nitric CLI
59+
participant Provider as Nitric Provider <br> (plugin)
60+
participant IAC as IaC <br> (e.g. Terraform)
61+
62+
Worker->>SDK: Register Websocket(s)
63+
SDK->>Nitric: Register Websocket(s)
64+
65+
Worker->>SDK: Register Connection Handler
66+
SDK->>Nitric: Register Connection Handler
67+
Worker->>SDK: Register Message Handler
68+
SDK->>Nitric: Register Message Handler
69+
Worker->>SDK: Register Disconnection Handler
70+
SDK->>Nitric: Register Disconnection Handler
71+
72+
Nitric->>Provider: Forward Nitric Spec
73+
Provider->>IAC: Provision Websocket API
74+
Provider->>IAC: Provision IAM
75+
```
76+
77+
### Runtime Sequence
78+
79+
Here is the sequence of events that occur at runtime when a websocket connection is established, messages are sent and received, and the connection is closed.
80+
5081
```mermaid
5182
sequenceDiagram
5283
participant Client as Client
84+
participant WSGateway as WebSocket Gateway <br> (e.g. AWS API Gateway)
85+
participant NitricRuntime as Nitric Runtime <br> (plugin)
5386
participant NitricSDK as Nitric SDK
54-
participant NitricRuntime as Nitric Runtime
55-
participant WebSocketGateway as Cloud WebSocket Gateway (e.g., AWS API Gateway, GCP WebSocket Gateway)
87+
participant App as App Code
5688
57-
Client->>NitricSDK: Connect to WebSocket endpoint
58-
NitricSDK->>NitricRuntime: Forward connection request
59-
NitricRuntime->>WebSocketGateway: Establish WebSocket connection
89+
Client->>WSGateway: Connect to ws:// endpoint
90+
WSGateway->>NitricRuntime: Forward Connection Event
91+
NitricRuntime->>NitricSDK: Connection Callback
6092
6193
loop Real-Time Communication
62-
Client->>NitricSDK: Send or receive WebSocket message
63-
NitricSDK->>NitricRuntime: Forward message
64-
NitricRuntime->>WebSocketGateway: Relay message
65-
WebSocketGateway-->>NitricRuntime: Forward response or broadcast message
66-
NitricRuntime-->>NitricSDK: Relay message to the client
67-
NitricSDK-->>Client: Deliver message
94+
alt Client Message
95+
Client->>WSGateway: Send WS Message
96+
WSGateway->>NitricRuntime: Forward Message
97+
NitricRuntime->>NitricSDK: Forward Message
98+
NitricSDK->>App: Message Callback
99+
else Server Message
100+
App->>NitricSDK: Send WS Message
101+
NitricSDK->>NitricRuntime: Forward Message
102+
NitricRuntime->>WSGateway: Forward Message
103+
WSGateway->>Client: Deliver Message
104+
end
68105
end
69106
70-
alt Disconnect
71-
Client->>NitricSDK: Disconnect from WebSocket
72-
NitricSDK->>NitricRuntime: Notify runtime
73-
NitricRuntime->>WebSocketGateway: Close WebSocket connection
74-
end
107+
Client->>WSGateway: Disconnect
108+
WSGateway->>NitricRuntime: Forward Disconnection Event
109+
NitricRuntime->>NitricSDK: Disconnection Callback
75110
```
76111

77112
## 3. Component

0 commit comments

Comments
 (0)