# xmartis3/pipeshub-ai-einfra architecture

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

- Interactive diagram: https://gitdiagram.com/xmartis3/pipeshub-ai-einfra
- Repository: https://github.com/xmartis3/pipeshub-ai-einfra

## Overview

#### 1. System Purpose and Deployable Entry Points
PipesHub is a self-hosted workplace AI platform: it ingests enterprise data, preserves permission/relationship metadata, indexes searchable representations, and serves grounded search, chat, agents, and actions. It is a polyglot service system rather than a single application.
- Node API bootstrap: `backend/nodejs/apps/src/index.ts`, `backend/nodejs/apps/src/app.ts`
- Python service processes: `backend/python/app/connectors_main.py`, `backend/python/app/indexing_main.py`, `backend/python/app/query_main.py`
- Web/Electron UI: `frontend/app/(main)/layout.tsx`, `frontend/electron/main.ts`

#### 2. Node.js Control Plane and Public API
The TypeScript backend is the control plane for HTTP APIs, authentication, workspace administration, connector configuration/scheduling, storage, and notifications. Modules follow route → controller → container/service boundaries, with shared auth, validation, rate limiting, metrics, and error middleware.
- API surfaces: `backend/nodejs/apps/src/modules/enterprise_search/routes/es.routes.ts`, `backend/nodejs/apps/src/modules/configuration_manager/routes/cm_routes.ts`
- Cross-cutting request/security boundary: `backend/nodejs/apps/src/libs/middlewares/auth.middleware.ts`, `backend/nodejs/apps/src/libs/middlewares/require-scopes.middleware.ts`
- API contract/documentation: `backend/nodejs/apps/src/modules/api-docs/pipeshub-openapi.yaml`

#### 3. Identity, Tenancy, Credentials, and Configuration
Identity is separated into user authentication/SAML/session handling, OAuth-provider capability for third-party clients, and token management for connectors. Configuration is stored through swappable encrypted/distributed key-value implementations, allowing deployment selection between Redis and etcd.
- Authentication and account lifecycle: `backend/nodejs/apps/src/modules/auth/services/session.service.ts`, `backend/nodejs/apps/src/modules/user_management/routes/users.routes.ts`
- OAuth and connector-token boundaries: `backend/nodejs/apps/src/modules/oauth_provider/services/oauth_token.service.ts`, `backend/nodejs/apps/src/modules/tokens_manager/services/token-event.producer.ts`
- KV abstractions/providers: `backend/nodejs/apps/src/libs/keyValueStore/keyValueStoreFactory.ts`, `backend/python/app/config/key_value_store_factory.py`

#### 4. Connector Ingestion and Event Pipeline
Connector instances are configured and scheduled by Node, then Python connector infrastructure instantiates source-specific connectors, refreshes credentials, fetches source entities, and emits normalized record/entity events. The connector registry/factory isolates common lifecycle and OAuth behavior from the large set of SaaS, database, filesystem, and web integrations.
- Scheduling/orchestration: `backend/nodejs/apps/src/modules/crawling_manager/services/connector_schedule_orchestrator.ts`, `backend/nodejs/apps/src/modules/crawling_manager/services/crawling_worker.ts`
- Python connector core: `backend/python/app/connectors/core/factory/connector_factory.py`, `backend/python/app/connectors/core/base/data_processor/data_source_entities_processor.py`
- Event handoff: `backend/python/app/connectors/services/event_service.py`, `backend/python/app/services/messaging/kafka/producer/producer.py`

#### 5. Document Processing, Indexing, and Knowledge Stores
Asynchronous indexing consumes record events, extracts structured blocks from files/content, and writes coordinated representations to blob storage, vector search, and a graph database. This is the principal data boundary: raw external content becomes permission-aware records, embeddings, and graph entities/edges.
- Indexing pipeline/sinks: `backend/python/app/modules/indexing/run.py`, `backend/python/app/modules/transformers/sink_orchestrator.py`
- Parsing/OCR and Docling service: `backend/python/app/modules/parsers/pdf/docling_processor.py`, `backend/python/app/services/docling/docling_service.py`
- Stores: `backend/python/app/services/vector_db/qdrant/qdrant.py`, `backend/python/app/services/graph_db/graph_db_factory.py`

