# itssoap/reverse-proxy architecture

> Architecture diagram of the GitHub repository itssoap/reverse-proxy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/itssoap/reverse-proxy
- Repository: https://github.com/itssoap/reverse-proxy

## Overview

##### Main Components

a. Client Layer:

b. Reverse Proxy Layer (Core):
- FastAPI Application Server
- Multiple Uvicorn Workers (managed by Gunicorn)
- Load distribution across workers

c. Caching Layer:
- Redis Cache Server
- To the main proxy layer

d. Target Services:
- External services/websites being proxied

##### Component Relationships

- Client → Reverse Proxy (HTTP/HTTPS requests)
- Reverse Proxy ↔ Redis Cache (bi-directional for cache checks/updates)
- Reverse Proxy → Target Services (forwarded requests)
- Target Services → Reverse Proxy (responses)
- Reverse Proxy → Client (final response)

##### Architectural Details

Specific elements:
- FastAPI Router/Endpoints
- Redis Cache Manager (from utils/redis_cache.py)
- Logging System (from utils/info_logger.py)
- Static File Serving (show static directory)

##### Technical Specifications

Labels indicating:
- Python 3.10+
- FastAPI Framework
- Redis Cache
- Gunicorn/Uvicorn Workers
- Docker Container boundary (if deployed via Docker)

##### Additional Elements

Annotations for:
- Environment configurations
- Cache validation flows
- Static file serving paths
- Worker scaling capabilities

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef client fill:#B3E5FC,stroke:#0288D1
    classDef proxy fill:#C8E6C9,stroke:#388E3C
    classDef cache fill:#FFCCBC,stroke:#E64A19
    classDef service fill:#E1BEE7,stroke:#7B1FA2
    classDef infra fill:#CFD8DC,stroke:#607D8B
    classDef static fill:#FFF9C4,stroke:#FBC02D

    %% Client Layer
    Client[Client Requests]:::client

    %% Reverse Proxy Layer
    subgraph ProxyLayer[Reverse Proxy System]
        Entry["Entry Point (start.sh)"]:::infra
        click Entry "https://github.com/itssoap/Reverse-proxy/blob/main/start.sh"
        
        MainApp["FastAPI Application Server"]:::proxy
        click MainApp "https://github.com/itssoap/Reverse-proxy/blob/main/reverse-proxy/__main__.py"
        
        Logger["Logging System"]:::proxy
        click Logger "https://github.com/itssoap/Reverse-proxy/blob/main/reverse-proxy/utils/info_logger.py"
        
        subgraph Workers[Uvicorn Workers]
            Worker1["Worker 1"]:::infra
            Worker2["Worker 2"]:::infra
            Worker3["Worker 3"]:::infra
        end
        
        subgraph StaticFiles[Static File Serving]
            CSS["CSS Resources"]:::static
            click CSS "https://github.com/itssoap/Reverse-proxy/tree/main/static/css/"
            JS["JavaScript Resources"]:::static
            click JS "https://github.com/itssoap/Reverse-proxy/tree/main/static/js/"
            Images["Image Assets"]:::static
            click Images "https://github.com/itssoap/Reverse-proxy/tree/main/static/img/"
        end
    end

    %% Cache Layer
    subgraph CacheLayer[Caching System]
        Redis["Redis Cache Server"]:::cache
        CacheManager["Cache Manager"]:::cache
        click CacheManager "https://github.com/itssoap/Reverse-proxy/blob/main/reverse-proxy/utils/redis_cache.py"
    end

    %% Configuration
    subgraph Config[Configuration]
        EnvConfig["Environment Config"]:::infra
        click EnvConfig "https://github.com/itssoap/Reverse-proxy/blob/main/.env.sample"
        DockerConfig["Docker Config"]:::infra
        click DockerConfig "https://github.com/itssoap/Reverse-proxy/blob/main/docker-compose.yml"
        ProjectMeta["Project Metadata"]:::infra
        click ProjectMeta "https://github.com/itssoap/Reverse-proxy/blob/main/pyproject.toml"
    end

    %% Target Services
    TargetServices["External Target Services"]:::service

    %% Relationships
    Client --> Entry
    Entry --> MainApp
    MainApp --> Workers
    Workers --> |Cache Check| CacheManager
    CacheManager --> |Cache Operations| Redis
    Workers --> |Cache Miss| TargetServices
    TargetServices --> Workers
    Workers --> Client
    MainApp --> StaticFiles
    Config --> MainApp
    MainApp --> Logger

    %% Legend
    subgraph Legend
        L1[Client Components]:::client
        L2[Proxy Components]:::proxy
        L3[Cache Components]:::cache
        L4[Target Services]:::service
        L5[Infrastructure]:::infra
        L6[Static Resources]:::static
    end
```
