This repository was archived by the owner on May 20, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 17
add architecture sections to docs #701
Merged
Merged
Changes from 32 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
9835ce5
Add mermaid-mdx and basic sitewide config.
tjholm d8fd010
update global theme, and apis diagram.
tjholm cd4f7fc
center align diagrams and add more examples.
tjholm 1788b62
try install additional deps.
tjholm d5b80f5
fix config.
tjholm ce438ff
install browser before deps.
tjholm b004e25
fix vercel cache issue (#695)
davemooreuws 57e2363
use defaults for non vercel env
davemooreuws cc12345
wip: experimenting with c4 diagrams
raksiv a1141ae
wip: feedback
raksiv a3023df
edits
jyecusch 4bbf8be
wip: feedback
raksiv da876e6
nitric diagram styling wip
davemooreuws 09bcffb
split API sequence diagrams between runtime and build time
jyecusch 12f22f2
update storage sequence diagrams
jyecusch 909d705
update kv sequences
jyecusch 66cab4d
add zoom and panning to mermaid svgs
davemooreuws 265ad59
update async messaging sequences
jyecusch ed50b16
remove unused prop
davemooreuws 6cf6fc6
update schedule sequences
jyecusch ab58233
Update secrets sequences
jyecusch 73fca98
update ws and sql sequences
jyecusch cf5f77e
add aria-label to mermaid zoom buttons
davemooreuws 6390009
fix typos and broken links
davemooreuws d5c1f7e
update reference link
davemooreuws d13a24d
remove diagrams on resource pages add linking to architecture page
HomelessDinosaur 0a122ac
fix broken links
davemooreuws c35e578
Apply suggestions from code review
davemooreuws d71b980
fixes and style summary element
davemooreuws da39283
add multi lang examples to arch services page
davemooreuws c758bb4
add pulumi references to infra docs
davemooreuws bc96ddc
update and improve seo descriptions
davemooreuws 4ee4cdc
Apply suggestions from code review
HomelessDinosaur fc17725
Update docs/architecture/index.mdx
HomelessDinosaur f26de9a
update architecture over page
jyecusch c52f62b
Add an intro to the services page
jyecusch 077c64c
minor edits
jyecusch cb84238
fix spellcheck
davemooreuws File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const isCI = !!process.env.VERCEL_ENV | ||
|
||
if (!isCI) { | ||
// just use the default configuration on non vercel CI environments | ||
return {} | ||
} | ||
|
||
/** | ||
* @type {import("puppeteer").Configuration} | ||
*/ | ||
module.exports = { | ||
cacheDirectory: '/vercel/.cache/puppeteer', | ||
executablePath: | ||
'/vercel/.cache/puppeteer/chrome/linux-131.0.6778.204/chrome-linux64/chrome', | ||
chrome: { | ||
skipDownload: true, | ||
}, | ||
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'], | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
mesa-libgbm | ||
nss | ||
nspr | ||
at-spi2-atk | ||
cups-libs | ||
libdrm | ||
libXcomposite | ||
libXdamage | ||
libXext | ||
libXrandr | ||
libgbm | ||
libxcb | ||
alsa-lib | ||
atk | ||
gtk3 | ||
pango | ||
libxkbcommon |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,6 +236,13 @@ EC2 | |
.jpg | ||
preflight | ||
lifecycle | ||
NodeJS | ||
priviledge | ||
APIS | ||
TLS | ||
SRE | ||
ACM | ||
nav | ||
MacOS | ||
quantized | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
--- | ||
description: 'Learn how Nitric provisions and manages APIs across AWS, GCP, and Azure using Terraform and Pulumi.' | ||
--- | ||
|
||
# APIs | ||
|
||
## 1. System Context | ||
|
||
**Developers** use Nitric to define required APIs and routes/methods within their application. | ||
|
||
- App code uses the [API resource](/apis) to define APIs and their routes/methods. | ||
- Developers define API(s) their application requires, including the specifications and implement logic to handle HTTP requests. | ||
- Authentication, authorization, and middleware can be added to API routes to secure and enhance functionality. | ||
|
||
**Operations** use default or overridden IaC (e.g Terraform modules) to provision the necessary resources for their target cloud(s), such as API Gateways. | ||
|
||
<details> | ||
<summary>Example AWS Provider</summary> | ||
|
||
- **AWS API Gateway v2** serves as the HTTP API management service. | ||
- **AWS Lambda** functions are deployed to handle API requests. | ||
- **AWS IAM** (automated using IaC) provides roles and policies for secure interaction between API Gateway and Lambda functions. | ||
- **AWS ACM** manages TLS certificates for custom domain names. | ||
|
||
```mermaid | ||
flowchart TD | ||
Developer["Developer"] | ||
Operations["Operations"] | ||
App["nitric up"] | ||
APIGateway["AWS API Gateway v2<br>(HTTP API)"] | ||
Lambda["AWS Lambda Functions"] | ||
IAM["AWS IAM"] | ||
ACM["AWS ACM<br>(Certificates)"] | ||
|
||
Developer -->|Define API| App | ||
Operations -->|Terraform| App | ||
App -->|Create API Gateway| APIGateway | ||
App -->|Deploy Lambda Functions| Lambda | ||
App -->|Configure Permissions| IAM | ||
APIGateway -->|Invoke| Lambda | ||
ACM -->|Provide Certificates| APIGateway | ||
IAM -->|Manage Access| APIGateway | ||
App -->ACM | ||
|
||
classDef default line-height:1; | ||
classDef edgeLabel line-height:2; | ||
``` | ||
|
||
</details> | ||
<details> | ||
<summary>Example GCP Provider</summary> | ||
|
||
- **Google API Gateway** serves as the HTTP API management service, routing requests to backend services. | ||
- **Google Cloud Run** services are deployed to handle API requests with serverless execution. | ||
- **Google IAM** provides roles and policies to secure interactions between API Gateway, Cloud Run, and other GCP services. | ||
- **Certificates** (Google-managed or custom) ensure secure HTTPS communication for custom domain names. | ||
- **Google Service Account** is created and configured to allow API Gateway to invoke the Cloud Run backend securely. | ||
|
||
```mermaid | ||
flowchart TD | ||
Developer["Developer"] | ||
Operations["Operations"] | ||
App["nitric up"] | ||
APIGateway["Google API Gateway"] | ||
CloudRun["Google Cloud Run"] | ||
IAM["Google IAM"] | ||
Certificates["Certificates<br>(Google Managed or Custom)"] | ||
ServiceAccount["Google Service Account"] | ||
|
||
Developer -->|Define API| App | ||
Operations -->|Terraform| App | ||
App -->|Create API Gateway| APIGateway | ||
App -->|Deploy Cloud Run Services| CloudRun | ||
App -->|Configure Permissions| IAM | ||
APIGateway -->|Invoke| CloudRun | ||
Certificates -->|Provide Certificates| APIGateway | ||
IAM -->|Manage Access| APIGateway | ||
App -->ServiceAccount | ||
App -->Certificates | ||
|
||
classDef default line-height:1; | ||
classDef edgeLabel line-height:2; | ||
``` | ||
|
||
</details> | ||
|
||
## 2. Sequence | ||
|
||
### Build Sequence | ||
|
||
Here is the sequence of events that occur when a developer registers an API with Nitric, including the registration of routes, security, and middleware. | ||
|
||
```mermaid | ||
sequenceDiagram | ||
participant Worker as App Worker(s) | ||
participant SDK as Nitric SDK | ||
participant Nitric as Nitric CLI | ||
participant Provider as Nitric Provider <br> (plugin) | ||
participant IAC as IaC <br> (e.g. Terraform) | ||
|
||
Worker->>SDK: Register API(s) | ||
SDK->>Nitric: Register API(s) | ||
|
||
opt Authentication | ||
Worker->>SDK: Register Security | ||
SDK->>Nitric: Register Security | ||
end | ||
|
||
Worker->>SDK: Register Route Callback(s) | ||
SDK->>Nitric: Register Route(s) | ||
Worker->>SDK: Register Middleware(s) | ||
|
||
Nitric->>Nitric: Generate OpenAPI Spec | ||
Nitric->>Provider: Forward Nitric Spec | ||
Provider->>IAC: Provision API Gateway | ||
Provider->>IAC: Provision IAM | ||
``` | ||
|
||
### Runtime Sequence | ||
|
||
Here is the sequence of events that occur at runtime when a client makes an HTTP request to an API registered and deployed using Nitric. | ||
|
||
```mermaid | ||
sequenceDiagram | ||
participant Client as Client | ||
participant APIGateway as API Gateway <br> (e.g. AWS API Gateway) | ||
participant Auth as Auth Provider | ||
participant Nitric as Nitric Runtime <br> (plugin) | ||
participant SDK as Nitric SDK | ||
participant Worker as App Worker | ||
|
||
Client->>APIGateway: HTTP Request | ||
opt Authentication | ||
APIGateway->>Auth: Verify Token | ||
APIGateway-->>Client: Unauthorized | ||
end | ||
APIGateway->>Nitric: Forward Request | ||
Nitric->>Nitric: Convert Request Format | ||
Nitric->>SDK: Route HTTP Event | ||
SDK->>Worker: Execute Route Callback | ||
|
||
Worker->>Worker: Process Request | ||
Worker-->>Client: Response | ||
``` | ||
|
||
## 3. Component | ||
|
||
### API Module | ||
|
||
- Dynamically creates and manages API gateways to expose application functionality through HTTP endpoints and routes. | ||
- Configures API properties, including protocol type, API specifications (e.g., OpenAPI), and metadata for identification and lifecycle management. | ||
- Provisions and associates backend integrations with API routes, supporting multiple targets such as serverless functions, containers, or application services. | ||
- Automates the setup of custom domain names with secure certificates, abstracting provider-specific configurations for HTTPS communication. | ||
- Grants least privilege permissions to enable secure communication between the API gateway and backend services, ensuring robust security practices. | ||
- Supports versioning and staging of APIs, enabling seamless updates and rollbacks without disrupting existing deployments. | ||
- Abstracts the complexities of cloud-native API gateway services, providing a unified interface for developing and deploying HTTP APIs across different providers. | ||
|
||
## 4. Code | ||
|
||
**Developers** write application code that uses the [API resource](/apis) from the SDK, defining the APIs routes, methods, middleware and auth. | ||
|
||
SDK Reference by language: | ||
|
||
- [NodeJS SDK](/reference/nodejs/api/api) | ||
- [Python SDK](/reference/python/api/api) | ||
- [Go SDK](/reference/go/api/api) | ||
- [Dart SDK](/reference/dart/api/api) | ||
|
||
**Operations** will use or extend the Nitric infrastructure modules, including both Terraform and Pulumi: | ||
|
||
- Terraform Modules: | ||
- [AWS API Terraform Module](https://github.com/nitrictech/nitric/blob/main/cloud/aws/deploytf/.nitric/modules/api/main.tf) | ||
- [GCP API Terraform Module](https://github.com/nitrictech/nitric/blob/main/cloud/gcp/deploytf/.nitric/modules/api/main.tf) | ||
- Pulumi Modules: | ||
- [AWS API Pulumi Module](https://github.com/nitrictech/nitric/blob/main/cloud/aws/deploy/api.go) | ||
- [GCP API Pulumi Module](https://github.com/nitrictech/nitric/blob/main/cloud/gcp/deploy/api.go) | ||
- [Azure API Pulumi Module](https://github.com/nitrictech/nitric/blob/main/cloud/azure/deploy/api.go) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.