# krypton-byte/neonize architecture

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

- Interactive diagram: https://gitdiagram.com/krypton-byte/neonize
- Repository: https://github.com/krypton-byte/neonize

## Overview

##### Main Components
- Client Application (User’s Script or Bot):
– Represents the user’s code that imports and calls the Neonize API (as shown in examples like basic.py).
- Neonize Python Library:
– Contains modules under the “neonize” directory such as the client, API, event handling, and utilities.
– Includes the Protobuf modules (in neonize/proto) that are used for serializing/deserializing message data.
- Communication Layer (Protobuf):
– Acts as the medium for data exchange between Neonize and WhatsApp’s underlying protocol via Whatsmeow functions.
- Underlying WhatsApp Automation (Whatsmeow Binding):
- Proto/Code Generation & Support (Goneonize):
– This part (inside the “goneonize” directory) contains Go code, proto definitions, and helper scripts (build_python_proto.py) that generate Python pb2 files.
– It plays a role in keeping the protocol definitions synchronized.
- Database Store:
– According to the README, Neonize supports SQLite and PostgreSQL.
– Include these stores to indicate how message or settings data is stored and accessed.
- Tools & CI/CD:
– The “tools” directory, GitHub workflows, and documentation files (in “docs” and CI configuration under “.github”) are also part of the overall ecosystem.
– You may simplify this into a “DevOps / Utility” component which handles versioning, build automation, and documentation.

##### Relationships and Interactions
- The Client Application invokes the Neonize Python Library API.
- Neonize internally uses Protobuf serialized messages to structure the requests and responses.
- The library (via its Whatsmeow binding) communicates with WhatsApp endpoints or services.
- For protocol consistency, the Goneonize module (using Go) and utility scripts are used to build the proto files consumed by Neonize.
- When configured, a database (SQLite or Postgres) is connected to the Neonize client to store session, chat, or automation-specific data.
- The CI/CD and tooling components (shown in the .github and tools directories) are used by developers to test, build, and release the project.

##### Architectural Patterns and Important Components
- Layered Architecture:
– Presentation Layer: The client code (scripts or bots).
– Application/Domain Layer: The Neonize library and API for processing WhatsApp automation.
– Data & Communication Layer: Protobuf messages, database interactions, and bridge components (Whatsmeow binding).
– Utility/Support Layer: Proto generation (Goneonize) and build/CI configurations.
- Modular Design:
– Clear separation between protocol generation (goneonize), the Python binding (neonize), and example usage (examples folder).
- Extensibility:
– The design supports multiple databases and can be easily extended with additional automation functions and integrations.

– Include external services, such as Whatsmeow and database systems, as separate components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        CA["Client Application\n(User Script)"]:::client
    end

    %% Application/Domain Layer
    subgraph "Application/Domain Layer"
        NL["Neonize Library (Python)"]:::python
        PC["Protobuf Communication"]:::proto
        WI["Whatsmeow Integration"]:::external
    end

    %% Data & Communication Layer
    subgraph "Database Store (SQLite/Postgres)"
        DS1["Chat Settings Store"]:::db
        DS2["Contact Store"]:::db
    end

    %% Utility/Support Layer
    subgraph "Utility/Support Layer"
        GP["Proto Generator (Goneonize)"]:::go
        subgraph "CI/CD & DevOps Tools"
            CICD1[".github"]:::devops
            CICD2["Tools"]:::devops
        end
    end

    %% Connections
    CA -->|"calls_API"| NL
    NL -->|"serializes_using"| PC
    NL -->|"integrates_with"| WI
    NL -->|"stores_data"| DS1
    NL -->|"stores_data"| DS2
    GP -->|"generates_proto_for"| PC
    CICD1 -->|"automates_build"| GP
    CICD2 -->|"automates_build"| GP

    %% Click Events
    click CA "https://github.com/krypton-byte/neonize/blob/master/examples/basic.py"
    click NL "https://github.com/krypton-byte/neonize/tree/master/neonize/"
    click PC "https://github.com/krypton-byte/neonize/tree/master/neonize/proto/"
    click WI "https://github.com/krypton-byte/neonize/blob/master/neonize/_binder.py"
    click GP "https://github.com/krypton-byte/neonize/tree/master/goneonize/"
    click DS1 "https://github.com/krypton-byte/neonize/blob/master/goneonize/chat_settings_store.go"
    click DS2 "https://github.com/krypton-byte/neonize/blob/master/goneonize/contact_store.go"
    click CICD1 "https://github.com/krypton-byte/neonize/tree/master/.github/"
    click CICD2 "https://github.com/krypton-byte/neonize/tree/master/tools/"

    %% Styles
    classDef client fill:#ffdddd,stroke:#990000,stroke-width:2px;
    classDef python fill:#ddffdd,stroke:#006600,stroke-width:2px;
    classDef proto fill:#ddddff,stroke:#000099,stroke-width:2px;
    classDef external fill:#f2f2f2,stroke:#666666,stroke-width:2px;
    classDef go fill:#ffe6cc,stroke:#cc6600,stroke-width:2px;
    classDef db fill:#ffffcc,stroke:#999900,stroke-width:2px;
    classDef devops fill:#ddffff,stroke:#009999,stroke-width:2px;
```
