Skip to content

aminmomin2/convocate

Repository files navigation

Convocate 🤖

AI-Powered Digital Twin Platform for Realistic Conversation Practice

Convocate is a sophisticated Next.js application that creates AI-powered digital twins from real chat conversations. It analyzes communication patterns, personality traits, and writing styles to generate lifelike AI personas that respond exactly like the original person. Perfect for sales training, difficult conversation practice, and personal development.

🚀 Live Demo

Try Convocate Live

✨ Key Features

🎯 Digital Twin Creation

  • Multi-Format Support: Import conversations from WhatsApp, CSV, JSON, and SMS backup formats
  • Advanced AI Analysis: GPT-5 powered personality profiling with 15+ behavioral dimensions
  • Style Matching: Captures tone, formality, pacing, vocabulary, and unique communication quirks
  • Context Awareness: Maintains conversation context and relationship dynamics

💬 Interactive Practice

  • Real-time Chat: Natural conversation flow with streaming responses
  • Performance Scoring: AI-powered feedback on communication effectiveness
  • Style Improvement Tips: Actionable suggestions for better conversation skills
  • Usage Tracking: Built-in rate limiting and usage monitoring

🔒 Privacy & Security

  • Client-Side Processing: All data processing happens in your browser
  • No Cloud Storage: Personas stored locally in localStorage
  • Rate Limiting: Built-in protection against abuse
  • Data Control: Complete control over your conversation data

🏗️ Architecture Overview

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   Frontend      │    │   API Routes    │    │   AI Services   │
│   (Next.js)     │◄──►│   (Next.js)     │◄──►│   (OpenAI)      │
└─────────────────┘    └─────────────────┘    └─────────────────┘
         │                       │                       │
         │                       │                       │
         ▼                       ▼                       ▼
┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   Components    │    │   File Parsing  │    │   GPT-5 Mini    │
│   (React)       │    │   (Multi-format)│    │   (Personality) │
└─────────────────┘    └─────────────────┘    └─────────────────┘
         │                       │                       │
         │                       │                       │
         ▼                       ▼                       ▼
┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   LocalStorage  │    │   Rate Limiting │    │   Style Profiles│
│   (Personas)    │    │   (In-Memory)   │    │   (JSON Schema) │
└─────────────────┘    └─────────────────┘    └─────────────────┘

Technology Stack

Layer Technology Purpose
Frontend Next.js 15 + React 19 Modern React framework with App Router
Styling Tailwind CSS 4 Utility-first CSS framework
UI Components Radix UI + Custom Reusable System Accessible, consistent components
Type Safety TypeScript 5 Static type checking and IntelliSense
AI Integration OpenAI GPT-5 Mini Advanced language model for personality analysis
File Processing PapaParse + xml2js Multi-format chat export parsing
State Management React Hooks + localStorage Client-side state persistence
API Next.js API Routes Serverless API endpoints

🎨 Component Architecture

Reusable Component System

Convocate features a comprehensive, production-ready reusable component system designed for consistency, maintainability, and developer experience.

Core UI Components (8 total)

  1. Tag - Replaces repetitive tag/badge patterns (9 colors, 3 sizes)
  2. IconLabel - Standardizes icon + text combinations (3 sizes, 3 variants)
  3. Container - Layout containers with consistent spacing (5 sizes, 5 padding options)
  4. Stack - Flex layout patterns (HStack, VStack, Center variants)
  5. LoadingSkeleton - Unified loading system (7 variants, specialized components)
  6. ErrorMessage - Standardized error handling (3 variants, retry/dismiss)
  7. Avatar - Consistent avatar system (6 sizes, status indicators)
  8. StatusIndicator - Status states throughout the app (7 types, 3 sizes)

Benefits Achieved

  • ~11% code reduction across migrated components
  • 20+ repetitive patterns eliminated
  • 100% consistency in similar patterns
  • Better maintainability - changes in one place affect everywhere
  • Improved developer experience - faster development with reusable patterns

Usage Examples

// Before: Repetitive patterns
<span className="text-xs bg-blue-100 text-blue-700 rounded px-2 py-1">
<div className="flex items-center text-xs font-medium text-muted-foreground">
  <Lightbulb className="w-3 h-3 mr-1" />
  Positive Triggers
</div>

// After: Clean, reusable components
<Tag variant="blue" size="sm">Emotion</Tag>
<IconLabel icon={<Lightbulb className="w-3 h-3" />} size="sm" variant="muted">
  Positive Triggers
</IconLabel>

Core Application Components

ChatWindow.tsx

Main chat interface component with streaming responses and real-time scoring.

Key Features:

  • Streaming message display
  • Typing indicators
  • Error handling with reusable ErrorMessage component
  • Sample prompts
  • Message history persistence

FileUploadDropbox.tsx

Drag-and-drop file upload with multi-format support.

Supported Formats:

  • WhatsApp TXT exports
  • CSV with headers
  • JSON message arrays
  • SMS Backup XML

PersonaSelector.tsx

Persona selection and management interface with consistent styling using reusable components.

ScorePanel.tsx

Real-time performance scoring and improvement tips with unified loading states.

🛠️ Installation & Setup

Prerequisites

  • Node.js 18+ (LTS recommended)
  • npm or yarn package manager
  • OpenAI API Key (GPT-5 Mini access required)

Quick Start

  1. Clone the repository

    git clone https://github.com/aminmomin2/convocate.git
    cd convocate
  2. Install dependencies

    npm install
    # or
    yarn install
  3. Configure environment variables

    cp env.example .env.local

    Edit .env.local:

    OPENAI_API_KEY=your_openai_api_key_here
  4. Start development server

    npm run dev
    # or
    yarn dev
  5. Open your browser Navigate to http://localhost:3000

