# 404-repo/three-gen-subnet architecture

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

- Interactive diagram: https://gitdiagram.com/404-repo/three-gen-subnet
- Repository: https://github.com/404-repo/three-gen-subnet

## Overview

##### Project Overview and Purpose
- This project (“THREE GEN | SUBNET 17”) is a decentralized 3D content generation platform. It integrates multiple 3D generative model approaches (e.g., Gaussian Splatting, Neural Radiance Fields, 3D Diffusion Models, and point-cloud techniques) to create virtual worlds, games, and AR/VR/XR experiences. The subnet is designed to work within the broader Bittensor ecosystem and supports both miner and validator neurons.
- The project aims to allow both experienced and non-technical users to generate gaming and virtual world assets in real time.

##### Key Modules Based on the File Tree and README
a. Generation Module (“generation”):
- This is the central module responsible for content creation. It comprises various libraries and utilities (e.g., DreamGaussianLib, rendering pipelines, configuration files, and scripts). It also contains sub-components for ImageDream and MVDream that include specific AI model integrations.
- Contains setup scripts (e.g., setup_env.sh, conda environment files) and configuration YAML files which dictate behavior for image and text generation.

b. Neurons Module (“neurons”):
- This module contains the entry points for both miner and validator neurons. It manages RPC endpoints, miner and validator configuration (miner.config.js, validator.config.js), wallet integration, and various worker scripts.
- It organizes components into subdirectories for the auto updater, common utilities, miner processes, mocks for testing, and validators.
- This module orchestrates the bridging with the Bittensor protocols and manages both generation and validation workflows.

c. Validation Module (“validation”):
- Dedicated to quality assurance, consistency checks, and content integrity. The module includes a validation endpoint setup, test scripts, and libraries for rendering validation outputs (using gs_camera, gs_renderer, and a validation pipeline).
- Works in parallel with the neurons to serve task requests and run validations on generated content.

d. Prompt Generation Components:
- Although not a primary directory, the README highlights prompt generation via both “prompt generators” and a “prompt collector” system. This is an external integration point (with references to separate repositories), which feeds into the broader workflow for content creation prompts.

##### Relationships and Data Flow
- The Generation module exposes an API (via endpoints like /generate_video) that is used by the miner neurons. Data flows from the generation backend (which internally uses multiple AI models) to the miner, and then from the miner to validators.
- The validator neurons fetch generated content and validate it through the Validation module. There is a clear data pipeline: generation → miner neuron → validation → (possibly back to prompt collection & further iterations).
- PM2 is used in both the generation and neurons modules to manage process supervision. Conda environments manage dependency isolation for each module.

##### Architectural Patterns and Design Principles
- The project adopts a modular design separating concerns into Generation, Neurons, and Validation. This separation is crucial for decoupling the content creation from processing and quality control.
- The use of setup scripts and Conda environment files indicate an emphasis on reproducible and isolated deployment.
- The integration with PM2 for process supervision implies a microservices-like approach to managing service lifecycles.
- There is clear separation between core logic (in Python packages within each module) and configuration/deployment scripts, which follows typical best practices for scalable systems.

##### Detailing Relationships and Interactions
- Validator neurons to the Validation module, showing that validators pull tasks and results for assessment.
- Provide annotations such as “Conda Environment Setup,” “PM2 Process Management,” and “Bittensor Protocol Integration” to clarify key responsibilities.

