How valynt/valueos works
1. Repository shape
- This is a pnpm monorepo for ValueOS, a modular-monolith SaaS platform.
- The main production runtimes are:
- apps/ValyntApp — customer-facing web app
- packages/backend — Express API/runtime
- apps/mcp-dashboard — internal observability UI for MCP, not a customer product
- Shared libraries live under packages/*, while deploy/runtime definitions live under infra/, ops/, supabase/, and scripts/.
2. Primary user-facing flow
- Browser traffic lands in apps/ValyntApp, which is a React + Vite frontend.
- The frontend uses feature modules, route guards, and context providers to render customer workflows such as onboarding, value modeling, deal assembly, billing, settings, and executive outputs.
- It calls the backend API for authenticated reads/writes, then renders persisted state and generated artifacts back to the user.
3. Backend as the system hub
- packages/backend is the central application boundary.
- It exposes REST/route handlers plus tRPC-style APIs, and it owns:
- authentication/authorization enforcement
- tenant context resolution
- business workflows
- agent orchestration
- persistence and integrations
- billing/metering
- security and observability hooks
- The backend is organized into clear layers: api/, services/, runtime/, repositories/, middleware/, workers/, and lib/.
4. Domain and workflow core
- The core business domain is “value engineering” and is centered on value cases, value trees, ROI models, opportunities, hypotheses, evidence, and realization plans.
- The backend’s services/value, services/workflow, services/value-graph, services/trust, and services/integrity modules form the main business pipeline.
- Typical progression is: capture context → model value → run agents/workflows → validate trust/integrity → generate artifacts → persist results.
5. Agent fabric
- A major subsystem is the agent layer in packages/backend/src/lib/agent-fabric and related services/agents / services/value.
- The repo references an 11-agent fabric, including agents for opportunity, target, financial modeling, integrity, realization, expansion, narrative, compliance, discovery, context extraction, and deal assembly.
- Agent execution is not free-form: it is gated by secureInvoke, circuit breakers, Zod/schema validation, prompt registries, redaction, and policy checks.
- The agent system consumes structured domain state rather than relying on keyword-based prompting.
6. Data/storage boundary
- Supabase/Postgres is the primary system of record.
- The schema and security model are defined in infra/supabase/ with extensive migrations and rollback scripts.
- Row-level security is a first-class boundary: tenant isolation is enforced in the database, then reinforced in backend middleware and tests.
- Redis is used for cache, rate limiting, session/state support, queues/streams, and some distributed coordination.
- The backend’s repositories wrap all direct persistence access, keeping service code separated from table-level concerns.
7. Multi-tenancy and security model
- Tenant scope is a core architectural boundary across UI, API, and database layers.
- The platform uses Supabase Auth, JWT claims, RBAC, MFA/WebAuthn support, session controls, CSRF/CORS protections, and request auditing.
- Security logic appears in both packages/backend/src/security and packages/backend/src/middleware, plus Supabase RLS policies in the database layer.
- Many tests explicitly target cross-tenant leakage, spoofed headers, privilege escalation, and policy regressions.
8. Asynchronous and event-driven work
- The backend includes worker processes under packages/backend/src/workers for jobs such as billing aggregation, CRM sync, research ingestion, webhook retry, artifact generation, and workflow watchdog tasks.
- Messaging/queue abstractions exist in services/messaging, services/realtime, services/metering, and related runtime adapters.
- This means the architecture is not purely request/response; several business functions are completed asynchronously and then surfaced back to the UI through polling, realtime updates, or persisted workflow state.
9. Server-driven UI and shared presentation
- packages/sdui is a separate engine for server-driven UI rendering, component registry, schema validation, state hydration, and partial patching.
- The backend has matching SDUI services/adapters that generate schemas and action payloads for the frontend.
- This creates a boundary where backend can shape UI behavior and layout, while the client renders from a constrained component model.
- Shared UI primitives live in packages/components, which supports both the main app and reusable design-system surfaces.
10. MCP and external protocol layers
- packages/mcp and backend MCP services implement Model Context Protocol modules, especially CRM and ground-truth capabilities.
- These packages act as integration/protocol adapters rather than core product UI.
- The internal apps/mcp-dashboard is an operational surface for observing and managing this layer.
- These pieces matter to the architecture because they separate external tool/protocol access from the main customer workflow path.
11. Integrations and external systems
- Third-party systems are handled through dedicated adapters in packages/integrations and backend service modules.
- The repo includes CRM support such as HubSpot and Salesforce, plus webhooks, OAuth callbacks, and connection management.
- External data sources also appear in the “ground-truth” and “memory” subsystems, where SEC/market/benchmark style inputs are ingested, cached, and reused for agent reasoning.
12. Platform and deployment
- The deployment model is Kubernetes-first with blue/green support, HPA, network policies, and zero-trust security controls.
- Infrastructure code lives in infra/k8s, infra/terraform, and infra/observability, with Supabase schema management under infra/supabase.
- Observability is production-grade: OpenTelemetry, Prometheus, Grafana, Loki/Tempo-style tracing/logging, plus extensive CI gates and policy checks.
- ops/ and top-level scripts/ provide local/dev/staging/production orchestration, validation, migrations, and release automation.
13. How to draw the architecture
- A good diagram should show:
- browser clients → ValyntApp
- ValyntApp → backend API
- backend API → domain services/runtime/agents
- backend → Supabase/Postgres, Redis, and external services
- backend → workers/queues for async jobs
- backend ↔ SDUI engine for schema-driven UI
- backend ↔ MCP/integration adapters for CRM and ground-truth tools
- infrastructure/observability/security as cross-cutting platform layers
- Keep the main conceptual boundary as: presentation in apps/ValyntApp, orchestration and business logic in packages/backend, state in Supabase/Redis, and execution/integration in workers, agents, and adapters.
Main entry points: backend Backend · services Domain Services · workers Workers · migrations Supabase DB
Components 19
Applications
Customer-facing and internal runtimes
- ValyntApp · Primary customer web app for value-engineering workflows
apps/ValyntApp - MCP Dashboard · Internal observability surface for MCP and protocol workflows
apps/mcp-dashboard
Shared Packages
Reusable platform, UI, protocol, and domain packages
- Backend · Central API and orchestration boundary
packages/backend - SDUI Engine · Server-driven UI schema, registry, hydration, and patching
packages/sdui - Design System · Shared presentation primitives used across apps
packages/components/design-system/src - Shared Domain · Cross-package domain types, contracts, and utilities
packages/shared/src - Integrations · CRM and third-party system adapters
packages/integrations - MCP Packages · Model Context Protocol CRM and ground-truth packages
packages/mcp - Memory · Shared memory, provenance, semantic, and lifecycle primitives
packages/memory - Workers · Background job runtime for billing, CRM sync, artifacts, and watchdog tasks
packages/backend/src/workers - API Layer · REST, route handlers, and typed API entrypoints
packages/backend/src/api - Domain Services · Value, workflow, trust, integrity, billing, auth, and integrations services
packages/backend/src/services - Runtime Core · Execution runtime, policy engine, adapters, and decision routing
packages/backend/src/runtime - Agent Fabric · Secure agent execution, prompt registry, routing, redaction, and circuit breakers
packages/backend/src/lib/agent-fabric - Value Graph · Value-case, ROI, trust, integrity, and artifact pipeline
packages/backend/src/services/value-graph
Platform
Infrastructure, database, observability, and operations
- Supabase DB · System of record with auth, RLS, and migrations
infra/supabase/supabase/migrations - Redis · Cache, rate limiting, sessions, and queue coordination
infra/k8s/base/redis-streams.yaml - K8s Runtime · Blue/green, HPA, network policy, and service orchestration
infra/k8s - Observability · Tracing, logging, alerting, and dashboards
infra/observability
Connections 28
- ValyntApp → Backend: authenticated API calls · Customer UI reads and writes domain state through backend APIs
- ValyntApp → SDUI Engine: renders schemas · Client renders constrained server-driven UI output
- ValyntApp → Design System: shared UI · Uses shared design-system primitives and reusable surfaces
- MCP Dashboard → Backend: ops API · Internal dashboard consumes backend and MCP operational data
- Backend → API Layer: exposes · REST and typed entrypoints are surfaced through the API layer
- Backend → Domain Services: orchestrates · Business workflows and integrations are implemented in domain services
- Backend → Runtime Core: executes · Workflow execution and policy enforcement use runtime components
- Backend → Agent Fabric: runs agents · Agent invocation is mediated through the secure agent fabric
- Backend → Value Graph: value pipeline · Core value-case and graph workflows are handled here
- Backend → Workers: async jobs · Long-running and retryable jobs are offloaded to workers
- Backend → Supabase DB: persists state · Postgres/Supabase is the system of record
- Backend → Redis: cache and queues · Redis backs caching, sessions, rate limiting, and queues
- Domain Services → Value Graph: domain flow · Value modeling, trust, integrity, and artifacts are composed into the main pipeline
- Domain Services → Integrations: connectors · CRM and external systems are accessed through adapter packages
- Domain Services → MCP Packages: protocol bridge · MCP capabilities are exposed via dedicated protocol adapters
- Domain Services → Memory: shared context · Semantic and provenance memory support service reasoning
- Runtime Core → Supabase DB: RLS-backed state · Runtime reads and writes are validated against the database boundary
- Runtime Core → Redis: coordination · Execution coordination and transient workflow state use Redis
- Agent Fabric → Memory: context store · Agents consume and persist structured context and provenance
- Agent Fabric → Supabase DB: durable facts · Agent state and lineage are persisted in Postgres
- Workers → Redis: consumes queues · Workers process queued and streamed background tasks
- Workers → Supabase DB: job output · Completed jobs persist artifacts and workflow state to the database
- Supabase DB → Observability: audit signals · Database, auth, and RLS events surface into monitoring and audit flows
- K8s Runtime → Backend: deploys · Kubernetes runs the backend service and its replicas
- K8s Runtime → Workers: deploys · Worker processes are scheduled separately in the cluster
- K8s Runtime → MCP Dashboard: deploys · Internal dashboard is also hosted in the Kubernetes runtime
- Observability → Backend: watches · Tracing, metrics, and alerts cover API and service behavior
- Observability → Workers: watches · Background jobs are monitored through the same platform telemetry