# norbinsh/drawings architecture

> Architecture diagram of the GitHub repository norbinsh/drawings, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/norbinsh/drawings
- Repository: https://github.com/norbinsh/drawings

## Overview

##### Main Components

- Use a hub-and-spoke model to connect related concepts
- Clear categorization of patterns (e.g., "Load Balancing", "Traffic Management", "Scaling Patterns")

- Ring representation with hash space
- Node distribution
- Virtual nodes
- Key mapping process
- Rebalancing scenarios

- Algorithm representation (Token Bucket/Leaky Bucket)
- Request flow
- Counter/storage mechanism
- Distributed coordination (if applicable)

- Load balancing layer
- Caching layer
- Database sharding
- Message queues
- Service discovery

##### Specific Implementation Details

a) Consistent Hashing:
**[Client] → [Hash Function] → [Hash Ring]**
- ↓
- [Node Distribution]
- ↓
- [Virtual Node Mapping]

b) Rate Limiter:
**[Incoming Requests] → [Rate Limiter Service]**
- ↓
- [Storage (Redis/Memory)] ← [Counter/Token Logic]
- ↓
- [Accept/Reject Decision]

##### Documentation Integration

- A brief description
- Key design decisions
- Trade-offs considered
- Performance characteristics
- Scaling limitations

- Version control compatibility
- Collaborative editing
- Export options

Remember to:
- Both happy and error paths
- Performance bottlenecks
- Document assumptions
- Provide scaling considerations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Overview["System Design Patterns Overview"]
        direction TB
        
        Main[("System Design<br/>Reference")]
        
        subgraph Patterns["Core Design Patterns"]
            direction TB
            CH["Consistent<br/>Hashing"]
            RL["Rate<br/>Limiter"]
            STM["Scale to<br/>Millions"]
            EST["System<br/>Estimations"]
        end
        
        Main --> Patterns
        
        subgraph Components["Implementation Details"]
            direction TB
            
            subgraph CHDetails["Consistent Hashing Implementation"]
                direction TB
                HashFunc["Hash Function"]
                Ring["Hash Ring"]
                VNodes["Virtual Nodes"]
                NodeDist["Node Distribution"]
            end
            
            subgraph RLDetails["Rate Limiter Implementation"]
                direction TB
                TokenBucket["Token Bucket"]
                Storage["Storage Layer"]
                Counter["Counter Logic"]
                Decision["Accept/Reject"]
            end
            
            subgraph STMDetails["Scale to Millions Architecture"]
                direction TB
                LoadBal["Load Balancer"]
                Cache["Cache Layer"]
                DB["Database Sharding"]
                Queue["Message Queues"]
            end
        end
        
        CH --> CHDetails
        RL --> RLDetails
        STM --> STMDetails
    end
    
    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef pattern fill:#d4e6f1,stroke:#2874a6,stroke-width:2px
    classDef implementation fill:#d5f5e3,stroke:#196f3d,stroke-width:2px
    classDef storage fill:#fdebd0,stroke:#d35400,stroke-width:2px
    
    %% Apply styles
    class Main default
    class CH,RL,STM,EST pattern
    class HashFunc,Ring,VNodes,NodeDist,TokenBucket,Counter,Decision,LoadBal,Cache,DB,Queue implementation
    class Storage storage
    
    %% Click events
    click CH "https://github.com/norbinsh/drawings/tree/main/consistent_hashing"
    click RL "https://github.com/norbinsh/drawings/tree/main/rate_limiter"
    click STM "https://github.com/norbinsh/drawings/blob/main/scale_to_millions.drawio"
    click EST "https://github.com/norbinsh/drawings/blob/main/back_of_the_envelope_estimations.drawio"
```
