# marctheshark3/sigmanaut-mining-pool-ui architecture

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

- Interactive diagram: https://gitdiagram.com/marctheshark3/sigmanaut-mining-pool-ui
- Repository: https://github.com/marctheshark3/sigmanaut-mining-pool-ui

## Overview

##### Main Components
- Frontend Interfaces:
- The primary dashboard UI (likely served by app.py and its associated layouts in the “layouts” directory).
- The “off-chain” component (a separate React app located in the off-chain folder) that likely provides additional or alternative user interface and functionalities.
- Backend/API:
- The main Python application (see app.py, proto-app.py, and supplementary scripts such as temp.py) that interfaces with mining operations data.
- A set of utility modules (in the “utils” directory) for data management, API reading, calculation, etc.
- Nginx/Reverse Proxy:
- The project includes various Nginx configuration files (in conf and nginx directories) which likely serve as a reverse-proxy, handling routing, SSL termination, and load balancing.
- Docker Infrastructure:
- Dockerfile(s) and docker-compose.yaml indicate containerized services. The overall deployment includes one container for the core Python application, one for the off-chain frontend service, possibly a separate Nginx container, and supporting components (like SSL initialization scripts).
- Orchestration & Deployment Scripts:
- Scripts such as “entrypoint.sh”, “generate-ssl.sh”, and various shell scripts in the scripts directory help in bootstrapping, SSL initialization, and dependency installation.
- External Integrations:

##### Relationships and Data Flow
- The users interact with the dashboard via a web browser accessing the frontend.
- Requests hit the reverse proxy (Nginx) which handles SSL termination if needed and forwards traffic to the appropriate backend service.
- For core functionalities, the Dockerized main Python app (with its own REST API endpoints or web server) processes real-time mining data and communicates with the utilities for data management.
- The off-chain service (running in its own container) also serves assets and client-side code that might interact with the main backend via APIs.
- Within the Docker ecosystem, containers communicate with one another through defined network channels, and scripts are used to automate certificate generation and application boot-up.
- External mining software connects through the specified pool URL and ports (from 3052 to 3055), with Nginx directing and managing secure versus non-secure connections.

##### Highlighting Architectural Patterns and Design Principles
- Containerization: Deployment is handled using Docker containers orchestrated by docker-compose.
- Separation of Concerns: The architecture differentiates between various components – frontend UI, backend API, reverse-proxy, and utility scripts.
- Scalability & Modularity: There are clear separations (for example, “off-chain” is maintained as a separate component) that allow for individual scaling or upgrading.
- Security Best Practices: With automatic SSL certificate management (via Certbot within a container) and reverse proxy configurations in Nginx.

##### Technologies, Frameworks, and Libraries
- Python for the core backend, likely using Flask or another lightweight framework (inferred from the use of app.py and related modules).
- React/TypeScript for the “off-chain” front end (components, tsx files, package.json).
- Nginx for reverse proxy and SSL termination.
- Docker & Docker Compose for container orchestration and consistent deployment.
- Additional tooling: Various bash scripts, YAML configuration files, and testing frameworks (like locust for load-testing and unittest/pytest scripts under tests and utils/tests).

