# evansabraham/rate_limiter architecture

> Architecture diagram of the GitHub repository evansabraham/rate_limiter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/evansabraham/rate_limiter
- Repository: https://github.com/evansabraham/rate_limiter

## Overview

This is a small FastAPI authentication and rate-limiting demo. Requests enter through registered API endpoints: signup validates input, hashes and stores a password; login checks stored credentials; forgot-password returns a non-enumerating message. The app also provides status and sample admin endpoints. Rate limits use SlowAPI configured with Redis, while SQLModel sessions persist users in PostgreSQL. The README documents Swagger UI. Relationships shown come from the sampled source or README; database and Redis are represented as external services.

Main entry points: [`main.py`](https://github.com/evansabraham/rate_limiter/blob/master/main.py) (FastAPI app), [`database.py`](https://github.com/evansabraham/rate_limiter/blob/master/database.py) (DB sessions), [`schemas.py`](https://github.com/evansabraham/rate_limiter/blob/master/schemas.py) (Request schemas), [`models.py`](https://github.com/evansabraham/rate_limiter/blob/master/models.py) (User model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_app["FastAPI app<br/>[main.py]"]
  node_status["Health status<br/>[main.py]"]
  node_admin["Admin sample<br/>[main.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
  node_swagger["Swagger UI<br/>[main.py]"]
end

subgraph group_auth["User workflows"]
  node_signup["Signup<br/>[main.py]"]
  node_login["Login<br/>[main.py]"]
  node_forgot["Forgot password<br/>[main.py]"]
  node_hasher["Password hashing<br/>[main.py]"]
end

subgraph group_infra["Limits and persistence"]
  node_limiter["Rate limiting<br/>[main.py]"]
  node_redis[("Redis")]
  node_sessions["DB sessions<br/>[database.py]"]
  node_user["User model<br/>[models.py]"]
  node_postgres[("PostgreSQL")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_app -->|"routes signup"| node_signup
node_app -->|"routes login"| node_login
node_app -->|"routes reset"| node_forgot
node_app -->|"routes status"| node_status
node_app -->|"routes admin"| node_admin
node_signup -->|"validates payload"| node_schemas
node_login -->|"validates payload"| node_schemas
node_forgot -->|"validates payload"| node_schemas
node_signup -->|"hashes password"| node_hasher
node_login -->|"verifies password"| node_hasher
node_app -->|"configures limits"| node_limiter
node_limiter -->|"stores counters"| node_redis
node_app -->|"creates schema"| node_sessions
node_signup -->|"opens session"| node_sessions
node_login -->|"opens session"| node_sessions
node_forgot -->|"opens session"| node_sessions
node_sessions -->|"uses model"| node_user
node_sessions -->|"connects via engine"| node_postgres
node_app -->|"serves API docs"| node_swagger

click node_app "https://github.com/evansabraham/rate_limiter/blob/master/main.py"
click node_signup "https://github.com/evansabraham/rate_limiter/blob/master/main.py"
click node_login "https://github.com/evansabraham/rate_limiter/blob/master/main.py"
click node_forgot "https://github.com/evansabraham/rate_limiter/blob/master/main.py"
click node_status "https://github.com/evansabraham/rate_limiter/blob/master/main.py"
click node_admin "https://github.com/evansabraham/rate_limiter/blob/master/main.py"
click node_schemas "https://github.com/evansabraham/rate_limiter/blob/master/schemas.py"
click node_hasher "https://github.com/evansabraham/rate_limiter/blob/master/main.py"
click node_limiter "https://github.com/evansabraham/rate_limiter/blob/master/main.py"
click node_sessions "https://github.com/evansabraham/rate_limiter/blob/master/database.py"
click node_user "https://github.com/evansabraham/rate_limiter/blob/master/models.py"
click node_swagger "https://github.com/evansabraham/rate_limiter/blob/master/main.py"

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_app,node_status,node_admin,node_schemas,node_swagger,node_client toneBlue
class node_signup,node_login,node_forgot,node_hasher toneAmber
class node_limiter,node_redis,node_sessions,node_user,node_postgres toneMint
```

## Components

### API

- [FastAPI app](https://github.com/evansabraham/rate_limiter/blob/master/main.py): `main.py`
- [Health status](https://github.com/evansabraham/rate_limiter/blob/master/main.py): `main.py`
- [Admin sample](https://github.com/evansabraham/rate_limiter/blob/master/main.py): `main.py`
- [Request schemas](https://github.com/evansabraham/rate_limiter/blob/master/schemas.py): `schemas.py`
- [Swagger UI](https://github.com/evansabraham/rate_limiter/blob/master/main.py): `main.py`

### User workflows

- [Signup](https://github.com/evansabraham/rate_limiter/blob/master/main.py): `main.py`
- [Login](https://github.com/evansabraham/rate_limiter/blob/master/main.py): `main.py`
- [Forgot password](https://github.com/evansabraham/rate_limiter/blob/master/main.py): `main.py`
- [Password hashing](https://github.com/evansabraham/rate_limiter/blob/master/main.py): `main.py`

### Limits and persistence

- [Rate limiting](https://github.com/evansabraham/rate_limiter/blob/master/main.py): `main.py`
- **Redis**
- [DB sessions](https://github.com/evansabraham/rate_limiter/blob/master/database.py): `database.py`
- [User model](https://github.com/evansabraham/rate_limiter/blob/master/models.py): `models.py`
- **PostgreSQL**

### Other components

- **API client**

## Connections

- API client → FastAPI app: sends requests (evidence: `README.md`)
- FastAPI app → Signup: routes signup (evidence: `main.py`)
- FastAPI app → Login: routes login (evidence: `main.py`)
- FastAPI app → Forgot password: routes reset (evidence: `main.py`)
- FastAPI app → Health status: routes status (evidence: `main.py`)
- FastAPI app → Admin sample: routes admin (evidence: `main.py`)
- Signup → Request schemas: validates payload (evidence: `main.py`)
- Login → Request schemas: validates payload (evidence: `main.py`)
- Forgot password → Request schemas: validates payload (evidence: `main.py`)
- Signup → Password hashing: hashes password (evidence: `main.py`)
- Login → Password hashing: verifies password (evidence: `main.py`)
- FastAPI app → Rate limiting: configures limits (evidence: `main.py`)
- Rate limiting → Redis: stores counters (evidence: `main.py`)
- FastAPI app → DB sessions: creates schema (evidence: `main.py`)
- Signup → DB sessions: opens session (evidence: `main.py`)
- Login → DB sessions: opens session (evidence: `main.py`)
- Forgot password → DB sessions: opens session (evidence: `main.py`)
- DB sessions → User model: uses model (evidence: `database.py`)
- DB sessions → PostgreSQL: connects via engine (evidence: `database.py`)
- FastAPI app → Swagger UI: serves API docs (evidence: `README.md`)
