ManyMinds is a real‑time AI‑powered chat application built with a React Native front‑end and a Laravel back‑end. It showcases:
- AI chat powered by OpenAI's GPT‑4o‑realtime model.
- Live voice streaming using WebRTC (React Native WebRTC) for two‑way audio communication.
- Authentication via Laravel Sanctum.
- Rich conversation management (create, list, view, and stream messages).
- AI profile handling and prompt building services.
- Realtime session creation for voice calls.
The project is a learning sandbox for modern mobile development, real‑time communication, and server‑side AI integration.
| Feature | Description |
|---|---|
| Chat Service | Handles sending/receiving messages, creating conversations, and streaming AI responses. |
| Realtime Voice Service | Sets up a WebRTC peer connection, captures microphone audio, streams voice from OpenAI, and provides a data channel for control messages. |
| Auth Service | Register, login, and fetch the current user using Laravel Sanctum tokens. |
| AI Profile Management | CRUD endpoints for AI profiles (system prompts, temperature, etc.). |
| Prompt Builder | Server‑side service that builds prompts for the AI model. |
| Realtime Session API | Generates an ephemeral token for the OpenAI realtime endpoint. |
| Laravel API | RESTful routes for auth, AI profiles, conversations, messages, feedback, and realtime sessions. |
| React Native UI | Modern mobile UI with dark mode support, gradient backgrounds, and smooth animations. |
- Frontend: React Native (TypeScript),
react-native-webrtc,axios,react-navigation - Backend: Laravel 12 (PHP 8.2), Sanctum, OpenAI PHP SDK (
openai-php/laravel) - Realtime: OpenAI Realtime API (
gpt-4o-realtime-preview-2024-12-17) - Database: SQLite (default) – can be swapped for MySQL/PostgreSQL.
- Package Management: npm (frontend), Composer (backend)
- Development Tools: Vite (frontend bundler), Laravel Sail (Docker dev environment optional)
- Node.js (>=18) and npm
- PHP (>=8.2) and Composer
- Android SDK (for Android emulator/device) – see React Native docs.
- OpenAI API key with access to the Realtime model.
- Clone the repository and navigate to the project root.
- Copy the example env file and set your variables:
cp backend/.env.example backend/.env
- Edit
backend/.envand add:OPENAI_API_KEY=your_openai_key_here
- Install dependencies and run migrations:
cd backend composer install php artisan key:generate php artisan migrate --force - (Optional) Start the Laravel development server:
The API will be available at
php artisan serve
http://127.0.0.1:8000/api.
- Install npm packages:
cd my-app npm install - Create a
.envfile inmy-app(copy from.env.exampleif present) and set the backend URL if you are not using the default localhost:VITE_API_BASE_URL=http://127.0.0.1:8000/api
- Run the app on Android (or iOS):
The Metro bundler will start and the app will launch on the emulator/device.
npm run android # or `npm run ios`
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/auth/register |
Register a new user. |
POST |
/api/auth/login |
Login and receive a Sanctum token. |
GET |
/api/me |
Get the authenticated user. |
GET/POST |
/api/ai-profiles |
Manage AI profiles. |
GET |
/api/conversations |
List conversations. |
POST |
/api/conversations |
Create a new conversation. |
GET |
/api/conversations/{id} |
View a conversation. |
GET |
/api/conversations/{id}/messages |
List messages for a conversation. |
POST |
/api/conversations/{id}/messages |
Send a message (handled by ChatController). |
POST |
/api/conversations/{id}/realtime-session |
Generate an ephemeral token for the OpenAI Realtime endpoint. |
POST |
/api/messages/{id}/feedback |
Submit feedback for a message. |
- The front‑end calls
chatService.getRealtimeSession(conversationId)to obtain an ephemeral token. RealtimeVoiceServicecreates aRTCPeerConnectionand captures the microphone viamediaDevices.getUserMedia.- An SDP offer is sent to OpenAI's Realtime endpoint (
https://api.openai.com/v1/realtime). - The response SDP answer is applied, establishing a two‑way audio stream.
- A data channel (
oai-events) is used for control messages (e.g., sending text prompts during a call).
- Backend: Run
php artisan testto execute the Laravel test suite. - Frontend: Use the React Native testing library or manually test the UI on an emulator/device.
- Realtime: Verify voice streaming by starting a call from the chat screen; you should hear the AI's spoken response and see the microphone indicator.
- Fork the repository.
- Create a feature branch (
git checkout -b feature/awesome-feature). - Make your changes and ensure both backend and frontend tests pass.
- Open a Pull Request describing the changes.
This project is licensed under the MIT License – see the LICENSE file for details.
For questions or suggestions, feel free to open an issue or contact the repository maintainer.