Skip to content

VictorAzizJ/mediator

Repository files navigation

Mediator

A structured conversation platform for emotionally difficult dialogues. Originally designed for families, now production-ready for enterprise teams β€” HR departments, managers, and workplace conflict resolution.

Vision

B2C (Free): A safe space for family conversations β€” structured turn-taking, trigger detection, and trauma-informed design.

B2B (Enterprise): Professional tools for HR teams, 1-on-1 check-ins, and conflict resolution β€” observer modes, compliance logging, and team health analytics.

v0 Release (Jan 2025): Production-ready for organizations with full analytics, transcription, and enterprise landing page.


Current Status

What's Built & Working

Feature Status Last Updated
Core Conversation
Turn-taking with configurable duration (60/90/120s) βœ… Working Jan 2025
Session creation/joining (6-char codes) βœ… Working Dec 2024
Real-time sync via Socket.io βœ… Working Dec 2024
Volume monitoring with auto-pause βœ… Working Dec 2024
Breathing exercise (synced, skippable) βœ… Working Jan 2025
Round control (unlimited/3/5) βœ… Working Jan 2025
End conversation button βœ… Working Jan 2025
Security & Reliability
Redis session persistence βœ… Working Dec 2024
Session reconnection βœ… Working Dec 2024
Zod input validation βœ… Working Dec 2024
Rate limiting (join: 10/min, create: 5/min) βœ… Working Dec 2024
Secure session codes (crypto) βœ… Working Dec 2024
Privacy consent flow βœ… Working Jan 2025
Microphone permission flow βœ… Working Jan 2025
Error boundaries βœ… Working Jan 2025
B2B Features
Observer mode βœ… Working Jan 2025
Admin dashboard βœ… Working Jan 2025
Check-in templates (10 workplace scenarios) βœ… Working Jan 2025
Speaking time tracking βœ… Working Jan 2025
PDF export βœ… Working Jan 2025
Audit logging βœ… Working Jan 2025
v0 Features
Real-time transcription (Deepgram) βœ… Ready Jan 2025
Speaker diarization βœ… Ready Jan 2025
Conversation health analytics βœ… Ready Jan 2025
User analytics dashboard βœ… Ready Jan 2025
Enterprise landing page βœ… Ready Jan 2025

Architecture

Tech Stack

  • Frontend: Next.js 16, React 19, TypeScript, Tailwind CSS, Framer Motion
  • Backend: Socket.io, Redis (optional fallback to in-memory)
  • AI: Claude API (Anthropic) with local fallbacks
  • Transcription: Deepgram API (Nova-2 with diarization)
  • State: Zustand
  • Validation: Zod schemas
  • Security: Node.js crypto module, rate limiting

System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      CLIENT LAYER                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚   Next.js App                        Web Audio API          β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚   β”‚ React Componentsβ”‚               β”‚ Volume Monitor  β”‚    β”‚
β”‚   β”‚ Zustand Store   β”‚               β”‚ Audio Streaming β”‚    β”‚
β”‚   β”‚ Socket.io Clientβ”‚               β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚             β”‚
β”‚            β”‚                                 β”‚             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚                                 β”‚
             β–Ό                                 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      SERVER LAYER                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚   Socket.io Server          Next.js API           Deepgram  β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚   β”‚ Session Mgmt    β”‚      β”‚ /ai/trigger   β”‚    β”‚ Nova-2 β”‚ β”‚
β”‚   β”‚ Turn Control    β”‚      β”‚ /ai/summarize β”‚    β”‚ WSS    β”‚ β”‚
β”‚   β”‚ Audit Logging   β”‚      β”‚ /ai/prompt    β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚   β”‚ Rate Limiting   β”‚      β”‚ /transcriptionβ”‚               β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
β”‚            β”‚                                               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚
             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      DATA LAYER                             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚   Redis (Sessions)         PostgreSQL (Analytics)          β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚
β”‚   β”‚ TTL: 24 hours   β”‚      β”‚ Metrics         β”‚             β”‚
β”‚   β”‚ Session State   β”‚      β”‚ Audit Logs      β”‚             β”‚
β”‚   β”‚ Participant Dataβ”‚      β”‚ Team Health     β”‚             β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚
β”‚                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Features

Core Conversation Tools

  • Structured Turn-Taking: Configurable timers (60/90/120s) with visual cues
  • Real-Time Volume Monitoring: Gentle alerts when voices rise
  • Trigger Detection: AI-powered detection of blame language and escalation
  • Reflection Prompts: Thoughtful prompts for perspective-taking
  • Breathing Exercises: 4-7-8 breathing with sync (can be skipped)
  • Conversation Summaries: Neutral, AI-generated summaries with private notes

B2B Enterprise Features

  • Observer Mode: HR/coaches can observe with participant consent
  • Check-in Templates: 10 pre-built workplace scenarios (1-on-1s, conflict resolution, performance)
  • Speaking Time Analytics: Visual % split with balance tracking
  • PDF Export: Compliance-ready documentation
  • Admin Dashboard: Session management and team oversight
  • Audit Logging: Complete activity trail for compliance

v0 Analytics Stack

  • Conversation Health Scoring: Balance, regulation, engagement, safety metrics
  • Real-Time Transcription: Deepgram Nova-2 with speaker diarization
  • Trend Analysis: Track improvement over time
  • Coaching Insights: AI-generated personalized recommendations
  • Role-Based Access: Individuals see their data, managers see aggregates

