# kevinoliveira/buttercup-to-keepassxc architecture

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

- Interactive diagram: https://gitdiagram.com/kevinoliveira/buttercup-to-keepassxc
- Repository: https://github.com/kevinoliveira/buttercup-to-keepassxc

## Overview

##### Input/Output Processing
- End with an output node for the KeePassXC CSV file

##### Core Processing Components
a. CSV Parser
b. Data Transformer
c. CSV Writer

##### Data Flow Architecture
Input → Parse → Transform → Write → Output

##### Top Level (Input/Output)
- [Buttercup CSV] → [Processing Layer] → [KeePassXC CSV]

##### Detailed Processing Layer
- [CSV Parser] → [Data Transformer] → [CSV Writer]

##### Data Transformation Details
Specific transformations:
- Flattening
- TOTP detection
- Custom field processing
- Date handling

Use these specific visual elements:

- Blue: Input/Output
- Green: Processing components
- Yellow: Transformation logic
- Red: Error handling/validation

##### Data Transformation Rules
- How nested groups are flattened
- TOTP detection logic
- Custom field processing

##### Validation Points
- CSV format verification
- TOTP authentication string validation
- Name collision handling

##### Technical Details
- Built with Bun runtime
- TypeScript implementation
- CSV parsing/writing capabilities

- File I/O operations
- Data transformation processes
- Validation checkpoints
- Optional processing paths

Remember to include a note about the temporal nature of the solution (valid as of September 2024) and the test/example files available in the project.

## Diagram (Mermaid)

```mermaid
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#2b7bb9',
    'primaryTextColor': '#fff',
    'primaryBorderColor': '#2b7bb9',
    'lineColor': '#2b7bb9',
    'secondaryColor': '#006100',
    'tertiaryColor': '#ffab00'
  }
}}%%

flowchart TB
    classDef input fill:#2b7bb9,stroke:#333,stroke-width:2px
    classDef process fill:#006100,stroke:#333,stroke-width:2px,color:white
    classDef transform fill:#ffab00,stroke:#333,stroke-width:2px
    classDef output fill:#2b7bb9,stroke:#333,stroke-width:2px
    classDef validation fill:#ff0000,stroke:#333,stroke-width:2px,color:white

    subgraph Input
        ButtercupCSV[("Buttercup CSV")]:::input
        ButtercupVault[("Buttercup Vault")]:::input
    end

    subgraph "Processing Layer"
        Parser["CSV Parser"]:::process
        Transform["Data Transformer"]:::process
        Writer["CSV Writer"]:::process

        subgraph "Transformation Rules"
            FlattenGroups["Group Flattening"]:::transform
            TOTPDetect{"TOTP Detection"}:::transform
            CustomFields["Custom Field Processing"]:::transform
            DateHandle["Date Handling"]:::transform
        end

        subgraph "Validation"
            CSVValidate["CSV Format Check"]:::validation
            TOTPValidate["TOTP String Validation"]:::validation
            GroupValidate["Group Collision Check"]:::validation
        end
    end

    subgraph Output
        KeePassCSV[("KeePassXC CSV")]:::output
        KeePassVault[("KeePassXC Vault")]:::output
    end

    ButtercupCSV --> Parser
    ButtercupVault --> Parser
    Parser --> CSVValidate
    CSVValidate --> Transform
    Transform --> FlattenGroups
    FlattenGroups --> TOTPDetect
    TOTPDetect --> TOTPValidate
    TOTPValidate --> CustomFields
    CustomFields --> DateHandle
    DateHandle --> GroupValidate
    GroupValidate --> Writer
    Writer --> KeePassCSV
    Writer --> KeePassVault

    %% Click events for component mapping
    click Parser "https://github.com/kevinoliveira/buttercup-to-keepassxc/blob/main/main.ts"
    click Transform "https://github.com/kevinoliveira/buttercup-to-keepassxc/blob/main/helpers.ts"
    click Writer "https://github.com/kevinoliveira/buttercup-to-keepassxc/blob/main/main.ts"
    click ButtercupCSV "https://github.com/kevinoliveira/buttercup-to-keepassxc/blob/main/examples/buttercup-exported-file.csv"
    click KeePassCSV "https://github.com/kevinoliveira/buttercup-to-keepassxc/blob/main/examples/keepassxc-to-import-file.csv"
    click ButtercupVault "https://github.com/kevinoliveira/buttercup-to-keepassxc/blob/main/examples/buttercup-test-vault.bcup"
    click KeePassVault "https://github.com/kevinoliveira/buttercup-to-keepassxc/blob/main/examples/keepassxc-test-vault.kdbx"
    click TOTPValidate "https://github.com/kevinoliveira/buttercup-to-keepassxc/blob/main/helpers.test.ts"
    click CustomFields "https://github.com/kevinoliveira/buttercup-to-keepassxc/blob/main/types.ts"

    %% Legend
    subgraph Legend
        L1[("File I/O")]:::input
        L2["Processing"]:::process
        L3["Transformation"]:::transform
        L4["Validation"]:::validation
    end
```
