# paxapos/fiscalberry architecture

> Architecture diagram of the GitHub repository paxapos/fiscalberry, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/paxapos/fiscalberry
- Repository: https://github.com/paxapos/fiscalberry

## Overview

Fiscalberry is a networked print server: a client submits JSON commands, Fiscalberry translates them for the configured printer, and returns the printer response. Runtime entry points start the service and Socket.IO connection; device discovery and adoption/configuration support setup, while RabbitMQ provides a separate messaging and remote-error capability. Edges reflect the README and shown source references/calls; several implementation details, especially printer detection and UI behavior, were not sampled, so uncertain links are omitted.

Main entry points: [`src/fiscalberry/common/ComandosHandler.py`](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/ComandosHandler.py) (Command handler), [`src/fiscalberry/common/service_controller.py`](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/service_controller.py) (Service controller), [`src/fiscalberry/common/fiscalberry_sio.py`](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/fiscalberry_sio.py) (Socket.IO server link), [`src/fiscalberry/ui/fiscalberry_app.py`](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/ui/fiscalberry_app.py) (Kivy application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Service runtime"]
  node_service["Service controller"]
  node_socketio["Socket.IO server link<br/>[fiscalberry_sio.py]"]
  node_config[("Configuration<br/>[Configberry.py]")]
end

subgraph group_printing["Print pipeline"]
  node_command_handler["Command handler<br/>[ComandosHandler.py]"]
  node_fiscal_commands["Fiscal drivers"]
  node_escp_commands["ESC/P commands<br/>[EscPComandos.py]"]
end

subgraph group_device["Device operations"]
  node_discover["Device discovery<br/>[discover.py]"]
  node_detector["Printer detection"]
  node_bluetooth["Bluetooth printing"]
  node_printer_errors["Printer error detection"]
  node_rabbit_process["RabbitMQ process<br/>[process_handler.py]"]
  node_rabbit_consumer["RabbitMQ consumer<br/>[consumer.py]"]
  node_error_publisher["Remote error publisher<br/>[error_publisher.py]"]
end

subgraph group_management["Setup and management"]
  node_gui["Kivy application<br/>[fiscalberry_app.py]"]
  node_adoption["Adoption screen<br/>[adopt_screen.py]"]
  node_login["Login screen<br/>[login_screen.py]"]
  node_tokens[("JWT token manager<br/>[token_manager.py]")]
end

node_client(("JSON client"))
node_printer["Connected printer"]
node_printer_response["Printer response"]
node_backend["Fiscalberry backend"]

node_client -->|"sends JSON"| node_socketio
node_socketio -->|"dispatches commands"| node_command_handler
node_command_handler -->|"uses fiscal driver"| node_fiscal_commands
node_command_handler -->|"uses ESC/P driver"| node_escp_commands
node_fiscal_commands -->|"prints commands"| node_printer
node_escp_commands -->|"prints commands"| node_printer
node_printer -->|"returns result"| node_printer_response
node_printer_response -->|"replies via socket"| node_client
node_service -->|"starts connection"| node_socketio
node_service -->|"starts discovery"| node_discover
node_discover -->|"lists printers"| node_detector
node_socketio -->|"starts consumer"| node_rabbit_process
node_rabbit_process -->|"starts consumer"| node_rabbit_consumer
node_command_handler -->|"analyzes responses"| node_printer_errors
node_printer_errors -->|"publishes errors"| node_error_publisher
node_command_handler -->|"reports errors"| node_error_publisher
node_gui -->|"starts services"| node_service
node_gui -->|"uses screen"| node_adoption
node_gui -->|"uses screen"| node_login
node_login -->|"authenticates"| node_tokens
node_tokens -->|"requests login"| node_backend
node_config -->|"supplies settings"| node_discover
node_config -->|"supplies settings"| node_service

click node_service "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/service_controller.py"
click node_socketio "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/fiscalberry_sio.py"
click node_config "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/Configberry.py"
click node_command_handler "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/ComandosHandler.py"
click node_fiscal_commands "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/FiscalberryComandos.py"
click node_escp_commands "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/EscPComandos.py"
click node_discover "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/discover.py"
click node_detector "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/printer_detector.py"
click node_bluetooth "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/bluetooth_printer.py"
click node_printer_errors "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/printer_error_detector.py"
click node_rabbit_process "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/rabbitmq/process_handler.py"
click node_rabbit_consumer "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/rabbitmq/consumer.py"
click node_error_publisher "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/rabbitmq/error_publisher.py"
click node_gui "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/ui/fiscalberry_app.py"
click node_adoption "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/ui/adopt_screen.py"
click node_login "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/ui/login_screen.py"
click node_tokens "https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/token_manager.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_service,node_socketio,node_config,node_client toneBlue
class node_command_handler,node_fiscal_commands,node_escp_commands toneAmber
class node_discover,node_detector,node_bluetooth,node_printer_errors,node_rabbit_process,node_rabbit_consumer,node_error_publisher toneMint
class node_gui,node_adoption,node_login,node_tokens toneRose
class node_printer,node_printer_response,node_backend toneIndigo
```

## Components

### Service runtime

- [Service controller](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/service_controller.py): `src/fiscalberry/common/service_controller.py`
- [Socket.IO server link](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/fiscalberry_sio.py): `src/fiscalberry/common/fiscalberry_sio.py`
- [Configuration](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/Configberry.py): `src/fiscalberry/common/Configberry.py`

### Print pipeline

- [Command handler](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/ComandosHandler.py): `src/fiscalberry/common/ComandosHandler.py`
- [Fiscal drivers](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/FiscalberryComandos.py): `src/fiscalberry/common/FiscalberryComandos.py`
- [ESC/P commands](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/EscPComandos.py): `src/fiscalberry/common/EscPComandos.py`

### Device operations

- [Device discovery](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/discover.py): `src/fiscalberry/common/discover.py`
- [Printer detection](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/printer_detector.py): `src/fiscalberry/common/printer_detector.py`
- [Bluetooth printing](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/bluetooth_printer.py): `src/fiscalberry/common/bluetooth_printer.py`
- [Printer error detection](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/printer_error_detector.py): `src/fiscalberry/common/printer_error_detector.py`
- [RabbitMQ process](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/rabbitmq/process_handler.py): `src/fiscalberry/common/rabbitmq/process_handler.py`
- [RabbitMQ consumer](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/rabbitmq/consumer.py): `src/fiscalberry/common/rabbitmq/consumer.py`
- [Remote error publisher](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/rabbitmq/error_publisher.py): `src/fiscalberry/common/rabbitmq/error_publisher.py`

### Setup and management

- [Kivy application](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/ui/fiscalberry_app.py): `src/fiscalberry/ui/fiscalberry_app.py`
- [Adoption screen](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/ui/adopt_screen.py): `src/fiscalberry/ui/adopt_screen.py`
- [Login screen](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/ui/login_screen.py): `src/fiscalberry/ui/login_screen.py`
- [JWT token manager](https://github.com/paxapos/fiscalberry/blob/main/src/fiscalberry/common/token_manager.py): `src/fiscalberry/common/token_manager.py`

### Other components

- **JSON client**
- **Connected printer**
- **Printer response**
- **Fiscalberry backend**

## Connections

- JSON client → Socket.IO server link: sends JSON
- Socket.IO server link → Command handler: dispatches commands (evidence: `src/fiscalberry/common/fiscalberry_sio.py`)
- Command handler → Fiscal drivers: uses fiscal driver (evidence: `src/fiscalberry/common/ComandosHandler.py`)
- Command handler → ESC/P commands: uses ESC/P driver (evidence: `src/fiscalberry/common/ComandosHandler.py`)
- Fiscal drivers → Connected printer: prints commands
- ESC/P commands → Connected printer: prints commands
- Connected printer → Printer response: returns result
- Printer response → JSON client: replies via socket
- Service controller → Socket.IO server link: starts connection (evidence: `src/fiscalberry/common/service_controller.py`)
- Service controller → Device discovery: starts discovery (evidence: `src/fiscalberry/common/service_controller.py`)
- Device discovery → Printer detection: lists printers (evidence: `src/fiscalberry/common/discover.py`)
- Socket.IO server link → RabbitMQ process: starts consumer (evidence: `src/fiscalberry/common/fiscalberry_sio.py`)
- RabbitMQ process → RabbitMQ consumer: starts consumer (evidence: `src/fiscalberry/common/rabbitmq/process_handler.py`)
- Command handler → Printer error detection: analyzes responses (evidence: `src/fiscalberry/common/ComandosHandler.py`)
- Printer error detection → Remote error publisher: publishes errors (evidence: `src/fiscalberry/common/printer_error_detector.py`)
- Command handler → Remote error publisher: reports errors (evidence: `src/fiscalberry/common/ComandosHandler.py`)
- Kivy application → Service controller: starts services (evidence: `src/fiscalberry/ui/fiscalberry_app.py`)
- Kivy application → Adoption screen: uses screen (evidence: `src/fiscalberry/ui/fiscalberry_app.py`)
- Kivy application → Login screen: uses screen (evidence: `src/fiscalberry/ui/fiscalberry_app.py`)
- Login screen → JWT token manager: authenticates (evidence: `src/fiscalberry/ui/login_screen.py`)
- JWT token manager → Fiscalberry backend: requests login (evidence: `src/fiscalberry/common/token_manager.py`)
- Configuration → Device discovery: supplies settings (evidence: `src/fiscalberry/common/discover.py`)
- Configuration → Service controller: supplies settings (evidence: `src/fiscalberry/common/service_controller.py`)
