Skip to content

aws-samples/sample-group-chat-ai

Group Chat AI - Collaborative AI Conversations

โ€ข ๐Ÿ‡บ๐Ÿ‡ธ This document is also available in: English โ€ข ๐Ÿ‡ธ๐Ÿ‡ฆ ู‡ุฐุง ุงู„ู…ุณุชู†ุฏ ู…ุชูˆูุฑ ุฃูŠุถุงู‹ ุจู€: ุงู„ุนุฑุจูŠุฉ โ€ข ๐Ÿ‡ฉ๐Ÿ‡ช Dieses Dokument ist auch verfรผgbar in: Deutsch โ€ข ๐Ÿ‡ช๐Ÿ‡ธ Este documento tambiรฉn estรก disponible en: Espaรฑol โ€ข ๐Ÿ‡ซ๐Ÿ‡ท Ce document est รฉgalement disponible en: Franรงais โ€ข ๐Ÿ‡ฎ๐Ÿ‡ฑ ืžืกืžืš ื–ื” ื–ืžื™ืŸ ื’ื ื‘: ืขื‘ืจื™ืช โ€ข ๐Ÿ‡ฎ๐Ÿ‡น Questo documento รจ disponibile anche in: Italiano โ€ข ๐Ÿ‡ฏ๐Ÿ‡ต ใ“ใฎๆ–‡ๆ›ธใฏไปฅไธ‹ใฎ่จ€่ชžใงใ‚‚ใ”ๅˆฉ็”จใ„ใŸใ ใ‘ใพใ™: ๆ—ฅๆœฌ่ชž โ€ข ๐Ÿ‡ฐ๐Ÿ‡ท ์ด ๋ฌธ์„œ๋Š” ๋‹ค์Œ ์–ธ์–ด๋กœ๋„ ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค: ํ•œ๊ตญ์–ด โ€ข ๐Ÿ‡ณ๐Ÿ‡ฑ Dit document is ook beschikbaar in: Nederlands โ€ข ๐Ÿ‡ต๐Ÿ‡น Este documento tambรฉm estรก disponรญvel em: Portuguรชs โ€ข ๐Ÿ‡ท๐Ÿ‡บ ะญั‚ะพั‚ ะดะพะบัƒะผะตะฝั‚ ั‚ะฐะบะถะต ะดะพัั‚ัƒะฟะตะฝ ะฝะฐ: ะ ัƒััะบะธะน โ€ข ๐Ÿ‡ธ๐Ÿ‡ช Detta dokument รคr ocksรฅ tillgรคngligt pรฅ: Svenska โ€ข ๐Ÿ‡จ๐Ÿ‡ณ ๆœฌๆ–‡ๆกฃ่ฟ˜ๆไพ›ไปฅไธ‹่ฏญ่จ€็‰ˆๆœฌ: ไธญๆ–‡


Group Chat AI is an advanced collaborative platform that enables dynamic group conversations with multiple AI personas. The system facilitates meaningful discussions across diverse perspectives, allowing users to explore ideas, get feedback, and engage in multi-participant conversations with AI agents representing different roles and viewpoints.

๐Ÿ—๏ธ Architecture Overview

User Input โ†’ React Frontend โ†’ API Gateway โ†’ ConversationOrchestrator
                                              โ†“
Session Manager โ† PersonaAgent โ† LLM Interface โ† Language Models (Bedrock/OpenAI/Anthropic/Ollama)

Key Features

  • Multi-Persona Conversations: Engage with multiple AI personas simultaneously in group discussions
  • Dynamic Interaction Patterns: Real-time conversation flow with natural turn-taking and responses
  • Diverse Perspectives: Each persona brings unique viewpoints, expertise, and communication styles
  • Collaborative Problem Solving: Work through complex topics with AI agents offering different approaches
  • Session Persistence: Maintain conversation context and persona consistency across sessions
  • Flexible Persona Customization: Create and modify AI personas with natural language descriptions
  • Multiple LLM Support: Leverage various language models including AWS Bedrock, OpenAI, Anthropic, and Ollama

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 20+
  • npm 8+
  • Docker (optional, for containerization)
  • AWS CLI (for deployment)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd group-chat-ai
  2. Install dependencies

    npm run install:all
  3. Set up environment variables

    # Backend
    cp backend/.env.example backend/.env
    # Edit backend/.env with your configuration
    
    # Frontend will use Vite's proxy configuration
  4. Build shared package

    npm run build:shared

Development

  1. Start the backend server

    npm run dev:backend

    Backend will be available at http://localhost:3000

  2. Start the frontend development server

    npm run dev:frontend

    Frontend will be available at http://localhost:3001

  3. Test the API

    curl http://localhost:3000/health