##### Summary of Elements
- Main Modules: Generation, Neurons (miner and validator paths), and Validation.
- Sub-components: AI model libraries (DreamGaussianLib), rendering utilities, configuration files, and scripts.
- External Services: Bittensor integration, prompt generator, and prompt collector.
- Process Management: Indicate environment management (Conda) and process supervision (PM2).

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Generation Module
    subgraph "Generation Module"
        Gen["Generation Module"]:::genModule
        DreamLib["AI Models & Utilities (DreamGaussianLib)"]:::genSub
        Rendering["Rendering Utilities"]:::genSub
        ExtrasImage["ImageDream Integration"]:::genSub
        ExtrasMVDream["MVDream Integration"]:::genSub
        Config["Configuration & Environment Setup"]:::genSub
        CondaFile["Conda Env File"]:::genSub
        SetupScript["Setup Script"]:::genSub
    end

    %% Neurons Module
    subgraph "Neurons Module"
        Neurons["Neurons Module"]:::neuModule
        Miner["Miner Neurons"]:::neuSub
        MinerConfig["Miner Config"]:::neuSub
        Validator["Validator Neurons"]:::neuSub
        ValidatorConfig["Validator Config"]:::neuSub
        ValidatorAPI["Validator API"]:::neuSub
        Common["Common Utilities"]:::neuSub
    end

    %% Validation Module
    subgraph "Validation Module"
        Validation["Validation Module"]:::valModule
        ValidEndpoint["Validation Endpoint"]:::valSub
        ValidLib["Validation Libraries"]:::valSub
    end

    %% External Services
    subgraph "External Services"
        Bittensor["Bittensor Integration"]:::ext
        PromptService["Prompt Generation Services"]:::ext
    end

    %% Process Management
    subgraph "Process Management"
        PM2["PM2 Process Management"]:::annotation
        CondaEnv["Conda Environment Setup"]:::annotation
    end

    %% Data Flow Connections
    PromptService -->|"feeds_prompts"| Gen
    Gen -->|"calls_miner_RPC"| Miner
    Miner -->|"passes_content"| Validator
    Validator -->|"invokes_validation"| ValidEndpoint
    Validation -->|"quality_feedback"| PromptService
    Neurons -->|"Bittensor_integration"| Bittensor

    %% Process Management Associations (Dotted connections)
    PM2 -.-> Gen
    PM2 -.-> Neurons
    CondaEnv -.-> Gen
    CondaEnv -.-> Neurons

    %% Internal Module Connections in Generation Module
    Gen --> DreamLib
    DreamLib --> Rendering
    Gen --> ExtrasImage
    Gen --> ExtrasMVDream
    Gen --> Config
    Config --> CondaFile
    Config --> SetupScript

    %% Internal Module Connections in Neurons Module
    Neurons --> Miner
    Miner --> MinerConfig
    Neurons --> Validator
    Validator --> ValidatorConfig
    Validator --> ValidatorAPI
    Neurons --> Common

    %% Internal Module Connections in Validation Module
    Validation --> ValidEndpoint
    Validation --> ValidLib

    %% Click Events for Generation Module
    click Gen "https://github.com/404-repo/three-gen-subnet/tree/main/generation/"
    click DreamLib "https://github.com/404-repo/three-gen-subnet/tree/main/generation/DreamGaussianLib/"
    click Rendering "https://github.com/404-repo/three-gen-subnet/tree/main/generation/DreamGaussianLib/rendering/"
    click ExtrasImage "https://github.com/404-repo/three-gen-subnet/tree/main/generation/extras/ImageDream/"
    click ExtrasMVDream "https://github.com/404-repo/three-gen-subnet/tree/main/generation/extras/MVDream/"
    click Config "https://github.com/404-repo/three-gen-subnet/tree/main/generation/configs/"
    click CondaFile "https://github.com/404-repo/three-gen-subnet/blob/main/generation/conda_env_mining.yml"
    click SetupScript "https://github.com/404-repo/three-gen-subnet/blob/main/generation/setup_env.sh"

    %% Click Events for Neurons Module
    click Neurons "https://github.com/404-repo/three-gen-subnet/tree/main/neurons/"
    click Miner "https://github.com/404-repo/three-gen-subnet/tree/main/neurons/miner/"
    click MinerConfig "https://github.com/404-repo/three-gen-subnet/blob/main/neurons/miner/config.py"
    click Validator "https://github.com/404-repo/three-gen-subnet/tree/main/neurons/validator/"
    click ValidatorConfig "https://github.com/404-repo/three-gen-subnet/blob/main/neurons/validator/config.py"
    click ValidatorAPI "https://github.com/404-repo/three-gen-subnet/tree/main/neurons/validator/api/"
    click Common "https://github.com/404-repo/three-gen-subnet/tree/main/neurons/common/"

    %% Click Events for Validation Module
    click Validation "https://github.com/404-repo/three-gen-subnet/tree/main/validation/"
    click ValidEndpoint "https://github.com/404-repo/three-gen-subnet/blob/main/validation/serve.py"
    click ValidLib "https://github.com/404-repo/three-gen-subnet/tree/main/validation/validation_lib/"

    %% Styles
    classDef genModule fill:#AED581,stroke:#333,stroke-width:2px,color:#000;
    classDef genSub fill:#C8E6C9,stroke:#2E7D32,stroke-width:1px,color:#000;
    classDef neuModule fill:#81C784,stroke:#333,stroke-width:2px,color:#000;
    classDef neuSub fill:#A5D6A7,stroke:#1B5E20,stroke-width:1px,color:#000;
    classDef valModule fill:#FFCC80,stroke:#333,stroke-width:2px,color:#000;
    classDef valSub fill:#FFE0B2,stroke:#E65100,stroke-width:1px,color:#000;
    classDef ext fill:#CE93D8,stroke:#6A1B9A,stroke-width:2px,color:#000;
    classDef annotation fill:#FFF176,stroke:#F9A825,stroke-width:1px,color:#000;
```
