How marcelorayzen/rayzen-ai works
Purpose and topology
Rayzen AI is a TypeScript monorepo for a personal AI platform: semantic project memory, LLM-assisted work, controlled desktop execution, and evolving documentation. V1 is the active stack: Next.js UI, NestJS API, and local PC Agent. V2 is a separate mission-oriented backend with /v2 routes and an isolated Prisma schema.
• apps/web/app/page.tsx
• apps/api/src/main.ts
• apps/api-v2/src/main.ts
User/API entry boundary
The Next.js App Router client provides chat, project, graph, discovery, mission, and settings surfaces. Its API client and streaming/event hooks connect browser state to the V1 API over HTTP/SSE. V1 Nest bootstrap composes domain modules; authentication protects API access.
• apps/web/lib/api-client.ts
• apps/web/app/hooks/useChatStream.ts
• apps/api/src/app.module.ts
• apps/api/src/modules/auth/jwt-auth.guard.ts
V1 orchestration pipeline
The V1 orchestrator is the central control plane for user messages: validation precedes intent handling/routing and streamed responses, then invokes specialized modules. Work modes influence behavior; output/prompt validation forms a security boundary around LLM interaction.
• apps/api/src/modules/orchestrator/orchestrator.service.ts
• apps/api/src/modules/validation/validation.service.ts
• apps/api/src/modules/execution/execution.service.ts
Knowledge, memory, and project state
Persistent project context is modeled through memory, Brain ingestion/search, graph/knowledge-graph, project state, events, and wiki synthesis. Documents and conversations are embedded through Jina and stored/queryable in PostgreSQL with pgvector; this context feeds LLM requests and UI panels.
• apps/api/src/modules/memory/memory.service.ts
• apps/api/src/modules/brain/brain.service.ts
• apps/api/src/modules/graph/knowledge-graph.service.ts
• apps/api/prisma/schema.prisma
LLM and content-service boundary
Backend modules call provider-agnostic LLM services through LiteLLM. Specialized capabilities include document generation, content/diagram output, voice via Groq, and Notion synchronization. API modules own domain prompts and validation rather than exposing providers directly to the browser.
• apps/api/src/modules/orchestrator/orchestrator.service.ts
• apps/api/src/modules/document-processing/document-processing.service.ts
• apps/api/src/modules/voice/voice.service.ts
• infra/litellm/config.yaml
Remote execution and safety boundary
Execution creates queued work for the Node.js PC Agent; the agent polls Redis and dispatches only typed, allowlisted actions. Path guards, role policy, and dry-run behavior constrain filesystem, shell-adjacent, Docker, Git, and desktop actions. Agent results return through the API bridge/session model for presentation and auditability.
• apps/api/src/modules/agent-bridge/agent-bridge.service.ts
• apps/agent/src/poller.ts
• apps/agent/src/executor.ts
• apps/agent/src/security/whitelist.ts
V2 mission-engine track
V2 introduces missions composed of executable steps, routing, approval gates, policies, specialists/skills, knowledge governance, workflow scheduling, quality benchmarking, and observability. It is architecturally distinct from V1 but shares the platform’s PostgreSQL-based operational model.
• apps/api-v2/src/mission/mission.service.ts
• apps/api-v2/src/mission/step-executor.service.ts
• apps/api-v2/src/approval-gates/approval-gates.service.ts
• apps/api-v2/prisma/schema.prisma
Runtime and infrastructure
Primary runtimes are Node.js/TypeScript, Next.js, NestJS/Fastify, Docker Compose, PostgreSQL 16 + pgvector, Redis 7/BullMQ, and Prisma. LiteLLM fronts OpenAI/Groq/Anthropic-compatible LLM access; Jina supplies embeddings; optional integrations include Notion and Groq voice. Deployment is containerized behind Caddy/Cloudflare Tunnel infrastructure.
• docker-compose.yml
• infra/caddy/Caddyfile
• apps/api/Dockerfile
• apps/agent/Dockerfile.server
Main entry points: orchestrator.service.ts Orchestrator · main.ts V1 Nest API · poller.ts PC Agent poller · api-client.ts API client & streams
Components 21
Client
- Next.js UI · Chat, project, graph, discovery, mission, and settings surfaces.
apps/web/app/page.tsx - API client & streams
apps/web/lib/api-client.ts
V1 control plane
- V1 Nest API · Authenticated composition root for V1 domain modules.
apps/api/src/main.ts - JWT auth
apps/api/src/modules/auth/jwt-auth.guard.ts - Orchestrator · Validates, routes, streams, and coordinates specialized work.
apps/api/src/modules/orchestrator/orchestrator.service.ts - Prompt/output validation
apps/api/src/modules/validation/validation.service.ts
Knowledge services
- Memory & Brain · Embeds and retrieves documents and conversations.
apps/api/src/modules/brain/brain.service.ts - Knowledge graph
apps/api/src/modules/graph/knowledge-graph.service.ts - PostgreSQL + pgvector · Prisma-backed project, memory, graph, and conversation data.
apps/api/prisma/schema.prisma
Controlled execution
- Execution service
apps/api/src/modules/execution/execution.service.ts - Agent bridge · Returns execution results for presentation and auditability.
apps/api/src/modules/agent-bridge/agent-bridge.service.ts - Redis / BullMQ
- PC Agent poller · Polls queued work and dispatches typed actions.
apps/agent/src/poller.ts - Allowlist & guards · Constrains filesystem, shell, Docker, Git, and desktop actions.
apps/agent/src/security/whitelist.ts
V2 mission engine
- V2 Nest API · Separate `/v2` runtime and operational model.
apps/api-v2/src/main.ts - Mission service · Coordinates missions, routing, specialists, policies, and scheduling.
apps/api-v2/src/mission/mission.service.ts - Step executor · Runs executable mission steps through approval gates.
apps/api-v2/src/mission/step-executor.service.ts - Approval gates
apps/api-v2/src/approval-gates/approval-gates.service.ts - V2 PostgreSQL schema · Isolated Prisma schema for V2 data.
apps/api-v2/prisma/schema.prisma
Other components
- LiteLLM · Routes provider-agnostic LLM requests to compatible model providers.
infra/litellm/config.yaml - Jina
Connections 22
- Next.js UI → API client & streams: uses
- API client & streams → V1 Nest API: HTTP/SSE
- V1 Nest API → JWT auth: protects access
- V1 Nest API → Orchestrator: user messages
- Orchestrator → Prompt/output validation: validate input/output
- Orchestrator → Memory & Brain: retrieves context
- Orchestrator → Knowledge graph: project context
- Orchestrator → LiteLLM: LLM requests
- Orchestrator → Execution service: execution work
- Memory & Brain → Jina: embeddings
- Memory & Brain → PostgreSQL + pgvector: stores/searches vectors
- Knowledge graph → PostgreSQL + pgvector: persists graph
- Execution service → Redis / BullMQ: enqueue
- PC Agent poller → Redis / BullMQ: polls
- PC Agent poller → Allowlist & guards: authorizes actions
- PC Agent poller → Agent bridge: reports results
- Agent bridge → V1 Nest API: sessions/results
- API client & streams → V2 Nest API: /v2 HTTP
- V2 Nest API → Mission service: mission requests
- Mission service → Step executor: plans steps
- Step executor → Approval gates: requires approval
- Mission service → V2 PostgreSQL schema: persists missions