# mobilpadde/moths architecture

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

- Interactive diagram: https://gitdiagram.com/mobilpadde/moths
- Repository: https://github.com/mobilpadde/moths

## Overview

##### Main Components

a) Core Generator Component:
- Generator struct which is the main entry point
- Relationship with the configuration options

b) Token Management Layer:
- Token generation and validation flow
- Code package that handles the actual token operations
- Checks subsystem that validates various parameters

c) Emoji Provider System:
- Emoji categories (cats, dogs, faces, etc.)
- How the emoji system interfaces with the generator

##### Specific Implementation Details

**┌─────────────────────────────────────────────────────────┐**
- Moths TOTP System                      │

- ┌─────────────┐        ┌──────────────────────┐       │
- Options   │───────▶│    Token Generator   │       │
- ┘        └──────────────────────┘       │
- Secret            - NewGenerator()                  │
- Period            - Next()                          │
- Amount            - Validate()                      │
- Time                      │                         │
- ▼                          │
- ┌─────────────┐    ┌──────────────────────┐          │
- Checks    │◀───│     Code Handler     │          │
- ┘    └──────────────────────┘          │
- Amount           - Buffer                          │
- Emojis           - Validation                      │
- Period           - Configuration                   │
- Secret                                            │

- ┌─────────────────────────────────────────┐         │
- Emoji Provider                │         │
- ┌─────────┐ ┌────────┐ ┌────────────┐   │         │
- Cats   │ │  Dogs  │ │   Faces    │   │         │
- ┘ └────────┘ └────────────┘   │         │
- ┘         │
- ┘

##### Important Details to Capture

a) Configuration Flow:
- How options are passed to the generator
- Configuration validation process

b) Token Generation Process:
- Flow from generator to code creation
- How emojis are selected and combined

c) Validation Flow:
- Token validation process
- How checks are performed

##### Technical Notes

- Time-based nature of the system
- Relationship with TOTP standards
- Where custom emoji sets can be integrated

- Clear component boundaries
- Text annotations
- Proper spacing for readability

Remember to maintain a balance between showing enough detail to understand the system while keeping it clean and readable. The focus should be on the core TOTP functionality and the unique emoji-based implementation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Main
        Generator["Generator"]
        NewGen["NewGenerator()"]
        Next["Next()"]
        Validate["Validate()"]
        
        Generator --> NewGen
        NewGen --> Next
        NewGen --> Validate
    end
    
    subgraph Options
        Amount["Amount Option"]
        Secret["Secret Option"]
        Period["Period Option"]
        Time["Time Option"]
        Emoji["Emoji Option"]
        Encoding["Encoding Option"]
    end
    
    subgraph "Code Handler"
        Buffer["Buffer Management"]
        CodeConfig["Code Configuration"]
        CodeGen["Code Generation"]
        CodeValidate["Code Validation"]
    end
    
    subgraph Checks
        CheckAmount["Amount Validation"]
        CheckEmoji["Emoji Validation"]
        CheckPeriod["Period Validation"]
        CheckSecret["Secret Validation"]
    end
    
    subgraph "Emoji Provider"
        EmojiInterface["Emoji Interface"]
        
        subgraph Categories
            Cats["Cats"]
            Dogs["Dogs"]
            Faces["Faces"]
            BodyParts["Body Parts"]
            Bugs["Bugs"]
            Flags["Country Flags"]
            Gestures["Gestures"]
        end
        
        EmojiInterface --> Categories
    end
    
    Options --> NewGen
    NewGen --> CodeHandler
    CodeHandler --> Checks
    CodeHandler --> EmojiInterface
    
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px;
    classDef main fill:#b3d1ff,stroke:#333,stroke-width:2px;
    classDef options fill:#ffe6cc,stroke:#333,stroke-width:2px;
    classDef code fill:#d9ead3,stroke:#333,stroke-width:2px;
    classDef checks fill:#fff2cc,stroke:#333,stroke-width:2px;
    classDef emoji fill:#e6b8af,stroke:#333,stroke-width:2px;
    
    class Generator,NewGen,Next,Validate main;
    class Amount,Secret,Period,Time,Emoji,Encoding options;
    class Buffer,CodeConfig,CodeGen,CodeValidate code;
    class CheckAmount,CheckEmoji,CheckPeriod,CheckSecret checks;
    class EmojiInterface,Cats,Dogs,Faces,BodyParts,Bugs,Flags,Gestures emoji;
    
    click Generator "https://github.com/Mobilpadde/moths/blob/main/token/newGenerator.go"
    click Next "https://github.com/Mobilpadde/moths/blob/main/token/next.go"
    click Validate "https://github.com/Mobilpadde/moths/blob/main/token/validate.go"
    click Amount "https://github.com/Mobilpadde/moths/blob/main/token/option/amount.go"
    click Secret "https://github.com/Mobilpadde/moths/blob/main/token/option/secret.go"
    click Period "https://github.com/Mobilpadde/moths/blob/main/token/option/period.go"
    click Time "https://github.com/Mobilpadde/moths/blob/main/token/option/time.go"
    click Emoji "https://github.com/Mobilpadde/moths/blob/main/token/option/emojies.go"
    click Encoding "https://github.com/Mobilpadde/moths/blob/main/token/option/encode.go"
    click Buffer "https://github.com/Mobilpadde/moths/blob/main/token/code/buffer.go"
    click CodeConfig "https://github.com/Mobilpadde/moths/blob/main/token/code/config.go"
    click CodeGen "https://github.com/Mobilpadde/moths/blob/main/token/code/newCode.go"
    click CodeValidate "https://github.com/Mobilpadde/moths/blob/main/token/code/validate.go"
    click CheckAmount "https://github.com/Mobilpadde/moths/blob/main/token/checks/checkAmount.go"
    click CheckEmoji "https://github.com/Mobilpadde/moths/blob/main/token/checks/checkEmojies.go"
    click CheckPeriod "https://github.com/Mobilpadde/moths/blob/main/token/checks/checkPeriod.go"
    click CheckSecret "https://github.com/Mobilpadde/moths/blob/main/token/checks/checkSecret.go"
    click EmojiInterface "https://github.com/Mobilpadde/moths/blob/main/token/emojies/emoji.go"
    click Cats "https://github.com/Mobilpadde/moths/blob/main/token/emojies/cats.go"
    click Dogs "https://github.com/Mobilpadde/moths/blob/main/token/emojies/dogs.go"
    click Faces "https://github.com/Mobilpadde/moths/blob/main/token/emojies/faces.go"
    click BodyParts "https://github.com/Mobilpadde/moths/blob/main/token/emojies/bodyParts.go"
    click Bugs "https://github.com/Mobilpadde/moths/blob/main/token/emojies/bugs.go"
    click Flags "https://github.com/Mobilpadde/moths/blob/main/token/emojies/countryFlags.go"
    click Gestures "https://github.com/Mobilpadde/moths/blob/main/token/emojies/gestures.go"
```
