Skip to content

Commit 9ec9217

Browse files
authored
Merge pull request #65 from github/copilot/fix-64
Add detailed Mermaid flow diagram to README
2 parents e49431a + 321e37b commit 9ec9217

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ Congratulations! You have successfully set up a basic Hooks server which will li
140140

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

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+
143145
### Advanced
144146

145147
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)