使用说明
NavieTake模拟
人工智能驱动的聊天和语音助手演示,模拟Grab风格的驾驶员(DAX)和乘客(PAX)通信系统。
🏗️ 建筑
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ DAX App │ │ PAX App │ │ Bedrock Agent │
│ (Driver UI) │ │ (Passenger UI) │ │ (Central AI) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
└───────────────────────┼───────────────────────┘
│
┌─────────────────┐
│ MCP Server │
│ (API Gateway) │
└─────────────────┘
│
┌─────────────────┐
│ Lambda Functions│
│ (Backend APIs) │
└─────────────────┘
│
┌─────────────────┐
│ DynamoDB │
│ (Storage) │
└─────────────────┘
🚀 特性
- 语音和文字聊天:驾驶员和乘客之间的实时通信
- 人工智能助手:用于智能对话处理的AWS Bedrock Agent
- 移动优先设计:针对移动设备优化的响应式React应用程序
- 无服务器后端:用于可扩展API端点的AWS Lambda函数
- 实时更新:用于即时消息传递的类似WebSocket的轮询
- 成本优化:预计全面生产部署每月约10.47美元
📁 项目结构
NavieTakieSimulation/
├── terraform/ # Infrastructure as Code
│ ├── main.tf # Main Terraform configuration
│ ├── variables.tf # Variable definitions
│ ├── outputs.tf # Output values
│ └── user_data.sh # EC2 initialization script
├── lambda-functions/ # AWS Lambda Functions
│ ├── send_message.py # Send message handler
│ ├── make_call.py # Call initiation handler
│ ├── get_message.py # Message retrieval handler
│ └── requirements.txt # Python dependencies
├── mcp-server/ # MCP Server (API Gateway)
│ ├── app.py # FastAPI application
│ ├── requirements.txt # Python dependencies
│ ├── Dockerfile # Container configuration
│ └── docker-compose.yml # Local development
├── frontend/ # React Applications
│ ├── dax-app/ # Driver Assistant Experience
│ │ ├── src/ # React source code
│ │ ├── public/ # Static assets
│ │ └── package.json # Dependencies
│ └── pax-app/ # Passenger Assistant Experience
│ ├── src/ # React source code
│ ├── public/ # Static assets
│ └── package.json # Dependencies
├── bedrock-agent/ # AWS Bedrock Agent Configuration
│ ├── agent-config.json # Agent configuration
│ └── agent-deployment.yaml # CloudFormation template
├── staging/ # Local Development & Testing
│ ├── docker-compose.yml # Complete staging environment
│ ├── test_runner.py # Comprehensive test suite
│ └── requirements.txt # Testing dependencies
├── scripts/ # Deployment Scripts
│ └── deploy.sh # Automated deployment script
└── README.md # This file
🛠️ 先决条件
在部署之前,请确保已安装以下内容:
- AWS-CLI (v2.x)
- 地形 (v1.x)
- 码头工人 (v20.x)
- Node.js (v18.x)
- python (v3.9+)
- jq公司 (用于JSON解析)
🚀 快速开始
1.克隆和设置
git clone <repository-url>
cd NavieTakieSimulation
2.配置AWS
aws configure
# Enter your AWS Access Key ID, Secret Access Key, and region
3.部署一切
chmod +x scripts/deploy.sh
./scripts/deploy.sh
部署脚本将:
- ✅ 检查先决条件
- 🏗️ 构建前端应用程序
- ☁️ 部署AWS基础设施
- 🔧 部署Lambda函数
- 🖥️ 将MCP服务器部署到EC2
- 🌐 将前端应用程序部署到S3
- 🔍 运行健康检查
- 📊 显示部署摘要
🧪 地方发展
模拟环境
cd staging
docker-compose up -d
这将开始:
- MCP服务器 在…上
http://localhost:8000 - DynamoDB本地 在…上
http://localhost:8001 - DAX应用程序 在…上
http://localhost:3000 - PAX应用程序 在…上
http://localhost:3001
单个组件
MCP服务器
cd mcp-server
pip install -r requirements.txt
uvicorn app:app --host 0.0.0.0 --port 8000
前端应用程序
# DAX App
cd frontend/dax-app
npm install
npm start
# PAX App
cd frontend/pax-app
npm install
npm start
🧪 测试
运行完整的测试套件
cd staging
python test_runner.py
个人测试
# Test MCP Server
curl http://localhost:8000/health
# Test Lambda Functions
aws lambda invoke --function-name send-message --payload '{"booking_code":"TEST","message":"Hello","sender":"driver"}' response.json
# Test Frontend Apps
curl http://localhost:3000
curl http://localhost:3001
🌐 生产URL
部署后,您的应用程序将在以下位置可用:
- DAX(驱动程序):
https://dax.sameer-jha.com - PAX(乘客):
https://pax.sameer-jha.com - MCP服务器:
https://mcp.sameer-jha.com
💰 成本细分
| 服务 | 每月费用 | 说明 |
|---|---|---|
| EC2(t3.micro) | ~8.47美元 | MCP服务器托管 |
| Lambda | ~ 0.50美元 | API函数 |
| DynamoDB | ~1.00美元 | 消息存储 |
| S3+云前端 | ~0.50美元 | 静态托管 |
| 总计 | ~$10.47 | 全面生产 |
🔧 配置
环境变量
# AWS Configuration
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
# Application Configuration
REACT_APP_API_URL=http://localhost:8000
DYNAMODB_TABLE=chat-messages
域配置
更新域 scripts/deploy.sh:
DOMAIN="your-domain.com"
DAX_SUBDOMAIN="dax"
PAX_SUBDOMAIN="pax"
MCP_SUBDOMAIN="mcp"
🔒 安全
- IAM角色:所有服务的最低权限访问
- 安全组:网络访问受限
- 超文本传输安全协议:所有端点的SSL/TLS加密
- CORS:已配置用于跨源请求
- 输入验证:所有API输入均经过验证
📊 监控
CloudWatch指标
- Lambda函数调用和持续时间
- DynamoDB读/写容量
- EC2实例指标
- CloudFront分布指标
应用程序日志
- CloudWatch中的Lambda函数日志
- MCP服务器在Docker容器中登录
- 前端应用程序在浏览器控制台中登录
🚨 故障排除
常见问题
-
EC2实例未启动
aws ec2 describe-instances --instance-ids <instance-id> -
Lambda函数错误
aws logs describe-log-groups --log-group-name-prefix /aws/lambda/ -
前端构建失败
cd frontend/dax-app npm install --force npm run build -
MCP服务器连接问题
ssh -i key.pem ubuntu@<ec2-ip> docker logs mcp-server
健康检查
# Test MCP Server
curl -f http://localhost:8000/health
# Test Lambda Functions
aws lambda invoke --function-name send-message --payload '{"test":"data"}' response.json
# Test Frontend Apps
curl -f http://localhost:3000
🤝 贡献
- 分叉存储库
- 创建要素分支
- 进行更改
- 添加测试
- 提交拉取请求
📄 许可证
此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。
🆘 支持
有关支持和问题:
- 在存储库中创建问题
- 检查故障排除部分
- 查看日志和指标
🎯 路线图
- []WebSocket支持实时消息传递
- []推送通知
- []多语言支持
- []高级AI功能
- []分析仪表板
- []移动应用程序(React Native)
内置于❤️ 使用AWS、React和Python
