# aestheticsuraj234/chaibook-llm-build architecture

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

- Interactive diagram: https://gitdiagram.com/aestheticsuraj234/chaibook-llm-build
- Repository: https://github.com/aestheticsuraj234/chaibook-llm-build

## Overview

This appears to be a workspace-based knowledge assistant: users manage workspaces and add text, PDF, website, or YouTube sources, then chat using retrieved workspace context. The server separates HTTP controllers, domain services, persistence, and AI/source-processing integrations. The excerpts show source and workspace routing and chat orchestration; the README is empty, and the client page and several integrations were not sampled, so client-to-API wiring and some internal event flows are not asserted.

Main entry points: [`server/src/services/source.services.ts`](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/services/source.services.ts) (Source Services), [`server/src/services/chat.services.ts`](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/services/chat.services.ts) (Chat Services), [`server/src/services/source-processing.services.ts`](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/services/source-processing.services.ts) (Source Processing), [`server/src/services/workspace.services.ts`](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/services/workspace.services.ts) (Workspace Services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_webapp["Web App<br/>[page.tsx]"]
  node_layout["App Layout<br/>[layout.tsx]"]
end

subgraph group_workspace["Workspace Management"]
  node_workspace_routes["Workspace Routes"]
  node_workspace_controller["Workspace Controller"]
  node_workspace_service["Workspace Services"]
end

subgraph group_sources["Knowledge Sources"]
  node_source_routes["Source Routes<br/>[source.routes.ts]"]
  node_source_controller["Source Controller"]
  node_source_service["Source Services<br/>[source.services.ts]"]
  node_source_processing["Source Processing"]
  node_chunking["Text Chunking<br/>[chunking.ts]"]
  node_pdf["PDF Handling<br/>[pdf.ts]"]
  node_web_import["Website Import<br/>[firecrawl.ts]"]
  node_video_import["YouTube Import<br/>[youtube.ts]"]
end

subgraph group_chat["Chat and Retrieval"]
  node_chat_service["Chat Services<br/>[chat.services.ts]"]
  node_rag["RAG Retrieval<br/>[retrieve.ts]"]
end

subgraph group_platform["Persistence and Integrations"]
  node_workspace_store[("Workspace Repository")]
  node_source_store[("Source Repository")]
  node_cloud_storage["File Storage<br/>[cloudinary.ts]"]
  node_vector_store[("Vector Index<br/>[pinecone.ts]")]
  node_conversation_store[("Conversation Repository")]
  node_message_store[("Message Repository")]
  node_openai["OpenAI Models<br/>[openai.ts]"]
  node_web_search["Web Search<br/>[tavily.ts]"]
  node_summarization_events["Conversation Events"]
end

node_user(("User"))

node_user -.->|"uses"| node_webapp
node_webapp -.->|"renders within"| node_layout
node_workspace_routes -->|"routes to"| node_workspace_controller
node_workspace_controller -->|"calls"| node_workspace_service
node_workspace_service -.->|"reads and writes"| node_workspace_store
node_workspace_service -->|"deletes vectors"| node_vector_store
node_source_routes -->|"routes to"| node_source_controller
node_source_controller -->|"calls"| node_source_service
node_source_service -->|"reads and writes"| node_source_store
node_source_service -->|"checks workspace"| node_workspace_service
node_source_service -->|"handles PDFs"| node_pdf
node_source_service -->|"imports websites"| node_web_import
node_source_service -->|"imports videos"| node_video_import
node_source_service -->|"stores files"| node_cloud_storage
node_source_service -.->|"starts processing"| node_source_processing
node_source_processing -->|"splits text"| node_chunking
node_source_processing -->|"extracts text"| node_pdf
node_source_processing -->|"embeds chunks"| node_openai
node_source_processing -->|"indexes chunks"| node_vector_store
node_chat_service -->|"checks workspace"| node_workspace_service
node_chat_service -->|"retrieves context"| node_rag
node_rag -->|"searches vectors"| node_vector_store
node_chat_service -->|"manages conversations"| node_conversation_store
node_chat_service -->|"persists messages"| node_message_store
node_chat_service -->|"searches web"| node_web_search
node_chat_service -.->|"streams responses"| node_openai
node_chat_service -->|"queues summaries"| node_summarization_events

click node_webapp "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/client/app/page.tsx"
click node_layout "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/client/app/layout.tsx"
click node_workspace_routes "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/routes/workspace.routes.ts"
click node_workspace_controller "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/controllers/workspace.controller.ts"
click node_workspace_service "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/services/workspace.services.ts"
click node_workspace_store "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/repository/workspace.repository.ts"
click node_source_routes "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/routes/source.routes.ts"
click node_source_controller "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/controllers/source.controller.ts"
click node_source_service "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/services/source.services.ts"
click node_source_processing "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/services/source-processing.services.ts"
click node_source_store "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/repository/source.repository.ts"
click node_chunking "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/chunking.ts"
click node_pdf "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/pdf.ts"
click node_web_import "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/firecrawl.ts"
click node_video_import "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/youtube.ts"
click node_cloud_storage "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/cloudinary.ts"
click node_vector_store "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/pinecone.ts"
click node_chat_service "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/services/chat.services.ts"
click node_rag "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/rag/retrieve.ts"
click node_conversation_store "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/repository/conversation.repository.ts"
click node_message_store "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/repository/message.repository.ts"
click node_openai "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/openai.ts"
click node_web_search "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/tavily.ts"
click node_summarization_events "https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/conversation-events.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_webapp,node_layout,node_user toneBlue
class node_workspace_routes,node_workspace_controller,node_workspace_service toneAmber
class node_source_routes,node_source_controller,node_source_service,node_source_processing,node_chunking,node_pdf,node_web_import,node_video_import toneMint
class node_chat_service,node_rag toneRose
class node_workspace_store,node_source_store,node_cloud_storage,node_vector_store,node_conversation_store,node_message_store,node_openai,node_web_search,node_summarization_events toneIndigo
```

## Components

### Client

- [Web App](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/client/app/page.tsx): `client/app/page.tsx`
- [App Layout](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/client/app/layout.tsx): `client/app/layout.tsx`

### Workspace Management

- [Workspace Routes](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/routes/workspace.routes.ts): `server/src/routes/workspace.routes.ts`
- [Workspace Controller](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/controllers/workspace.controller.ts): `server/src/controllers/workspace.controller.ts`
- [Workspace Services](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/services/workspace.services.ts): `server/src/services/workspace.services.ts`

### Knowledge Sources

- [Source Routes](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/routes/source.routes.ts): `server/src/routes/source.routes.ts`
- [Source Controller](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/controllers/source.controller.ts): `server/src/controllers/source.controller.ts`
- [Source Services](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/services/source.services.ts): `server/src/services/source.services.ts`
- [Source Processing](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/services/source-processing.services.ts): `server/src/services/source-processing.services.ts`
- [Text Chunking](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/chunking.ts): `server/src/lib/chunking.ts`
- [PDF Handling](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/pdf.ts): `server/src/lib/pdf.ts`
- [Website Import](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/firecrawl.ts): `server/src/lib/firecrawl.ts`
- [YouTube Import](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/youtube.ts): `server/src/lib/youtube.ts`

### Chat and Retrieval

- [Chat Services](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/services/chat.services.ts): `server/src/services/chat.services.ts`
- [RAG Retrieval](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/rag/retrieve.ts): `server/src/lib/rag/retrieve.ts`

### Persistence and Integrations

- [Workspace Repository](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/repository/workspace.repository.ts): `server/src/repository/workspace.repository.ts`
- [Source Repository](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/repository/source.repository.ts): `server/src/repository/source.repository.ts`
- [File Storage](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/cloudinary.ts): `server/src/lib/cloudinary.ts`
- [Vector Index](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/pinecone.ts): `server/src/lib/pinecone.ts`
- [Conversation Repository](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/repository/conversation.repository.ts): `server/src/repository/conversation.repository.ts`
- [Message Repository](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/repository/message.repository.ts): `server/src/repository/message.repository.ts`
- [OpenAI Models](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/openai.ts): `server/src/lib/openai.ts`
- [Web Search](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/tavily.ts): `server/src/lib/tavily.ts`
- [Conversation Events](https://github.com/aestheticsuraj234/chaibook-llm-build/blob/main/server/src/lib/conversation-events.ts): `server/src/lib/conversation-events.ts`

### Other components

- **User**

## Connections

- User → Web App: uses
- Web App → App Layout: renders within
- Workspace Routes → Workspace Controller: routes to (evidence: `server/src/routes/workspace.routes.ts`)
- Workspace Controller → Workspace Services: calls (evidence: `server/src/controllers/workspace.controller.ts`)
- Workspace Services → Workspace Repository: reads and writes (evidence: `server/src/services/workspace.services.ts`)
- Workspace Services → Vector Index: deletes vectors (evidence: `server/src/services/workspace.services.ts`)
- Source Routes → Source Controller: routes to (evidence: `server/src/routes/source.routes.ts`)
- Source Controller → Source Services: calls (evidence: `server/src/controllers/source.controller.ts`)
- Source Services → Source Repository: reads and writes (evidence: `server/src/services/source.services.ts`)
- Source Services → Workspace Services: checks workspace (evidence: `server/src/services/source.services.ts`)
- Source Services → PDF Handling: handles PDFs (evidence: `server/src/services/source.services.ts`)
- Source Services → Website Import: imports websites (evidence: `server/src/services/source.services.ts`)
- Source Services → YouTube Import: imports videos (evidence: `server/src/services/source.services.ts`)
- Source Services → File Storage: stores files (evidence: `server/src/services/source.services.ts`)
- Source Services → Source Processing: starts processing
- Source Processing → Text Chunking: splits text (evidence: `server/src/services/source-processing.services.ts`)
- Source Processing → PDF Handling: extracts text (evidence: `server/src/services/source-processing.services.ts`)
- Source Processing → OpenAI Models: embeds chunks (evidence: `server/src/services/source-processing.services.ts`)
- Source Processing → Vector Index: indexes chunks (evidence: `server/src/services/source-processing.services.ts`)
- Chat Services → Workspace Services: checks workspace (evidence: `server/src/services/chat.services.ts`)
- Chat Services → RAG Retrieval: retrieves context (evidence: `server/src/services/chat.services.ts`)
- RAG Retrieval → Vector Index: searches vectors (evidence: `server/src/lib/rag/retrieve.ts`)
- Chat Services → Conversation Repository: manages conversations (evidence: `server/src/services/chat.services.ts`)
- Chat Services → Message Repository: persists messages (evidence: `server/src/services/chat.services.ts`)
- Chat Services → Web Search: searches web (evidence: `server/src/services/chat.services.ts`)
- Chat Services → OpenAI Models: streams responses
- Chat Services → Conversation Events: queues summaries (evidence: `server/src/services/chat.services.ts`)
