- π― Overview
- β¨ Features
- ποΈ Architecture
- π Quick Start
- π Training Scenarios
- π οΈ Development
- π§ͺ Testing
- π’ Deployment
- π Documentation
- π‘οΈ Security
- π Performance
- π§ Troubleshooting
- π€ Contributing
- π License
ChatTrain MVP1 enables 5 pilot users to complete 30-minute AI-powered training scenarios with real-time feedback. Built with modern web technologies and OpenAI integration for enterprise-grade customer service training.
- π― Interactive Learning: Real-time chat scenarios with AI customers
- β‘ Instant Feedback: Immediate evaluation and improvement suggestions
- π Progress Tracking: Detailed session analytics and performance metrics
- π Enterprise Security: Automatic PII masking and data protection
- π± Modern UI: Responsive React interface with split-pane design
- Real-time Chat Training: Interactive scenarios with AI customers
- Instant Feedback: Keyword-based evaluation with improvement suggestions
- Document Integration: Reference materials displayed during training
- Data Security: Automatic PII masking for sensitive information
- Scenario Management: YAML-based content with Git workflow
Get ChatTrain running in under 5 minutes!
Make sure you have these installed:
- π’ Node.js 20+ - Download here
- π Python 3.11+ - Download here
- π³ Docker - Download here
- π OpenAI API Key - Get yours here
# 1. Clone the repository
git clone https://github.com/kiwamust/ChatTrain.git
cd ChatTrain
# 2. Setup everything (dependencies, environment, database)
make setup
# 3. Configure your OpenAI API key
cp .env.example .env
echo "OPENAI_API_KEY=your_api_key_here" >> .env
# 4. Start the development environment
make dev- Frontend: http://localhost:3000 (Main application)
- Backend API: http://localhost:8000 (API endpoints)
- API Docs: http://localhost:8000/docs (Interactive documentation)
# Verify everything is working
make health
# Check service status
make status
# View logs if needed
make logs# If you prefer using only Docker
docker compose up -d
# Then configure your .env file and restartCustomer files claim after car accident - practice empathy, information gathering, and next steps.
User experiencing login issues - practice troubleshooting, password reset, and technical support.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ChatTrain MVP1 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββ β
β β Frontend β β Backend β β Storage β β
β β (React + TS) βββββΊβ (FastAPI) βββββΊβ β β
β β Port 3000 β β Port 8000 β β β β
β β β β β β β β
β β βββββββββββββββ β β ββββββββββββββββ β β βββββββββββ β β
β β β Chat UI β β β β WebSocket β β β β SQLite β β β
β β β Interface β β β β /chat/stream β β β β Databaseβ β β
β β βββββββββββββββ β β ββββββββββββββββ β β βββββββββββ β β
β β βββββββββββββββ β β ββββββββββββββββ β β βββββββββββ β β
β β β Document β β β β REST API β β β β YAML β β β
β β β Viewer β β β β Endpoints β β β β Content β β β
β β βββββββββββββββ β β ββββββββββββββββ β β βββββββββββ β β
β βββββββββββββββββββ β ββββββββββββββββ β βββββββββββββββ β
β β β Security β β β
β βββββββββββββββββββ β β PII Masking β β βββββββββββββββ β
β β i18n Support β β ββββββββββββββββ β β OpenAI API β β
β β (EN/JA) β β β β β gpt-4o-mini β β
β βββββββββββββββββββ ββββββββββΌββββββββββ βββββββββββββββ β
β β β
β ββββββββββΌββββββββββ β
β β LLM Integration β β
β β & Feedback β β
β β Generation β β
β ββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Frontend: React 19.1.0 + TypeScript + Vite
- Backend: FastAPI 0.104.1 + Uvicorn + WebSockets
- Database: SQLite (development) / PostgreSQL (production)
- LLM: OpenAI GPT-4o-mini integration
- Security: Regex-based PII masking + rate limiting
- Content: YAML-based scenario management + Git workflow
- Deployment: Docker + Docker Compose
- Internationalization: React-i18next (EN/JA)
- β 5 pilot users supported concurrently
- β 2 scenarios Γ 30 minutes training sessions
- β LLM feedback with evaluation scores
- β Data masking for sensitive information
- β <3 second response times
# Setup & Installation
make setup # Initial environment setup
make install # Alias for setup
# Development
make dev # Start development servers
make dev-logs # Start with live logs
make dev-build # Build and start development
# Testing
make test # Run all tests
make test-backend # Backend tests only
make test-frontend # Frontend tests only
make test-integration # Integration tests
make test-load # Load testing
# Production
make build # Build production images
make deploy # Deploy to production
make deploy-backup # Deploy with backup
# Monitoring & Control
make status # Show service status
make health # Health checks
make logs # View development logs
make stop # Stop services
make restart # Restart services
# Maintenance
make backup # Create data backup
make clean # Clean up containers
make update # Update dependencies- Initial Setup:
make setup(run once) - Daily Development:
make dev - Running Tests:
make test(before commits) - Code Quality:
make lint(if available) - Health Checks:
make health(troubleshooting)
Create a .env file with these required variables:
# Required
OPENAI_API_KEY=your_openai_api_key_here
# Optional (with defaults)
FRONTEND_PORT=3000
BACKEND_PORT=8000
DATABASE_URL=sqlite:///./chattrain.db
LOG_LEVEL=INFOsrc/
βββ frontend/ # React TypeScript application
β βββ components/ # Reusable UI components
β βββ hooks/ # Custom React hooks
β βββ services/ # API integration
β βββ types/ # TypeScript definitions
βββ backend/ # FastAPI Python application
β βββ app/ # Main application code
β βββ services/ # Business logic
β βββ security/ # Security modules
content/ # Training scenarios (YAML + docs)
tests/ # Test suite
docs/ # Documentation
scripts/ # Utility scripts
- Technical Design - System architecture
- API Specification - REST + WebSocket APIs
- YAML Schema - Scenario format
- Security Requirements - Data protection
- Testing Strategy - QA approach
- Deployment Guide - Setup instructions
- Pilot User Guide - End user instructions
# Run all tests
pytest tests/ -v
# Run specific test categories
pytest tests/test_api.py -v # API endpoints
pytest tests/test_websocket.py -v # Real-time chat
pytest tests/test_integration.py -v # End-to-end flows# 5-user load test
python scripts/integration_test_enhanced.py --users 5
# System health check
make health- Data Masking: Automatic PII protection (accounts, cards, emails, phones)
- Input Validation: XSS/injection prevention
- Rate Limiting: 20 requests/minute per user
- Audit Logging: Complete security event tracking
- Response Time: <3 seconds validated
- Concurrent Users: 5 pilots supported
- Database: SQLite <1MB footprint
- Cost: ~$0.00015 per training message
make dev
# Frontend: http://localhost:3000
# Backend: http://localhost:8000make build
make deploy
# Includes Docker, health monitoring, backup proceduresπ« Services won't start
Symptoms: make dev fails or services don't respond
Solutions:
# 1. Check Docker is running
docker info
# 2. Check port availability
lsof -i :3000 # Frontend port
lsof -i :8000 # Backend port
# 3. Clean and restart
make clean
make setup
make dev
# 4. Check logs for errors
make logsπ OpenAI API Issues
Symptoms: Chat doesn't work, API errors in logs
Solutions:
# 1. Verify API key is set
cat .env | grep OPENAI_API_KEY
# 2. Test API key manually
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.openai.com/v1/models
# 3. Check API quota/billing
# Visit: https://platform.openai.com/usageποΈ Database Connection Issues
Symptoms: Database errors, session data not saving
Solutions:
# 1. Check database logs
make logs-db
# 2. Reset database (β οΈ destroys data)
make reset-db
# 3. Check file permissions
ls -la *.dbπ WebSocket Connection Failures
Symptoms: Chat interface not updating, connection drops
Solutions:
# 1. Check backend logs
make logs-backend
# 2. Verify WebSocket endpoint
curl -i -N \
-H "Connection: Upgrade" \
-H "Upgrade: websocket" \
http://localhost:8000/chat/stream
# 3. Check firewall/proxy settingsπ Performance Issues
Symptoms: Slow responses, high CPU usage
Solutions:
# 1. Run performance check
make health
# 2. Check resource usage
docker stats
# 3. Run load test to identify bottlenecks
make test-load
# 4. Check OpenAI response times in logs- Check the logs:
make logsfor all services - Run health check:
make healthfor system status - Review documentation: See docs/ folder
- Check GitHub Issues: Search existing issues
- Create new issue: Include logs and system info
# Enable debug logging
echo "LOG_LEVEL=DEBUG" >> .env
make restart
# View detailed logs
make logs- Select training scenario
- Complete 30-minute chat session
- Receive feedback and scoring
- Review reference documents
- Export session summary
- 80%+ completion rate
- Meaningful feedback received
- <3 second response times
- Positive user experience
- Create YAML file in
content/new_scenario/ - Add supporting documents (PDF/Markdown)
- Validate:
python scripts/validate_scenarios.py - Commit and deploy
id: "scenario_name_v1"
title: "Scenario Title"
duration_minutes: 30
bot_messages:
- content: "Customer message"
expected_keywords: ["help", "assist"]
llm_config:
model: "gpt-4o-mini"
temperature: 0.7MIT License - see LICENSE file for details.
We welcome contributions! Here's how to get started:
# 1. Fork the repository on GitHub
# 2. Clone your fork
git clone https://github.com/YOUR_USERNAME/ChatTrain.git
cd ChatTrain
# 3. Add upstream remote
git remote add upstream https://github.com/kiwamust/ChatTrain.git
# 4. Create a feature branch
git checkout -b feature/your-feature-name
# 5. Setup development environment
make setup- Frontend: Follow React/TypeScript best practices
- Backend: Follow FastAPI and Python PEP 8 standards
- Documentation: Update relevant docs for new features
- Tests: Add tests for new functionality
- Commits: Use conventional commit messages
type(scope): description
[optional body]
[optional footer]
Types: feat, fix, docs, style, refactor, test, chore
Examples:
feat(chat): add typing indicator for AI responses
fix(security): improve PII masking regex patterns
docs(readme): update installation instructions
test(api): add websocket connection tests-
Create Feature Branch
git checkout -b feature/your-feature
-
Make Changes
- Write clean, documented code
- Add/update tests as needed
- Update documentation
-
Test Your Changes
make test # Run all tests make health # Health check make lint # Code quality (if available)
-
Commit and Push
git add . git commit -m "feat(scope): your feature description" git push origin feature/your-feature
-
Open Pull Request
- Use the provided PR template
- Link related issues
- Add screenshots for UI changes
- Request review from maintainers
π― High Priority
- Bug fixes and security improvements
- Performance optimizations
- Test coverage improvements
- Documentation enhancements
π Feature Ideas
- New training scenarios
- UI/UX improvements
- Additional language support
- Analytics and reporting features
π Content Contributions
- Training scenario YAML files
- Reference documents
- Translation improvements
- User guides and tutorials
- Automated Checks: All PRs run automated tests
- Maintainer Review: Core team reviews code quality
- Testing: Features tested in development environment
- Documentation: Ensure docs are updated
- Merge: Squash and merge with conventional commit message
- π¬ Discussions: Use GitHub Discussions for questions
- π Bug Reports: Create detailed GitHub Issues
- π‘ Feature Requests: Submit GitHub Issues with enhancement label
- π§ Security Issues: Email maintainers directly
Contributors are recognized in:
- README acknowledgments
- Release notes
- Contributor graphs
- Special recognition for major contributions
ChatTrain MVP1 successfully delivers:
- Complete AI training platform
- 5 pilot user capacity
- Production-ready security
- Comprehensive testing
- Easy deployment and maintenance
Ready for pilot testing! π
ChatTrain MVP1 - Built with β€οΈ for customer service excellence
π Report Bug β’ β¨ Request Feature β’ π Documentation β’ π¬ Discussions
Made with: React β’ FastAPI β’ OpenAI β’ Docker β’ TypeScript β’ Python
Β© 2024 ChatTrain. Released under the MIT License.