# mal-xa/printhub architecture

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

- Interactive diagram: https://gitdiagram.com/mal-xa/printhub
- Repository: https://github.com/mal-xa/printhub

## Overview

This repository contains two print workflows: a LAN-oriented print server/client with a local printer agent, and a PrintHub web application for order-based printing. In the LAN workflow, users submit jobs and monitor printers; the server handles API requests and coordinates with agents, which register, receive dispatches, and print through their local system. PrintHub adds user accounts, order management, file uploads, and per-file print-job monitoring. The README is placeholder text; relationships below are limited to excerpted source and SOURCE INDEX references, with unsampled capabilities represented only where the tree supports them.

Main entry points: [`printing-system/print-agent/src/application/use-cases`](https://github.com/mal-xa/printhub/tree/main/printing-system/print-agent/src/application/use-cases) (Agent Use Cases), [`printing-system/print-agent/src/app.ts`](https://github.com/mal-xa/printhub/blob/main/printing-system/print-agent/src/app.ts) (Agent Runtime), [`printing-system/print-client/packages/print-client/src/App.tsx`](https://github.com/mal-xa/printhub/blob/main/printing-system/print-client/packages/print-client/src/App.tsx) (Job And Printer UI), [`printing-system/print-server/src/presentation/http/controllers`](https://github.com/mal-xa/printhub/tree/main/printing-system/print-server/src/presentation/http/controllers) (HTTP Controllers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lan_client["LAN Client"]
  node_lan_ui["Job And Printer UI<br/>[App.tsx]"]
  node_lan_poll["Polling Hooks<br/>[usePolling.ts]"]
  node_lan_api["Print API Client<br/>[printApi.ts]"]
  node_common["Shared API Contracts"]
end

subgraph group_lan_server["LAN Server"]
  node_http["HTTP Application<br/>[app.ts]"]
  node_controllers["HTTP Controllers"]
  node_services["Print Services"]
  node_ws_gateway["WebSocket Gateway<br/>[ws-gateway.ts]"]
  node_file_storage[("Uploaded File Store")]
  node_server_repos[("Server Repositories")]
end

subgraph group_agent["Print Agent"]
  node_agent_app["Agent Runtime<br/>[app.ts]"]
  node_agent_router["WebSocket Event Router<br/>[ws-event-router.ts]"]
  node_agent_cases["Agent Use Cases"]
  node_agent_transport["Agent WebSocket"]
  node_agent_print["Local Printing"]
  node_agent_queue[("Local Job Queue")]
end

subgraph group_hub_client["PrintHub Client"]
  node_hub_ui["Order And Admin UI"]
  node_hub_services["Client Services"]
end

subgraph group_hub_server["PrintHub Server"]
  node_hub_auth["Authentication Service<br/>[auth.service.ts]"]
  node_hub_routes["Order API Routes<br/>[order.routes.ts]"]
  node_hub_print_controller["Print Job Controller"]
  node_hub_print_service["Print Job Service"]
  node_hub_queue["Print Queue Worker<br/>[printQueue.job.ts]"]
  node_hub_data[("Hub Repositories")]
end

node_user(("Print User"))
node_hub_user(("PrintHub User"))
node_firebase{{"Firebase Auth"}}

node_user -->|"submits jobs"| node_lan_ui
node_lan_ui -.->|"loads status"| node_lan_poll
node_lan_poll -.->|"fetches data"| node_lan_api
node_lan_ui -.->|"submits jobs"| node_lan_api
node_http -->|"routes requests"| node_controllers
node_controllers -->|"calls services"| node_services
node_controllers -.->|"stores uploads"| node_file_storage
node_services -.->|"uses repositories"| node_server_repos
node_agent_app -->|"schedules work"| node_agent_cases
node_agent_app -->|"attaches router"| node_agent_router
node_agent_router -->|"dispatches events"| node_agent_cases
node_agent_app -.->|"connects transport"| node_agent_transport
node_agent_cases -.->|"prints jobs"| node_agent_print
node_agent_cases -.->|"persists jobs"| node_agent_queue
node_ws_gateway -.->|"exchanges events"| node_agent_transport
node_hub_user -.->|"places orders"| node_hub_ui
node_hub_ui -.->|"uses services"| node_hub_services
node_hub_services -.->|"calls API"| node_hub_routes
node_hub_user -.->|"authenticates"| node_hub_auth
node_hub_auth -->|"verifies tokens"| node_firebase
node_hub_routes -->|"routes print jobs"| node_hub_print_controller
node_hub_print_controller -->|"creates jobs"| node_hub_print_service
node_hub_print_controller -->|"starts processing"| node_hub_queue
node_hub_print_service -.->|"uses repositories"| node_hub_data

click node_lan_ui "https://github.com/mal-xa/printhub/blob/main/printing-system/print-client/packages/print-client/src/App.tsx"
click node_lan_poll "https://github.com/mal-xa/printhub/blob/main/printing-system/print-client/src/hooks/usePolling.ts"
click node_lan_api "https://github.com/mal-xa/printhub/blob/main/printing-system/print-client/src/api/printApi.ts"
click node_common "https://github.com/mal-xa/printhub/tree/main/printing-system/print-common/src"
click node_http "https://github.com/mal-xa/printhub/blob/main/printing-system/print-server/src/presentation/http/app.ts"
click node_controllers "https://github.com/mal-xa/printhub/tree/main/printing-system/print-server/src/presentation/http/controllers"
click node_services "https://github.com/mal-xa/printhub/tree/main/printing-system/print-server/src/application/services"
click node_ws_gateway "https://github.com/mal-xa/printhub/blob/main/printing-system/print-server/src/infrastructure/websocket/ws-gateway.ts"
click node_file_storage "https://github.com/mal-xa/printhub/blob/main/printing-system/print-server/src/infrastructure/storage/local-file-storage.ts"
click node_server_repos "https://github.com/mal-xa/printhub/tree/main/printing-system/print-server/src/infrastructure/persistence/in-memory"
click node_agent_app "https://github.com/mal-xa/printhub/blob/main/printing-system/print-agent/src/app.ts"
click node_agent_router "https://github.com/mal-xa/printhub/blob/main/printing-system/print-agent/src/interface/ws-event-router.ts"
click node_agent_cases "https://github.com/mal-xa/printhub/tree/main/printing-system/print-agent/src/application/use-cases"
click node_agent_transport "https://github.com/mal-xa/printhub/blob/main/printing-system/print-agent/src/infrastructure/transport/websocket-client.ts"
click node_agent_print "https://github.com/mal-xa/printhub/blob/main/printing-system/print-agent/src/infrastructure/printing/cups-printing-system.ts"
click node_agent_queue "https://github.com/mal-xa/printhub/blob/main/printing-system/print-agent/src/infrastructure/persistence/json-file-job-queue.repository.ts"
click node_hub_ui "https://github.com/mal-xa/printhub/tree/main/printing-system/printhub/1/client/src/routes"
click node_hub_services "https://github.com/mal-xa/printhub/tree/main/printing-system/printhub/1/client/src/services"
click node_hub_auth "https://github.com/mal-xa/printhub/blob/main/printing-system/printhub/1/server/src/services/auth.service.ts"
click node_hub_routes "https://github.com/mal-xa/printhub/blob/main/printing-system/printhub/1/server/src/routes/order.routes.ts"
click node_hub_print_controller "https://github.com/mal-xa/printhub/blob/main/printing-system/printhub/1/server/src/controllers/printJob.controller.ts"
click node_hub_print_service "https://github.com/mal-xa/printhub/tree/main/printing-system/printhub/1/server/src/services"
click node_hub_queue "https://github.com/mal-xa/printhub/blob/main/printing-system/printhub/1/server/src/jobs/printQueue.job.ts"
click node_hub_data "https://github.com/mal-xa/printhub/tree/main/printing-system/printhub/1/server/src/repositories"

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_lan_ui,node_lan_poll,node_lan_api,node_common,node_user,node_hub_user toneBlue
class node_http,node_controllers,node_services,node_ws_gateway,node_file_storage,node_server_repos toneAmber
class node_agent_app,node_agent_router,node_agent_cases,node_agent_transport,node_agent_print,node_agent_queue toneMint
class node_hub_ui,node_hub_services toneRose
class node_hub_auth,node_hub_routes,node_hub_print_controller,node_hub_print_service,node_hub_queue,node_hub_data,node_firebase toneIndigo
```

## Components

### LAN Client

- [Job And Printer UI](https://github.com/mal-xa/printhub/blob/main/printing-system/print-client/packages/print-client/src/App.tsx): `printing-system/print-client/packages/print-client/src/App.tsx`
- [Polling Hooks](https://github.com/mal-xa/printhub/blob/main/printing-system/print-client/src/hooks/usePolling.ts): `printing-system/print-client/src/hooks/usePolling.ts`
- [Print API Client](https://github.com/mal-xa/printhub/blob/main/printing-system/print-client/src/api/printApi.ts): `printing-system/print-client/src/api/printApi.ts`
- [Shared API Contracts](https://github.com/mal-xa/printhub/tree/main/printing-system/print-common/src): `printing-system/print-common/src`

### LAN Server

- [HTTP Application](https://github.com/mal-xa/printhub/blob/main/printing-system/print-server/src/presentation/http/app.ts): `printing-system/print-server/src/presentation/http/app.ts`
- [HTTP Controllers](https://github.com/mal-xa/printhub/tree/main/printing-system/print-server/src/presentation/http/controllers): `printing-system/print-server/src/presentation/http/controllers`
- [Print Services](https://github.com/mal-xa/printhub/tree/main/printing-system/print-server/src/application/services): `printing-system/print-server/src/application/services`
- [WebSocket Gateway](https://github.com/mal-xa/printhub/blob/main/printing-system/print-server/src/infrastructure/websocket/ws-gateway.ts): `printing-system/print-server/src/infrastructure/websocket/ws-gateway.ts`
- [Uploaded File Store](https://github.com/mal-xa/printhub/blob/main/printing-system/print-server/src/infrastructure/storage/local-file-storage.ts): `printing-system/print-server/src/infrastructure/storage/local-file-storage.ts`
- [Server Repositories](https://github.com/mal-xa/printhub/tree/main/printing-system/print-server/src/infrastructure/persistence/in-memory): `printing-system/print-server/src/infrastructure/persistence/in-memory`

### Print Agent

- [Agent Runtime](https://github.com/mal-xa/printhub/blob/main/printing-system/print-agent/src/app.ts): `printing-system/print-agent/src/app.ts`
- [WebSocket Event Router](https://github.com/mal-xa/printhub/blob/main/printing-system/print-agent/src/interface/ws-event-router.ts): `printing-system/print-agent/src/interface/ws-event-router.ts`
- [Agent Use Cases](https://github.com/mal-xa/printhub/tree/main/printing-system/print-agent/src/application/use-cases): `printing-system/print-agent/src/application/use-cases`
- [Agent WebSocket](https://github.com/mal-xa/printhub/blob/main/printing-system/print-agent/src/infrastructure/transport/websocket-client.ts): `printing-system/print-agent/src/infrastructure/transport/websocket-client.ts`
- [Local Printing](https://github.com/mal-xa/printhub/blob/main/printing-system/print-agent/src/infrastructure/printing/cups-printing-system.ts): `printing-system/print-agent/src/infrastructure/printing/cups-printing-system.ts`
- [Local Job Queue](https://github.com/mal-xa/printhub/blob/main/printing-system/print-agent/src/infrastructure/persistence/json-file-job-queue.repository.ts): `printing-system/print-agent/src/infrastructure/persistence/json-file-job-queue.repository.ts`

### PrintHub Client

- [Order And Admin UI](https://github.com/mal-xa/printhub/tree/main/printing-system/printhub/1/client/src/routes): `printing-system/printhub/1/client/src/routes`
- [Client Services](https://github.com/mal-xa/printhub/tree/main/printing-system/printhub/1/client/src/services): `printing-system/printhub/1/client/src/services`

### PrintHub Server

- [Authentication Service](https://github.com/mal-xa/printhub/blob/main/printing-system/printhub/1/server/src/services/auth.service.ts): `printing-system/printhub/1/server/src/services/auth.service.ts`
- [Order API Routes](https://github.com/mal-xa/printhub/blob/main/printing-system/printhub/1/server/src/routes/order.routes.ts): `printing-system/printhub/1/server/src/routes/order.routes.ts`
- [Print Job Controller](https://github.com/mal-xa/printhub/blob/main/printing-system/printhub/1/server/src/controllers/printJob.controller.ts): `printing-system/printhub/1/server/src/controllers/printJob.controller.ts`
- [Print Job Service](https://github.com/mal-xa/printhub/tree/main/printing-system/printhub/1/server/src/services): `printing-system/printhub/1/server/src/services`
- [Print Queue Worker](https://github.com/mal-xa/printhub/blob/main/printing-system/printhub/1/server/src/jobs/printQueue.job.ts): `printing-system/printhub/1/server/src/jobs/printQueue.job.ts`
- [Hub Repositories](https://github.com/mal-xa/printhub/tree/main/printing-system/printhub/1/server/src/repositories): `printing-system/printhub/1/server/src/repositories`

### Other components

- **Print User**
- **PrintHub User**
- **Firebase Auth**

## Connections

- Print User → Job And Printer UI: submits jobs (evidence: `printing-system/print-client/packages/print-client/src/App.tsx`)
- Job And Printer UI → Polling Hooks: loads status
- Polling Hooks → Print API Client: fetches data
- Job And Printer UI → Print API Client: submits jobs
- HTTP Application → HTTP Controllers: routes requests (evidence: `printing-system/print-server/src/presentation/http/app.ts`)
- HTTP Controllers → Print Services: calls services (evidence: `printing-system/print-server/src/presentation/http/controllers/printers.controller.ts`)
- HTTP Controllers → Uploaded File Store: stores uploads
- Print Services → Server Repositories: uses repositories
- Agent Runtime → Agent Use Cases: schedules work (evidence: `printing-system/print-agent/src/app.ts`)
- Agent Runtime → WebSocket Event Router: attaches router (evidence: `printing-system/print-agent/src/app.ts`)
- WebSocket Event Router → Agent Use Cases: dispatches events (evidence: `printing-system/print-agent/src/interface/ws-event-router.ts`)
- Agent Runtime → Agent WebSocket: connects transport
- Agent Use Cases → Local Printing: prints jobs
- Agent Use Cases → Local Job Queue: persists jobs
- WebSocket Gateway → Agent WebSocket: exchanges events
- PrintHub User → Order And Admin UI: places orders
- Order And Admin UI → Client Services: uses services
- Client Services → Order API Routes: calls API
- PrintHub User → Authentication Service: authenticates
- Authentication Service → Firebase Auth: verifies tokens (evidence: `printing-system/printhub/1/server/src/services/auth.service.ts`)
- Order API Routes → Print Job Controller: routes print jobs (evidence: `printing-system/printhub/1/server/src/routes/order.routes.ts`)
- Print Job Controller → Print Job Service: creates jobs (evidence: `printing-system/printhub/1/server/src/controllers/printJob.controller.ts`)
- Print Job Controller → Print Queue Worker: starts processing (evidence: `printing-system/printhub/1/server/src/controllers/printJob.controller.ts`)
- Print Job Service → Hub Repositories: uses repositories (evidence: `printing-system/printhub/1/server/src/services/auth.service.ts`)
