Sistem Chatbot AI untuk perusahaan mesin coding industri menggunakan Laravel 12, Mistral AI, dan Qdrant Vector Database.
MesinCoding Chatbot adalah sistem AI berbasis web yang membantu pengguna untuk mendapatkan informasi tentang produk mesin coding industri. Sistem ini menggunakan teknologi RAG (Retrieval Augmented Generation) untuk memberikan respons yang akurat berdasarkan knowledge base dokumen.
- Chatbot AI - Bertanya tentang produk mesin coding menggunakan natural language
- RAG-powered Responses - Jawaban berdasarkan dokumen yang diindeks ke vector database
- Document Management - Upload dan kelola dokumen pengetahuan (Admin)
- User Management - CRUD user dengan role-based access control
- Responsive Design - Tampilan optimal di desktop dan mobile
- Fast Responses - Pattern matching + caching untuk respons cepat
- Secure - Authentication, authorization, dan CSRF protection
| Komponen | Teknologi |
|---|---|
| Backend | Laravel 12, PHP 8.2+ |
| Frontend | Blade Templates, Tailwind CSS 3.1, Alpine.js 3.4 |
| Database | MySQL |
| Vector DB | Qdrant Cloud |
| LLM Provider | Mistral AI |
| Authentication | Laravel Breeze |
| Authorization | Spatie Laravel Permission |
┌─────────────────────────────────────────────────────────────────────┐
│ CLIENT LAYER │
│ Browser (Chrome/Firefox/Safari) + Alpine.js + Tailwind CSS │
└─────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────┐
│ BACKEND LAYER │
│ │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ Laravel 11 Application │ │
│ │ │ │
│ │ Controllers │ Services │ Middleware │ │
│ │ • Chatbot │ • MistralAI │ • Auth │ │
│ │ • Document │ • Qdrant │ • Role:admin │ │
│ │ • User │ • Embedding │ │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Mistral AI │ │ Qdrant │ │ MySQL │
│ (LLM API) │ │ (Vector DB) │ │ (Metadata) │
└─────────────┘ └─────────────┘ └─────────────┘
User Question → Embed Question → Vector Search (Qdrant) → Get Context
│ │
│ ▼
│ Relevance Check (threshold 0.6)
│ │
│ ┌───────┴───────┐
│ ▼ ▼
│ Relevant Not Relevant
│ │ │
│ ▼ ▼
│ Build RAG Prompt Direct API Call
│ │ │
│ └───────┬───────┘
│ ▼
│ Mistral AI
│ │
│ ▼
│ Clean Response
│ │
│ ▼
└─────────────▶ User Answer
mesincoding-chatbot/
├── app/
│ ├── Console/Commands/ # Artisan commands
│ ├── Constants/ # Konstanta aplikasi
│ ├── Exceptions/ # Custom exceptions
│ ├── Http/
│ │ ├── Controllers/ # Controllers
│ │ │ ├── Admin/ # Admin controllers
│ │ │ ├── Auth/ # Auth controllers
│ │ │ ├── ChatbotController.php
│ │ │ └── ...
│ │ └── Requests/ # Form requests
│ ├── Jobs/ # Queue jobs
│ ├── Models/ # Eloquent models
│ └── Services/ # Business logic
│ ├── MistralAiService.php # Mistral AI integration
│ ├── EmbeddingService.php # Generate embeddings
│ ├── QdrantService.php # Vector DB operations
│ ├── RetrievalService.php # RAG retrieval
│ └── ...
├── config/ # Laravel config files
├── database/
│ ├── factories/
│ ├── migrations/ # Database migrations
│ └── seeders/ # Database seeders
├── public/ # Document root
├── resources/
│ ├── css/ # Tailwind CSS
│ ├── js/ # JavaScript (Alpine.js)
│ └── views/ # Blade templates
├── routes/ # Route definitions
├── storage/
│ ├── app/chatbot/ # Chatbot dataset
│ └── app/documents/ # Uploaded documents
└── tests/ # Test files
- PHP 8.2+
- Composer 2.5+
- Node.js 18+
- MySQL 8.0+
- Mistral AI API Key
- Qdrant Cloud Account
- Clone Repository
git clone https://github.com/RIOKOWI/compro-ai-chatbot.git
cd compro-ai-chatbot- Install Dependencies
composer install
npm install- Setup Environment
cp .env.example .env
php artisan key:generate- Configure Environment (.env)
# Database
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mesincoding
DB_USERNAME=root
DB_PASSWORD=
# Mistral AI
MISTRAL_API_KEY=your_api_key_here
MISTRAL_BASE_URL=https://api.mistral.ai/v1/chat/completions
MISTRAL_MODEL=mistral-medium-latest
MISTRAL_EMBEDDING_URL=https://api.mistral.ai/v1/embeddings
MISTRAL_MODEL_EMBED=mistral-embed-2312
# Qdrant
QDRANT_HOST=https://your-cluster.qdrant.io
QDRANT_API_KEY=your_qdrant_api_key
QDRANT_CLUSTER_NAME=mesin
QDRANT_DIMENSION=1024- Setup Database
mysql -u root -p
CREATE DATABASE compro_ai_chatbot CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
EXIT;
php artisan migrate --seed- Build Assets
npm run dev # Development
# atau
npm run build # Production- Run Development Server
php artisan serveBuka browser: http://localhost:8000
Anda harus bikin UserSeeder dengan role admin lalu jalankan Seed nya
Halaman utama dengan informasi produk dan chat widget.
Widget chat dengan Alpine.js untuk interaksi real-time.
Panel admin untuk manajemen user dan dokumen.
Upload dan monitoring status dokumen.
# Run all tests
php artisan test
# Run specific test
php artisan test --filter=ChatbotTest| Module | Status |
|---|---|
| Authentication | ✅ |
| Chatbot | ✅ |
| Document Management | ✅ |
| User Management | ✅ |
| Role-based Access | ✅ |
- Server Setup
sudo apt update && sudo apt upgrade -y
sudo apt install -y nginx php8.2-fpm php8.2-mysql ...- Clone & Configure
git clone https://github.com/RIOKOWI/compro-ai-chatbot.git /var/www/compro-ai-chatbot
cd /var/www/compro-ai-chatbot
composer install --optimize-autoloader --no-dev
npm run build- Configure Nginx
sudo cp deployment/nginx.conf /etc/nginx/sites-available/mesincoding
sudo ln -s /etc/nginx/sites-available/mesincoding /etc/nginx/sites-enabled/- SSL Setup
sudo certbot --nginx -d mesincoding.my.id- Final Setup
php artisan migrate --force
php artisan db:seed --force
php artisan config:cache
php artisan route:cache- Password Hashing (bcrypt)
- CSRF Protection
- SQL Injection Prevention
- XSS Prevention
- Role-based Access Control (RBAC)
- Session Management
- Input Validation
- Response Caching (68% cache hit rate)
- Vector Search Indexing (Qdrant)
- Batch Embedding Processing
- Asset Minification (Vite)
- Database Query Optimization
- Fork repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'feat(scope): Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License.
Tim Developer Kelompok 1
Built with ❤️ using Laravel, Mistral AI, and Qdrant