Security & Privacy

  • Redis Session Persistence: 24-hour TTL with secure fallback
  • Cryptographic Security: crypto.randomBytes for all tokens
  • Input Validation: Zod schemas on all socket events
  • Rate Limiting: Brute-force protection
  • Privacy Consent Flow: GDPR-aligned opt-in
  • Audit Trail: Immutable logging for compliance

Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn
  • Redis (optional)

Installation

git clone <repo>
cd mediator
npm install
cp .env.local.example .env.local

Environment Variables

# Required
NEXT_PUBLIC_SOCKET_URL=http://localhost:3001
SOCKET_PORT=3001

# AI Features (optional but recommended)
ANTHROPIC_API_KEY=your_anthropic_key

# Transcription (optional)
DEEPGRAM_API_KEY=your_deepgram_key

# Session Storage (optional, falls back to in-memory)
REDIS_URL=redis://localhost:6379

# Production
NEXT_PUBLIC_APP_URL=https://mediator.app
NODE_ENV=production

Running the App

# Run both servers (recommended)
npm run dev:all

# Or separately:
npm run dev        # Next.js on :3000
npm run dev:socket # Socket.io on :3001

URLs

Route Purpose
/ Enterprise marketing landing page
/demo Full conversation app (code-protected: MEDIATOR2025)
/admin Admin dashboard
/observer Observer join page

Project Structure

src/
β”œβ”€β”€ app/                      # Next.js app directory
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ ai/              # Claude AI endpoints
β”‚   β”‚   └── transcription/   # Deepgram token endpoint
β”‚   β”œβ”€β”€ admin/               # Admin dashboard page
β”‚   β”œβ”€β”€ demo/                # Code-protected conversation app
β”‚   β”œβ”€β”€ observer/            # Observer join page
β”‚   └── page.tsx             # Enterprise landing page
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ admin/               # Admin dashboard components
β”‚   β”œβ”€β”€ analytics/           # Health scores, trends, insights
β”‚   β”œβ”€β”€ breathing/           # Breathing exercise
β”‚   β”œβ”€β”€ conversation/        # Main screens
β”‚   β”œβ”€β”€ observer/            # Observer mode components
β”‚   β”œβ”€β”€ onboarding/          # Privacy, mic permissions
β”‚   β”œβ”€β”€ templates/           # Check-in template selector
β”‚   β”œβ”€β”€ transcription/       # Real-time transcript UI
β”‚   └── ui/                  # Reusable components
β”œβ”€β”€ hooks/
β”‚   β”œβ”€β”€ useSocket.ts         # Socket.io management
β”‚   β”œβ”€β”€ useVolumeMonitor.ts  # Microphone volume
β”‚   └── useTranscription.ts  # Deepgram transcription
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ ai.ts                # AI helpers with fallbacks
β”‚   β”œβ”€β”€ analytics.ts         # Metrics calculations
β”‚   β”œβ”€β”€ deepgram.ts          # Transcription client
β”‚   β”œβ”€β”€ checkInTemplates.ts  # B2B templates
β”‚   └── pdfExport.ts         # PDF generation
β”œβ”€β”€ store/
β”‚   └── session.ts           # Zustand state
└── types/
    └── index.ts             # TypeScript definitions

server.js                    # Socket.io server
V0-IMPLEMENTATION-PLAN.md    # Detailed v0 specs
ROADMAP.md                   # Feature roadmap

B2B Use Cases

Use Case Template Target Buyer
Weekly 1-on-1s weekly-1on1 Managers, HR
Conflict Resolution conflict-resolution HR, Employee Relations
Performance Check-ins performance-review Managers, HR
Stay Interviews stay-interview HR, Retention Teams
Project Retrospectives project-retro Engineering Managers
Feedback Exchange feedback-exchange Teams, Peers
Career Development career-development Managers, L&D
Onboarding Check-ins onboarding-checkin Managers, HR
Return from Leave return-from-leave HR, Managers
Difficult Conversations difficult-conversation HR, Managers

Analytics Metrics

Conversation Health Score (0-100)

Metric Weight Description
Communication Balance 25% Equal speaking time distribution
Emotional Regulation 30% Pause usage, trigger response
Engagement Depth 20% Turn duration, reflection engagement
Safety Indicator 25% Completion rate, trigger patterns

Role-Based Access

Role Can See
Individual Own metrics, own transcripts, personal trends
Manager Team aggregates, anonymized patterns
HR Admin Org-wide health, department comparisons

Design Principles

Trauma-Informed UX

  • Soft colors, no harsh reds
  • Invitational language ("Would you like to...")
  • Always-visible exit options
  • Reduced motion support
  • Non-punitive framing

Privacy First

  • Audio processed in real-time, never stored (unless transcription enabled)
  • Private notes never synced to partner
  • Individual metrics private by default
  • Aggregation before sharing up the chain

B2B Professional Tone

  • Workplace-appropriate language
  • Consent-based observation
  • Compliance-ready logging
  • Growth-oriented analytics (not surveillance)

Deployment Checklist

Pre-Production

  • SSL/TLS certificates configured
  • CORS restricted to production domains
  • Rate limiting tuned
  • Redis instance configured
  • Environment variables set
  • Error tracking (Sentry) configured

Production

  • Load testing completed
  • Accessibility audit passed
  • Privacy policy published
  • Terms of service published
  • Cookie consent implemented

Contributing

See ROADMAP.md for detailed task breakdowns and V0-IMPLEMENTATION-PLAN.md for v0 specifications.

License

MIT

About

A safe space for difficult conversations - guided family mediation tool with AI support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors