# libbygpt/printflow architecture

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

- Interactive diagram: https://gitdiagram.com/libbygpt/printflow
- Repository: https://github.com/libbygpt/printflow

## Overview

Printflow pairs a Windows desktop client with a socket-backed HTTP server. A user signs in, explicitly enables monitoring, the client observes Windows spooler metadata and syncs print jobs; optional virtual-printer capture uploads a document into the same server document flow. The server stores users, jobs and documents, extracts approved text, and can answer AI chat from document text or print activity; admin views also expose live client status. The README documents these capabilities, while several server routes and client core calls were not excerpted, so their links are cited to the README rather than implying source inspection.

Main entry points: [`server/server.py`](https://github.com/libbygpt/printflow/blob/main/server/server.py) (HTTP API and routes), [`client/printflow_client/ui/client_window.py`](https://github.com/libbygpt/printflow/blob/main/client/printflow_client/ui/client_window.py) (Client dashboard), [`server/app/services/document_processing.py`](https://github.com/libbygpt/printflow/blob/main/server/app/services/document_processing.py) (Document processing), [`client/printflow_client/app.py`](https://github.com/libbygpt/printflow/blob/main/client/printflow_client/app.py) (App bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Desktop client"]
  node_bootstrap["App bootstrap<br/>[app.py]"]
  node_login["Sign-in UI<br/>[login_window.py]"]
  node_client_ui["Client dashboard<br/>[client_window.py]"]
  node_admin_ui["Admin dashboard<br/>[main_window.py]"]
  node_client_core["API, auth, sync<br/>[core.py]"]
  node_monitor["Spooler monitor"]
  node_local_print["Local printing"]
  node_virtual_capture["Virtual printer capture"]
end

subgraph group_server["HTTP backend"]
  node_http_server["HTTP API and routes<br/>[server.py]"]
  node_relay["Print relay<br/>[print_relay.py]"]
  node_support["Audit and print tasks<br/>[support.py]"]
end

subgraph group_documents["Documents and AI"]
  node_document_flow["Document processing"]
  node_text_extract["Text extraction<br/>[text_extraction.py]"]
  node_document_content["Document content"]
  node_ai_context["AI context<br/>[ai_context.py]"]
  node_llm["AI chat<br/>[llm.py]"]
end

subgraph group_status["Live status"]
  node_socket_client["Heartbeat client"]
  node_socket_server["Heartbeat server"]
  node_socket_protocol["Length-prefixed protocol<br/>[socket_protocol.py]"]
end

subgraph group_storage["Persistence and security"]
  node_settings_auth["Settings and auth helpers<br/>[__init__.py]"]
  node_database[("SQLite and ORM<br/>[__init__.py]")]
  node_models["Domain records<br/>[__init__.py]"]
  node_tls["TLS configuration<br/>[tls.py]"]
end

node_user(("Desktop user"))
node_printer(("Windows printers"))
node_llm_provider{{"LLM provider"}}

node_user -->|"signs in"| node_login
node_bootstrap -->|"shows"| node_login
node_bootstrap -->|"opens"| node_client_ui
node_bootstrap -->|"opens"| node_admin_ui
node_client_ui -->|"calls API"| node_client_core
node_client_ui -->|"polls"| node_monitor
node_client_ui -->|"handles captures"| node_virtual_capture
node_monitor -->|"reads spooler"| node_printer
node_monitor -->|"reports jobs"| node_client_ui
node_client_core -->|"syncs metadata"| node_http_server
node_virtual_capture -->|"delivers file"| node_client_ui
node_client_ui -->|"uploads document"| node_http_server
node_http_server -.->|"dispatches print"| node_relay
node_relay -.->|"prints document"| node_printer
node_http_server -->|"processes upload"| node_document_flow
node_document_flow -->|"extracts text"| node_text_extract
node_text_extract -->|"uses content rules"| node_document_content
node_http_server -->|"builds chat context"| node_ai_context
node_ai_context -->|"hydrates documents"| node_document_flow
node_ai_context -->|"reads approved text"| node_document_content
node_http_server -->|"requests answer"| node_llm
node_llm -.->|"queries model"| node_llm_provider
node_http_server -->|"records activity"| node_support
node_client_ui -.->|"prints locally"| node_local_print
node_client_ui -->|"starts status"| node_socket_client
node_socket_client -->|"sends heartbeat"| node_socket_server
node_socket_server -->|"decodes messages"| node_socket_protocol
node_http_server -->|"reads and writes"| node_database
node_document_flow -->|"stores documents"| node_database
node_database -->|"maps records"| node_models
node_http_server -->|"configures transport"| node_tls

click node_bootstrap "https://github.com/libbygpt/printflow/blob/main/client/printflow_client/app.py"
click node_login "https://github.com/libbygpt/printflow/blob/main/client/printflow_client/ui/login_window.py"
click node_client_ui "https://github.com/libbygpt/printflow/blob/main/client/printflow_client/ui/client_window.py"
click node_admin_ui "https://github.com/libbygpt/printflow/blob/main/client/printflow_client/ui/main_window.py"
click node_client_core "https://github.com/libbygpt/printflow/blob/main/client/printflow_client/core.py"
click node_monitor "https://github.com/libbygpt/printflow/blob/main/client/printflow_client/services/print_monitor_service.py"
click node_local_print "https://github.com/libbygpt/printflow/blob/main/client/printflow_client/services/local_print_service.py"
click node_virtual_capture "https://github.com/libbygpt/printflow/blob/main/client/printflow_client/services/virtual_printer_service.py"
click node_http_server "https://github.com/libbygpt/printflow/blob/main/server/server.py"
click node_relay "https://github.com/libbygpt/printflow/blob/main/server/app/services/print_relay.py"
click node_document_flow "https://github.com/libbygpt/printflow/blob/main/server/app/services/document_processing.py"
click node_text_extract "https://github.com/libbygpt/printflow/blob/main/server/app/services/text_extraction.py"
click node_document_content "https://github.com/libbygpt/printflow/blob/main/server/app/services/document_content.py"
click node_ai_context "https://github.com/libbygpt/printflow/blob/main/server/app/services/ai_context.py"
click node_llm "https://github.com/libbygpt/printflow/blob/main/server/app/services/llm.py"
click node_support "https://github.com/libbygpt/printflow/blob/main/server/app/services/support.py"
click node_socket_client "https://github.com/libbygpt/printflow/blob/main/client/printflow_client/services/socket_status_client.py"
click node_socket_server "https://github.com/libbygpt/printflow/blob/main/server/app/services/socket_status_server.py"
click node_socket_protocol "https://github.com/libbygpt/printflow/blob/main/server/app/services/socket_protocol.py"
click node_settings_auth "https://github.com/libbygpt/printflow/blob/main/server/app/core/__init__.py"
click node_database "https://github.com/libbygpt/printflow/blob/main/server/app/db/__init__.py"
click node_models "https://github.com/libbygpt/printflow/blob/main/server/app/models/__init__.py"
click node_tls "https://github.com/libbygpt/printflow/blob/main/server/app/services/tls.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_bootstrap,node_login,node_client_ui,node_admin_ui,node_client_core,node_monitor,node_local_print,node_virtual_capture,node_user toneBlue
class node_http_server,node_relay,node_support toneAmber
class node_document_flow,node_text_extract,node_document_content,node_ai_context,node_llm toneMint
class node_socket_client,node_socket_server,node_socket_protocol toneRose
class node_settings_auth,node_database,node_models,node_tls,node_printer,node_llm_provider toneIndigo
```

## Components

### Desktop client

- [App bootstrap](https://github.com/libbygpt/printflow/blob/main/client/printflow_client/app.py): `client/printflow_client/app.py`
- [Sign-in UI](https://github.com/libbygpt/printflow/blob/main/client/printflow_client/ui/login_window.py): `client/printflow_client/ui/login_window.py`
- [Client dashboard](https://github.com/libbygpt/printflow/blob/main/client/printflow_client/ui/client_window.py): `client/printflow_client/ui/client_window.py`
- [Admin dashboard](https://github.com/libbygpt/printflow/blob/main/client/printflow_client/ui/main_window.py): `client/printflow_client/ui/main_window.py`
- [API, auth, sync](https://github.com/libbygpt/printflow/blob/main/client/printflow_client/core.py): `client/printflow_client/core.py`
- [Spooler monitor](https://github.com/libbygpt/printflow/blob/main/client/printflow_client/services/print_monitor_service.py): `client/printflow_client/services/print_monitor_service.py`
- [Local printing](https://github.com/libbygpt/printflow/blob/main/client/printflow_client/services/local_print_service.py): `client/printflow_client/services/local_print_service.py`
- [Virtual printer capture](https://github.com/libbygpt/printflow/blob/main/client/printflow_client/services/virtual_printer_service.py): `client/printflow_client/services/virtual_printer_service.py`

### HTTP backend

- [HTTP API and routes](https://github.com/libbygpt/printflow/blob/main/server/server.py): `server/server.py`
- [Print relay](https://github.com/libbygpt/printflow/blob/main/server/app/services/print_relay.py): `server/app/services/print_relay.py`
- [Audit and print tasks](https://github.com/libbygpt/printflow/blob/main/server/app/services/support.py): `server/app/services/support.py`

### Documents and AI

- [Document processing](https://github.com/libbygpt/printflow/blob/main/server/app/services/document_processing.py): `server/app/services/document_processing.py`
- [Text extraction](https://github.com/libbygpt/printflow/blob/main/server/app/services/text_extraction.py): `server/app/services/text_extraction.py`
- [Document content](https://github.com/libbygpt/printflow/blob/main/server/app/services/document_content.py): `server/app/services/document_content.py`
- [AI context](https://github.com/libbygpt/printflow/blob/main/server/app/services/ai_context.py): `server/app/services/ai_context.py`
- [AI chat](https://github.com/libbygpt/printflow/blob/main/server/app/services/llm.py): `server/app/services/llm.py`

### Live status

- [Heartbeat client](https://github.com/libbygpt/printflow/blob/main/client/printflow_client/services/socket_status_client.py): `client/printflow_client/services/socket_status_client.py`
- [Heartbeat server](https://github.com/libbygpt/printflow/blob/main/server/app/services/socket_status_server.py): `server/app/services/socket_status_server.py`
- [Length-prefixed protocol](https://github.com/libbygpt/printflow/blob/main/server/app/services/socket_protocol.py): `server/app/services/socket_protocol.py`

### Persistence and security

- [Settings and auth helpers](https://github.com/libbygpt/printflow/blob/main/server/app/core/__init__.py): `server/app/core/__init__.py`
- [SQLite and ORM](https://github.com/libbygpt/printflow/blob/main/server/app/db/__init__.py): `server/app/db/__init__.py`
- [Domain records](https://github.com/libbygpt/printflow/blob/main/server/app/models/__init__.py): `server/app/models/__init__.py`
- [TLS configuration](https://github.com/libbygpt/printflow/blob/main/server/app/services/tls.py): `server/app/services/tls.py`

### Other components

- **Desktop user**
- **Windows printers**
- **LLM provider**

## Connections

- Desktop user → Sign-in UI: signs in (evidence: `README.md`)
- App bootstrap → Sign-in UI: shows (evidence: `client/printflow_client/app.py`)
- App bootstrap → Client dashboard: opens (evidence: `client/printflow_client/app.py`)
- App bootstrap → Admin dashboard: opens (evidence: `client/printflow_client/app.py`)
- Client dashboard → API, auth, sync: calls API (evidence: `client/printflow_client/ui/client_window.py`)
- Client dashboard → Spooler monitor: polls (evidence: `client/printflow_client/ui/client_window.py`)
- Client dashboard → Virtual printer capture: handles captures (evidence: `client/printflow_client/ui/client_window.py`)
- Spooler monitor → Windows printers: reads spooler (evidence: `README.md`)
- Spooler monitor → Client dashboard: reports jobs (evidence: `client/printflow_client/services/print_monitor_service.py`)
- API, auth, sync → HTTP API and routes: syncs metadata (evidence: `README.md`)
- Virtual printer capture → Client dashboard: delivers file (evidence: `client/printflow_client/services/virtual_printer_service.py`)
- Client dashboard → HTTP API and routes: uploads document (evidence: `README.md`)
- HTTP API and routes → Print relay: dispatches print (evidence: `server/server.py`)
- Print relay → Windows printers: prints document
- HTTP API and routes → Document processing: processes upload (evidence: `server/server.py`)
- Document processing → Text extraction: extracts text (evidence: `server/app/services/document_processing.py`)
- Text extraction → Document content: uses content rules (evidence: `server/app/services/text_extraction.py`)
- HTTP API and routes → AI context: builds chat context (evidence: `server/server.py`)
- AI context → Document processing: hydrates documents (evidence: `server/app/services/ai_context.py`)
- AI context → Document content: reads approved text (evidence: `server/app/services/ai_context.py`)
- HTTP API and routes → AI chat: requests answer (evidence: `server/server.py`)
- AI chat → LLM provider: queries model
- HTTP API and routes → Audit and print tasks: records activity (evidence: `server/server.py`)
- Client dashboard → Local printing: prints locally (evidence: `client/printflow_client/ui/client_window.py`)
- Client dashboard → Heartbeat client: starts status (evidence: `client/printflow_client/app.py`)
- Heartbeat client → Heartbeat server: sends heartbeat (evidence: `README.md`)
- Heartbeat server → Length-prefixed protocol: decodes messages (evidence: `server/app/services/socket_status_server.py`)
- HTTP API and routes → SQLite and ORM: reads and writes (evidence: `server/server.py`)
- Document processing → SQLite and ORM: stores documents (evidence: `server/app/services/document_processing.py`)
- SQLite and ORM → Domain records: maps records (evidence: `server/app/db/__init__.py`)
- HTTP API and routes → TLS configuration: configures transport (evidence: `README.md`)
