feat: Initialize OmniSupport AI project structure
Sets up the basic project structure for OmniSupport AI, including: - Vite build tool configuration. - React and necessary dependencies. - TypeScript configuration. - Basic HTML and root component setup. - Initial type definitions and mock data for core entities like tickets, agents, and queues. - A README with setup instructions. - A .gitignore file for common build artifacts and development files.
This commit is contained in:
0
backend/Dockerfile
Normal file
0
backend/Dockerfile
Normal file
39
backend/db.js
Normal file
39
backend/db.js
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
import mysql from 'mysql2/promise';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const pool = mysql.createPool({
|
||||
host: process.env.DB_HOST || 'db',
|
||||
port: process.env.DB_PORT || 3306,
|
||||
user: process.env.DB_USER || 'omni_user',
|
||||
password: process.env.DB_PASSWORD || 'omni_pass',
|
||||
database: process.env.DB_NAME || 'omnisupport',
|
||||
waitForConnections: true,
|
||||
connectionLimit: 10,
|
||||
queueLimit: 0
|
||||
});
|
||||
|
||||
export const query = async (sql, params) => {
|
||||
try {
|
||||
const [results] = await pool.execute(sql, params);
|
||||
return results;
|
||||
} catch (error) {
|
||||
console.error('Database query error:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const checkConnection = async () => {
|
||||
try {
|
||||
const connection = await pool.getConnection();
|
||||
await connection.ping();
|
||||
connection.release();
|
||||
console.log('✅ Connected to MySQL Database');
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error('❌ Database connection failed:', error.message);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
47
backend/index.js
Normal file
47
backend/index.js
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
import { checkConnection, query } from './db.js';
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
app.use(cors());
|
||||
app.use(express.json());
|
||||
|
||||
// Health Check & DB Init trigger
|
||||
app.get('/api/health', async (req, res) => {
|
||||
const dbStatus = await checkConnection();
|
||||
res.json({
|
||||
status: 'ok',
|
||||
database: dbStatus ? 'connected' : 'disconnected',
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
});
|
||||
|
||||
// --- API ENDPOINTS EXAMPLES (To replace Mock Data) ---
|
||||
|
||||
// Get All Agents
|
||||
app.get('/api/agents', async (req, res) => {
|
||||
try {
|
||||
const agents = await query('SELECT * FROM agents');
|
||||
res.json(agents);
|
||||
} catch (e) {
|
||||
res.status(500).json({ error: e.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Get Tickets
|
||||
app.get('/api/tickets', async (req, res) => {
|
||||
try {
|
||||
const tickets = await query('SELECT * FROM tickets ORDER BY created_at DESC');
|
||||
res.json(tickets);
|
||||
} catch (e) {
|
||||
res.status(500).json({ error: e.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`🚀 Backend Server running on port ${PORT}`);
|
||||
checkConnection(); // Initial check
|
||||
});
|
||||
21
backend/package.json
Normal file
21
backend/package.json
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
{
|
||||
"name": "omnisupport-backend",
|
||||
"version": "1.0.0",
|
||||
"description": "Backend API for OmniSupport AI",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node index.js",
|
||||
"dev": "nodemon index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.18.2",
|
||||
"mysql2": "^3.9.2",
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^16.4.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^3.1.0"
|
||||
}
|
||||
}
|
||||
38
backend/schema.sql
Normal file
38
backend/schema.sql
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
CREATE TABLE IF NOT EXISTS agents (
|
||||
id VARCHAR(36) PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) UNIQUE NOT NULL,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
role ENUM('superadmin', 'supervisor', 'agent') DEFAULT 'agent',
|
||||
avatar TEXT,
|
||||
queues JSON,
|
||||
skills JSON,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS client_users (
|
||||
id VARCHAR(36) PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) UNIQUE NOT NULL,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
company VARCHAR(255),
|
||||
status ENUM('active', 'inactive') DEFAULT 'active',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tickets (
|
||||
id VARCHAR(36) PRIMARY KEY,
|
||||
subject VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
status ENUM('APERTO', 'IN LAVORAZIONE', 'RISOLTO', 'CHIUSO') DEFAULT 'APERTO',
|
||||
priority ENUM('Bassa', 'Media', 'Alta', 'Critica') DEFAULT 'Media',
|
||||
customer_name VARCHAR(255),
|
||||
assigned_agent_id VARCHAR(36),
|
||||
queue VARCHAR(50),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Insert Default Superadmin if not exists
|
||||
INSERT IGNORE INTO agents (id, name, email, password, role, queues) VALUES
|
||||
('a0', 'Super Admin', 'fcarra79@gmail.com', 'Mr10921.', 'superadmin', '["General", "Tech Support", "Billing"]');
|
||||
Reference in New Issue
Block a user