# tyberiusprime/anysnake2 architecture

> Architecture diagram of the GitHub repository tyberiusprime/anysnake2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tyberiusprime/anysnake2
- Repository: https://github.com/tyberiusprime/anysnake2

## Overview

##### Main Components Identification

a) Core Components:
- Configuration Parser (config.rs)
- Flake Writer (flake_writer.rs)
- Version Control System Handler (vcs.rs)
- Python Package Parser (python_parsing.rs)
- Trust-on-First-Use System (tofu.rs)

b) External Systems:
- Nix/Nixpkgs
- Singularity Container Runtime
- Poetry2nix
- NixR
- Rust-overlay
- GitHub API

- Blue: Core Anysnake2 components
- Green: External systems/dependencies
- Yellow: Configuration and build artifacts
- Orange: Runtime components
- Gray: File system mounts and volumes

- Rectangles: Main components
- Hexagons: External services

##### Flow Representation

A. Configuration Phase:
**anysnake2.toml → Config Parser → Version Check → Self-restart (if needed)**

B. Build Phase:
**Flake Writer → Nix Build → Singularity Container Creation**

C. Runtime Phase:
**Container Runtime → Mounted Volumes → User Environment**

##### Key Interactions to Highlight

- Version self-management system
- Flake generation process
- Container creation and management
- Package management for different languages
- Trust-on-First-Use (TOFU) mechanism
- Volume mounting and environment setup

##### Detailed Component Relationships

**Config Parser → Flake Writer**
- ↓
**VCS Handler → GitHub API**
- ↓
**Flake Writer → Nix Build System**
- ↓
**Container Builder → Singularity Runtime**

##### Additional Elements

- Configuration options
- Supported language versions
- Container runtime options
- Mount point specifications

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core Components
    Config["Configuration Parser"]:::core
    FlakeWriter["Flake Writer"]:::core
    VCS["VCS Handler"]:::core
    PythonParser["Python Package Parser"]:::core
    TOFU["Trust-on-First-Use System"]:::core
    Main["Main Entry Point"]:::core
    Lib["Core Library"]:::core

    %% External Systems
    Nix["Nix/Nixpkgs"]:::external
    Singularity["Singularity Runtime"]:::external
    Poetry["Poetry2nix"]:::external
    NixR["NixR"]:::external
    RustOverlay["Rust-overlay"]:::external
    GitHub["GitHub API"]:::external

    %% Configuration and Build Artifacts
    ConfigFile["anysnake2.toml"]:::config
    FlakeTemplate["Flake Template"]:::config
    NixFunctions["Nix Functions"]:::config
    RuntimeScript["Runtime Script"]:::runtime

    %% Configuration Phase
    ConfigFile --> Config
    Config --> Main
    Main --> TOFU
    TOFU --> VCS

    %% Build Phase
    Config --> FlakeWriter
    FlakeTemplate --> FlakeWriter
    NixFunctions --> FlakeWriter
    FlakeWriter --> Nix
    VCS --> GitHub
    PythonParser --> Poetry

    %% Runtime Phase
    Nix --> Singularity
    Poetry --> Singularity
    NixR --> Singularity
    RustOverlay --> Singularity
    RuntimeScript --> Singularity

    %% Library Integration
    Lib --> Config
    Lib --> FlakeWriter
    Lib --> VCS
    Lib --> PythonParser
    Lib --> TOFU

    %% Styles
    classDef core fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef external fill:#90EE90,stroke:#333,stroke-width:2px
    classDef config fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef runtime fill:#FFA07A,stroke:#333,stroke-width:2px

    %% Click Events
    click Config "https://github.com/tyberiusprime/anysnake2/blob/main/src/config.rs"
    click FlakeWriter "https://github.com/tyberiusprime/anysnake2/blob/main/src/flake_writer.rs"
    click VCS "https://github.com/tyberiusprime/anysnake2/blob/main/src/vcs.rs"
    click PythonParser "https://github.com/tyberiusprime/anysnake2/blob/main/src/python_parsing.rs"
    click TOFU "https://github.com/tyberiusprime/anysnake2/blob/main/src/tofu.rs"
    click FlakeTemplate "https://github.com/tyberiusprime/anysnake2/blob/main/src/nix/flake_template.nix"
    click NixFunctions "https://github.com/tyberiusprime/anysnake2/blob/main/src/nix/functions.nix"
    click RuntimeScript "https://github.com/tyberiusprime/anysnake2/blob/main/src/run.sh"
    click Main "https://github.com/tyberiusprime/anysnake2/blob/main/src/main.rs"
    click Lib "https://github.com/tyberiusprime/anysnake2/blob/main/src/lib.rs"

    %% Legend
    subgraph Legend
        CoreComp["Core Component"]:::core
        ExtSys["External System"]:::external
        ConfigArt["Configuration/Artifact"]:::config
        RuntimeComp["Runtime Component"]:::runtime
    end
```