#### 6. Retrieval, LLM, Agents, and Tools
The Python query service exposes search, chatbot, speech, and agent routes. Retrieval combines indexed knowledge with vector/graph access; Q&A and deep-agent workflows maintain state, stream responses, cite sources, and route permitted tool calls. AI model providers are registry-driven, supporting hosted and self-hosted model backends.
- Query APIs: `backend/python/app/api/routes/search.py`, `backend/python/app/api/routes/chatbot.py`
- Agent graphs: `backend/python/app/modules/agents/qna/graph.py`, `backend/python/app/modules/agents/deep/orchestrator.py`
- Tool/action registration and model providers: `backend/python/app/agents/registry/toolset_registry.py`, `backend/python/app/config/ai_models/registry.py`

#### 7. Client and Operational Infrastructure
The Next.js frontend provides authenticated workspace configuration, connector management, knowledge-base browsing, visual agent construction, and streaming chat with citations. Docker Compose and Helm deploy the services and backing infrastructure; graph DB choice, messaging choice, and KV configuration are deployment-level decisions.
- Core UX: `frontend/app/(main)/chat/page.tsx`, `frontend/app/(main)/agents/agent-builder/agent-builder.tsx`
- Knowledge/connector UX: `frontend/app/(main)/knowledge-base/page.tsx`, `frontend/app/(main)/workspace/connectors/page.tsx`
- Deployment definitions: `deployment/docker-compose/docker-compose.prod.yml`, `deployment/helm/pipeshub-ai/templates/deployment.yaml`, `deployment/helm/pipeshub-ai/templates/qdrant-statefulset.yaml`

