A real-time voice conversational assistant powered by OpenAI GPT-4 and Text-to-Speech.
- 🗣️ Voice Input - Browser-based speech recognition (Spanish)
- 🤖 AI Responses - GPT-4 powered conversational AI
- 🔊 Voice Output - OpenAI TTS with 6 voice options
- 💾 Persistent History - SQLite database for messages and users
- ⚡ Real-time Streaming - Streamed AI responses
| Layer | Technologies |
|---|---|
| Frontend | React 19, TypeScript, Vite, Material-UI |
| Backend | Express.js, TypeORM, SQLite |
| AI | OpenAI GPT-4, OpenAI TTS |
| Validation | Zod |
src/
├── server/ # Backend
│ ├── core/errors/ # Custom error classes
│ ├── application/dtos/ # Request validation (Zod)
│ ├── infrastructure/ # Database entities
│ ├── presentation/ # Middlewares & responses
│ ├── services/ # Business logic
│ └── controllers/ # Route handlers
│
├── features/ # Frontend (feature-based)
│ ├── auth/ # Authentication context
│ ├── chat/ # Chat logic & components
│ └── voice/ # TTS & speech recognition
│
└── shared/ # Shared utilities
├── api/ # Centralized API client
└── components/ # ErrorBoundary, etc.
- Node.js 18+
- OpenAI API Key
git clone <repository-url>
cd voice-ai-app
# Frontend dependencies
npm install
# Backend dependencies
cd src/server && npm installCreate .env in src/server/:
OPENAI_API_KEY=sk-your-api-key
PORT=3001
NODE_ENV=development# Terminal 1 - Backend
cd src/server && npm run dev
# Terminal 2 - Frontend
npm run devOpen http://localhost:5173
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/users |
Create/update user |
POST |
/api/openai |
Send message, get AI response + audio |
GET |
/api/messages/:userId |
Get user's message history |
GET |
/api/voices |
List available TTS voices |
GET |
/api/health |
Health check |
curl -X POST http://localhost:3001/api/openai \
-H "Content-Type: application/json" \
-d '{"text": "Hello", "voiceId": "echo", "userId": "user-1"}'{
"success": true,
"data": {
"text": "AI response text",
"audio": "base64-encoded-audio",
"messageId": "uuid"
},
"timestamp": "2024-01-01T00:00:00.000Z"
}┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Browser │────▶│ Express │────▶│ OpenAI │
│ (React) │◀────│ Server │◀────│ API │
└─────────────┘ └──────┬──────┘ └─────────────┘
│
┌──────▼──────┐
│ SQLite │
│ (TypeORM) │
└─────────────┘
- ✅ Input validation with Zod schemas
- ✅ Rate limiting (100 req/15min, 20 req/min for chat)
- ✅ Centralized error handling
- ✅ Request logging
| ID | Name |
|---|---|
alloy |
Alloy |
echo |
Echo |
fable |
Fable |
onyx |
Onyx |
nova |
Nova |
shimmer |
Shimmer |
MIT