# antun3s/web-snitch architecture

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

- Interactive diagram: https://gitdiagram.com/antun3s/web-snitch
- Repository: https://github.com/antun3s/web-snitch

## Overview

##### Project type and purpose
- Web Snitch is a tiny, single‐service web application packaged in a Docker container.
- Its sole responsibility is to report server environment details (IP, hostname, uptime) and client connection info (IP, headers) as plain text via HTTP.

##### File structure
- Top‐level files only:
- Dockerfile – builds the container image (Python 3.12 on Alpine, installs dependencies).
- app.py – a Flask app that defines a single route ("/") to gather system and request info.
- requirements.txt – Flask dependency.
- README.md – usage and technical notes.
- No frontend directory, no database, no external microservices.

##### README for additional insights
- Confirms the tech stack: Python 3.12, Alpine Linux, Flask web server.
- Confirms container size (~61 MB), exposes port 8080, no styling, plain text output.

##### Main components and interactions
a. Client
- Browser or CLI (curl) sending HTTP GET to host:8080.
b. Docker Host
- Docker Engine listens on host port 8080, routes traffic into container port 8080.
c. Container
- Alpine‐based Linux OS
- Python runtime + Flask
- app.py grabs:
- OS calls for IP, hostname, `uptime`
- HTTP request metadata for client IP and headers
d. Response
- Flask serializes data into plain‐text payload, returns HTTP 200.

##### Architectural patterns and principles
- Single‐service “microservice” style: small surface area, one HTTP endpoint.
- Containerization for isolation and reproducible environment.
- Minimal OS layer (Alpine) to reduce attack surface and image size.

##### Technologies, frameworks, libraries
- Docker + Dockerfile (Alpine Linux base, Python 3.12)
- Flask (lightweight Python web framework)
- Standard Python libraries / OS calls for hostname, IP, uptime

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Network Entities
    Client["Client (Browser/CLI)"]:::network
    DockerHost["Docker Host<br/>(Docker Engine)"]:::network

    %% Container Boundary
    subgraph "Docker Container"
        direction TB
        AlpineOS["Alpine Linux OS"]:::runtime
        PythonFlask["Python 3.12 + Flask<br/>(app.py)"]:::runtime
        OSUtils["OS Utilities<br/>(hostname, IP, uptime)"]:::systemcalls
    end

    %% Build Context
    subgraph "Build Context"
        direction TB
        DockerfileNode["Dockerfile"]:::build
        Requirements["requirements.txt"]:::build
        README["README.md"]:::docs
    end

    %% Data Flow
    Client -->|"HTTP GET"| DockerHost
    DockerHost -->|"Host:8080 → Container:8080"| PythonFlask
    PythonFlask -->|"system call"| OSUtils
    OSUtils -->|"data"| PythonFlask
    PythonFlask -->|"HTTP 200 OK + text"| DockerHost
    DockerHost -->|"HTTP 200 OK + text"| Client

    %% Click Events
    click PythonFlask "https://github.com/antun3s/web-snitch/blob/main/app.py"
    click DockerfileNode "https://github.com/antun3s/web-snitch/tree/main/Dockerfile"
    click Requirements "https://github.com/antun3s/web-snitch/blob/main/requirements.txt"
    click README "https://github.com/antun3s/web-snitch/blob/main/README.md"

    %% Styles
    classDef network fill:#bbdefb,stroke:#1e88e5,color:#0d47a1,stroke-width:1px;
    classDef runtime fill:#c8e6c9,stroke:#43a047,color:#1b5e20,stroke-width:1px;
    classDef systemcalls fill:#fff9c4,stroke:#fdd835,color:#f57f17,stroke-width:1px;
    classDef build fill:#ffe0b2,stroke:#fb8c00,color:#e65100,stroke-width:1px;
    classDef docs fill:#eceff1,stroke:#90a4ae,color:#37474f,stroke-width:1px;
```