Production Deployment

Vercel (Recommended)

npm run build
vercel --prod

Docker

docker build -t convocate .
docker run -p 3000:3000 -e OPENAI_API_KEY=your_key convocate

📁 Project Structure

convocate/
├── src/
│   ├── app/                    # Next.js App Router
│   │   ├── api/               # API Routes
│   │   │   ├── chat/          # Chat completion endpoint
│   │   │   ├── score/         # Style scoring endpoint
│   │   │   └── upload/        # File upload & persona creation
│   │   ├── dashboard/         # Dashboard pages
│   │   │   └── [personaId]/   # Dynamic persona chat pages
│   │   ├── layout.tsx         # Root layout component
│   │   └── page.tsx           # Landing page
│   ├── components/            # React components
│   │   ├── ui/               # Reusable UI component system
│   │   │   ├── tag.tsx       # Tag/badge component
│   │   │   ├── icon-label.tsx # Icon + text component
│   │   │   ├── container.tsx # Layout containers
│   │   │   ├── stack.tsx     # Flex layout patterns
│   │   │   ├── loading-skeleton.tsx # Loading states
│   │   │   ├── error-message.tsx # Error handling
│   │   │   ├── avatar.tsx    # Avatar system
│   │   │   └── status-indicator.tsx # Status states
│   │   ├── layout/           # Layout components
│   │   ├── chat/             # Chat interface components
│   │   ├── dashboard/        # Dashboard components
│   │   └── landing/          # Landing page components
│   ├── lib/                  # Shared libraries
│   │   ├── openai.ts         # OpenAI client configuration
│   │   └── utils.ts          # Utility functions
│   ├── types/                # TypeScript type definitions
│   │   └── persona.ts        # Persona and message types
│   ├── utils/                # Utility functions
│   │   ├── clearData.ts      # Data cleanup utilities
│   │   └── fetcher.ts        # API fetch utilities
│   └── styles/               # Global styles
│       └── globals.css       # Tailwind CSS imports
├── public/                   # Static assets
├── package.json              # Dependencies and scripts
├── tailwind.config.js        # Tailwind CSS configuration
├── tsconfig.json             # TypeScript configuration
└── README.md                 # This file

🔧 API Documentation

POST /api/upload

Upload conversation files and create AI personas.

Request:

// FormData with files
const formData = new FormData();
formData.append('files', file1);
formData.append('files', file2);

Response:

{
  sessionId: string;
  personas: StoredPersona[];
  totalPersonasCreated: number;
  limitInfo?: {
    message: string;
    skippedCount: number;
    totalParticipants: number;
  };
  excludedInfo?: {
    message: string;
    excludedCount: number;
    excludedParticipants: Array<{
      sender: string;
      messageCount: number;
      needed: number;
    }>;
  };
}

POST /api/chat

Send messages to AI personas and get responses.

Request:

{
  personaName: string;
  transcript: Msg[];
  chatHistory: Msg[];
  userMessage: string;
  styleProfile: StyleProfile;
}

Response:

{
  twinReply: string;
  score?: number;
  tips?: string[];
  usage: {
    totalMessagesUsed: number;
    maxMessagesPerIP: number;
    contextMessagesUsed: number;
  };
}

POST /api/score

Get detailed style analysis and improvement tips.

Request:

{
  userMessage: string;
  personaResponse: string;
  styleProfile: StyleProfile;
}

Response:

{
  score: number; // 0-100
  tips: string[];
  analysis: {
    tone: string;
    style: string;
    effectiveness: string;
  };
}

🔍 Technical Deep Dive

Personality Analysis Pipeline

  1. File Parsing: Multi-format conversation import
  2. Message Sampling: Intelligent selection of representative messages
  3. Style Extraction: GPT-5 powered personality profiling
  4. Profile Creation: Structured style profile with 15+ dimensions
  5. Context Preservation: Conversation history and relationship dynamics

Rate Limiting & Security

  • IP-based limits: 2 personas per IP, 40 messages total
  • File size limits: 1MB maximum per file
  • Concurrency control: Semaphore-based parallel processing
  • Memory management: Automatic cleanup of old persona data

Performance Optimizations

  • Message sampling: Token-aware selection for cost efficiency
  • Streaming responses: Real-time message display
  • Lazy loading: Component-level code splitting
  • Caching: localStorage for persona persistence
  • Reusable components: Reduced bundle size and improved maintainability

🧪 Testing

# Run linting
npm run lint

# Type checking
npx tsc --noEmit

# Build for production
npm run build

🚀 Deployment

Environment Variables

Variable Description Required
OPENAI_API_KEY OpenAI API key with GPT-5 Mini access Yes
NEXT_PUBLIC_APP_URL Public URL for the application No

Build Commands

# Development
npm run dev

# Production build
npm run build

# Start production server
npm start

📈 Performance Metrics

Build Performance

  • Bundle Size: 100 kB shared
  • Page Sizes: 4.8 kB - 12.1 kB per page
  • Build Time: Fast compilation
  • Code Reduction: ~11% through reusable components

Component Efficiency

  • 20+ repetitive patterns eliminated
  • 8 reusable components created
  • 100% consistency in similar patterns
  • Zero build warnings or errors

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • OpenAI for GPT-5 Mini API access
  • Vercel for hosting and deployment
  • Next.js team for the amazing framework
  • Tailwind CSS for the utility-first styling approach
  • Radix UI for accessible component primitives

📞 Contact


Built with ❤️ by Amin Momin

Convocate - Where AI meets authentic human communication.

About

Create AI “digital twins” from real chat history for realistic conversation practice—sales roleplay, hard talks, and personal growth. Privacy-first, Next.js + GPT-5.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors