# remorses/docker-phobia architecture

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

- Interactive diagram: https://gitdiagram.com/remorses/docker-phobia
- Repository: https://github.com/remorses/docker-phobia

## Overview

##### Main Components
- CLI/Backend Core (Go):
- The CLI entry point found in main.go (and related Go files, including those in the ls‑tar directory) forms the core backend. This component is responsible for processing the Docker image input, interfacing with dive’s API to retrieve image layers and file size information, and producing a JSON file structure.
- Web Server:
- Part of the Go application spins up an HTTP server (listening on port 8080) to provide endpoints for the visualization.
- JSON Data Exporter:
- A module that aggregates and outputs JSON that represents the Docker image’s file structure (with sizes and layer information).
- Frontend Visualization (Website):
- Located in the website directory, this part includes TypeScript/React code (with Vite, Tailwind CSS, etc.) that fetches the JSON data and renders the interactive treemap. The design includes separate entry points for client and server (entry.client.tsx and entry.server.tsx) and clearly defined routes for different views.

##### Relationships and Data Flow
- The operator initiates the process by running docker‑phobia from the command line.
- The CLI parses provided Docker image tags or uses interactive input. It then calls routines (using dive’s API) to analyze the Docker image.
- The analysis component generates a JSON output that structurally represents file sizes, directories, and Docker layers.
- Concurrently, the Go web server is started, serving this JSON data via an API.
- The frontend (in the website folder) is a separate client application that, once the browser is launched (or via redirection), fetches the JSON from the backend API.

##### Architectural Patterns and Technologies
- Separation of Concerns:
- There is a clear division between Docker image analysis (backend business logic) and the frontend visualization.
- API Driven Design:
- The backend produces JSON output via an HTTP server, separating the data retrieval/processing from its presentation.
- Modular Code Structure:
- The use of separate directories (e.g., ls‑tar for low-level tar extraction utilities and website for frontend logic) indicates modular design.
- Technologies:
- Go (for the CLI, image analysis, web server),
- dive (as a dependency for Docker image retrieval/analysis),
- React/TypeScript with Vite, Tailwind CSS (for the frontend UI).

##### Final Reminder
- Be very detailed in capturing each of these essential architectural elements.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Operator
    A["Operator: Run docker-phobia"]:::operator

    %% CLI/Backend Application
    subgraph "CLI/Backend Application"
        B["CLI Entry (Go)"]:::backend
        C["Image Analyzer (dive API)"]:::backend
        D["JSON Data Exporter"]:::backend
        E["HTTP Server (Port 8080)"]:::backend
        F["Tar Utility: ls‑tar/main.go"]:::backend
        G["Tar Utility: ls‑tar/seekablehttp.go"]:::backend
    end

    %% Frontend Visualization
    subgraph "Frontend Visualization (Website)"
        H["Entry Client (React/TS)"]:::frontend
        I["Entry Server (React/TS)"]:::frontend
        J["Treemap Visualizer"]:::frontend
    end

    %% Data Flow Connections
    A -->|"DockerImageInput"| B
    B -->|"CallsDiveAPI"| C
    C -->|"GeneratesJSON"| D
    D -->|"StartsAPI"| E
    F ---|"Supports"| G
    E -->|"ServesJSON"| H
    E -->|"ServesJSON"| I
    H -->|"FetchesJSON"| J
    I -->|"RendersTreemap"| J

    %% Click Events
    click B "https://github.com/remorses/docker-phobia/blob/main/main.go"
    click F "https://github.com/remorses/docker-phobia/blob/main/ls‑tar/main.go"
    click G "https://github.com/remorses/docker-phobia/blob/main/ls‑tar/seekablehttp.go"
    click H "https://github.com/remorses/docker-phobia/blob/main/website/src/entry.client.tsx"
    click I "https://github.com/remorses/docker-phobia/blob/main/website/src/entry.server.tsx"

    %% Styles
    classDef operator fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef backend fill:#b3d9ff,stroke:#333,stroke-width:2px;
    classDef frontend fill:#d1ffd1,stroke:#333,stroke-width:2px;
```
