# rey1332/printstream architecture

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

- Interactive diagram: https://gitdiagram.com/rey1332/printstream
- Repository: https://github.com/rey1332/printstream

## Overview

PrintStream is a self-hosted business operations and data intelligence platform. Users enter through the application, manage ERP workspaces and business records, and can import or connect data, build and run pipelines, query datasets, and expose permitted data to MCP assistants. Administration governs accounts, companies, access, and service settings. The README documents broad ERP and Terminal capabilities; sampled source excerpts and the source index support only selected implementation links, so other feature relationships are not inferred.

Main entry points: [`src/server/auth/request.ts`](https://github.com/rey1332/printstream/blob/main/src/server/auth/request.ts) (Session handling), [`src/app/api/erp/workspace/route.ts`](https://github.com/rey1332/printstream/blob/main/src/app/api/erp/workspace/route.ts) (Workspace API), [`src/app/api/data/route.ts`](https://github.com/rey1332/printstream/blob/main/src/app/api/data/route.ts) (Data API), [`src/app/erp/page.tsx`](https://github.com/rey1332/printstream/blob/main/src/app/erp/page.tsx) (ERP workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application access"]
  node_app["Application shell<br/>[page.tsx]"]
  node_authui["Sign-in and MFA<br/>[page.tsx]"]
end

subgraph group_erp["ERP operations"]
  node_dataapi["Data API<br/>[route.ts]"]
  node_dataexec["Data access engine<br/>[execute.ts]"]
  node_erpui["ERP workspace<br/>[page.tsx]"]
  node_erprules["ERP rules<br/>[erpRules.ts]"]
  node_erpworkspace["Workspace API<br/>[route.ts]"]
  node_ingestui["ERP import<br/>[ingestClient.ts]"]
  node_ingestplan["Import planning<br/>[plan.ts]"]
end

subgraph group_terminal["Data and analytics"]
  node_terminalui["Terminal workbench<br/>[page.tsx]"]
  node_terminalapi["Terminal API<br/>[route.ts]"]
  node_terminalservice["Terminal services<br/>[service.ts]"]
  node_pipelinesui["Pipeline editor<br/>[PipelineEditor.tsx]"]
  node_workflowapi["Workflow API client<br/>[storage.ts]"]
  node_workflowexec["Workflow executor<br/>[executor.ts]"]
  node_pipelineexec["Pipeline runtime<br/>[pipelines.ts]"]
  node_mcpapi["MCP endpoint<br/>[route.ts]"]
  node_intel["Intelligence runtime<br/>[service.ts]"]
end

subgraph group_security["Identity and governance"]
  node_authapi["Auth API<br/>[route.ts]"]
  node_authsvc["Authentication service<br/>[service.ts]"]
  node_authreq["Session handling<br/>[request.ts]"]
end

subgraph group_platform["Platform services"]
  node_db[("PostgreSQL executor<br/>[executor.ts]")]
  node_adminui["Administration<br/>[page.tsx]"]
  node_adminsvc["Admin services<br/>[service.ts]"]
  node_mailgateway["Company mail gateway<br/>[engine.ts]"]
end

node_user(("Business user"))
node_emailservice["External mail provider"]

node_user -->|"opens"| node_app
node_user -->|"signs in"| node_authui
node_authui -.->|"authenticates"| node_authapi
node_authapi -->|"calls"| node_authsvc
node_authapi -->|"reads session"| node_authreq
node_authsvc -->|"uses transactions"| node_db
node_authreq -->|"loads dependencies"| node_authsvc
node_user -->|"manages operations"| node_erpui
node_erpui -.->|"reads and writes"| node_dataapi
node_dataapi -->|"checks identity"| node_authreq
node_dataapi -->|"executes requests"| node_dataexec
node_dataexec -->|"runs transactions"| node_db
node_erpui -.->|"applies rules"| node_erprules
node_user -->|"imports data"| node_ingestui
node_ingestui -->|"plans import"| node_ingestplan
node_user -->|"explores data"| node_terminalui
node_terminalui -.->|"requests actions"| node_terminalapi
node_terminalapi -->|"dispatches actions"| node_terminalservice
node_terminalapi -->|"dispatches intelligence"| node_intel
node_user -->|"builds pipelines"| node_pipelinesui
node_pipelinesui -->|"loads and runs"| node_workflowapi
node_workflowapi -.->|"calls workflow API"| node_pipelineexec
node_pipelineexec -->|"executes graph"| node_workflowexec
node_user -->|"connects assistant"| node_mcpapi
node_mcpapi -->|"checks session"| node_authreq
node_user -->|"administers service"| node_adminui
node_adminui -.->|"manages platform"| node_adminsvc
node_erpworkspace -->|"reads session"| node_authreq
node_erpworkspace -->|"validates roles"| node_erprules
node_erpworkspace -.->|"sends invitations"| node_mailgateway
node_mailgateway -.->|"dispatches mail"| node_emailservice

click node_app "https://github.com/rey1332/printstream/blob/main/src/app/page.tsx"
click node_authui "https://github.com/rey1332/printstream/blob/main/src/app/login/page.tsx"
click node_authapi "https://github.com/rey1332/printstream/blob/main/src/app/api/auth/%5Baction%5D/route.ts"
click node_authsvc "https://github.com/rey1332/printstream/blob/main/src/server/auth/service.ts"
click node_authreq "https://github.com/rey1332/printstream/blob/main/src/server/auth/request.ts"
click node_db "https://github.com/rey1332/printstream/blob/main/src/server/db/executor.ts"
click node_dataapi "https://github.com/rey1332/printstream/blob/main/src/app/api/data/route.ts"
click node_dataexec "https://github.com/rey1332/printstream/blob/main/src/server/db/execute.ts"
click node_erpui "https://github.com/rey1332/printstream/blob/main/src/app/erp/page.tsx"
click node_erprules "https://github.com/rey1332/printstream/blob/main/src/app/erp/lib/erpRules.ts"
click node_erpworkspace "https://github.com/rey1332/printstream/blob/main/src/app/api/erp/workspace/route.ts"
click node_ingestui "https://github.com/rey1332/printstream/blob/main/src/app/erp/import/ingestClient.ts"
click node_ingestplan "https://github.com/rey1332/printstream/blob/main/src/lib/ingest/plan.ts"
click node_terminalui "https://github.com/rey1332/printstream/blob/main/src/app/terminal/page.tsx"
click node_terminalapi "https://github.com/rey1332/printstream/blob/main/src/app/api/terminal/route.ts"
click node_terminalservice "https://github.com/rey1332/printstream/blob/main/src/server/terminal/service.ts"
click node_pipelinesui "https://github.com/rey1332/printstream/blob/main/src/app/pipelines/%5Bid%5D/PipelineEditor.tsx"
click node_workflowapi "https://github.com/rey1332/printstream/blob/main/src/lib/workflow/storage.ts"
click node_workflowexec "https://github.com/rey1332/printstream/blob/main/src/lib/workflow/executor.ts"
click node_pipelineexec "https://github.com/rey1332/printstream/blob/main/src/server/terminal/pipelines.ts"
click node_mcpapi "https://github.com/rey1332/printstream/blob/main/src/app/api/mcp/route.ts"
click node_intel "https://github.com/rey1332/printstream/blob/main/src/server/intel/service.ts"
click node_adminui "https://github.com/rey1332/printstream/blob/main/src/app/admin/page.tsx"
click node_adminsvc "https://github.com/rey1332/printstream/blob/main/src/server/admin/service.ts"
click node_mailgateway "https://github.com/rey1332/printstream/blob/main/src/server/mail/gateway/engine.ts"

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_app,node_authui,node_user toneBlue
class node_dataapi,node_dataexec,node_erpui,node_erprules,node_erpworkspace,node_ingestui,node_ingestplan toneAmber
class node_terminalui,node_terminalapi,node_terminalservice,node_pipelinesui,node_workflowapi,node_workflowexec,node_pipelineexec,node_mcpapi,node_intel toneMint
class node_authapi,node_authsvc,node_authreq toneRose
class node_db,node_adminui,node_adminsvc,node_mailgateway,node_emailservice toneIndigo
```

## Components

### Application access

- [Application shell](https://github.com/rey1332/printstream/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Sign-in and MFA](https://github.com/rey1332/printstream/blob/main/src/app/login/page.tsx): `src/app/login/page.tsx`

### ERP operations

- [Data API](https://github.com/rey1332/printstream/blob/main/src/app/api/data/route.ts): `src/app/api/data/route.ts`
- [Data access engine](https://github.com/rey1332/printstream/blob/main/src/server/db/execute.ts): `src/server/db/execute.ts`
- [ERP workspace](https://github.com/rey1332/printstream/blob/main/src/app/erp/page.tsx): `src/app/erp/page.tsx`
- [ERP rules](https://github.com/rey1332/printstream/blob/main/src/app/erp/lib/erpRules.ts): `src/app/erp/lib/erpRules.ts`
- [Workspace API](https://github.com/rey1332/printstream/blob/main/src/app/api/erp/workspace/route.ts): `src/app/api/erp/workspace/route.ts`
- [ERP import](https://github.com/rey1332/printstream/blob/main/src/app/erp/import/ingestClient.ts): `src/app/erp/import/ingestClient.ts`
- [Import planning](https://github.com/rey1332/printstream/blob/main/src/lib/ingest/plan.ts): `src/lib/ingest/plan.ts`

### Data and analytics

- [Terminal workbench](https://github.com/rey1332/printstream/blob/main/src/app/terminal/page.tsx): `src/app/terminal/page.tsx`
- [Terminal API](https://github.com/rey1332/printstream/blob/main/src/app/api/terminal/route.ts): `src/app/api/terminal/route.ts`
- [Terminal services](https://github.com/rey1332/printstream/blob/main/src/server/terminal/service.ts): `src/server/terminal/service.ts`
- [Pipeline editor](https://github.com/rey1332/printstream/blob/main/src/app/pipelines/%5Bid%5D/PipelineEditor.tsx): `src/app/pipelines/[id]/PipelineEditor.tsx`
- [Workflow API client](https://github.com/rey1332/printstream/blob/main/src/lib/workflow/storage.ts): `src/lib/workflow/storage.ts`
- [Workflow executor](https://github.com/rey1332/printstream/blob/main/src/lib/workflow/executor.ts): `src/lib/workflow/executor.ts`
- [Pipeline runtime](https://github.com/rey1332/printstream/blob/main/src/server/terminal/pipelines.ts): `src/server/terminal/pipelines.ts`
- [MCP endpoint](https://github.com/rey1332/printstream/blob/main/src/app/api/mcp/route.ts): `src/app/api/mcp/route.ts`
- [Intelligence runtime](https://github.com/rey1332/printstream/blob/main/src/server/intel/service.ts): `src/server/intel/service.ts`

### Identity and governance

- [Auth API](https://github.com/rey1332/printstream/blob/main/src/app/api/auth/%5Baction%5D/route.ts): `src/app/api/auth/[action]/route.ts`
- [Authentication service](https://github.com/rey1332/printstream/blob/main/src/server/auth/service.ts): `src/server/auth/service.ts`
- [Session handling](https://github.com/rey1332/printstream/blob/main/src/server/auth/request.ts): `src/server/auth/request.ts`

### Platform services

- [PostgreSQL executor](https://github.com/rey1332/printstream/blob/main/src/server/db/executor.ts): `src/server/db/executor.ts`
- [Administration](https://github.com/rey1332/printstream/blob/main/src/app/admin/page.tsx): `src/app/admin/page.tsx`
- [Admin services](https://github.com/rey1332/printstream/blob/main/src/server/admin/service.ts): `src/server/admin/service.ts`
- [Company mail gateway](https://github.com/rey1332/printstream/blob/main/src/server/mail/gateway/engine.ts): `src/server/mail/gateway/engine.ts`

### Other components

- **Business user**
- **External mail provider**

## Connections

- Business user → Application shell: opens (evidence: `README.md`)
- Business user → Sign-in and MFA: signs in (evidence: `README.md`)
- Sign-in and MFA → Auth API: authenticates
- Auth API → Authentication service: calls (evidence: `src/app/api/auth/[action]/route.ts`)
- Auth API → Session handling: reads session (evidence: `src/app/api/auth/[action]/route.ts`)
- Authentication service → PostgreSQL executor: uses transactions (evidence: `src/server/auth/service.ts`)
- Session handling → Authentication service: loads dependencies (evidence: `src/server/auth/request.ts`)
- Business user → ERP workspace: manages operations (evidence: `README.md`)
- ERP workspace → Data API: reads and writes
- Data API → Session handling: checks identity (evidence: `src/app/api/data/route.ts`)
- Data API → Data access engine: executes requests (evidence: `src/app/api/data/route.ts`)
- Data access engine → PostgreSQL executor: runs transactions (evidence: `src/server/db/execute.ts`)
- ERP workspace → ERP rules: applies rules
- Business user → ERP import: imports data (evidence: `README.md`)
- ERP import → Import planning: plans import (evidence: `src/app/erp/import/ingestClient.ts`)
- Business user → Terminal workbench: explores data (evidence: `README.md`)
- Terminal workbench → Terminal API: requests actions
- Terminal API → Terminal services: dispatches actions (evidence: `src/app/api/terminal/route.ts`)
- Terminal API → Intelligence runtime: dispatches intelligence (evidence: `src/app/api/terminal/route.ts`)
- Business user → Pipeline editor: builds pipelines (evidence: `README.md`)
- Pipeline editor → Workflow API client: loads and runs (evidence: `src/app/pipelines/[id]/PipelineEditor.tsx`)
- Workflow API client → Pipeline runtime: calls workflow API
- Pipeline runtime → Workflow executor: executes graph (evidence: `src/server/terminal/pipelines.ts`)
- Business user → MCP endpoint: connects assistant (evidence: `README.md`)
- MCP endpoint → Session handling: checks session (evidence: `src/app/api/mcp/route.ts`)
- Business user → Administration: administers service (evidence: `README.md`)
- Administration → Admin services: manages platform
- Workspace API → Session handling: reads session (evidence: `src/app/api/erp/workspace/route.ts`)
- Workspace API → ERP rules: validates roles (evidence: `src/app/api/erp/workspace/route.ts`)
- Workspace API → Company mail gateway: sends invitations
- Company mail gateway → External mail provider: dispatches mail