##### Elements
- Clear labels for every component:
- “User Browser”
- “Python Backend Service” (with services such as API endpoints and utility processing; include references to app.py, utils, etc.)
- “Off-chain Frontend Service” (React app)
- “External Mining Clients” (with indicated ports for standard/high-performance connections, secure/non-secure)
- “Docker Orchestration” (a container that represents Docker Compose)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Layer: Users
    UserBrowser["User Browser"]:::user
    ExtClients["External Mining Clients (Ports:3052-3055)"]:::external

    %% Docker Containers
    subgraph "Nginx Container"
        Nginx["Nginx Reverse Proxy"]:::nginx
        Nginx -->|"config"| NginxConf["Nginx Config (conf/)"]:::config
        Nginx -->|"templates"| NginxTemplates["Nginx Templates (nginx/)"]:::config
    end

    subgraph "Python Backend Container"
        PBackend["Primary UI & Backend Service"]:::backend
        PBackend -->|"serves"| UI["Primary UI Server (app.py)"]:::backend
        PBackend -->|"provides"| API["API Scripts (proto-app.py, temp.py)"]:::backend
        PBackend -->|"includes"| Layouts["Layouts (layouts/)"]:::backend
        PBackend -->|"uses"| Utils["Utility Modules (utils/)"]:::backend
    end

    subgraph "Off-chain Container"
        Offchain["Off-chain Frontend Service"]:::frontend
    end

    %% Deployment & Orchestration
    subgraph "Deployment & Orchestration"
        DockerConfig["Docker Configuration (Dockerfile, docker-compose.yaml)"]:::docker
        OffchainDocker["Off-chain Docker (off-chain/Dockerfile)"]:::docker
        Entrypoint["Entrypoint Script (entrypoint.sh)"]:::scripts
        SslScript["Generate SSL Script (generate-ssl.sh)"]:::scripts
        DeployScripts["Deployment Scripts (scripts/)"]:::scripts
    end

    %% Communication Flow
    UserBrowser -->|"HTTP_Request"| Nginx
    ExtClients -->|"Mining_Data"| Nginx
    Nginx -->|"Routes_UI/API"| PBackend
    Nginx -->|"Routes_Frontend"| Offchain
    UI -->|"renders"| Layouts

    %% Docker Orchestration Connections
    DockerConfig --- PBackend
    DockerConfig --- Nginx
    DockerConfig --- Offchain
    Entrypoint --- DockerConfig
    SslScript --- DockerConfig
    DeployScripts --- DockerConfig
    OffchainDocker --- Offchain

    %% Click Events for Component Mapping
    click UI "https://github.com/marctheshark3/sigmanaut-mining-pool-ui/blob/main/app.py"
    click Layouts "https://github.com/marctheshark3/sigmanaut-mining-pool-ui/tree/main/layouts/"
    click Offchain "https://github.com/marctheshark3/sigmanaut-mining-pool-ui/tree/main/off-chain/"
    click API "https://github.com/marctheshark3/sigmanaut-mining-pool-ui/blob/main/proto-app.py"
    click Utils "https://github.com/marctheshark3/sigmanaut-mining-pool-ui/tree/main/utils/"
    click NginxConf "https://github.com/marctheshark3/sigmanaut-mining-pool-ui/tree/main/conf/"
    click NginxTemplates "https://github.com/marctheshark3/sigmanaut-mining-pool-ui/tree/main/nginx/"
    click DockerConfig "https://github.com/marctheshark3/sigmanaut-mining-pool-ui/tree/main/Dockerfile"
    click OffchainDocker "https://github.com/marctheshark3/sigmanaut-mining-pool-ui/tree/main/off-chain/Dockerfile"
    click Entrypoint "https://github.com/marctheshark3/sigmanaut-mining-pool-ui/blob/main/entrypoint.sh"
    click SslScript "https://github.com/marctheshark3/sigmanaut-mining-pool-ui/blob/main/generate-ssl.sh"
    click DeployScripts "https://github.com/marctheshark3/sigmanaut-mining-pool-ui/tree/main/scripts/"

    %% Styles
    classDef user fill:#FFEBCD,stroke:#8B4513,stroke-width:2px;
    classDef external fill:#FFE4E1,stroke:#CD5C5C,stroke-width:2px;
    classDef nginx fill:#ADD8E6,stroke:#000080,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#006400,stroke-width:2px;
    classDef frontend fill:#FFB6C1,stroke:#C71585,stroke-width:2px;
    classDef docker fill:#D3D3D3,stroke:#696969,stroke-width:2px;
    classDef scripts fill:#E0FFFF,stroke:#20B2AA,stroke-width:2px;
    classDef config fill:#FFFACD,stroke:#DAA520,stroke-width:2px;
```
