Build and chat with your personalized AI companion - Voice calls included!
- Tomodachi AI API
- π€ Custom AI Companions
- Create personalized AI companions with unique personalities
- Choose from various roles (Assistant, Friend, Partner)
- Customize appearance and voice
- π¬ Advanced Chat Features
- Real-time messaging with WebSocket support
- Message history tracking
- Smart context management
- ποΈ Voice Integration
- Text-to-Speech using ElevenLabs
- Natural voice conversations
- Multiple voice options
- π Security
- JWT-based authentication
- Role-based access control
- Secure API endpoints
- β‘ High Performance
- Built with Bun runtime
- Redis caching
- PostgreSQL for data persistence
- Runtime & Framework
- Bun - Ultra-fast JavaScript runtime
- Hono - Lightweight web framework
- TypeScript - Type-safe code
- Database & Caching
- PostgreSQL - Primary database
- Redis - Caching and queue management
- Prisma - ORM
- AI Services
- OpenAI - Chat completions (GPT-4)
- ElevenLabs - Voice synthesis
- DevOps
- Docker - Containerization
- Docker Compose - Multi-container management
- Docker >= 24.0.0
- Docker Compose >= 2.21.0
- Bun >= 1.0.0 (for local development)
- OpenAI API Key
- ElevenLabs API Key
- Clone the repository
git clone https://github.com/zidanhafiz/TomodachiAI-API.git
cd TomodachiAI-API
- Set up environment variables
cp .env.example .env
- Configure environment variables
# Application
PORT=3000
FRONTEND_URL=http://localhost:3000
# Database
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=tomodachi
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/tomodachi
DOCKER_DATABASE_URL=postgresql://postgres:postgres@db:5432/tomodachi
# Redis
REDIS_HOST=redis
REDIS_PORT=6379
# JWT
JWT_SECRET=your_jwt_secret
# AI Services
OPENAI_API_KEY=your_openai_api_key
ELEVENLABS_API_KEY=your_elevenlabs_api_key
# Start development services
docker compose -f compose.dev.yml up -d
# View logs
docker compose -f compose.dev.yml logs -f
# Stop services
docker compose -f compose.dev.yml down
# Build and start production services
docker compose -f compose.prod.yml up -d --build
# View logs
docker compose -f compose.prod.yml logs -f
# Stop services
docker compose -f compose.prod.yml down
- API
- Development:
http://localhost:4000
- Production:
http://localhost:3000
- Development:
- PostgreSQL:
localhost:5432
- Redis:
localhost:6379
- RedisInsight (Dev only):
http://localhost:8001
POST /api/auth/register
POST /api/auth/login
POST /api/auth/refresh
POST /api/agents/create
GET /api/agents
GET /api/agents/:id
PATCH /api/agents/:id
DELETE /api/agents/:id
POST /api/chat/message
GET /api/chat/history
POST /api/voice/synthesize
Detailed API documentation available at /v1/api-docs
when running the server.
# Install dependencies
bun install
# Generate Prisma client
bunx prisma generate
# Run database migrations
bunx prisma migrate dev
# Start development server
bun run dev
src/
βββ models/ # Database models
βββ routes/ # API routes
βββ middlewares/# Custom middlewares
βββ utils/ # Utility functions
βββ workers/ # Background workers
# Run all tests
bun test
# Run specific test file
bun test test/api/users.test.ts
- Build the image:
docker compose -f compose.prod.yml build
- Deploy:
docker compose -f compose.prod.yml up -d
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Instagram - @hafizrofiyani