# yugantargrowth-cmyk/thalos architecture

> Architecture diagram of the GitHub repository yugantargrowth-cmyk/thalos, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yugantargrowth-cmyk/thalos
- Repository: https://github.com/yugantargrowth-cmyk/thalos

## Overview

THALOS is an agentic business operating system: a founder submits requests to an authenticated API, where intelligence routing and agent delegation can invoke permitted tools and business services. Separate product branches handle CRM, finance, knowledge ingestion/search, approvals, integrations, and durable background jobs. The README documents the main architecture and capabilities; source excerpts confirm selected call paths. Several route and worker details are unsampled, so their internal links are omitted where not evidenced.

Main entry points: [`src/api/app.ts`](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/app.ts) (Express app), [`src/lib/supabase.ts`](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/lib/supabase.ts) (Supabase database), [`src/persistence/ingestionQueue.ts`](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/persistence/ingestionQueue.ts) (Document ingestion), [`src/business/crmService.ts`](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/business/crmService.ts) (CRM lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_server["API server<br/>[server.ts]"]
  node_app["Express app<br/>[app.ts]"]
  node_middleware["Request middleware<br/>[errorHandler.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_intelligence_route["Intelligence API<br/>[intelligence.ts]"]
  node_finance_route["Finance API<br/>[finance.ts]"]
  node_crm_route["Client API<br/>[clients.ts]"]
  node_knowledge_route["Knowledge API<br/>[knowledge.ts]"]
  node_integrations_route["Integrations API<br/>[integrations.ts]"]
end

subgraph group_intelligence["Agent intelligence"]
  node_orchestrator["Intent orchestrator<br/>[orchestrator.ts]"]
  node_agents["Agent runtime<br/>[agentService.ts]"]
  node_llm["LLM providers<br/>[llmClient.ts]"]
  node_tool_dispatch["Tool dispatcher<br/>[toolDispatcher.ts]"]
end

subgraph group_business["Business operations"]
  node_crm["CRM lifecycle<br/>[crmService.ts]"]
  node_finance["Finance services<br/>[financeService.ts]"]
  node_pdf["Proposal PDFs<br/>[pdfBuilder.ts]"]
end

subgraph group_data["Persistence and jobs"]
  node_knowledge["Knowledge search<br/>[ragSearch.ts]"]
  node_ingestion["Document ingestion<br/>[ingestionQueue.ts]"]
  node_documents["Document repository"]
  node_worker["Job worker<br/>[worker.ts]"]
  node_supabase[("Supabase database<br/>[supabase.ts]")]
  node_vault["Credential vault<br/>[vault.ts]"]
  node_audit["Audit log<br/>[audit.ts]"]
end

node_founder(("Founder"))

node_founder -->|"sends requests"| node_server
node_server -->|"starts"| node_app
node_app -->|"applies"| node_middleware
node_app -->|"mounts"| node_auth
node_app -->|"routes requests"| node_intelligence_route
node_app -->|"mounts"| node_finance_route
node_app -->|"mounts"| node_crm_route
node_app -->|"mounts"| node_knowledge_route
node_app -->|"mounts"| node_integrations_route
node_intelligence_route -->|"delegates"| node_orchestrator
node_orchestrator -->|"delegates tasks"| node_agents
node_orchestrator -->|"calls model"| node_llm
node_agents -->|"requests completion"| node_llm
node_agents -->|"executes tools"| node_tool_dispatch
node_tool_dispatch -->|"dispatches tools"| node_crm
node_finance_route -->|"calls services"| node_finance
node_finance -->|"builds documents"| node_pdf
node_crm_route -->|"calls service"| node_crm
node_knowledge_route -.->|"serves search"| node_knowledge
node_worker -->|"processes jobs"| node_ingestion
node_ingestion -->|"generates embeddings"| node_llm
node_ingestion -->|"updates chunks"| node_documents
node_ingestion -->|"queues jobs"| node_supabase
node_crm -->|"reads and writes"| node_supabase
node_crm -->|"records events"| node_audit
node_integrations_route -->|"encrypts credentials"| node_vault
node_integrations_route -->|"stores integration data"| node_supabase
node_audit -->|"inserts audit records"| node_supabase
node_documents -->|"stores documents"| node_supabase

click node_server "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/server.ts"
click node_app "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/app.ts"
click node_middleware "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/middleware/errorHandler.ts"
click node_auth "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/routes/auth.ts"
click node_intelligence_route "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/routes/intelligence.ts"
click node_finance_route "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/routes/finance.ts"
click node_crm_route "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/routes/clients.ts"
click node_knowledge_route "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/routes/knowledge.ts"
click node_integrations_route "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/routes/integrations.ts"
click node_orchestrator "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/intelligence/orchestrator.ts"
click node_agents "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/intelligence/agentService.ts"
click node_llm "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/intelligence/llmClient.ts"
click node_tool_dispatch "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/execution/toolDispatcher.ts"
click node_crm "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/business/crmService.ts"
click node_finance "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/business/financeService.ts"
click node_pdf "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/business/proposals/pdfBuilder.ts"
click node_knowledge "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/persistence/ragSearch.ts"
click node_ingestion "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/persistence/ingestionQueue.ts"
click node_documents "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/persistence/repositories/documentRepository.ts"
click node_worker "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/worker/worker.ts"
click node_supabase "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/lib/supabase.ts"
click node_vault "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/lib/vault.ts"
click node_audit "https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/lib/audit.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_server,node_app,node_middleware,node_auth,node_intelligence_route,node_finance_route,node_crm_route,node_knowledge_route,node_integrations_route toneBlue
class node_orchestrator,node_agents,node_llm,node_tool_dispatch toneAmber
class node_crm,node_finance,node_pdf toneMint
class node_knowledge,node_ingestion,node_documents,node_worker,node_supabase,node_vault,node_audit toneRose
class node_founder toneIndigo
```

## Components

### API and access

- [API server](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/server.ts): `src/api/server.ts`
- [Express app](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/app.ts): `src/api/app.ts`
- [Request middleware](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/middleware/errorHandler.ts): `src/api/middleware/errorHandler.ts`
- [Authentication](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/routes/auth.ts): `src/api/routes/auth.ts`
- [Intelligence API](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/routes/intelligence.ts): `src/api/routes/intelligence.ts`
- [Finance API](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/routes/finance.ts): `src/api/routes/finance.ts`
- [Client API](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/routes/clients.ts): `src/api/routes/clients.ts`
- [Knowledge API](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/routes/knowledge.ts): `src/api/routes/knowledge.ts`
- [Integrations API](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/api/routes/integrations.ts): `src/api/routes/integrations.ts`

### Agent intelligence

- [Intent orchestrator](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/intelligence/orchestrator.ts): `src/intelligence/orchestrator.ts`
- [Agent runtime](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/intelligence/agentService.ts): `src/intelligence/agentService.ts`
- [LLM providers](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/intelligence/llmClient.ts): `src/intelligence/llmClient.ts`
- [Tool dispatcher](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/execution/toolDispatcher.ts): `src/execution/toolDispatcher.ts`

### Business operations

- [CRM lifecycle](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/business/crmService.ts): `src/business/crmService.ts`
- [Finance services](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/business/financeService.ts): `src/business/financeService.ts`
- [Proposal PDFs](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/business/proposals/pdfBuilder.ts): `src/business/proposals/pdfBuilder.ts`

### Persistence and jobs

- [Knowledge search](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/persistence/ragSearch.ts): `src/persistence/ragSearch.ts`
- [Document ingestion](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/persistence/ingestionQueue.ts): `src/persistence/ingestionQueue.ts`
- [Document repository](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/persistence/repositories/documentRepository.ts): `src/persistence/repositories/documentRepository.ts`
- [Job worker](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/worker/worker.ts): `src/worker/worker.ts`
- [Supabase database](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [Credential vault](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/lib/vault.ts): `src/lib/vault.ts`
- [Audit log](https://github.com/yugantargrowth-cmyk/thalos/blob/main/src/lib/audit.ts): `src/lib/audit.ts`

### Other components

- **Founder**

## Connections

- Founder → API server: sends requests
- API server → Express app: starts (evidence: `src/api/server.ts`)
- Express app → Request middleware: applies (evidence: `src/api/app.ts`)
- Express app → Authentication: mounts (evidence: `src/api/app.ts`)
- Express app → Intelligence API: routes requests (evidence: `src/api/app.ts`)
- Express app → Finance API: mounts (evidence: `src/api/app.ts`)
- Express app → Client API: mounts (evidence: `src/api/app.ts`)
- Express app → Knowledge API: mounts (evidence: `src/api/app.ts`)
- Express app → Integrations API: mounts (evidence: `src/api/app.ts`)
- Intelligence API → Intent orchestrator: delegates (evidence: `src/api/routes/intelligence.ts`)
- Intent orchestrator → Agent runtime: delegates tasks (evidence: `src/intelligence/orchestrator.ts`)
- Intent orchestrator → LLM providers: calls model (evidence: `src/intelligence/orchestrator.ts`)
- Agent runtime → LLM providers: requests completion (evidence: `src/intelligence/agentService.ts`)
- Agent runtime → Tool dispatcher: executes tools (evidence: `src/intelligence/agentService.ts`)
- Tool dispatcher → CRM lifecycle: dispatches tools (evidence: `src/execution/toolDispatcher.ts`)
- Finance API → Finance services: calls services (evidence: `src/api/routes/finance.ts`)
- Finance services → Proposal PDFs: builds documents (evidence: `src/business/financeService.ts`)
- Client API → CRM lifecycle: calls service (evidence: `src/api/routes/clients.ts`)
- Knowledge API → Knowledge search: serves search
- Job worker → Document ingestion: processes jobs (evidence: `src/worker/worker.ts`)
- Document ingestion → LLM providers: generates embeddings (evidence: `src/persistence/ingestionQueue.ts`)
- Document ingestion → Document repository: updates chunks (evidence: `src/persistence/ingestionQueue.ts`)
- Document ingestion → Supabase database: queues jobs (evidence: `src/persistence/ingestionQueue.ts`)
- CRM lifecycle → Supabase database: reads and writes (evidence: `src/business/crmService.ts`)
- CRM lifecycle → Audit log: records events (evidence: `src/business/crmService.ts`)
- Integrations API → Credential vault: encrypts credentials (evidence: `src/api/routes/integrations.ts`)
- Integrations API → Supabase database: stores integration data (evidence: `src/api/routes/integrations.ts`)
- Audit log → Supabase database: inserts audit records (evidence: `src/lib/audit.ts`)
- Document repository → Supabase database: stores documents (evidence: `src/persistence/repositories/documentRepository.ts`)