๐Ÿ“ Project Structure

group-chat-ai/
โ”œโ”€โ”€ shared/                 # Shared TypeScript types and utilities
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ types/         # Common type definitions
โ”‚   โ”‚   โ”œโ”€โ”€ constants/     # Application constants
โ”‚   โ”‚   โ””โ”€โ”€ utils/         # Shared utility functions
โ”œโ”€โ”€ backend/               # Express.js API server
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ controllers/   # API route handlers
โ”‚   โ”‚   โ”œโ”€โ”€ services/      # Business logic services
โ”‚   โ”‚   โ”œโ”€โ”€ middleware/    # Express middleware
โ”‚   โ”‚   โ”œโ”€โ”€ config/        # Configuration files
โ”‚   โ”‚   โ””โ”€โ”€ utils/         # Backend utilities
โ”œโ”€โ”€ frontend/              # React application
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/    # Reusable React components
โ”‚   โ”‚   โ”œโ”€โ”€ pages/         # Page components
โ”‚   โ”‚   โ”œโ”€โ”€ services/      # API service layer
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/         # Custom React hooks
โ”‚   โ”‚   โ””โ”€โ”€ utils/         # Frontend utilities
โ”œโ”€โ”€ infrastructure/        # AWS CDK infrastructure code
โ”œโ”€โ”€ tests/                 # Test files
โ””โ”€โ”€ documents/             # Project documentation

๐Ÿ”ง Available Scripts

Root Level

  • npm run install:all - Install all dependencies
  • npm run build - Build all packages
  • npm run test - Run all tests
  • npm run lint - Lint all packages

Backend

  • npm run dev:backend - Start backend in development mode
  • npm run build:backend - Build backend
  • npm run test:backend - Run backend tests

Frontend

  • npm run dev:frontend - Start frontend development server
  • npm run build:frontend - Build frontend for production
  • npm run test:frontend - Run frontend tests

Personas & Internationalization

  • npm run personas:generate - Generate English personas.json from shared definitions
  • npm run docs:translate - Translate all documentation to supported languages
  • npm run docs:translate:single -- --lang es - Translate to specific language

๐ŸŒ API Endpoints

Health Check

  • GET /health - Basic health check
  • GET /health/detailed - Detailed health information

Personas

  • GET /personas - Get all available personas
  • GET /personas/:personaId - Get specific persona details

Sessions

  • POST /sessions - Create new conversation session
  • POST /sessions/:sessionId/messages - Send message and get responses
  • PUT /sessions/:sessionId/personas - Update session personas
  • GET /sessions/:sessionId/summary - Get session summary
  • DELETE /sessions/:sessionId - End session
  • GET /sessions/:sessionId - Get session details

๐Ÿค– AI Integration

The system supports multiple LLM providers through a configurable interface:

  • OpenAI (GPT-3.5/GPT-4)
  • Anthropic (Claude)
  • AWS Bedrock (Various models)
  • Ollama (Local models)

Configure via environment variables:

LLM_PROVIDER=openai
LLM_MODEL=gpt-3.5-turbo
LLM_TEMPERATURE=0.7
LLM_MAX_TOKENS=500

Development Mode

In development, the system uses mock responses to simulate AI interactions without requiring API keys.

๐ŸŽญ Personas

The system includes diverse AI personas that can be customized for various group conversation scenarios:

  1. Strategic Advisor - High-level planning, vision, and strategic direction
  2. Technical Expert - Deep technical knowledge, implementation details, and solutions
  3. Analyst - Data-driven insights, research, and analytical perspectives
  4. Creative Thinker - Innovation, brainstorming, and out-of-the-box ideas
  5. Facilitator - Discussion management, consensus building, and collaboration

Persona Structure

Each persona is defined by just 4 simple fields:

  • Name: Display name (e.g., "Strategic Advisor")
  • Role: Short role identifier (e.g., "Strategist")
  • Details: Free text description including background, priorities, concerns, and influence level
  • Avatar Selection: Visual representation from available avatar options

Persona Customization

  • Edit Default Personas: Modify any default persona's details in natural language
  • Create Custom Personas: Build completely custom personas with your own descriptions
  • Session Persistence: All persona customizations persist throughout browser sessions
  • Import/Export: Save and share persona configurations via JSON files
  • Tile-Based Interface: Visual tile selection with comprehensive editing capabilities

Technical Implementation

