# lhx-space/infra-docs architecture

> Architecture diagram of the GitHub repository lhx-space/infra-docs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lhx-space/infra-docs
- Repository: https://github.com/lhx-space/infra-docs

## Overview

infra-docs is a collaborative wiki and document platform. The main workflow is a user browsing teams, wikis, and documents in a client, then using the shared application and API for workspace operations; web and desktop clients also connect to the collaboration service for live Yjs editing. The API handles persistent product operations and coordinates background media/export jobs, while AI and error-monitoring capabilities form distinct branches. The graph preserves README-documented client and service links; several unsampled feature internals are represented only at their documented subsystem boundary.

Main entry points: [`packages/app/src/App.tsx`](https://github.com/lhx-space/infra-docs/blob/main/packages/app/src/App.tsx) (Shared app), [`packages/api-client/src/network/client.ts`](https://github.com/lhx-space/infra-docs/blob/main/packages/api-client/src/network/client.ts) (REST client), [`apps/ai-server/src/main.rs`](https://github.com/lhx-space/infra-docs/blob/main/apps/ai-server/src/main.rs) (AI service), [`apps/web/src/main.tsx`](https://github.com/lhx-space/infra-docs/blob/main/apps/web/src/main.tsx) (Web client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User clients"]
  node_web["Web client<br/>[main.tsx]"]
  node_desktop["Desktop client<br/>[main.tsx]"]
  node_mobile["Mobile browser<br/>[index.tsx]"]
end

subgraph group_frontend["Shared application"]
  node_application["Shared app<br/>[App.tsx]"]
  node_workspace["Team and wiki UI<br/>[TeamList.tsx]"]
  node_document["Document editor"]
  node_rich_editor["Tiptap editor<br/>[DocumentEditor.tsx]"]
  node_client_state["Client state<br/>[document.ts]"]
  node_http_client["REST client<br/>[client.ts]"]
end

subgraph group_backend["Product backend"]
  node_api["REST API<br/>[app.ts]"]
  node_product_services["Wiki and document services<br/>[document.ts]"]
  node_postgres[("PostgreSQL")]
  node_media_storage["Media storage<br/>[storage.ts]"]
  node_job_worker["Export and video jobs<br/>[worker.ts]"]
end

subgraph group_realtime["Realtime and AI"]
  node_collab["Yjs collaboration<br/>[ws.rs]"]
  node_grpc_api["Internal gRPC<br/>[server.ts]"]
  node_ai_server["AI service<br/>[main.rs]"]
  node_ai_chat["Chat and audio<br/>[chat.rs]"]
  node_ai_indexer["Document indexing<br/>[indexer.rs]"]
end

subgraph group_support["Monitoring"]
  node_error_monitor["Error monitoring<br/>[dispatch.ts]"]
end

node_user(("User"))

node_user -->|"uses"| node_web
node_user -->|"uses"| node_desktop
node_user -->|"uses"| node_mobile
node_web -->|"loads"| node_application
node_desktop -->|"loads"| node_application
node_application -->|"uses"| node_error_monitor
node_application -.->|"routes to"| node_workspace
node_application -.->|"routes to"| node_document
node_document -.->|"embeds"| node_rich_editor
node_document -.->|"uses"| node_client_state
node_client_state -->|"calls"| node_http_client
node_web -->|"REST"| node_http_client
node_desktop -->|"REST"| node_http_client
node_mobile -->|"REST"| node_http_client
node_http_client -->|"requests"| node_api
node_api -.->|"routes requests"| node_product_services
node_product_services -.->|"reads and writes"| node_postgres
node_api -.->|"uploads media"| node_media_storage
node_api -.->|"queues jobs"| node_job_worker
node_web -->|"Yjs WebSocket"| node_collab
node_desktop -->|"Yjs WebSocket"| node_collab
node_collab -->|"gRPC"| node_grpc_api
node_grpc_api -.->|"syncs content"| node_postgres
node_ai_server -->|"serves"| node_ai_chat
node_ai_server -->|"spawns"| node_ai_indexer
node_ai_server -->|"connects"| node_grpc_api
node_ai_server -.->|"indexes documents"| node_postgres

click node_web "https://github.com/lhx-space/infra-docs/blob/main/apps/web/src/main.tsx"
click node_desktop "https://github.com/lhx-space/infra-docs/blob/main/apps/desktop/src/renderer/src/main.tsx"
click node_mobile "https://github.com/lhx-space/infra-docs/blob/main/apps/mobile/src/app/(tabs)/index.tsx"
click node_application "https://github.com/lhx-space/infra-docs/blob/main/packages/app/src/App.tsx"
click node_workspace "https://github.com/lhx-space/infra-docs/blob/main/packages/app/src/pages/team/TeamList.tsx"
click node_document "https://github.com/lhx-space/infra-docs/blob/main/packages/app/src/pages/wiki/DocumentEditorPage.tsx"
click node_rich_editor "https://github.com/lhx-space/infra-docs/blob/main/packages/tiptap-editor/src/components/DocumentEditor.tsx"
click node_client_state "https://github.com/lhx-space/infra-docs/blob/main/packages/core/src/store/document.ts"
click node_http_client "https://github.com/lhx-space/infra-docs/blob/main/packages/api-client/src/network/client.ts"
click node_api "https://github.com/lhx-space/infra-docs/blob/main/apps/api/src/app.ts"
click node_product_services "https://github.com/lhx-space/infra-docs/blob/main/apps/api/src/services/document.ts"
click node_media_storage "https://github.com/lhx-space/infra-docs/blob/main/apps/api/src/services/storage.ts"
click node_job_worker "https://github.com/lhx-space/infra-docs/blob/main/apps/api/src/worker.ts"
click node_collab "https://github.com/lhx-space/infra-docs/blob/main/apps/collab-server/src/handler/ws.rs"
click node_grpc_api "https://github.com/lhx-space/infra-docs/blob/main/apps/api/src/grpc/server.ts"
click node_ai_server "https://github.com/lhx-space/infra-docs/blob/main/apps/ai-server/src/main.rs"
click node_ai_chat "https://github.com/lhx-space/infra-docs/blob/main/apps/ai-server/src/handler/chat.rs"
click node_ai_indexer "https://github.com/lhx-space/infra-docs/blob/main/apps/ai-server/src/service/indexer.rs"
click node_error_monitor "https://github.com/lhx-space/infra-docs/blob/main/packages/error-monitor/src/core/dispatch.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_web,node_desktop,node_mobile,node_user toneBlue
class node_application,node_workspace,node_document,node_rich_editor,node_client_state,node_http_client toneAmber
class node_api,node_product_services,node_postgres,node_media_storage,node_job_worker toneMint
class node_collab,node_grpc_api,node_ai_server,node_ai_chat,node_ai_indexer toneRose
class node_error_monitor toneIndigo
```

## Components

### User clients

- [Web client](https://github.com/lhx-space/infra-docs/blob/main/apps/web/src/main.tsx): `apps/web/src/main.tsx`
- [Desktop client](https://github.com/lhx-space/infra-docs/blob/main/apps/desktop/src/renderer/src/main.tsx): `apps/desktop/src/renderer/src/main.tsx`
- [Mobile browser](https://github.com/lhx-space/infra-docs/blob/main/apps/mobile/src/app/(tabs)/index.tsx): `apps/mobile/src/app/(tabs)/index.tsx`

### Shared application

- [Shared app](https://github.com/lhx-space/infra-docs/blob/main/packages/app/src/App.tsx): `packages/app/src/App.tsx`
- [Team and wiki UI](https://github.com/lhx-space/infra-docs/blob/main/packages/app/src/pages/team/TeamList.tsx): `packages/app/src/pages/team/TeamList.tsx`
- [Document editor](https://github.com/lhx-space/infra-docs/blob/main/packages/app/src/pages/wiki/DocumentEditorPage.tsx): `packages/app/src/pages/wiki/DocumentEditorPage.tsx`
- [Tiptap editor](https://github.com/lhx-space/infra-docs/blob/main/packages/tiptap-editor/src/components/DocumentEditor.tsx): `packages/tiptap-editor/src/components/DocumentEditor.tsx`
- [Client state](https://github.com/lhx-space/infra-docs/blob/main/packages/core/src/store/document.ts): `packages/core/src/store/document.ts`
- [REST client](https://github.com/lhx-space/infra-docs/blob/main/packages/api-client/src/network/client.ts): `packages/api-client/src/network/client.ts`

### Product backend

- [REST API](https://github.com/lhx-space/infra-docs/blob/main/apps/api/src/app.ts): `apps/api/src/app.ts`
- [Wiki and document services](https://github.com/lhx-space/infra-docs/blob/main/apps/api/src/services/document.ts): `apps/api/src/services/document.ts`
- **PostgreSQL**
- [Media storage](https://github.com/lhx-space/infra-docs/blob/main/apps/api/src/services/storage.ts): `apps/api/src/services/storage.ts`
- [Export and video jobs](https://github.com/lhx-space/infra-docs/blob/main/apps/api/src/worker.ts): `apps/api/src/worker.ts`

### Realtime and AI

- [Yjs collaboration](https://github.com/lhx-space/infra-docs/blob/main/apps/collab-server/src/handler/ws.rs): `apps/collab-server/src/handler/ws.rs`
- [Internal gRPC](https://github.com/lhx-space/infra-docs/blob/main/apps/api/src/grpc/server.ts): `apps/api/src/grpc/server.ts`
- [AI service](https://github.com/lhx-space/infra-docs/blob/main/apps/ai-server/src/main.rs): `apps/ai-server/src/main.rs`
- [Chat and audio](https://github.com/lhx-space/infra-docs/blob/main/apps/ai-server/src/handler/chat.rs): `apps/ai-server/src/handler/chat.rs`
- [Document indexing](https://github.com/lhx-space/infra-docs/blob/main/apps/ai-server/src/service/indexer.rs): `apps/ai-server/src/service/indexer.rs`

### Monitoring

- [Error monitoring](https://github.com/lhx-space/infra-docs/blob/main/packages/error-monitor/src/core/dispatch.ts): `packages/error-monitor/src/core/dispatch.ts`

### Other components

- **User**

## Connections

- User → Web client: uses (evidence: `README.md`)
- User → Desktop client: uses (evidence: `README.md`)
- User → Mobile browser: uses (evidence: `README.md`)
- Web client → Shared app: loads (evidence: `apps/web/src/main.tsx`)
- Desktop client → Shared app: loads (evidence: `apps/desktop/src/renderer/src/main.tsx`)
- Shared app → Error monitoring: uses (evidence: `packages/app/src/App.tsx`)
- Shared app → Team and wiki UI: routes to
- Shared app → Document editor: routes to
- Document editor → Tiptap editor: embeds
- Document editor → Client state: uses
- Client state → REST client: calls
- Web client → REST client: REST (evidence: `README.md`)
- Desktop client → REST client: REST (evidence: `README.md`)
- Mobile browser → REST client: REST (evidence: `README.md`)
- REST client → REST API: requests (evidence: `README.md`)
- REST API → Wiki and document services: routes requests
- Wiki and document services → PostgreSQL: reads and writes
- REST API → Media storage: uploads media
- REST API → Export and video jobs: queues jobs
- Web client → Yjs collaboration: Yjs WebSocket (evidence: `README.md`)
- Desktop client → Yjs collaboration: Yjs WebSocket (evidence: `README.md`)
- Yjs collaboration → Internal gRPC: gRPC (evidence: `README.md`)
- Internal gRPC → PostgreSQL: syncs content
- AI service → Chat and audio: serves (evidence: `apps/ai-server/src/main.rs`)
- AI service → Document indexing: spawns (evidence: `apps/ai-server/src/main.rs`)
- AI service → Internal gRPC: connects (evidence: `apps/ai-server/src/main.rs`)
- AI service → PostgreSQL: indexes documents
