# cyfrin/web3py-favorites-cu architecture

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

- Interactive diagram: https://gitdiagram.com/cyfrin/web3py-favorites-cu
- Repository: https://github.com/cyfrin/web3py-favorites-cu

## Overview

##### Main Components

a) Client-Side Components:
- Python Deployment Scripts Layer
- Two variants: Safe (deploy_favorites.py) and Unsafe (deploy_favorites_unsafe.py)
- Encryption utility (encrypt_key.py)

b) Blockchain Infrastructure:
- Tenderly Virtual TestNet
- Smart Contract Layer (favorites.vy Vyper contract)

c) Security & Configuration:
- Environment Configuration (.env)
- Key Management System
- Encrypted Key Storage
- Key Encryption/Decryption Process

##### Relationships and Data Flow

**[Python Deployment Scripts] → [Key Management] → [Tenderly TestNet] → [Smart Contract]**

##### Specific Design Elements

Use these visual elements:
- Blue rectangles for Python components
- Green hexagons for blockchain components
- Red diamonds for security-related components
- Yellow rectangles for configuration elements

##### Component Details

a) Python Deployment Layer:
- Both deployment paths:
1. Unsafe Path: Direct private key usage
2. Safe Path: Encrypted key workflow
- To key management system

b) Blockchain Layer:
- Tenderly TestNet connection
- RPC endpoint interface
- Smart contract deployment target

c) Security Layer:
- Key encryption/decryption flow
- Environment variable management
- Configuration handling

##### Important Interactions to Highlight

- Private key encryption flow
- Deployment script interaction with Tenderly
- Environment variable usage
- Contract deployment process

##### Technical Stack Indicators

Labels for:
- Python/UV environment
- Vyper smart contract
- Web3.py library
- Tenderly infrastructure

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Python Deployment Layer"
        direction TB
        SafeDeploy["Safe Deploy Script"]:::python
        UnsafeDeploy["Unsafe Deploy Script"]:::python
        KeyMgmt["Key Management System"]:::security
    end

    subgraph "Security & Configuration"
        direction TB
        EnvConfig["Environment Config"]:::config
        KeyStorage["Encrypted Key Storage"]:::security
        KeyProcess["Key Encryption/Decryption"]:::security
    end

    subgraph "Blockchain Infrastructure"
        direction TB
        Tenderly["Tenderly TestNet"]:::blockchain
        SmartContract["Favorites Smart Contract"]:::blockchain
    end

    subgraph "Development Environment"
        direction TB
        DevConfig["Dev Container Config"]:::config
        Dependencies["Project Dependencies"]:::config
    end

    %% Relationships
    SafeDeploy --> KeyMgmt
    UnsafeDeploy --> Tenderly
    KeyMgmt --> KeyProcess
    KeyProcess --> KeyStorage
    KeyStorage --> Tenderly
    Tenderly --> SmartContract
    EnvConfig --> SafeDeploy
    EnvConfig --> UnsafeDeploy
    DevConfig --> Dependencies

    %% Click Events
    click SafeDeploy "https://github.com/Cyfrin/web3py-favorites-cu/blob/main/deploy_favorites.py"
    click UnsafeDeploy "https://github.com/Cyfrin/web3py-favorites-cu/blob/main/deploy_favorites_unsafe.py"
    click KeyMgmt "https://github.com/Cyfrin/web3py-favorites-cu/blob/main/encrypt_key.py"
    click SmartContract "https://github.com/Cyfrin/web3py-favorites-cu/blob/main/favorites.vy"
    click EnvConfig "https://github.com/Cyfrin/web3py-favorites-cu/blob/main/.env.example"
    click DevConfig "https://github.com/Cyfrin/web3py-favorites-cu/blob/main/.devcontainer/devcointainer.json"
    click Dependencies "https://github.com/Cyfrin/web3py-favorites-cu/blob/main/requirements.txt"

    %% Styling
    classDef python fill:#3776AB,color:white
    classDef security fill:#FF6B6B,color:white
    classDef blockchain fill:#6BBB69,color:white
    classDef config fill:#FFD93D,color:black

    %% Legend
    subgraph Legend
        direction TB
        P["Python Component"]:::python
        S["Security Component"]:::security
        B["Blockchain Component"]:::blockchain
        C["Configuration"]:::config
    end
```
