Skip to content

27HarshalPatel/Support-Ticket-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Support Ticket System

A full-stack support ticket management system with AI-powered ticket classification using LLMs.

Tech Stack

  • Backend: Django 4.2 + Django REST Framework + PostgreSQL
  • Frontend: React 18
  • LLM Integration: Anthropic Claude (configurable)
  • Infrastructure: Docker + Docker Compose

Features

Core Functionality

  • ✅ Create, read, update support tickets
  • ✅ Filter tickets by category, priority, status
  • ✅ Search tickets by title and description
  • ✅ Real-time statistics dashboard
  • ✅ Database-level aggregations (no Python loops)

AI-Powered Classification

  • ✅ Automatic category and priority suggestions using LLM
  • ✅ Real-time classification as user types description or title
  • Intelligent keyword-based fallback when LLM unavailable
  • ✅ User can accept or override LLM suggestions
  • ✅ Smart pattern matching for technical, billing, and account issues

Classification Examples

The system intelligently classifies tickets based on keywords:

Critical Priority:

  • "Server is down" → Technical / Critical
  • "Unable to access" → Account / Critical
  • "System outage" → Technical / Critical
  • "Data loss" → Technical / Critical

High Priority:

  • "Payment not working" → Billing / High
  • "Error 500" → Technical / High
  • "Can't login" → Account / High

Technical Issues:

  • Keywords: server, error, bug, crash, API, performance, slow, timeout
  • Category: Technical

Billing Issues:

  • Keywords: charge, payment, invoice, refund, subscription, price
  • Category: Billing

Account Issues:

  • Keywords: login, password, access, permission, profile, reset
  • Category: Account

LLM Provider Choice

Selected: Anthropic Claude Sonnet 4 with Intelligent Fallback

Why Anthropic Claude?

  1. Superior Reasoning: Claude excels at nuanced classification tasks, understanding context and severity better than alternatives
  2. Reliable JSON Output: Consistent structured responses critical for production systems
  3. Speed-Accuracy Balance: Sonnet 4 provides enterprise-grade accuracy while maintaining low latency
  4. Safety: Built-in safety features reduce risk of inappropriate classifications
  5. API Simplicity: Clean, well-documented API with excellent error handling

Hybrid Classification Approach

The system uses a two-tier classification strategy:

  1. Primary: LLM Classification (when API key available)

    • Uses Claude Sonnet 4 with enhanced prompt
    • Analyzes both title and description
    • Considers urgency, impact, and nature of issue
    • Returns accurate category and priority
  2. Fallback: Keyword-Based Classification (always available)

    • Works without API key
    • Uses regex pattern matching
    • Identifies critical keywords (down, crash, outage, error, etc.)
    • Scores category relevance
    • Ensures system always provides intelligent suggestions

Classification Logic

Priority Determination:

  • Critical: server down, system outage, data loss, security breach, can't access
  • High: significant issues, bugs, errors, blocked work
  • Medium: help requests, questions, performance issues
  • Low: minor issues, cosmetic problems

Category Determination:

  • Technical: server, error, bug, crash, API, integration, performance, timeout
  • Billing: charge, payment, invoice, refund, subscription, price
  • Account: login, password, access, permission, profile, reset
  • General: fallback for unmatched content

The LLM classification prompt is designed to:

  • Clearly define categories with examples
  • Establish priority levels based on business impact
  • Request structured JSON output for reliability
  • Handle edge cases gracefully

Project Structure

support-ticket-system/
├── backend/
│   ├── config/                 # Django project settings
│   │   ├── settings.py
│   │   ├── urls.py
│   │   └── wsgi.py
│   ├── tickets/                # Tickets Django app
│   │   ├── models.py          # Ticket data model
│   │   ├── serializers.py     # DRF serializers
│   │   ├── views.py           # API views
│   │   ├── urls.py            # URL routing
│   │   ├── llm_service.py     # LLM classification service
│   │   └── admin.py           # Django admin config
│   ├── Dockerfile
│   ├── requirements.txt
│   ├── entrypoint.sh
│   └── manage.py
├── frontend/
│   ├── public/
│   │   └── index.html
│   ├── src/
│   │   ├── components/
│   │   │   ├── TicketForm.js   # Ticket submission form
│   │   │   ├── TicketList.js   # Ticket list with filters
│   │   │   ├── TicketCard.js   # Individual ticket display
│   │   │   └── Stats.js        # Statistics dashboard
│   │   ├── App.js
│   │   ├── App.css
│   │   ├── index.js
│   │   └── index.css
│   ├── Dockerfile
│   └── package.json
├── docker-compose.yml
├── .gitignore
└── README.md

Setup Instructions

Prerequisites

Quick Start

  1. Clone the repository (or extract the zip file)

  2. Set your API key (optional but recommended for LLM features)

    export LLM_API_KEY="your-anthropic-api-key-here"
  3. Build and run the entire application

    docker-compose up --build
  4. Access the application

