# erickpulido/distributed-traffic-limiter architecture

> Architecture diagram of the GitHub repository erickpulido/distributed-traffic-limiter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/erickpulido/distributed-traffic-limiter
- Repository: https://github.com/erickpulido/distributed-traffic-limiter

## Overview

This repository is a Laravel application skeleton, with a separate Redis-backed token-bucket rate limiter as its clearest custom runtime feature. The visible HTTP entry point bootstraps Laravel and configures web routing; no sampled route demonstrates a request reaching the limiter. The README describes framework-wide capabilities, not application features confirmed in this skeleton, so those are not mapped as implemented subsystems.

Main entry points: [`app/Infrastructure/Traffic/TokenBucketLimiter.php`](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/app/Infrastructure/Traffic/TokenBucketLimiter.php) (Token bucket), [`public/index.php`](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/public/index.php) (Request entry), [`bootstrap/app.php`](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/bootstrap/app.php) (App bootstrap), [`app/Models/User.php`](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/app/Models/User.php) (User model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP application"]
  node_entry["Request entry<br/>[index.php]"]
  node_bootstrap["App bootstrap<br/>[app.php]"]
  node_web_routes["Web routes<br/>[web.php]"]
  node_controller_base["Controller base<br/>[Controller.php]"]
  node_welcome["Welcome page<br/>[welcome.blade.php]"]
end

subgraph group_traffic["Traffic control"]
  node_limiter["Token bucket"]
  node_lua_script["Bucket script<br/>[token_bucket.lua]"]
  node_limit_result["Limit result"]
  node_fail_mode["Failure mode<br/>[FailMode.php]"]
end

subgraph group_identity["User identity"]
  node_user_model["User model<br/>[User.php]"]
  node_auth_config["Auth config<br/>[auth.php]"]
  node_user_factory["User factory<br/>[UserFactory.php]"]
end

node_visitor(("HTTP client"))
node_redis[("Redis")]

node_visitor -->|"sends request"| node_entry
node_entry -->|"loads app"| node_bootstrap
node_bootstrap -->|"configures routing"| node_web_routes
node_limiter -->|"executes script"| node_redis
node_limiter -->|"loads script"| node_lua_script
node_limiter -->|"creates result"| node_limit_result
node_limiter -->|"checks mode"| node_fail_mode
node_auth_config -->|"selects model"| node_user_model
node_user_factory -->|"creates users"| node_user_model

click node_entry "https://github.com/erickpulido/distributed-traffic-limiter/blob/main/public/index.php"
click node_bootstrap "https://github.com/erickpulido/distributed-traffic-limiter/blob/main/bootstrap/app.php"
click node_web_routes "https://github.com/erickpulido/distributed-traffic-limiter/blob/main/routes/web.php"
click node_controller_base "https://github.com/erickpulido/distributed-traffic-limiter/blob/main/app/Http/Controllers/Controller.php"
click node_welcome "https://github.com/erickpulido/distributed-traffic-limiter/blob/main/resources/views/welcome.blade.php"
click node_limiter "https://github.com/erickpulido/distributed-traffic-limiter/blob/main/app/Infrastructure/Traffic/TokenBucketLimiter.php"
click node_lua_script "https://github.com/erickpulido/distributed-traffic-limiter/blob/main/app/Infrastructure/Traffic/token_bucket.lua"
click node_limit_result "https://github.com/erickpulido/distributed-traffic-limiter/blob/main/app/Infrastructure/Traffic/RateLimitResult.php"
click node_fail_mode "https://github.com/erickpulido/distributed-traffic-limiter/blob/main/app/Infrastructure/Traffic/FailMode.php"
click node_user_model "https://github.com/erickpulido/distributed-traffic-limiter/blob/main/app/Models/User.php"
click node_auth_config "https://github.com/erickpulido/distributed-traffic-limiter/blob/main/config/auth.php"
click node_user_factory "https://github.com/erickpulido/distributed-traffic-limiter/blob/main/database/factories/UserFactory.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_bootstrap,node_web_routes,node_controller_base,node_welcome,node_visitor toneBlue
class node_limiter,node_lua_script,node_limit_result,node_fail_mode,node_redis toneAmber
class node_user_model,node_auth_config,node_user_factory toneMint
```

## Components

### HTTP application

- [Request entry](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/public/index.php): `public/index.php`
- [App bootstrap](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/bootstrap/app.php): `bootstrap/app.php`
- [Web routes](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/routes/web.php): `routes/web.php`
- [Controller base](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/app/Http/Controllers/Controller.php): `app/Http/Controllers/Controller.php`
- [Welcome page](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/resources/views/welcome.blade.php): `resources/views/welcome.blade.php`

### Traffic control

- [Token bucket](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/app/Infrastructure/Traffic/TokenBucketLimiter.php): `app/Infrastructure/Traffic/TokenBucketLimiter.php`
- [Bucket script](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/app/Infrastructure/Traffic/token_bucket.lua): `app/Infrastructure/Traffic/token_bucket.lua`
- [Limit result](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/app/Infrastructure/Traffic/RateLimitResult.php): `app/Infrastructure/Traffic/RateLimitResult.php`
- [Failure mode](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/app/Infrastructure/Traffic/FailMode.php): `app/Infrastructure/Traffic/FailMode.php`

### User identity

- [User model](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/app/Models/User.php): `app/Models/User.php`
- [Auth config](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/config/auth.php): `config/auth.php`
- [User factory](https://github.com/erickpulido/distributed-traffic-limiter/blob/main/database/factories/UserFactory.php): `database/factories/UserFactory.php`

### Other components

- **HTTP client**
- **Redis**

## Connections

- HTTP client → Request entry: sends request (evidence: `public/index.php`)
- Request entry → App bootstrap: loads app (evidence: `public/index.php`)
- App bootstrap → Web routes: configures routing (evidence: `bootstrap/app.php`)
- Token bucket → Redis: executes script (evidence: `app/Infrastructure/Traffic/TokenBucketLimiter.php`)
- Token bucket → Bucket script: loads script (evidence: `app/Infrastructure/Traffic/TokenBucketLimiter.php`)
- Token bucket → Limit result: creates result (evidence: `app/Infrastructure/Traffic/TokenBucketLimiter.php`)
- Token bucket → Failure mode: checks mode (evidence: `app/Infrastructure/Traffic/TokenBucketLimiter.php`)
- Auth config → User model: selects model (evidence: `config/auth.php`)
- User factory → User model: creates users (evidence: `database/factories/UserFactory.php`)