Main entry points: [`deployment/docker-compose/docker-compose.prod.yml`](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/deployment/docker-compose/docker-compose.prod.yml) (Compose and Helm deployment), [`backend/nodejs/apps/src/index.ts`](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/nodejs/apps/src/index.ts) (Node API bootstrap), [`backend/python/app/services/vector_db/qdrant/qdrant.py`](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/services/vector_db/qdrant/qdrant.py) (Vector and graph stores), [`frontend/app/(main)/layout.tsx`](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/frontend/app/(main)/layout.tsx) (Next.js workspace UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Clients"]
  node_web_ui["Next.js workspace UI<br/>web client<br/>[layout.tsx]"]
  node_electron["Electron desktop shell<br/>desktop client<br/>[main.ts]"]
end

subgraph group_control["Node control plane"]
  node_node_api["Node API bootstrap<br/>HTTP control plane<br/>[index.ts]"]
  node_api_routes["Search and config APIs<br/>route modules<br/>[es.routes.ts]"]
  node_auth_boundary["Auth and scope boundary<br/>request middleware<br/>[auth.middleware.ts]"]
  node_identity_tokens["Identity and connector tokens<br/>identity services<br/>[session.service.ts]"]
  node_connector_scheduler["Connector scheduler<br/>orchestration service"]
end

subgraph group_ingestion["Connector ingestion"]
  node_connector_service["Python connector process<br/>worker service<br/>[connectors_main.py]"]
  node_connector_factory["Connector registry and lifecycle<br/>connector factory"]
  node_event_producer["Normalized event producer<br/>Kafka producer<br/>[event_service.py]"]
end

subgraph group_knowledge["Indexing and knowledge"]
  node_indexing_service["Python indexing process<br/>worker service<br/>[indexing_main.py]"]
  node_transform_pipeline["Parse and sink pipeline<br/>indexing pipeline<br/>[run.py]"]
  node_docling["Docling parsing and OCR<br/>document processing<br/>[docling_service.py]"]
end

subgraph group_ai["Query and AI"]
  node_query_service["Python query service<br/>AI API service<br/>[query_main.py]"]
  node_retrieval_api["Search and chat APIs<br/>query routes<br/>[search.py]"]
  node_agent_workflows["Q&amp;A and deep agents<br/>agent graphs<br/>[graph.py]"]
  node_tools_models["Tool and model registries<br/>AI provider boundary"]
end

subgraph group_operations["Deployment and stores"]
  node_kv_store[("Encrypted distributed KV<br/>configuration store")]
  node_event_bus["Record event bus<br/>messaging infrastructure<br/>[producer.py]"]
  node_knowledge_stores[("Vector and graph stores<br/>knowledge databases<br/>[qdrant.py]")]
  node_deployment["Compose and Helm deployment<br/>deployment definitions"]
end

node_electron -->|"hosts"| node_web_ui
node_web_ui -->|"workspace APIs"| node_node_api
node_web_ui -->|"streaming chat"| node_query_service
node_node_api -->|"protects requests"| node_auth_boundary
node_auth_boundary -->|"authorizes"| node_api_routes
node_node_api -->|"sessions and OAuth"| node_identity_tokens
node_node_api -->|"configures schedules"| node_connector_scheduler
node_identity_tokens -->|"stores state"| node_kv_store
node_connector_scheduler -->|"reads configuration"| node_kv_store
node_connector_scheduler -->|"triggers crawls"| node_connector_service
node_connector_service -->|"instantiates"| node_connector_factory
node_connector_factory -->|"normalizes entities"| node_event_producer
node_event_producer -->|"publishes records"| node_event_bus
node_event_bus -->|"consumed by"| node_indexing_service
node_indexing_service -->|"runs"| node_transform_pipeline
node_transform_pipeline -->|"extracts documents"| node_docling
node_transform_pipeline -->|"indexes records and graph"| node_knowledge_stores
node_query_service -->|"serves"| node_retrieval_api
node_retrieval_api -->|"retrieves grounded context"| node_knowledge_stores
node_retrieval_api -->|"invokes"| node_agent_workflows
node_agent_workflows -->|"uses tools and models"| node_tools_models
node_agent_workflows -->|"retrieves and cites"| node_knowledge_stores
node_deployment -.->|"deploys"| node_node_api
node_deployment -.->|"deploys"| node_connector_service
node_deployment -.->|"deploys"| node_indexing_service
node_deployment -.->|"deploys"| node_query_service
node_deployment -.->|"provisions"| node_knowledge_stores

click node_web_ui "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/frontend/app/(main)/layout.tsx"
click node_electron "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/frontend/electron/main.ts"
click node_node_api "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/nodejs/apps/src/index.ts"
click node_api_routes "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/nodejs/apps/src/modules/enterprise_search/routes/es.routes.ts"
click node_auth_boundary "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/nodejs/apps/src/libs/middlewares/auth.middleware.ts"
click node_identity_tokens "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/nodejs/apps/src/modules/auth/services/session.service.ts"
click node_connector_scheduler "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/nodejs/apps/src/modules/crawling_manager/services/connector_schedule_orchestrator.ts"
click node_kv_store "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/nodejs/apps/src/libs/keyValueStore/keyValueStoreFactory.ts"
click node_connector_service "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/connectors_main.py"
click node_connector_factory "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/connectors/core/factory/connector_factory.py"
click node_event_producer "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/connectors/services/event_service.py"
click node_event_bus "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/services/messaging/kafka/producer/producer.py"
click node_indexing_service "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/indexing_main.py"
click node_transform_pipeline "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/modules/indexing/run.py"
click node_docling "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/services/docling/docling_service.py"
click node_knowledge_stores "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/services/vector_db/qdrant/qdrant.py"
click node_query_service "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/query_main.py"
click node_retrieval_api "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/api/routes/search.py"
click node_agent_workflows "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/modules/agents/qna/graph.py"
click node_tools_models "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/agents/registry/toolset_registry.py"
click node_deployment "https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/deployment/docker-compose/docker-compose.prod.yml"

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_web_ui,node_electron toneBlue
class node_node_api,node_api_routes,node_auth_boundary,node_identity_tokens,node_connector_scheduler toneAmber
class node_connector_service,node_connector_factory,node_event_producer toneMint
class node_indexing_service,node_transform_pipeline,node_docling toneRose
class node_query_service,node_retrieval_api,node_agent_workflows,node_tools_models toneIndigo
class node_kv_store,node_event_bus,node_knowledge_stores,node_deployment toneTeal
```

## Components

### Clients

- [Next.js workspace UI](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/frontend/app/(main)/layout.tsx): web client · Configuration, connectors, knowledge, agents, and chat. · `frontend/app/(main)/layout.tsx`
- [Electron desktop shell](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/frontend/electron/main.ts): desktop client · `frontend/electron/main.ts`

### Node control plane

- [Node API bootstrap](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/nodejs/apps/src/index.ts): HTTP control plane · `backend/nodejs/apps/src/index.ts`
- [Search and config APIs](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/nodejs/apps/src/modules/enterprise_search/routes/es.routes.ts): route modules · `backend/nodejs/apps/src/modules/enterprise_search/routes/es.routes.ts`
- [Auth and scope boundary](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/nodejs/apps/src/libs/middlewares/auth.middleware.ts): request middleware · `backend/nodejs/apps/src/libs/middlewares/auth.middleware.ts`
- [Identity and connector tokens](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/nodejs/apps/src/modules/auth/services/session.service.ts): identity services · `backend/nodejs/apps/src/modules/auth/services/session.service.ts`
- [Connector scheduler](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/nodejs/apps/src/modules/crawling_manager/services/connector_schedule_orchestrator.ts): orchestration service · `backend/nodejs/apps/src/modules/crawling_manager/services/connector_schedule_orchestrator.ts`

### Connector ingestion

- [Python connector process](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/connectors_main.py): worker service · `backend/python/app/connectors_main.py`
- [Connector registry and lifecycle](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/connectors/core/factory/connector_factory.py): connector factory · `backend/python/app/connectors/core/factory/connector_factory.py`
- [Normalized event producer](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/connectors/services/event_service.py): Kafka producer · `backend/python/app/connectors/services/event_service.py`

### Indexing and knowledge

- [Python indexing process](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/indexing_main.py): worker service · `backend/python/app/indexing_main.py`
- [Parse and sink pipeline](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/modules/indexing/run.py): indexing pipeline · Transforms content into permission-aware searchable representations. · `backend/python/app/modules/indexing/run.py`
- [Docling parsing and OCR](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/services/docling/docling_service.py): document processing · `backend/python/app/services/docling/docling_service.py`

### Query and AI

- [Python query service](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/query_main.py): AI API service · `backend/python/app/query_main.py`
- [Search and chat APIs](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/api/routes/search.py): query routes · `backend/python/app/api/routes/search.py`
- [Q&A and deep agents](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/modules/agents/qna/graph.py): agent graphs · Streams grounded responses and routes permitted actions. · `backend/python/app/modules/agents/qna/graph.py`
- [Tool and model registries](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/agents/registry/toolset_registry.py): AI provider boundary · `backend/python/app/agents/registry/toolset_registry.py`

### Deployment and stores

- [Encrypted distributed KV](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/nodejs/apps/src/libs/keyValueStore/keyValueStoreFactory.ts): configuration store · Redis or etcd implementation selected at deployment. · `backend/nodejs/apps/src/libs/keyValueStore/keyValueStoreFactory.ts`
- [Record event bus](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/services/messaging/kafka/producer/producer.py): messaging infrastructure · `backend/python/app/services/messaging/kafka/producer/producer.py`
- [Vector and graph stores](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/backend/python/app/services/vector_db/qdrant/qdrant.py): knowledge databases · Coordinated embeddings and entity/relationship representations. · `backend/python/app/services/vector_db/qdrant/qdrant.py`
- [Compose and Helm deployment](https://github.com/xmartis3/pipeshub-ai-einfra/blob/main/deployment/docker-compose/docker-compose.prod.yml): deployment definitions · Deploys services and backing infrastructure. · `deployment/docker-compose/docker-compose.prod.yml`

## Connections

- Electron desktop shell → Next.js workspace UI: hosts
- Next.js workspace UI → Node API bootstrap: workspace APIs
- Next.js workspace UI → Python query service: streaming chat
- Node API bootstrap → Auth and scope boundary: protects requests
- Auth and scope boundary → Search and config APIs: authorizes
- Node API bootstrap → Identity and connector tokens: sessions and OAuth
- Node API bootstrap → Connector scheduler: configures schedules
- Identity and connector tokens → Encrypted distributed KV: stores state
- Connector scheduler → Encrypted distributed KV: reads configuration
- Connector scheduler → Python connector process: triggers crawls
- Python connector process → Connector registry and lifecycle: instantiates
- Connector registry and lifecycle → Normalized event producer: normalizes entities
- Normalized event producer → Record event bus: publishes records
- Record event bus → Python indexing process: consumed by
- Python indexing process → Parse and sink pipeline: runs
- Parse and sink pipeline → Docling parsing and OCR: extracts documents
- Parse and sink pipeline → Vector and graph stores: indexes records and graph
- Python query service → Search and chat APIs: serves
- Search and chat APIs → Vector and graph stores: retrieves grounded context
- Search and chat APIs → Q&A and deep agents: invokes
- Q&A and deep agents → Tool and model registries: uses tools and models
- Q&A and deep agents → Vector and graph stores: retrieves and cites
- Compose and Helm deployment → Node API bootstrap: deploys
- Compose and Helm deployment → Python connector process: deploys
- Compose and Helm deployment → Python indexing process: deploys
- Compose and Helm deployment → Python query service: deploys
- Compose and Helm deployment → Vector and graph stores: provisions