Each persona maintains:

  • Isolated conversation context for authentic responses
  • Natural language processing of details field for AI prompt generation
  • Role-specific response patterns based on described characteristics
  • Intelligent turn-taking for natural group conversation flow

๐ŸŒ Internationalization & Persona Management

Persona Definition Workflow

  1. Source of Truth: All persona definitions are maintained in shared/src/personas/index.ts
  2. Generation: Run npm run personas:generate to create English personas.json translation file
  3. Translation: Use existing translation scripts to generate localized persona files

Persona Translation Process

# 1. Update persona definitions in shared package
vim shared/src/personas/index.ts

# 2. Generate English personas.json from shared definitions
npm run personas:generate

# 3. Translate personas to all supported languages
npm run docs:translate  # Translates all files including personas.json
# Or translate to specific language
npm run docs:translate:single -- --lang es

# 4. Rebuild shared package if needed
npm run build:shared

Translation File Structure

  • Source: shared/src/personas/index.ts (TypeScript definitions)
  • Generated: frontend/public/locales/en/personas.json (English i18n)
  • Translated: frontend/public/locales/{lang}/personas.json (Localized versions)

Supported Languages

The system supports 14 languages for personas and documentation:

  • ๐Ÿ‡บ๐Ÿ‡ธ English (en) - Source language
  • ๐Ÿ‡ธ๐Ÿ‡ฆ ุงู„ุนุฑุจูŠุฉ (ar) - Arabic
  • ๐Ÿ‡ฉ๐Ÿ‡ช Deutsch (de) - German
  • ๐Ÿ‡ช๐Ÿ‡ธ Espaรฑol (es) - Spanish
  • ๐Ÿ‡ซ๐Ÿ‡ท Franรงais (fr) - French
  • ๐Ÿ‡ฎ๐Ÿ‡ฑ ืขื‘ืจื™ืช (he) - Hebrew
  • ๐Ÿ‡ฎ๐Ÿ‡น Italiano (it) - Italian
  • ๐Ÿ‡ฏ๐Ÿ‡ต ๆ—ฅๆœฌ่ชž (ja) - Japanese
  • ๐Ÿ‡ฐ๐Ÿ‡ท ํ•œ๊ตญ์–ด (ko) - Korean
  • ๐Ÿ‡ณ๐Ÿ‡ฑ Nederlands (nl) - Dutch
  • ๐Ÿ‡ต๐Ÿ‡น Portuguรชs (pt) - Portuguese
  • ๐Ÿ‡ท๐Ÿ‡บ ะ ัƒััะบะธะน (ru) - Russian
  • ๐Ÿ‡ธ๐Ÿ‡ช Svenska (sv) - Swedish
  • ๐Ÿ‡จ๐Ÿ‡ณ ไธญๆ–‡ (zh) - Chinese

Adding New Personas

  1. Add persona definition to shared/src/personas/index.ts
  2. Run npm run personas:generate to update English translations
  3. Run translation scripts to generate localized versions
  4. The new persona will be available in all supported languages

๐Ÿ”’ Security Features

  • Input Validation: All user inputs are validated and sanitized
  • Session Isolation: Each session maintains separate context
  • Error Handling: Graceful error handling with user-friendly messages
  • Rate Limiting: Built-in protection against abuse
  • HTTPS: All communications encrypted in production

๐Ÿ“Š Monitoring & Observability

  • Structured Logging: JSON-formatted logs with Winston
  • Health Checks: Comprehensive health monitoring
  • Metrics: Custom application metrics
  • Error Tracking: Detailed error logging and tracking

๐Ÿšข Deployment

Docker

# Build backend image
cd backend
npm run docker:build

# Run container
npm run docker:run

AWS Deployment

# Deploy infrastructure
cd infrastructure
npm run deploy:dev # replace :dev with staging or prod for those environments

โš ๏ธ Deployment Region Warning!

By default, the Routing Model for Bedrock is OpenAI gpt-oss:20b (openai.gpt-oss-20b-1:0). The Persona Model leverages Anthropic Claude 4 Sonnet (anthropic.claude-sonnet-4-20250514-v1:0). Please ensure you are deploying to a region that supports both models, or configure alternative models.

๐Ÿงช Testing

Unit Tests

npm run test

Integration Tests

npm run test:integration

E2E Tests

npm run test:e2e

๐Ÿ“ˆ Performance Targets

  • Response Time: < 3 seconds for persona responses
  • Availability: 99.9% API availability
  • Concurrency: Support 1000+ concurrent users
  • Group Conversations: Up to 5 personas per session with natural conversation flow

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

๐Ÿ“„ License

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

About

Simulate group conversations with multiple custom AI personas in a customized scenario

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •