AI-powered customer service system for timber construction projects
An intelligent multi-agent system built for ERNI Gruppe, a leading Swiss timber construction company. This system provides automated customer support for building projects, cost estimation, project status tracking, and consultation scheduling.
- Triage Agent - Intelligent routing to appropriate specialists
- Project Information Agent - General building and construction information
- Cost Estimation Agent - Preliminary project cost calculations
- Project Status Agent - Real-time project tracking and updates
- Appointment Booking Agent - Consultation scheduling with specialists
- FAQ Agent - Answers to common building questions
- Input Guardrails - Relevance and jailbreak protection
- Rate Limiting - API protection and abuse prevention
- Input Validation - Pydantic-based data validation
- Security Headers - CSP, HSTS, X-Frame-Options
- Health Checks -
/healthand/readinessendpoints - Docker Support - Multi-stage builds for backend and frontend
- CI/CD Pipeline - Automated testing and deployment
- Monitoring - Sentry integration, Prometheus metrics
- Documentation - Comprehensive deployment and API docs
- German and English language support
- Automatic language detection
- Context-aware responses
| Document | Description |
|---|---|
| AGENTS.md | Complete technical documentation of the multi-agent system |
| DEPLOYMENT.md | Production deployment guide with SSL, monitoring, security |
| STAGING_DEPLOYMENT.md | NEW: Staging deployment guide and testing procedures |
| CHANGELOG.md | NEW: Version history and release notes |
| PRODUCTION_CHECKLIST.md | Pre-deployment and post-deployment checklist |
| RUNBOOK.md | Day-2 operations, incident response, deployment playbooks |
| LOAD_TESTING_AND_SECURITY_AUDIT.md | Load & security testing instructions |
| ERNI_ADAPTATION.md | Business adaptation overview |
- Python 3.11+ (recommended 3.11 or 3.12)
- Node.js 18+ (LTS recommended)
- OpenAI API Key (Get one here)
git clone https://github.com/DIZ-admin/openai-cs-agents.git
cd openai-cs-agentsIMPORTANT: The .env file must be located in the python-backend/ directory, not in the project root.
Create a .env file in the python-backend directory:
cd python-backend
cp .env.example .envEdit python-backend/.env and add your secrets:
# OpenAI Configuration
OPENAI_API_KEY=sk-proj-your-api-key-here
OPENAI_VECTOR_STORE_ID=vs_your-vector-store-id-here
# Environment
ENVIRONMENT=development
DEBUG=true
# Security
SECRET_KEY=your-secret-key-here
JWT_SECRET_KEY=your-jwt-secret-key-here
# Authentication
# REQUIRE_AUTH: Enforce authentication for API endpoints
# - true: All endpoints require valid JWT token (recommended for production)
# - false: Endpoints are accessible without authentication (development only)
# Default: true for production, false for development
REQUIRE_AUTH=false
# Database
DB_PASSWORD=your-postgres-password
# Redis
REDIS_PASSWORD=your-redis-passwordImportant Environment Variables:
REQUIRE_AUTH: Controls authentication enforcement- Set to
truein production to require JWT tokens - Set to
falsein development for easier testing - Defaults to
truein production,falsein development
- Set to
Note: Never commit the .env file to version control. It's already in .gitignore.
Backend:
cd python-backend
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txtFrontend:
cd ui
npm installOption A: Run Both Services Simultaneously
cd ui
npm run dev- Frontend: http://localhost:3000
- Backend: http://127.0.0.1:8000
Option B: Run Services Separately
Backend:
cd python-backend
source .venv/bin/activate
uvicorn api:app --reload --port 8000Frontend:
cd ui
npm run dev:nextOpen http://localhost:3000 and try:
- "Hello, I want to build a wooden house"
- "How much would a 150m² house cost?"
- "I'd like to book a consultation"
# 1. Configure environment variables in python-backend/.env
cd python-backend
cp .env.example .env
# Edit .env and add your OPENAI_API_KEY, OPENAI_VECTOR_STORE_ID, SECRET_KEY, JWT_SECRET_KEY, DB_PASSWORD, REDIS_PASSWORD
# 2. Return to project root and start all services
cd ..
docker-compose up -dNote: Docker Compose automatically loads environment variables from python-backend/.env.
Services will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- Health Check: http://localhost:8000/health
- Настройте
python-backend/.envи заполните все секреты. - Запустите проверку окружения:
python scripts/preflight_check.py
- Убедитесь, что SSL-сертификаты находятся в
nginx/sslи заданPUBLIC_HOSTNAME. - Разверните продакшн-стек:
docker-compose -f docker-compose.prod.yml --env-file python-backend/.env up -d --build
- Проверьте:
https://<PUBLIC_HOSTNAME>/api/healthdocker-compose -f docker-compose.prod.yml logs -f
Расширенные инструкции по архитектуре, мониторингу, логированию и безопасности см. в python-backend/docs/DEPLOYMENT.md.
-
Initial Inquiry:
User: "Hello, I want to build a wooden house" Triage Agent → Project Information Agent -
Cost Estimation:
User: "How much would a 150m² house cost?" Project Information Agent → Cost Estimation Agent Cost Estimation Agent asks: - Project type? (Einfamilienhaus/Mehrfamilienhaus/Agrar) - Construction type? (Holzbau/Systembau) User: "Single-family house with timber frame construction" Agent: "📊 Preliminary Cost Estimate: - Type: Einfamilienhaus (150 m²) - Construction: Holzbau - Estimated cost: CHF 450,000 - 562,500 - Price per m²: CHF 3,000" -
Book Consultation:
User: "I'd like to book a consultation" Cost Estimation Agent → Appointment Booking Agent Agent: "Which specialist do you need? - Architekt (Architect) - Holzbau-Ingenieur (Timber Engineer) - Bauleiter (Construction Manager)" User: "Architect please, next Tuesday at 14:00" Agent: "✅ Consultation Booked! - Specialist: Architekt (André Arnold) - Date: Tuesday, 14:00 - Location: ERNI Gruppe, Guggibadstrasse 8, 6288 Schongau"
-
Project Status Check:
User: "What's the status of project 2024-156?" Triage Agent → Project Status Agent Agent: "📊 Project Status #2024-156 - Type: Einfamilienhaus - Location: Muri - Current stage: Production (75% complete) - Next milestone: Assembly 15-19 May 2025 - Project manager: Tobias Wili" -
FAQ Question:
User: "Why should I choose wood for my house?" Project Status Agent → FAQ Agent Agent: "🌲 Why Wood? ✓ Ecological and renewable ✓ Excellent thermal insulation ✓ Healthy indoor climate ✓ CO2-neutral ✓ Fast assembly ERNI is a certified Minergie partner." -
Guardrail Protection:
User: "Write a poem about strawberries" ⚠️ Relevance Guardrail triggered Agent: "Sorry, I can only answer questions related to building and construction."
┌─────────────────┐
│ Triage Agent │ ← Entry point, intelligent routing
└────────┬────────┘
│
┌────┴────┬────────┬────────┬────────┐
│ │ │ │ │
┌───▼───┐ ┌──▼──┐ ┌───▼───┐ ┌──▼──┐ ┌──▼──┐
│Project│ │Cost │ │Project│ │Appt │ │ FAQ │
│ Info │ │Est. │ │Status │ │Book │ │Agent│
└───────┘ └─────┘ └───────┘ └─────┘ └─────┘
Backend:
- Python 3.11+ with FastAPI
- OpenAI Agents SDK 0.3.3
- Pydantic for data validation
- Uvicorn/Gunicorn ASGI server
Frontend:
- Next.js 15.5.4 with App Router
- React 19
- TypeScript 5.x
- Tailwind CSS
Infrastructure:
- Docker & Docker Compose
- Nginx reverse proxy
- PostgreSQL 14+ (production)
- Redis 7.x (caching & rate limiting)
cd python-backend
source .venv/bin/activate
python -m pytest tests/ -vTest Coverage:
- ✅ 228 tests (100% passing)
- ✅ 90.04% code coverage (exceeds 80% requirement)
- ✅ Unit tests for all agents, tools, and guardrails
- ✅ Integration tests for API endpoints
- ✅ Mock data for offline testing
Unit Tests:
- Agent behavior and instructions
- Tool functionality (cost estimation, booking, FAQ)
- Guardrails (relevance, jailbreak protection)
- Context management
Integration Tests:
- API endpoints (
/health,/readiness,/chat,/agents) - Agent handoffs and state management
- Error handling and rate limiting
# Unit tests only
pytest tests/unit/ -v
# Integration tests only
pytest tests/integration/ -v
# With coverage report
pytest tests/ --cov=. --cov-report=html
# Open htmlcov/index.html in browser# 1. Navigate to backend
cd python-backend
# 2. Copy staging environment
cp .env.staging .env
# 3. Configure required variables
# - OPENAI_API_KEY (your staging key)
# - CORS_ORIGINS (your staging domain)
# - SECRET_KEY (generate with: openssl rand -hex 32)
# 4. Install dependencies
pip install -r requirements.txt
# 5. Run tests
python -m pytest tests/ -v
# 6. Start server
uvicorn api:app --host 0.0.0.0 --port 8000 --env-file .envFor detailed staging deployment instructions, see STAGING_DEPLOYMENT.md
This system is designed for ERNI Gruppe but can be adapted for other use cases:
- Modify Agents - Update agent instructions in
python-backend/main.py - Add Tools - Create new tools for specific business logic
- Update Context - Modify
BuildingProjectContextfor your data model - Customize UI - Update branding in
ui/components/ - Add Guardrails - Implement custom input validation
See AGENTS.md for detailed customization guide.
-
GET /health- Basic liveness check{ "status": "healthy", "timestamp": "2025-10-04T09:45:41.219950", "version": "1.0.0", "environment": "production" } -
GET /readiness- Comprehensive dependency check{ "status": "ready", "checks": { "openai_api": true, "environment_configured": true } }
POST /chat- Send message to agents{ "message": "I want to build a house", "conversation_id": "optional-uuid" }
cd python-backend
source .venv/bin/activate
pytest tests/ -vcd ui
npm test
npm run test:e2e# Test health endpoint
curl http://localhost:8000/health
# Test readiness endpoint
curl http://localhost:8000/readiness- Sentry - Error tracking and performance monitoring
- Prometheus - Metrics collection
- Grafana - Metrics visualization
- Structured JSON logging
- Log levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
- Log aggregation with ELK Stack (optional)
See DEPLOYMENT.md for monitoring setup instructions.
- ✅ Input validation with Pydantic
- ✅ Rate limiting (60 req/min for API)
- ✅ CORS policy configuration
- ✅ Security headers (CSP, HSTS, X-Frame-Options)
- ✅ Environment variable validation
- ✅ Secrets management best practices
- ✅ Input guardrails (relevance & jailbreak protection)
- Never commit API keys to version control
- Use environment-specific API keys
- Rotate keys every 90 days
- Enable HTTPS in production
- Regular security audits
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 for Python code
- Use TypeScript for frontend code
- Write tests for new features
- Update documentation
- Run linters before committing
The project includes a comprehensive test suite with 80%+ code coverage.
# Install test dependencies
cd python-backend
pip install pytest pytest-asyncio pytest-mock pytest-cov faker
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ -v --cov=. --cov-report=html --cov-report=term-missing
# Run specific test categories
pytest tests/unit/ -v # Unit tests only
pytest tests/integration/ -v # Integration tests only
pytest tests/unit/tools/ -v # Tool tests only
# Run tests in parallel (faster)
pytest tests/ -n auto -vComprehensive tests for:
- Guardrails: Input validation and security checks
- Tools: All 5 agent tools (FAQ lookup, cost estimation, specialist availability, consultation booking, project status)
- Agents: All 6 specialized agents (Triage, Project Information, Cost Estimation, Project Status, Appointment Booking, FAQ)
- API Endpoints: Health checks, readiness checks, and chat API
- Integration: End-to-end API testing with mocked dependencies
Tests run automatically via GitHub Actions on:
- Push to
main,production,developbranches - Pull requests to
main,production - Multiple Python versions (3.10, 3.11, 3.12)
- Security scanning with bandit and safety
- Docker build testing
- Additional CI jobs now run
pip-audit,scripts/preflight_check.py, API security tests (python-backend/security_audit/api_security_tests.py) и baseline load test (Locust). Убедитесь, что следующие секреты заданы в GitHub Actions:OPENAI_API_KEY_TEST,OPENAI_VECTOR_STORE_ID_TEST,SECRET_KEY_PROD,JWT_SECRET_KEY_PROD,DB_PASSWORD_PROD,REDIS_PASSWORD_PROD.
See .github/workflows/test.yml for the complete CI/CD pipeline.
This project is licensed under the MIT License. See the LICENSE file for details.
- OpenAI - For the Agents SDK and GPT models
- ERNI Gruppe - For the business requirements and domain expertise
- FastAPI - For the excellent Python web framework
- Next.js - For the powerful React framework
For questions, issues, or feature requests:
- GitHub Issues: Create an issue
- Documentation: AGENTS.md, DEPLOYMENT.md
- Email: support@example.com (replace with actual support email)
- Database integration (PostgreSQL)
- User authentication and authorization
- Multi-language support (French, Italian)
- Advanced analytics dashboard
- Email notifications for consultations
- Mobile app (React Native)
- Voice interface integration
- Document upload and analysis
- 3D building visualization
- Integration with ERNI's ERP system
Built with ❤️ for ERNI Gruppe | Powered by OpenAI Agents SDK
