Aplikasi chatbot yang menggunakan API AKBXR & Ferdev sebagai backend AI dengan React.js untuk frontend dan Node.js + Express untuk backend.
- 🤖 Chat real-time dengan AI menggunakan API AKBXR & Ferdev
- 💾 Penyimpanan riwayat chat ke database MySQL
- 🎨 UI yang modern dan responsif dengan Tailwind CSS
- ⚡ Real-time typing indicator
- 📱 Mobile-friendly design
- 🗑️ Fitur clear chat
- Node.js + Express
- MySQL dengan mysql2
- Axios untuk HTTP requests
- CORS untuk cross-origin requests
- dotenv untuk environment variables
- React.js 19
- React Router DOM
- Tailwind CSS
- Axios untuk API calls
- Vite sebagai build tool
├── backend/
│ ├── controllers/
│ │ └── chatController.js
│ ├── routes/
│ │ └── chatRoutes.js
│ ├── .env
│ ├── db.js
│ ├── server.js
│ └── package.json
└── frontend/
├── src/
│ ├── components/
│ │ └── ChatPage.jsx
│ ├── App.jsx
│ ├── main.jsx
│ └── router.jsx
├── .env
└── package.json
git clone <repository-url>
cd ai-chatbot
cd backend
npm install
Buat file .env
di folder backend:
PORT=3001
AKBXR_API_KEY=UNLIMITED-BETA
AKBXR_BASE_URL=https://api.akbxr.com/v1
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=ai_chatbot
Pastikan MySQL sudah terinstall dan running, kemudian buat database:
CREATE DATABASE ai_chatbot;
Aplikasi akan otomatis membuat tabel chat_history
saat pertama kali dijalankan.
cd ../frontend
npm install
Buat file .env
di folder frontend:
VITE_API_BASE_URL=http://localhost:3001/api
cd backend
npm start
Backend akan berjalan di http://localhost:3001
cd frontend
npm run dev
Frontend akan berjalan di http://localhost:5173
POST /api/chat
- Mengirim pesan chatGET /api/chat/history
- Mengambil riwayat chatGET /health
- Health check
{
"messages": [
{
"role": "user",
"content": "Hello, AI!"
}
],
"model": "auto"
}
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello! How can I help you today? 😊",
"padding": "ab",
"role": "assistant"
}
}
],
"id": "chatcmpl-BsUHauKz8BExyFxRJTp751pdXwbb8",
"usage": {
"completion_tokens": 11,
"prompt_tokens": 11,
"prompt_tokens_details": {
"cached_tokens": 0
},
"total_tokens": 22
},
"model": "auto",
"system_fingerprint": "fp_07e970ab25"
}
CREATE TABLE chat_history (
id INT AUTO_INCREMENT PRIMARY KEY,
user_message TEXT NOT NULL,
ai_reply TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
- Fork repository
- Buat branch fitur baru (
git checkout -b feature/AmazingFeature
) - Commit perubahan (
git commit -m 'Add some AmazingFeature'
) - Push ke branch (
git push origin feature/AmazingFeature
) - Buat Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Project Link: https://github.com/akbarryyan/ai-chat