Skip to content

Faisal-Sey/Ticketing-System

Repository files navigation

🎯 Support System

A full-stack support ticket management system built with Node.js, Express, TypeScript, MongoDB, React, Vite, and TailwindCSS.

✨ Features

  • Dual Integration Modes:

    • πŸ”— Embeddable widget for any application
    • 🌐 Standalone support portal
  • Core Functionality:

    • βœ… Create and track support tickets
    • πŸ’¬ Real-time chat with WebSocket support
    • 🚨 Ticket escalation with email notifications
    • πŸ“Š Ticket status tracking (Open, In Progress, Resolved, Closed)
    • 🎯 Priority levels (Low, Medium, High, Critical)
    • πŸ“§ Email notifications for escalations and updates
    • πŸ” Filter and search tickets
    • πŸ“± Responsive design

πŸ—οΈ Project Structure

support-system/
β”œβ”€β”€ backend/                 # Node.js + Express + TypeScript
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ models/         # MongoDB models
β”‚   β”‚   β”œβ”€β”€ controllers/    # Route controllers
β”‚   β”‚   β”œβ”€β”€ routes/         # API routes
β”‚   β”‚   β”œβ”€β”€ config/         # Database config
β”‚   β”‚   β”œβ”€β”€ utils/          # Utilities (email, ticket generator)
β”‚   β”‚   β”œβ”€β”€ middleware/     # Express middleware
β”‚   β”‚   └── server.ts       # Main server file
β”‚   β”œβ”€β”€ package.json
β”‚   └── tsconfig.json
β”‚
└── frontend/               # React + Vite + TypeScript
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ components/     # React components
    β”‚   β”œβ”€β”€ pages/          # Page components
    β”‚   β”œβ”€β”€ services/       # API and Socket services
    β”‚   β”œβ”€β”€ store/          # State management (Zustand)
    β”‚   β”œβ”€β”€ types/          # TypeScript types
    β”‚   β”œβ”€β”€ widget.tsx      # Embeddable widget entry
    β”‚   └── main.tsx        # Main app entry
    β”œβ”€β”€ public/
    β”‚   └── embed-example.html
    β”œβ”€β”€ package.json
    └── vite.config.ts

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • MongoDB (v6 or higher)
  • npm or yarn

Backend Setup

  1. Navigate to the backend directory:
cd backend
  1. Install dependencies:
npm install
  1. Create a .env file (copy from .env.example):
cp .env.example .env
  1. Configure your environment variables in .env:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/support-system
NODE_ENV=development
CORS_ORIGIN=http://localhost:5173

# Email Configuration (optional, for escalation notifications)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password
SUPPORT_EMAIL=support@yourcompany.com
  1. Start MongoDB:
# Using MongoDB service
mongod

# Or if using Docker
docker run -d -p 27017:27017 --name mongodb mongo:latest
  1. Start the development server:
npm run dev

The backend will run on http://localhost:5000

Frontend Setup

  1. Navigate to the frontend directory:
cd frontend
  1. Install dependencies:
npm install
  1. Create a .env file (copy from .env.example):
cp .env.example .env
  1. Configure your environment variables in .env:
VITE_API_URL=http://localhost:5000/api
VITE_SOCKET_URL=http://localhost:5000
  1. Start the development server:
npm run dev

The frontend will run on http://localhost:5173

Build for Production

Backend:

cd backend
npm run build
npm start

Frontend (Standalone App):

cd frontend
npm run build

Frontend (Embeddable Widget):

cd frontend
npm run build:widget

πŸ”Œ Integration Guide

Method 1: Embeddable Widget

Add the following code to your application (e.g., kofoAfro):

<!-- Add before closing </body> tag -->
<link rel="stylesheet" href="http://your-domain.com/support-widget.css">
<script src="http://your-domain.com/support-widget.iife.js"></script>
<script>
  window.addEventListener('load', function() {
    window.SupportWidget.init({
      applicationSource: 'KofoAfro',
      position: 'bottom-right', // or 'bottom-left'
      primaryColor: '#0ea5e9' // optional custom color
    });
  });
</script>

Method 2: Direct Link

Add a button or link in your application:

<a href="http://your-support-domain.com" target="_blank" class="support-button">
  Get Support
</a>

Example for KofoAfro Integration

In your kofoAfro/frontend/index.html or layout component:

<!DOCTYPE html>
<html lang="en">
<head>
  <!-- Your existing head content -->
</head>
<body>
  <div id="root"></div>
  
  <!-- Support Widget Integration -->
  <link rel="stylesheet" href="http://localhost:5173/dist/support-widget.css">
  <script src="http://localhost:5173/dist/support-widget.iife.js"></script>
  <script>
    window.addEventListener('load', function() {
      if (window.SupportWidget) {
        window.SupportWidget.init({
          applicationSource: 'KofoAfro',
          position: 'bottom-right',
          primaryColor: '#0ea5e9'
        });
      }
    });
  </script>
</body>
</html>

πŸ“‘ API Endpoints

Tickets

  • POST /api/tickets - Create a new ticket
  • GET /api/tickets - Get all tickets (with filters)
  • GET /api/tickets/stats - Get ticket statistics
  • GET /api/tickets/:ticketNumber - Get ticket by number
  • POST /api/tickets/:ticketNumber/messages - Add message to ticket
  • PATCH /api/tickets/:ticketNumber/status - Update ticket status
  • POST /api/tickets/:ticketNumber/escalate - Escalate ticket

WebSocket Events

  • join-ticket - Join a ticket room
  • leave-ticket - Leave a ticket room
  • send-message - Send a message
  • new-message - Receive new messages
  • typing - User typing indicator
  • user-typing - Receive typing notifications

🎨 Customization

Widget Appearance

You can customize the widget by passing configuration options:

window.SupportWidget.init({
  applicationSource: 'Your App Name',
  position: 'bottom-right', // 'bottom-right' or 'bottom-left'
  primaryColor: '#your-color' // Any valid CSS color
});

Styling

The widget uses TailwindCSS. You can override styles by targeting the widget classes in your application's CSS.

πŸ”’ Security Considerations

  1. CORS: Configure CORS_ORIGIN in backend .env to restrict API access
  2. Email: Use app-specific passwords for email services
  3. MongoDB: Use authentication in production
  4. Environment Variables: Never commit .env files
  5. Rate Limiting: Consider adding rate limiting for API endpoints

πŸ“§ Email Notifications

The system sends email notifications for:

  • Ticket escalations (to support team)
  • Ticket updates (to users)

Configure SMTP settings in backend .env file.

πŸ§ͺ Testing

Test the embeddable widget using the example HTML file:

# Open in browser
frontend/public/embed-example.html

πŸ“ License

MIT

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ž Support

For issues or questions, create a support ticket using the system itself! πŸ˜„

About

This is a ticketing system with embedding and standalone app features, it includes realtime chat.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages