# nepet/futhark architecture

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

- Interactive diagram: https://gitdiagram.com/nepet/futhark
- Repository: https://github.com/nepet/futhark

## Overview

##### Main Components

a) Core Rune Processing Engine
- Authentication Module (SHA-256)
- Restriction Parser
- Alternative Evaluator
- Encoding/Decoding Module (Base64)

b) External Interfaces
- Input Interface (for creating/deriving runes)
- Verification Interface (for validating runes)

##### Architectural Flow

a) Rune Creation Flow:
- Secret Input → AuthBase Generation → Restriction Addition → SHA-256 Processing → Base64 Encoding → Final Rune

b) Rune Verification Flow:
- Encoded Rune → Base64 Decoding → Auth Code Verification → Restriction Parsing → Alternative Evaluation → Verification Result

##### Specific Implementation Details

Project-specific elements:

a) Core Components (based on src/):
- lib.rs (main interface)
- sha256.rs (cryptographic operations)

b) Testing Components:
- test_vectors.csv
- benchmarking modules (from benches/)

##### Component Relationships

Key relationships:

**[Input Interface] → [Restriction Parser] → [SHA-256 Module]**
- ↓
**[Secret Store] → [AuthBase Generator] → [Authentication Module]**
- ↓
**[Base64 Encoder/Decoder] ← → [Final Rune Output]**

##### Implementation Notes

- The modular nature of the codebase (separate SHA-256 implementation)
- The benchmark capabilities (shown in benches/)
- The test vector validation system
- The extensibility for future functional checks

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Core Rune Processing Engine"
        CoreEngine["Core Engine"]:::core
        click CoreEngine "https://github.com/nepet/futhark/blob/main/src/lib.rs"
        
        subgraph "Authentication Components"
            AuthModule["Authentication Module"]:::auth
            click AuthModule "https://github.com/nepet/futhark/blob/main/src/sha256.rs"
            AuthBase["AuthBase Generator"]:::auth
            SecretStore["Secret Store"]:::storage
        end
        
        subgraph "Processing Components"
            RestParser["Restriction Parser"]:::processor
            AltEval["Alternative Evaluator"]:::processor
            Base64Proc["Base64 Encoder/Decoder"]:::processor
        end
    end
    
    subgraph "Testing & Benchmarking"
        TestVectors["Test Vector System"]:::testing
        click TestVectors "https://github.com/nepet/futhark/blob/main/tests/test_vectors.csv"
        
        DecodeBench["Decoding Benchmark"]:::benchmark
        click DecodeBench "https://github.com/nepet/futhark/blob/main/benches/decoding_benchmark.rs"
        
        PaddingBench["Padding Benchmark"]:::benchmark
        click PaddingBench "https://github.com/nepet/futhark/blob/main/benches/padding_benchmark.rs"
    end
    
    subgraph "Examples & CI"
        TimeExample["Time Restriction Example"]:::example
        click TimeExample "https://github.com/nepet/futhark/blob/main/examples/timelimit.rs"
        
        CI["CI Pipeline"]:::ci
        click CI "https://github.com/nepet/futhark/blob/main/.github/workflows/ci.yml"
    end
    
    subgraph "External Interfaces"
        Input["Input Interface"]:::interface
        Verify["Verification Interface"]:::interface
    end
    
    %% Relationships
    Input --> RestParser
    RestParser --> AuthModule
    SecretStore --> AuthBase
    AuthBase --> AuthModule
    AuthModule --> Base64Proc
    Base64Proc --> CoreEngine
    
    CoreEngine --> TestVectors
    CoreEngine --> DecodeBench
    CoreEngine --> PaddingBench
    CoreEngine --> TimeExample
    
    Verify --> Base64Proc
    Base64Proc --> AuthModule
    AuthModule --> AltEval
    AltEval --> RestParser
    
    %% Styles
    classDef core fill:#2b5797,stroke:#fff,stroke-width:2px,color:#fff
    classDef auth fill:#d04a4a,stroke:#fff,stroke-width:2px,color:#fff
    classDef processor fill:#3c8d2f,stroke:#fff,stroke-width:2px,color:#fff
    classDef storage fill:#7a7a7a,stroke:#fff,stroke-width:2px,color:#fff
    classDef testing fill:#a44bd4,stroke:#fff,stroke-width:2px,color:#fff
    classDef benchmark fill:#ffaa44,stroke:#fff,stroke-width:2px,color:#fff
    classDef interface fill:#4494ff,stroke:#fff,stroke-width:2px,color:#fff
    classDef example fill:#44aa44,stroke:#fff,stroke-width:2px,color:#fff
    classDef ci fill:#666666,stroke:#fff,stroke-width:2px,color:#fff
```