The application will:

  • Start PostgreSQL database
  • Run Django migrations automatically
  • Build and serve the React frontend
  • Everything works together seamlessly

Environment Variables

Set these in your shell or in a .env file:

  • LLM_API_KEY - Your Anthropic API key (required for LLM classification)
  • LLM_PROVIDER - LLM provider (default: "anthropic")
  • DEBUG - Django debug mode (default: "True")
  • POSTGRES_DB - Database name (default: "ticketdb")
  • POSTGRES_USER - Database user (default: "ticketuser")
  • POSTGRES_PASSWORD - Database password (default: "ticketpass")

Without Docker (Manual Setup)

If you need to run without Docker:

Backend:

cd backend
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver

Frontend:

cd frontend
npm install
npm start

Database: You'll need to set up PostgreSQL manually and update the connection settings.

API Endpoints

Tickets

  • POST /api/tickets/ - Create a new ticket (returns 201)
  • GET /api/tickets/ - List all tickets (newest first)
    • Query params: ?category=, ?priority=, ?status=, ?search=
  • PATCH /api/tickets/<id>/ - Update a ticket
  • GET /api/tickets/stats/ - Get aggregated statistics
  • POST /api/tickets/classify/ - Classify a description

Example Stats Response

{
  "total_tickets": 124,
  "open_tickets": 67,
  "avg_tickets_per_day": 8.3,
  "priority_breakdown": {
    "low": 30,
    "medium": 52,
    "high": 31,
    "critical": 11
  },
  "category_breakdown": {
    "billing": 28,
    "technical": 55,
    "account": 22,
    "general": 19
  }
}

Database Schema

Ticket Model

Field Type Constraints
id AutoField Primary Key
title CharField max_length=200, required
description TextField required
category CharField choices: billing, technical, account, general
priority CharField choices: low, medium, high, critical
status CharField choices: open, in_progress, resolved, closed; default=open
created_at DateTimeField auto_now_add=True

All constraints are enforced at the database level through Django migrations.

Design Decisions

Backend Architecture

  • ViewSets over APIView: Used DRF ViewSets for clean, RESTful API design
  • Database-level aggregation: Stats endpoint uses Django ORM's aggregate() and annotate() for efficiency
  • Graceful LLM failure: System continues working even if LLM is unavailable
  • Singleton LLM client: Reuses Anthropic client instance for efficiency

Frontend Design

  • Component separation: Clear separation between Form, List, Card, and Stats
  • Real-time updates: Stats dashboard refreshes after ticket creation/update
  • Progressive enhancement: Form works without LLM, enhanced when available
  • User control: Users can always override LLM suggestions

LLM Integration

  • On-blur classification: Triggers after user finishes typing description
  • Structured prompting: Clear instructions for consistent JSON responses
  • Validation: Server-side validation of LLM responses
  • Error handling: Logs errors, returns defaults on failure

Development Notes

Adding Migrations

docker-compose exec backend python manage.py makemigrations
docker-compose exec backend python manage.py migrate

Accessing Django Shell

docker-compose exec backend python manage.py shell

Viewing Logs

docker-compose logs -f backend
docker-compose logs -f frontend

Running Tests

# Backend
docker-compose exec backend python manage.py test

# Frontend
docker-compose exec frontend npm test

Production Considerations

For production deployment:

  1. Set DEBUG=False in Django settings
  2. Configure ALLOWED_HOSTS properly
  3. Use environment-specific secrets management
  4. Set up HTTPS/SSL
  5. Use production-grade web server (Gunicorn/uWSGI)
  6. Configure CORS properly for your domain
  7. Set up database backups
  8. Monitor LLM API usage and costs
  9. Implement rate limiting
  10. Add authentication/authorization

Examples

Example 1: Critical Technical Issue

Title: "Server is down" Description: "Production server not responding" Expected: Technical / Critical

Example 2: High Priority Billing

Title: "Payment failed" Description: "Credit card charge not working" Expected: Billing / High

Example 3: Account Access

Title: "Can't login" Description: "Password reset not working" Expected: Account / High

Example 4: General Question

Title: "How to export data?" Description: "I need to download my reports" Expected: General / Medium

Troubleshooting

Database connection issues:

  • Ensure PostgreSQL container is healthy: docker-compose ps
  • Check database logs: docker-compose logs db

LLM classification not working:

  • Verify LLM_API_KEY is set correctly
  • Check backend logs for API errors
  • System will fall back to defaults if LLM fails

Frontend can't reach backend:

  • Ensure both services are running
  • Check CORS configuration in Django settings
  • Verify API_BASE URL in frontend

License

This project is created as a technical assessment.

Author

Built with attention to code quality, proper architecture, and production-ready practices.

About

A Support Ticket System Dashboard in which users can submit support tickets, browse and filter them, and view aggregated metrics. The twist: when a ticket is submitted, an LLM automatically categorizes it and suggests a priority level based on the description - the user can then review and override these suggestions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors