feat: Add Ollama AI integration for automatic mail template generation

 New Features:
- 🤖 AI-powered mail template generation with Ollama
- 📧 Test mail sending with preview
- 🔧 Ollama server and model management
- 🎨 Beautiful AI generation dialog in Templates page
- ⚙️ Ollama settings panel with connection test

Backend:
- Add ollama.service.js - Ollama API integration
- Add ollama.controller.js - Template generation endpoint
- Add ollama.routes.js - /api/ollama/* routes
- Support for multiple Ollama models (llama3.2, mistral, gemma)
- JSON-formatted AI responses with subject + HTML body
- Configurable server URL and model selection

Frontend:
- Settings: Ollama configuration panel
  - Server URL input
  - Model selection
  - Connection test with model listing
- Templates: AI generation dialog
  - Company name, scenario, employee info inputs
  - Custom prompt for AI instructions
  - Auto-save to database
  - Test mail sending functionality

Documentation:
- OLLAMA_SETUP.md - Comprehensive setup guide
- Installation instructions
- Model recommendations
- Usage examples
- Troubleshooting

Tech Stack:
- Ollama API integration (REST)
- Axios HTTP client
- React dialogs with MUI
- Self-hosted AI (privacy-friendly)
- Zero external API dependencies

Example Usage:
  Company: Garanti Bankası
  Scenario: Account security warning
  → AI generates professional phishing test mail in seconds!
This commit is contained in:
salvacybersec
2025-11-10 21:13:58 +03:00
parent d41ff7671e
commit af0510e486
8 changed files with 1121 additions and 7 deletions

View File

@@ -0,0 +1,25 @@
const express = require('express');
const router = express.Router();
const ollamaController = require('../controllers/ollama.controller');
const { isAuthenticated } = require('../middleware/auth.middleware');
// All routes require authentication
router.use(isAuthenticated);
// Test Ollama connection
router.get('/test', ollamaController.testConnection);
// List available models
router.get('/models', ollamaController.listModels);
// Update Ollama settings
router.put('/settings', ollamaController.updateSettings);
// Generate template with AI
router.post('/generate-template', ollamaController.generateTemplate);
// Send test mail
router.post('/send-test-mail', ollamaController.sendTestMail);
module.exports = router;