Skip to content

About

An AI-powered company profile chatbot for MesinCoding, leveraging Retrieval-Augmented Generation (RAG) with Laravel 12, Mistral AI, and Qdrant Vector Database.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

MesinCoding Chatbot

Sistem Chatbot AI untuk perusahaan mesin coding industri menggunakan Laravel 12, Mistral AI, dan Qdrant Vector Database.

MesinCoding Banner PHP Laravel Tailwind CSS


Deskripsi Project

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.

Fitur Utama

  • 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

Tech Stack

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

Arsitektur Sistem

┌─────────────────────────────────────────────────────────────────────┐
│                           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) │
        └─────────────┘      └─────────────┘      └─────────────┘

RAG Pipeline Flow

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

Struktur Folder

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

Instalasi

Prerequisites

  • PHP 8.2+
  • Composer 2.5+
  • Node.js 18+
  • MySQL 8.0+
  • Mistral AI API Key
  • Qdrant Cloud Account

Steps

  1. Clone Repository
git clone https://github.com/RIOKOWI/compro-ai-chatbot.git
cd compro-ai-chatbot
  1. Install Dependencies
composer install
npm install
  1. Setup Environment
cp .env.example .env
php artisan key:generate
  1. 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
  1. Setup Database
mysql -u root -p
CREATE DATABASE compro_ai_chatbot CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
EXIT;

php artisan migrate --seed
  1. Build Assets
npm run dev    # Development
# atau
npm run build  # Production
  1. Run Development Server
php artisan serve

Buka browser: http://localhost:8000

Default Admin Credentials

Anda harus bikin UserSeeder dengan role admin lalu jalankan Seed nya


Screenshots

Landing Page

Halaman utama dengan informasi produk dan chat widget.

Chat Interface

Widget chat dengan Alpine.js untuk interaksi real-time.

Admin Dashboard

Panel admin untuk manajemen user dan dokumen.

Document Management

Upload dan monitoring status dokumen.


Testing

# Run all tests
php artisan test

# Run specific test
php artisan test --filter=ChatbotTest

Test Coverage

Module Status
Authentication ✅
Chatbot ✅
Document Management ✅
User Management ✅
Role-based Access ✅

Deployment

Production URL

https://mesincoding.my.id

Deployment Steps

  1. Server Setup
sudo apt update && sudo apt upgrade -y
sudo apt install -y nginx php8.2-fpm php8.2-mysql ...
  1. 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
  1. Configure Nginx
sudo cp deployment/nginx.conf /etc/nginx/sites-available/mesincoding
sudo ln -s /etc/nginx/sites-available/mesincoding /etc/nginx/sites-enabled/
  1. SSL Setup
sudo certbot --nginx -d mesincoding.my.id
  1. Final Setup
php artisan migrate --force
php artisan db:seed --force
php artisan config:cache
php artisan route:cache

Security Features

  • Password Hashing (bcrypt)
  • CSRF Protection
  • SQL Injection Prevention
  • XSS Prevention
  • Role-based Access Control (RBAC)
  • Session Management
  • Input Validation

Performance Optimizations

  • Response Caching (68% cache hit rate)
  • Vector Search Indexing (Qdrant)
  • Batch Embedding Processing
  • Asset Minification (Vite)
  • Database Query Optimization

Contributing

  1. Fork repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'feat(scope): Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

License

This project is licensed under the MIT License.


Authors

Tim Developer Kelompok 1


Built with ❤️ using Laravel, Mistral AI, and Qdrant

About

An AI-powered company profile chatbot for MesinCoding, leveraging Retrieval-Augmented Generation (RAG) with Laravel 12, Mistral AI, and Qdrant Vector Database.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages