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