S
SalesOS

System Architecture

SalesOS is built as multi-tenant AI infrastructure for sales skill intelligence — not a chat toy, but a structured feedback and measurement system.

AI Orchestration Layer

Claude API
Simulation Engine

Claude claude-sonnet-4-6 acting as enterprise buyer personas. System prompts enforce role, difficulty, objection style. Context window maintains session memory.

Structured Output
Scoring Engine

Separate Claude instance analyzes rep transcript. Outputs structured JSON against 5 skill dimensions. Validated with Zod schema before storage.

Guardrails
Prompt Guardrails

System prompts prevent buyer from being helpful, maintain character, enforce response length, simulate real objection patterns.

Data & Security Layer

Organization Isolation

Row Level Security (RLS) enforced at the database layer via Supabase PostgreSQL policies. Each organization has hard data boundaries — reps can only see their own sessions, managers can only see their org's team data.

-- Session isolation policy
SELECT * FROM sessions
WHERE user_id = auth.uid()
-- or manager org check

Structured Output Enforcement

Scoring responses are validated against a strict Zod schema before being accepted. Malformed or incomplete JSON is rejected — ensuring data integrity across all skill dimensions.

// Score validation
ScoreSchema.parse(response)
→ discovery: 0-10
→ objection_handling: 0-10
→ ... 5 dimensions total

Database Schema

organizations
id
name
created_at
users
id
name
email
role
organization_id
personas
id
title
industry
buyer_role
difficulty
personality_traits
objection_style
sessions
id
user_id
persona_id
transcript (JSON)
scores (JSON)

API Layer

POST/api/auth/setupCreates organization + user profile on signup (service role)
POST/api/sessionsCreates new simulation session, returns session ID
POST/api/chatSends message to Claude buyer, updates transcript in DB
POST/api/scoreAnalyzes full transcript, validates JSON score, saves to DB
POST/api/personasManager-only: creates custom buyer persona for org

Technology Stack

Frontend
Next.js 14 (App Router), TypeScript, Tailwind CSS
AI
Anthropic Claude claude-sonnet-4-6 via official SDK
Database
PostgreSQL via Supabase with Row Level Security
Auth
Supabase Auth (email/password) with SSR session management
Validation
Zod schema validation on all AI structured outputs
Charts
Recharts (Radar, Bar) for skill analytics visualization