# condenses/subnet-validating architecture

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

- Interactive diagram: https://gitdiagram.com/condenses/subnet-validating
- Repository: https://github.com/condenses/subnet-validating

## Overview

##### Main Components
- Validating Service:
- Represented by the “condenses_validating” directory that contains modules like main.py, log_processor.py, redis_manager.py, and others. This is the heart of the solution where the orchestration and validation logic resides.
- External Microservices:
- Synthesizing Service – exposes an endpoint (using uvicorn) that processes or synthesizes text based on a public dataset.
- Node Managing Service – manages credit and rate limits across “validator -> miner” pathways.
- Scoring Service – receives original and compressed messages for scoring based on the weighted formula described.
- Sidecar Bittensor Service – a dedicated service for metagraph synchronization and chain functions.
- Supporting Components:
- Log Viewer – a console-based tool to view and distinguish logs from various validation stages.
- Redis – hinted by the “redis_manager.py” and the installation script “scripts/install_redis.sh”, which likely acts as a cache or message broker.
- Docker – indicated by the Dockerfile, suggesting containerization and deployment orchestration for various services.
- Scripts – for setup and environment updates that hint at dynamic configuration (install_redis.sh, start.sh, update_env.py, vllm.sh).

##### Relationships and Interactions
- Validating Service <--> Synthesizing Service (indicating it sends user messages or requests for synthesis).
- Validating Service <--> Node Managing Service (for UID orchestration and rate limiting).
- Validating Service <--> Scoring Service (to send messages for scoring and receive evaluation results).
- Validating Service <--> Sidecar Bittensor (for blockchain/network sync operations related to weights and metagraph updates).
- Connections with Redis as an underlying datastore or message broker used by the Validating Service.
- The flow should also illustrate that Log Viewer monitors the outputs of the Validating Service for easier debugging and operational insight.

##### Architectural Patterns and Technologies
- Microservices/Service Orchestration:
- Each service is independently started and managed (using PM2 for process management and uvicorn hosts for REST endpoints).
- Containerization:
- Environment-based Configuration:
- Update-env scripts, configuration files (condenses_validating/config.py), and Redis management imply that runtime configuration is dynamic.
- Use of Uvicorn suggests asynchronous HTTP endpoints in Python, while PM2 indicates production process management.

##### Detailed Element Inclusion
- A label for each microservice along with its respective endpoint port as noted in the README (9100 for synthesizing, 9101 for node managing, 9102 for scoring, 9103 for sidecar-bittensor).
- Interaction between the validating process and the log viewer as a monitoring/debugging component.
- Essential environment variables (like HF_TOKEN, MODEL_NAME, TAOSTATS_API_KEY) near the corresponding service blocks to show external API integrations.

##### Additional Diagrammatic Practices
- That all components are labeled clearly with their file names or logical names where applicable.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Front/Orchestrator Layer
    subgraph "Front/Orchestrator Layer"
        VS["Validating Service\n(Orchestrates tasks, processes logs & scores texts)"]:::front
    end

    %% Backend/Service Layer
    subgraph "Backend/Service Layer"
        SYN["Synthesizing Service (9100)"]:::backend
        NM["Node Managing Service (9101)"]:::backend
        SCOR["Scoring Service (9102)"]:::backend
        SB["Sidecar Bittensor Service (9103)"]:::backend
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        
        LV["Log Viewer"]:::infrastructure
        %% Redis Support Subgraph
        subgraph "Redis Support"
            RED["Redis"]:::infrastructure
            INSTALL["Install Redis Script"]:::scripts
        end
        
        %% Containerization & Deployment Subgraph
        subgraph "Container & Deployment"
            DOCK["Docker Container"]:::container
            %% Scripts Subgraph
            subgraph "Scripts"
                START["Start Script"]:::scripts
                UPDATE["Update Env Script"]:::scripts
                VLLM["VLLM Script"]:::scripts
            end
        end
    end

    %% Relationships between Validating Service and External Microservices
    VS -->|"send_synthesis_req"| SYN
    SYN -->|"synthesis_response"| VS

    VS -->|"send_uid_req"| NM
    NM -->|"uid_response"| VS

    VS -->|"send_score_req"| SCOR
    SCOR -->|"score_result"| VS

    VS -->|"send_chain_sync"| SB
    SB -->|"sync_ack"| VS

    %% Relationships with Infrastructure Components
    VS -->|"cache_store"| RED
    RED -->|"cache_retrieve"| VS

    VS -->|"log_stream"| LV

    %% Containerization connections to indicate services run inside containers
    DOCK -->|"containerizes"| VS
    DOCK -->|"containerizes"| SYN
    DOCK -->|"containerizes"| NM
    DOCK -->|"containerizes"| SCOR
    DOCK -->|"containerizes"| SB

    %% Script interactions
    START -->|"launches"| VS
    UPDATE -->|"config_updates"| VS
    VLLM -->|"service_management"| VS
    INSTALL -->|"setup_redis"| RED

    %% Click Events
    click VS "https://github.com/condenses/subnet-validating/tree/main/condenses_validating/"
    click LV "https://github.com/condenses/subnet-validating/blob/main/condenses_validating/log_viewer.py"
    click RED "https://github.com/condenses/subnet-validating/blob/main/condenses_validating/redis_manager.py"
    click INSTALL "https://github.com/condenses/subnet-validating/blob/main/scripts/install_redis.sh"
    click DOCK "https://github.com/condenses/subnet-validating/tree/main/Dockerfile"
    click START "https://github.com/condenses/subnet-validating/blob/main/scripts/start.sh"
    click UPDATE "https://github.com/condenses/subnet-validating/blob/main/scripts/update_env.py"
    click VLLM "https://github.com/condenses/subnet-validating/blob/main/scripts/vllm.sh"

    %% Styles
    classDef front fill:#fde68a,stroke:#b45309,stroke-width:2px;
    classDef backend fill:#bfdbfe,stroke:#1e3a8a,stroke-width:2px;
    classDef infrastructure fill:#d1fae5,stroke:#047857,stroke-width:2px;
    classDef container fill:#fed7aa,stroke:#c05621,stroke-width:2px,stroke-dasharray: 5 5;
    classDef scripts fill:#e9d5ff,stroke:#6b21a8,stroke-width:2px;
```
