# drriguz/db-schema-key-generator architecture

> Architecture diagram of the GitHub repository drriguz/db-schema-key-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/drriguz/db-schema-key-generator
- Repository: https://github.com/drriguz/db-schema-key-generator

## Overview

##### Project Type and Purpose
- This is a small open-source desktop tool (C++/Qt) whose sole responsibility is generating license keys for DbSchema.
- It offers two user interfaces:
- A command-line interface (console)
- A Qt-based GUI

##### File Structure Analysis
Top-level:
- schema_generator/        ← main source folder
– console_main.cpp       ← CLI entry point
– main.cpp               ← GUI entry point (Qt)
– app.ui                 ← Qt Designer UI file
– app.cpp/.h, app.rc     ← GUI application logic & resources
– generator.h            ← core key-generation interface
– keygen                 ← CLI-built binary
– md5.cpp/.h             ← MD5 hashing module used by generator
– schema_generator.pro   ← Qt project file
– Makefile               ← build script

##### Key Components
a. Frontends
- CLI Frontend (console_main.cpp → keygen)
- GUI Frontend (main.cpp + app.ui + resources → Qt Application)
b. Core
- KeyGen Engine (generator.h + implementation)
c. Utility Module
- MD5 Hash Library (md5.cpp/.h)
d. Build & Config
- Makefile (build targets for CLI)
- Qt .pro (GUI build via Qt Creator)
e. External Dependencies
- Qt Framework (for GUI)

##### Relationships and Data Flow
- Both frontends invoke the KeyGen Engine with the user’s name as input.
- The KeyGen Engine calls into the MD5 module to produce a hash, then formats it into a license key.
- The generated key is returned to the calling frontend, which prints it (CLI) or displays it in the GUI.
- The Makefile orchestrates CLI builds; the .pro file and Qt’s build system produce the GUI binary.

##### Architectural Patterns & Principles
- Single executable offering two UIs sharing one core library (separation of concerns).
- Modular design: UI layers are distinct from business logic (generator).
- Reusable utility module (md5) extracted for hashing.

## Diagram (Mermaid)

```mermaid
flowchart TB
    User["User"]:::external

    subgraph "DbSchema Key Generator Application"
        subgraph "UI Layer"
            CLI["CLI Frontend\n(console_main.cpp)"]:::ui
            GUI["GUI Frontend\n(main.cpp, app.ui, app.cpp/.h, app.rc, res.qrc)"]:::ui
        end
        Engine["KeyGen Engine\n(generator.h)"]:::core
        MD5["MD5 Library\n(md5.cpp/.h)"]:::util
    end

    subgraph "Build & Config"
        Make["Makefile"]:::build
        CLI_bin["CLI Binary\n(keygen)"]:::build
        Pro["Qt Project File\n(.pro)"]:::build
        GUI_bin["GUI Binary"]:::build
        Make --> CLI_bin
        Pro --> GUI_bin
    end

    Qt["Qt Framework"]:::external

    User -->|"input name"| CLI
    User -->|"input via GUI"| GUI
    CLI -->|"invoke Engine"| Engine
    GUI -->|"invoke Engine"| Engine
    Engine -->|"hash call"| MD5
    MD5 -->|"hash result"| Engine
    Engine -->|"license key"| CLI
    Engine -->|"license key"| GUI
    Qt --> GUI

    click CLI "https://github.com/drriguz/db-schema-key-generator/blob/master/schema_generator/console_main.cpp"
    click CLI_bin "https://github.com/drriguz/db-schema-key-generator/tree/master/schema_generator/keygen"
    click GUI "https://github.com/drriguz/db-schema-key-generator/blob/master/schema_generator/main.cpp"
    click GUI "https://github.com/drriguz/db-schema-key-generator/blob/master/schema_generator/app.ui"
    click GUI "https://github.com/drriguz/db-schema-key-generator/blob/master/schema_generator/app.cpp"
    click GUI "https://github.com/drriguz/db-schema-key-generator/blob/master/schema_generator/app.h"
    click GUI "https://github.com/drriguz/db-schema-key-generator/blob/master/schema_generator/app.rc"
    click GUI "https://github.com/drriguz/db-schema-key-generator/blob/master/schema_generator/res.qrc"
    click Engine "https://github.com/drriguz/db-schema-key-generator/blob/master/schema_generator/generator.h"
    click MD5 "https://github.com/drriguz/db-schema-key-generator/blob/master/schema_generator/md5.cpp"
    click MD5 "https://github.com/drriguz/db-schema-key-generator/blob/master/schema_generator/md5.h"
    click Make "https://github.com/drriguz/db-schema-key-generator/tree/master/schema_generator/Makefile"
    click Pro "https://github.com/drriguz/db-schema-key-generator/blob/master/schema_generator/schema_generator.pro"

    classDef ui fill:#cce5ff,stroke:#66b2ff;
    classDef core fill:#d4edda,stroke:#28a745;
    classDef util fill:#fff3cd,stroke:#ffcd39;
    classDef build fill:#e2e3e5,stroke:#6c757d;
    classDef external fill:#f8d7da,stroke:#dc3545;
```
