Skip to content

Commit 2bf247b

Browse files
committed
docs(architecture): enhance diagrams with caching and improve visual design 🎨
1 parent f2ae1b0 commit 2bf247b

File tree

1 file changed

+90
-25
lines changed

1 file changed

+90
-25
lines changed

README.md

Lines changed: 90 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,49 @@ try {
189189

190190
## 🏗️ Architecture
191191

192-
### JWT Encoding Process
192+
### 🔄 Complete Data Flow
193+
194+
> This diagram shows the complete JWT workflow from data input to output. The **Sign** process creates encrypted tokens and stores them in cache, while **Verify** operations check cache first for 1,600x performance boost. **Decode** extracts raw data without verification, and **Cache Management** ensures memory efficiency with LRU eviction and TTL expiration.
195+
196+
```mermaid
197+
graph TD
198+
A[User Data] --> B[Sign Request]
199+
B --> C[Create Payload]
200+
C --> D[AES-256-GCM Encrypt]
201+
D --> E[Generate Token]
202+
E --> F[Store in Cache]
203+
F --> G[Return Token]
204+
205+
H[Token Verification] --> I{Cache Hit?}
206+
I -->|Yes| J[Return Cached Data]
207+
I -->|No| K[Decrypt Token]
208+
K --> L[Validate Integrity]
209+
L --> M[Store in Cache]
210+
M --> N[Return Decoded Data]
211+
212+
O[Token Decode] --> P[Extract Payload]
213+
P --> Q[Return Raw Data]
214+
215+
R[Cache Management] --> S[LRU Eviction]
216+
S --> T[TTL Expiration]
217+
T --> U[Memory Limit 10K]
218+
219+
style A fill:#e1f5fe,color:#000
220+
style G fill:#c8e6c9,color:#000
221+
style J fill:#c8e6c9,color:#000
222+
style N fill:#c8e6c9,color:#000
223+
style Q fill:#c8e6c9,color:#000
224+
style I fill:#fff9c4,color:#000
225+
style F fill:#e8f5e8,color:#000
226+
style M fill:#e8f5e8,color:#000
227+
style R fill:#f3e5f5,color:#000
228+
```
229+
230+
---
231+
232+
### 🔐 JWT Encoding Process
233+
234+
> This diagram details the token creation process with AES-256-GCM encryption. Each token gets a **random IV** for uniqueness, **version-based AAD** for compatibility, and **authentication tags** for tamper detection. The **caching system** stores encrypted tokens for instant retrieval, providing massive performance improvements for repeated verifications.
193235
194236
```mermaid
195237
graph TD
@@ -201,43 +243,66 @@ graph TD
201243
F --> G[Create Token Structure]
202244
G --> H[Base64 Encode]
203245
H --> I[Secure JWT Token]
246+
I --> J[Store in Cache]
247+
J --> K[LRU Eviction Check]
248+
K --> L[TTL Expiration]
204249
205-
J[Secret Key] --> K[Key Preparation]
206-
K --> F
207-
L[Random Salt] --> K
250+
M[Secret Key] --> N[Key Preparation]
251+
N --> F
252+
O[Random Salt] --> N
208253
209-
M[Version] --> N[Additional
254+
P[Version] --> Q[Additional
210255
Authenticated Data]
211-
N --> F
256+
Q --> F
212257
213-
F --> O[Authentication Tag]
214-
O --> G
258+
F --> R[Authentication Tag]
259+
R --> G
260+
261+
S[Cache Hit?] --> T[Return Cached Data]
262+
S --> U[Decrypt & Cache]
263+
U --> V[Return Decrypted Data]
215264
216265
style A fill:#e1f5fe,color:#000
217266
style I fill:#c8e6c9,color:#000
218267
style F fill:#fff3e0,color:#000
219-
style J fill:#fce4ec,color:#000
268+
style M fill:#fce4ec,color:#000
269+
style J fill:#e8f5e8,color:#000
270+
style S fill:#fff9c4,color:#000
220271
```
221272

222-
### Security Layers
273+
---
274+
275+
### 🛡️ Security Layers
276+
277+
> This diagram illustrates the security-focused verification process. **Cache validation** provides the first security layer, preventing DoS attacks through performance optimization. **Decryption** uses the secret key and random IV, while **integrity checks** verify authentication tags. The **caching system** acts as both a performance and security feature, ensuring fast and secure token validation.
223278
224279
```mermaid
225280
graph LR
226-
A[Input Data] --> B[Validation Layer]
227-
B --> C[Encryption Layer]
228-
C --> D[Integrity Layer]
229-
D --> E[Encoding Layer]
230-
E --> F[Secure Token]
231-
232-
G[Secret Key] --> C
233-
H[Random IV] --> C
234-
I[Version AAD] --> C
235-
J[Auth Tag] --> D
236-
237-
style B fill:#ffebee,color:#000
238-
style C fill:#fff3e0,color:#000
239-
style D fill:#f3e5f5,color:#000
240-
style E fill:#e8f5e8,color:#000
281+
A[Input Token] --> B[Cache Validation]
282+
B --> C[Validation Layer]
283+
C --> D[Decryption Layer]
284+
D --> E[Integrity Check]
285+
E --> F[Decoded Data]
286+
287+
B --> G[Cache Hit]
288+
G --> F
289+
290+
H[Cache Miss] --> C
291+
C --> I[Store in Cache]
292+
I --> F
293+
294+
J[Secret Key] --> D
295+
K[Random IV] --> D
296+
L[Version AAD] --> D
297+
M[Auth Tag] --> E
298+
299+
style B fill:#e8f5e8,color:#000
300+
style C fill:#ffebee,color:#000
301+
style D fill:#fff3e0,color:#000
302+
style E fill:#f3e5f5,color:#000
303+
style F fill:#e1f5fe,color:#000
304+
style G fill:#c8e6c9,color:#000
305+
style I fill:#fff9c4,color:#000
241306
```
242307

243308
---

0 commit comments

Comments
 (0)