Skip to content

Commit 321e37b

Browse files
committed
Add detailed Architecture Flow diagram to documentation
1 parent ef316c9 commit 321e37b

File tree

2 files changed

+66
-65
lines changed

2 files changed

+66
-65
lines changed

README.md

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -26,71 +26,6 @@ Hooks is a RESTful webhook server framework written in Ruby. It is designed to b
2626

2727
Hooks is designed to be very easy to setup and use. It provides a simple DSL for defining webhook endpoints and then you can use plugins to handle the incoming requests and optionally authenticate them.
2828

29-
### Architecture Flow
30-
31-
The following Mermaid diagram shows the complete request processing flow, including server bootstrap, plugin loading, and webhook request handling:
32-
33-
```mermaid
34-
flowchart TD
35-
A[Server Start] --> B[Builder.new]
36-
B --> C[Load & Validate Config]
37-
C --> D[Create Logger]
38-
D --> E[Load All Plugins]
39-
E --> F[Load Endpoints]
40-
F --> G[Create Grape API]
41-
G --> H[Server Ready]
42-
43-
H --> I[Incoming Request]
44-
I --> J[Generate Request ID]
45-
J --> K[Create Request Context]
46-
K --> L[Build Rack Environment]
47-
L --> M[Lifecycle: on_request]
48-
49-
M --> N{IP Filtering Enabled?}
50-
N -->|Yes| O[Check IP Allow/Block Lists]
51-
N -->|No| P[Enforce Request Limits]
52-
O --> Q{IP Allowed?}
53-
Q -->|No| R[Return 403 Forbidden]
54-
Q -->|Yes| P
55-
56-
P --> S[Read Request Body]
57-
S --> T{Auth Required?}
58-
T -->|Yes| U[Load Auth Plugin]
59-
T -->|No| V[Parse Payload]
60-
61-
U --> W[Validate Auth]
62-
W --> X{Auth Valid?}
63-
X -->|No| Y[Return 401/403 Error]
64-
X -->|Yes| V
65-
66-
V --> Z[Load Handler Plugin]
67-
Z --> AA[Normalize Headers]
68-
AA --> BB[Call Handler.call]
69-
BB --> CC[Lifecycle: on_response]
70-
CC --> DD[Log Success]
71-
DD --> EE[Return 200 + Response]
72-
73-
BB --> FF{Handler Error?}
74-
FF -->|Hooks::Plugins::Handlers::Error| GG[Return Handler Error Response]
75-
FF -->|StandardError| HH[Log Error]
76-
HH --> II[Lifecycle: on_error]
77-
II --> JJ[Return 500 + Error Response]
78-
79-
R --> KK[End]
80-
Y --> KK
81-
GG --> KK
82-
EE --> KK
83-
JJ --> KK
84-
85-
style A fill:#035980
86-
style H fill:#027306
87-
style R fill:#a10010
88-
style Y fill:#a10010
89-
style EE fill:#027306
90-
style JJ fill:#a10010
91-
style GG fill:#915a01
92-
```
93-
9429
Here is a very high-level overview of how Hooks works:
9530

9631
1. You define a global configuration file (e.g. `hooks.yml`) where you can specify where your webhook endpoint configs are located, and the directory where your plugins are located. Here is an example of a minimal configuration file:
@@ -205,6 +140,8 @@ Congratulations! You have successfully set up a basic Hooks server which will li
205140

206141
Keep reading to learn how to customize your Hooks server with different plugins for handlers, authentication, and more.
207142

143+
For an in-depth flow diagram of how the Hooks server processes incoming requests, see the [Architecture Flow](docs/architecture_flow.md) documentation.
144+
208145
### Advanced
209146

210147
This section will go into a more advanced and detailed example of how to setup a Hooks server with custom plugins, authentication, and more. This section also assumes you already have the `hooks-ruby` gem installed via a bundler Gemfile as shown in the [Installation](#installation-) section above.

docs/architecture_flow.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Architecture Flow
2+
3+
The following Mermaid diagram shows the complete request processing flow, including server bootstrap, plugin loading, and webhook request handling:
4+
5+
```mermaid
6+
flowchart TD
7+
A[Server Start] --> B[Builder.new]
8+
B --> C[Load & Validate Config]
9+
C --> D[Create Logger]
10+
D --> E[Load All Plugins]
11+
E --> F[Load Endpoints]
12+
F --> G[Create Grape API]
13+
G --> H[Server Ready]
14+
15+
H --> I[Incoming Request]
16+
I --> J[Generate Request ID]
17+
J --> K[Create Request Context]
18+
K --> L[Build Rack Environment]
19+
L --> M[Lifecycle: on_request]
20+
21+
M --> N{IP Filtering Enabled?}
22+
N -->|Yes| O[Check IP Allow/Block Lists]
23+
N -->|No| P[Enforce Request Limits]
24+
O --> Q{IP Allowed?}
25+
Q -->|No| R[Return 403 Forbidden]
26+
Q -->|Yes| P
27+
28+
P --> S[Read Request Body]
29+
S --> T{Auth Required?}
30+
T -->|Yes| U[Load Auth Plugin]
31+
T -->|No| V[Parse Payload]
32+
33+
U --> W[Validate Auth]
34+
W --> X{Auth Valid?}
35+
X -->|No| Y[Return 401/403 Error]
36+
X -->|Yes| V
37+
38+
V --> Z[Load Handler Plugin]
39+
Z --> AA[Normalize Headers]
40+
AA --> BB[Call Handler.call]
41+
BB --> CC[Lifecycle: on_response]
42+
CC --> DD[Log Success]
43+
DD --> EE[Return 200 + Response]
44+
45+
BB --> FF{Handler Error?}
46+
FF -->|Hooks::Plugins::Handlers::Error| GG[Return Handler Error Response]
47+
FF -->|StandardError| HH[Log Error]
48+
HH --> II[Lifecycle: on_error]
49+
II --> JJ[Return 500 + Error Response]
50+
51+
R --> KK[End]
52+
Y --> KK
53+
GG --> KK
54+
EE --> KK
55+
JJ --> KK
56+
57+
style A fill:#035980
58+
style H fill:#027306
59+
style R fill:#a10010
60+
style Y fill:#a10010
61+
style EE fill:#027306
62+
style JJ fill:#a10010
63+
style GG fill:#915a01
64+
```

0 commit comments

Comments
 (0)