# r3ne88/pbstation_fe architecture

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

- Interactive diagram: https://gitdiagram.com/r3ne88/pbstation_fe
- Repository: https://github.com/r3ne88/pbstation_fe

## Overview

1. **Overall shape**
   - This is a **Flutter desktop frontend** (Windows target present) for what looks like a **point-of-sale / operations system**: sales, cash register, customers, products, orders, quotes, invoices, printers, and user/admin management.
   - The repo is primarily a **presentation + client integration layer**; the backend is not included here.

2. **App entry and shell**
   - `lib/main.dart` is the application entry point.
   - `lib/routes/routes.dart` centralizes navigation.
   - `lib/screens/home/home_screen.dart` is the main authenticated shell, with left/right side menus and a window-style desktop layout (`windows_bar`, `window_buttons` widgets).

3. **Core user-facing modules**
   - The app is organized by business areas:
     - **Caja**: opening cash register, cash movements, cuts, sale processing, invoicing dialogs, historical cash sessions.
     - **Catálogo**: customers, products, branches, users, user passwords.
     - **Pedidos**: order intake, upload/production, history.
     - **Cotizaciones**: quotes.
     - **Impresoras**: printer configuration/forms.
     - **Login / Settings / Pruebas**: authentication, configuration, diagnostics/testing.
   - Each module has its own screens and, where needed, dialogs/forms.

4. **Screen and dialog composition**
   - Most workflows are implemented as a combination of:
     - list/detail screens,
     - modal dialogs for transactional steps,
     - dedicated forms for create/edit flows.
   - Examples include sale dialogs, corte dialogs, factura detail dialogs, movement forms, and entity forms for customers/products/users/branches.

5. **State management boundary**
   - Global and cross-screen state is managed through the `lib/provider` layer:
     - theme switching,
     - loading state,
     - module visibility/selection.
   - There are also feature-specific state objects in `lib/logic` such as `home_state.dart` and `venta_state.dart`, which likely hold UI state for the main shell and sale flow.

6. **Service layer and backend integration**
   - `lib/services` contains the app’s integration boundary to external systems:
     - auth/login,
     - customers, products, users, branches,
     - sales, cash boxes, invoices, quotes, orders, printers,
     - websocket communication,
     - configuration.
   - This layer is the main place where the UI crosses into network/backend operations.
   - The presence of `websocket_service.dart` suggests live updates or push-style synchronization for operational events.

7. **Domain models**
   - `lib/models` defines the data contracts used across the UI and services.
   - The model set is strongly domain-driven: `ventas`, `detalles_venta`, `cajas`, `cortes`, `facturas`, `clientes`, `productos`, `usuarios`, `sucursales`, `pedidos`, `cotizaciones`, `impresoras`, and related aggregates like counters, pagination, and sales-by-product.
   - These models are the shared schema between service responses and screen rendering.

8. **Business logic helpers**
   - `lib/logic` contains reusable non-UI business utilities:
     - money calculations,
     - text capitalization,
     - input formatting,
     - static search fields,
     - ticket generation/printing helpers,
     - floating messages,
     - permission dialogs,
     - admin password verification,
     - module helpers.
   - This layer sits between screens and services, encapsulating transactional behavior and reusable rules.

9. **Shared UI widgets and app chrome**
   - `lib/widgets` provides reusable visual components:
     - loaders and loading overlays,
     - connection status overlay,
     - custom dropdown/search controls,
     - buttons and navigation affordances,
     - background/animation framing,
     - cash-register specific widgets like blocked state and voucher board.
   - These widgets form the consistent shell across the different business screens.

10. **Visual configuration and assets**
    - `lib/theme/theme.dart` and the `provider/change_theme_provider.dart` indicate theme customization.
    - `assets/` contains images, frames, and icons, likely used for the desktop-branded UI and animated/loading visuals.
    - The app is designed with custom styling rather than relying on stock Flutter components.

11. **Desktop-specific boundary**
    - The `windows/` directory shows this repo is built and packaged as a **Flutter Windows desktop app**.
    - The presence of custom window chrome widgets in `lib/widgets/windows_bar.dart` and `window_buttons.dart` reinforces that it is intended for a desktop operator workflow, not only mobile/web.

