# depado/goploader architecture

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

- Interactive diagram: https://gitdiagram.com/depado/goploader
- Repository: https://github.com/depado/goploader

## Overview

##### Overall Project Structure
- Peripheral components such as CI/CD (represented by Dockerfiles, GitHub workflows, and Makefile) as support tooling, but focus on the runtime components.

##### Main Components

a. Client Application
- Inside, include:
- The entry point (client/main.go).
- A “Configuration Module” (client/conf/conf.go) representing how client settings are loaded.
- A “Screenshot Module” (client/screenshot/screenshot.go) indicating functionality to capture or manage visual content.
- This component is responsible for initiating file uploads and interacting with the Server.

b. Server Application
- Inside, divide it into multiple submodules to reflect its modular architecture:
- “Configuration Module” (server/conf/conf.go): Handles configuration settings.
- “Routing & Request Handling” (server/router/router.go and server/curl/*): Show that incoming HTTP requests are processed through a router, with additional help from a dedicated cURL package. Consider labeling data conversion and helper functions (server/curl/helpers.go, etc.).
- “Database Module” (server/database/database.go): Responsible for persistence or file metadata storage.
- “Models & Data Handling” (server/models/*): Explain that these files manage resources and statistics.
- “Logging & Monitoring”:
▪ “Logger” (server/logger/logger.go) for logging requests and errors.
▪ “Metrics” (server/metrics/metrics.go) and “Monitoring” (server/monitoring/monitoring.go) for system health and performance.
- “Setup & Initialization” (server/setup/setup.go): Handles initial configuration and startup routines.
- “Utility & Assets Management” (server/utils/*):
▪ Display that this part serves static files and assets (note the extensive assets folders with CSS, JS, fonts, and templates).
- “Views & Templating” (server/views/*): Represents the rendering of various web pages (both encrypted and unencrypted, as indicated by the file names).

##### Relationships and Interactions

- From the Router to the Logger, Database, Models, and Metrics modules.
- That the Request Handling submodules (routers and cURL helpers) process incoming HTTP requests and then delegate tasks such as persisting data or serving static assets.
- Connection between the “Utils/Assets” and “Views/Templating” components to underline that the server is responsible for serving the web interface (HTML, CSS, JS).
- Marking how the Configuration modules in both client and server feed into the startup and behavior of each component.

##### Architectural Patterns & Design Principles

- Clear separation of concerns across modules:
- The client keeps things light, focusing on interfacing with the server.
- The server is modularized into several components (routing, logging, database, etc.), which improves maintainability and testability.
- RESTful nature of interactions (if applicable via the router module) that indicates clear API endpoints for file sharing.
- Application layers (e.g., client vs. server).
- Supporting components (such as metrics or logging) versus core business functions (routing, database, models).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Application
    subgraph "Client Application"
        C_Main["Client Main Module"]:::client
        C_Conf["Client Configuration"]:::client
        C_Screenshot["Client Screenshot Module"]:::client
    end

    %% File Upload interaction from Client to Server
    C_Main ---|"FileUploadRequest"| S_Router

    %% Server Application
    subgraph "Server Application"
        %% Server Configuration and Initialization
        S_Conf["Server Configuration Module"]:::server
        S_Setup["Setup & Initialization"]:::server

        %% Request Handling Modules
        S_Router["Routing & Request Handling"]:::routing
        S_CURL["cURL Package\n(helpers, data, curl)"]:::routing

        %% Core Functional Modules
        S_Database["Database Module"]:::database
        S_Models["Models & Data Handling"]:::database

        %% Logging & Monitoring
        S_Logger["Logger"]:::monitoring
        S_Metrics["Metrics"]:::monitoring
        S_Monitoring["Monitoring"]:::monitoring

        %% Utility & Assets and Views
        S_Utils["Utility & Assets Management"]:::utils
        S_Views["Views & Templating"]:::utils
    end

    %% Internal Server Interactions
    S_Conf --> S_Setup
    S_Router -->|"logRequest"| S_Logger
    S_Router -->|"persistData"| S_Database
    S_Router -->|"processData"| S_Models
    S_Router -->|"collectMetrics"| S_Metrics
    S_Router -->|"serveView"| S_Views
    S_Router --> S_CURL
    S_Utils --> S_Views

    %% Styles
    classDef client fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef server fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef routing fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef database fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef monitoring fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef utils fill:#FFDEAD,stroke:#333,stroke-width:2px;

    %% Click Events for Client Components
    click C_Main "https://github.com/depado/goploader/blob/main/client/main.go"
    click C_Conf "https://github.com/depado/goploader/blob/main/client/conf/conf.go"
    click C_Screenshot "https://github.com/depado/goploader/blob/main/client/screenshot/screenshot.go"

    %% Click Events for Server Components
    click S_Conf "https://github.com/depado/goploader/blob/main/server/conf/conf.go"
    click S_Router "https://github.com/depado/goploader/blob/main/server/router/router.go"
    click S_CURL "https://github.com/depado/goploader/blob/main/server/curl/curl.go"
    click S_Database "https://github.com/depado/goploader/blob/main/server/database/database.go"
    click S_Models "https://github.com/depado/goploader/tree/main/server/models/"
    click S_Logger "https://github.com/depado/goploader/blob/main/server/logger/logger.go"
    click S_Metrics "https://github.com/depado/goploader/blob/main/server/metrics/metrics.go"
    click S_Monitoring "https://github.com/depado/goploader/blob/main/server/monitoring/monitoring.go"
    click S_Setup "https://github.com/depado/goploader/blob/main/server/setup/setup.go"
    click S_Utils "https://github.com/depado/goploader/tree/main/server/utils/"
    click S_Views "https://github.com/depado/goploader/tree/main/server/views/"
```
