How won-life/aideep_websocket works
This is a NestJS realtime server for Aideep, centered on Socket.IO and Yjs collaborative node editing. The main HTTP path validates an authenticated Markdown operation, checks workspace access and node state, applies it to the in-memory CRDT document, persists it, then broadcasts the update. The server also supports realtime presence, event-bus subscriptions, file attachments, and embedding jobs. Source excerpts establish the content-operation and document-save paths; several module capabilities are visible only in the tree or source index, so their unverified connections are omitted.
Main entry points: node-content.service.ts Operation coordinator · yjs-doc-manager.ts Yjs document manager · ws.gateway.ts Socket gateway · app.module.ts Nest application
Components 29
Server runtime
- Nest application
src/app.module.ts - HTTP bootstrap
src/main.ts
Node content
- Content operations API
src/domain/node-content/controller/node-content.controller.ts - Operation contract
src/domain/node-content/dto/nodeContentOperation.dto.ts - Operation coordinator
src/domain/node-content/service/node-content.service.ts - Node lookup
src/domain/node-content/repository/node-content.repository.ts - Workspace membership
src/domain/membership/repository/membership.repository.ts
Realtime collaboration
- Socket gateway
src/domain/ws/controller/ws.gateway.ts - Presence tracking
src/domain/ws/service/presence.service.ts - Socket event logging
src/domain/ws/service/ws-log.service.ts - Socket event types
src/domain/ws/type/ws.event.ts - Yjs document manager
src/global/yjs/yjs-doc-manager.ts - Yjs persistence service
src/global/yjs/yjs-crdt.service.ts - Markdown conversion
src/global/yjs/markdown-yjs.ts - Yjs awareness
src/global/yjs/yjs-ws-awareness.service.ts - Yjs event constants
src/global/yjs/yjs.constants.ts
Persistence and jobs
- Redis
- Redis client service
src/global/redis/redis.service.ts - Redis key definitions
src/global/redis/redis.keys.ts - Embedding queue
src/global/redis/embed-queue.service.ts - Relational database
- Prisma service
src/global/prisma/prisma.service.ts
Shared services
- JWT authentication
src/global/auth/strategy/jwt.strategy.ts - Realtime auth module
src/global/auth/realtime-auth.module.ts - Event bus subscriber
src/domain/event-bus/service/event-bus.subscriber.ts - File attachment service
src/domain/file-attachment/service/file-attachment.service.ts - Attachment repository
src/domain/file-attachment/repository/file-attachment.repository.ts
Other components
- API or socket client
- Object storage
Connections 36
- API or socket client → HTTP bootstrap: sends request
src/main.ts - HTTP bootstrap → Nest application: starts
src/main.ts - Nest application → Content operations API: registers module
src/app.module.ts - Nest application → Socket gateway: registers module
src/app.module.ts - Nest application → Realtime auth module: registers module
src/app.module.ts - Realtime auth module → JWT authentication: configures strategy
src/global/auth/realtime-auth.module.ts - API or socket client → Content operations API: posts operation
src/domain/node-content/controller/node-content.controller.ts - Content operations API → Operation coordinator: executes operation
src/domain/node-content/controller/node-content.controller.ts - Content operations API → Operation contract: accepts contract
src/domain/node-content/controller/node-content.controller.ts - Operation coordinator → Workspace membership: checks access
src/domain/node-content/service/node-content.service.ts - Operation coordinator → Node lookup: loads node
src/domain/node-content/service/node-content.service.ts - Operation coordinator → Redis client service: claims idempotency
src/domain/node-content/service/node-content.service.ts - Operation coordinator → Redis key definitions: builds cache key
src/domain/node-content/service/node-content.service.ts - Operation coordinator → Yjs document manager: appends Markdown
src/domain/node-content/service/node-content.service.ts - Operation coordinator → Socket gateway: broadcasts update
src/domain/node-content/service/node-content.service.ts - Yjs document manager → Yjs persistence service: loads and saves state
src/global/yjs/yjs-doc-manager.ts - Yjs document manager → Markdown conversion: converts document
src/global/yjs/yjs-doc-manager.ts - Yjs document manager → Embedding queue: queues embedding
src/global/yjs/yjs-doc-manager.ts - Yjs document manager → Yjs event constants: uses timings
src/global/yjs/yjs-doc-manager.ts - Yjs persistence service → Markdown conversion: uses conversion
src/global/yjs/yjs-crdt.service.ts - Socket gateway → Presence tracking: updates presence
src/domain/ws/controller/ws.gateway.ts - Socket gateway → Socket event logging: logs events
src/domain/ws/controller/ws.gateway.ts - Socket gateway → Socket event types: uses event types
src/domain/ws/controller/ws.gateway.ts - Presence tracking → Redis client service: stores presence
src/domain/ws/service/presence.service.ts - Presence tracking → Redis key definitions: selects key
src/domain/ws/service/presence.service.ts - Yjs awareness → Yjs event constants: uses event constants
src/global/yjs/yjs-ws-awareness.service.ts - Redis client service → Redis: connects
src/global/redis/redis.service.ts - Embedding queue → Redis client service: enqueues through
src/global/redis/embed-queue.service.ts - Embedding queue → Redis key definitions: uses queue key
src/global/redis/embed-queue.service.ts - Node lookup → Prisma service: queries through
src/domain/node-content/repository/node-content.repository.ts - Attachment repository → Prisma service: queries through
src/domain/file-attachment/repository/file-attachment.repository.ts - Attachment repository → Relational database: reads and writes
- Prisma service → Relational database: accesses database
- File attachment service → Attachment repository: delegates storage
src/domain/file-attachment/service/file-attachment.service.ts - File attachment service → Object storage: uses object storage
- Event bus subscriber → API or socket client: subscribes externally