12. **Primary data flow**
    - A typical flow is: **user action in a screen/dialog → local state/provider or logic helper → service call → model update → UI refresh**.
    - For operational modules like sales and cash management, this flow may also include **websocket-driven updates** and **print/ticket generation**.

13. **What to emphasize in an architecture diagram**
    - Draw the repo as a layered Flutter client with:
      - a **desktop shell/navigation layer**,
      - **feature screens** grouped by business domain,
      - a **shared logic/state/provider layer**,
      - a **service boundary** to backend APIs and websocket updates,
      - a **model layer** for domain entities,
      - and a **shared widget/theme layer** for reusable UI.

Main entry points: [`lib/screens/home/home_screen.dart`](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/home/home_screen.dart) (Home shell), [`lib/services`](https://github.com/r3ne88/pbstation_fe/tree/main/lib/services) (Services), [`lib/screens/caja/caja_screen.dart`](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/caja/caja_screen.dart) (Caja), [`lib/routes/routes.dart`](https://github.com/r3ne88/pbstation_fe/blob/main/lib/routes/routes.dart) (Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["App shell"]
  node_main["Main<br/>entrypoint<br/>[main.dart]"]
  node_routes["Routes<br/>navigation<br/>[routes.dart]"]
  node_home_screen["Home shell<br/>desktop shell<br/>[home_screen.dart]"]
  node_left_menu["Left menu<br/>nav chrome"]
  node_right_menu["Right menu<br/>nav chrome"]
end

subgraph group_features["Business features"]
  node_caja_screen["Caja<br/>cash ops<br/>[caja_screen.dart]"]
  node_venta_screen["Ventas<br/>sale flow<br/>[venta_screen.dart]"]
  node_facturacion_screen["Facturación<br/>billing"]
  node_catalogo_clientes["Clientes<br/>catalog"]
  node_catalogo_productos["Productos<br/>catalog"]
  node_catalogo_usuarios["Usuarios<br/>catalog"]
  node_catalogo_sucursales["Sucursales<br/>catalog"]
  node_pedidos["Pedidos<br/>orders"]
  node_cotizaciones["Cotizaciones<br/>quotes"]
  node_impresoras["Impresoras<br/>printers"]
  node_login["Login<br/>auth<br/>[login_screen.dart]"]
  node_settings["Settings<br/>configuration"]
end

subgraph group_core["Core layers"]
  node_logic{{"Logic<br/>helpers"}}
  node_provider{{"State"}}
  node_services{{"Services<br/>integration"}}
  node_models{{"Models<br/>domain schema"}}
  node_widgets{{"Widgets<br/>ui kit"}}
  node_theme["Theme<br/>styling<br/>[theme.dart]"]
end

subgraph group_platform["Platform"]
  node_windows[("Windows host<br/>desktop runtime")]
end

node_main -->|"uses"| node_routes
node_main -->|"initializes"| node_provider
node_routes -->|"opens"| node_login
node_routes -->|"opens"| node_home_screen
node_home_screen -->|"contains"| node_left_menu
node_home_screen -->|"contains"| node_right_menu
node_home_screen -->|"navigates"| node_caja_screen
node_home_screen -->|"navigates"| node_catalogo_clientes
node_home_screen -->|"navigates"| node_catalogo_productos
node_home_screen -->|"navigates"| node_pedidos
node_home_screen -->|"navigates"| node_cotizaciones
node_home_screen -->|"navigates"| node_impresoras
node_home_screen -->|"navigates"| node_settings
node_caja_screen -->|"launches"| node_venta_screen
node_caja_screen -->|"launches"| node_facturacion_screen
node_caja_screen -->|"uses"| node_logic
node_caja_screen -->|"calls"| node_services
node_catalogo_clientes -->|"calls"| node_services
node_catalogo_productos -->|"calls"| node_services
node_catalogo_usuarios -->|"calls"| node_services
node_catalogo_sucursales -->|"calls"| node_services
node_pedidos -->|"calls"| node_services
node_cotizaciones -->|"calls"| node_services
node_impresoras -->|"calls"| node_services
node_login -->|"calls"| node_services
node_provider -->|"controls"| node_theme
node_provider -->|"feeds"| node_widgets
node_logic -->|"transforms"| node_models
node_services -->|"returns"| node_models
node_widgets -->|"styles with"| node_theme
node_windows -->|"hosts"| node_home_screen

click node_main "https://github.com/r3ne88/pbstation_fe/blob/main/lib/main.dart"
click node_routes "https://github.com/r3ne88/pbstation_fe/blob/main/lib/routes/routes.dart"
click node_home_screen "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/home/home_screen.dart"
click node_left_menu "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/home/side_menu_left.dart"
click node_right_menu "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/home/side_menu_right.dart"
click node_caja_screen "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/caja/caja_screen.dart"
click node_venta_screen "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/caja/venta_screen.dart"
click node_facturacion_screen "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/caja/facturacion_screen.dart"
click node_catalogo_clientes "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/catalogo/clientes_screen.dart"
click node_catalogo_productos "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/catalogo/productos_screen.dart"
click node_catalogo_usuarios "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/catalogo/usuarios_screen.dart"
click node_catalogo_sucursales "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/catalogo/sucursales_screen.dart"
click node_pedidos "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/pedidos/pedidos_screen.dart"
click node_cotizaciones "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/cotizaciones_screen.dart"
click node_impresoras "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/impresora/impresoras_screen.dart"
click node_login "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/login_screen.dart"
click node_settings "https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/settings_screen.dart"
click node_logic "https://github.com/r3ne88/pbstation_fe/tree/main/lib/logic"
click node_provider "https://github.com/r3ne88/pbstation_fe/tree/main/lib/provider"
click node_services "https://github.com/r3ne88/pbstation_fe/tree/main/lib/services"
click node_models "https://github.com/r3ne88/pbstation_fe/tree/main/lib/models"
click node_widgets "https://github.com/r3ne88/pbstation_fe/tree/main/lib/widgets"
click node_theme "https://github.com/r3ne88/pbstation_fe/blob/main/lib/theme/theme.dart"
click node_windows "https://github.com/r3ne88/pbstation_fe/tree/main/windows"

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_main,node_routes,node_home_screen,node_left_menu,node_right_menu toneBlue
class node_caja_screen,node_venta_screen,node_facturacion_screen,node_catalogo_clientes,node_catalogo_productos,node_catalogo_usuarios,node_catalogo_sucursales,node_pedidos,node_cotizaciones,node_impresoras,node_login,node_settings toneAmber
class node_logic,node_provider,node_services,node_models,node_widgets,node_theme toneMint
class node_windows toneRose
```

## Components

### App shell

Desktop entry, navigation, and shared chrome.

- [Main](https://github.com/r3ne88/pbstation_fe/blob/main/lib/main.dart): entrypoint · App bootstrap and root configuration. · `lib/main.dart`
- [Routes](https://github.com/r3ne88/pbstation_fe/blob/main/lib/routes/routes.dart): navigation · Central route definitions. · `lib/routes/routes.dart`
- [Home shell](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/home/home_screen.dart): desktop shell · Authenticated desktop layout with side menus and window chrome. · `lib/screens/home/home_screen.dart`
- [Left menu](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/home/side_menu_left.dart): nav chrome · Primary module navigation. · `lib/screens/home/side_menu_left.dart`
- [Right menu](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/home/side_menu_right.dart): nav chrome · Secondary actions and context panel. · `lib/screens/home/side_menu_right.dart`

### Business features

Operator workflows grouped by domain.

- [Caja](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/caja/caja_screen.dart): cash ops · Cash register and operational cashier hub. · `lib/screens/caja/caja_screen.dart`
- [Ventas](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/caja/venta_screen.dart): sale flow · Sale processing and checkout workflow. · `lib/screens/caja/venta_screen.dart`
- [Facturación](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/caja/facturacion_screen.dart): billing · Invoice-related cashier workflows. · `lib/screens/caja/facturacion_screen.dart`
- [Clientes](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/catalogo/clientes_screen.dart): catalog · Customer management screens and forms. · `lib/screens/catalogo/clientes_screen.dart`
- [Productos](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/catalogo/productos_screen.dart): catalog · Product management screens and forms. · `lib/screens/catalogo/productos_screen.dart`
- [Usuarios](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/catalogo/usuarios_screen.dart): catalog · User administration and password tools. · `lib/screens/catalogo/usuarios_screen.dart`
- [Sucursales](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/catalogo/sucursales_screen.dart): catalog · Branch management screens and forms. · `lib/screens/catalogo/sucursales_screen.dart`
- [Pedidos](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/pedidos/pedidos_screen.dart): orders · Order intake, upload, and history. · `lib/screens/pedidos/pedidos_screen.dart`
- [Cotizaciones](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/cotizaciones_screen.dart): quotes · Quote management screen. · `lib/screens/cotizaciones_screen.dart`
- [Impresoras](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/impresora/impresoras_screen.dart): printers · Printer configuration and management. · `lib/screens/impresora/impresoras_screen.dart`
- [Login](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/login_screen.dart): auth · Authentication entry screen. · `lib/screens/login_screen.dart`
- [Settings](https://github.com/r3ne88/pbstation_fe/blob/main/lib/screens/settings_screen.dart): configuration · Application settings screen. · `lib/screens/settings_screen.dart`

### Core layers

Shared state, logic, services, models, and UI kit.

- [Logic](https://github.com/r3ne88/pbstation_fe/tree/main/lib/logic): helpers · Reusable business rules, formatting, and transactional helpers. · `lib/logic`
- [State](https://github.com/r3ne88/pbstation_fe/tree/main/lib/provider): state mgmt · Theme, loading, and module selection state. · `lib/provider`
- [Services](https://github.com/r3ne88/pbstation_fe/tree/main/lib/services): integration · Backend and websocket integration boundary. · `lib/services`
- [Models](https://github.com/r3ne88/pbstation_fe/tree/main/lib/models): domain schema · Shared data contracts for sales, customers, products, and operations. · `lib/models`
- [Widgets](https://github.com/r3ne88/pbstation_fe/tree/main/lib/widgets): ui kit · Reusable UI components and desktop chrome pieces. · `lib/widgets`
- [Theme](https://github.com/r3ne88/pbstation_fe/blob/main/lib/theme/theme.dart): styling · App visual theme definitions. · `lib/theme/theme.dart`

### Platform

Windows desktop packaging and runtime glue.

- [Windows host](https://github.com/r3ne88/pbstation_fe/tree/main/windows): desktop runtime · Flutter Windows packaging and native runner code. · `windows`

## Connections

- Main → Routes: uses · Bootstraps navigation.
- Main → State: initializes · Creates app-wide state.
- Routes → Login: opens · Entry route for authentication.
- Routes → Home shell: opens · Main authenticated shell.
- Home shell → Left menu: contains · Primary navigation chrome.
- Home shell → Right menu: contains · Secondary context chrome.
- Home shell → Caja: navigates · Operational cash workflow.
- Home shell → Clientes: navigates · Customer catalog.
- Home shell → Productos: navigates · Product catalog.
- Home shell → Pedidos: navigates · Orders module.
- Home shell → Cotizaciones: navigates · Quotes module.
- Home shell → Impresoras: navigates · Printer setup.
- Home shell → Settings: navigates · App configuration.
- Caja → Ventas: launches · Sale processing flow.
- Caja → Facturación: launches · Invoice workflows.
- Caja → Logic: uses · Cash calculations and ticket helpers.
- Caja → Services: calls · Cashbox and billing backend operations.
- Clientes → Services: calls · CRUD operations for customers.
- Productos → Services: calls · CRUD operations for products.
- Usuarios → Services: calls · User administration backend.
- Sucursales → Services: calls · Branch administration backend.
- Pedidos → Services: calls · Order upload and history integration.
- Cotizaciones → Services: calls · Quote backend operations.
- Impresoras → Services: calls · Printer configuration persistence.
- Login → Services: calls · Authentication request flow.
- State → Theme: controls · Theme switching and visual mode.
- State → Widgets: feeds · Loading and module visibility state into shared UI.
- Logic → Models: transforms · Business helpers operate on domain data.
- Services → Models: returns · API and websocket payload contracts.
- Widgets → Theme: styles with · Shared UI appearance.
- Windows host → Home shell: hosts · Desktop runtime entry path.
