How remorses/docker-phobia works
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!