Skip to content

craigderington/srvc-tckt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎫 Service Ticket System (srvc-tckt)

Java Spring Boot Kubernetes License

A distributed help desk / support ticket system designed to showcase workload management across Kubernetes pods

Features β€’ Quick Start β€’ Architecture β€’ Deployment β€’ API β€’ Contributing


πŸ“‹ Table of Contents


🌟 Overview

srvc-tckt (Service Ticket) is a full-featured, distributed support ticket management system built with Spring Boot and designed for Kubernetes environments. It demonstrates real-time workload distribution, agent performance tracking, and queue management across multiple pods.

Key Highlights

  • πŸš€ Cloud-Native: Built for Kubernetes with horizontal scaling
  • 🎯 Priority Management: Color-coded priority system (Urgent/High/Medium/Low)
  • πŸ”„ Real-Time Distribution: Watch tickets flow across pods in real-time
  • πŸ›‘οΈ Concurrency Safe: Optimistic locking prevents double-assignment
  • πŸ“Š Metrics & Monitoring: Built-in actuator endpoints and performance tracking
  • 🎨 Modern UI: Responsive Thymeleaf templates with JavaScript enhancements

✨ Features

Core Functionality

  • πŸ“‹ Ticket Management

    • Create, assign, update, and track support tickets
    • Full lifecycle management (NEW β†’ ASSIGNED β†’ IN_PROGRESS β†’ RESOLVED β†’ CLOSED β†’ ARCHIVED)
    • Priority-based queue with visual color coding
    • Category organization (Technical, Billing, Account, General)
  • πŸ‘₯ Multi-Agent Support

    • Multiple agents can work simultaneously
    • "Assign to Me" functionality with race condition prevention
    • Per-agent performance metrics and dashboards
    • Workload distribution visualization
  • 🎯 Priority System

    • πŸ”΄ URGENT - Immediate attention required
    • 🟠 HIGH - Important, prompt handling
    • 🟑 MEDIUM - Standard priority
    • 🟒 LOW - Can be deferred
  • πŸ“Š Analytics & Reporting

    • System-wide statistics dashboard
    • Per-agent performance metrics
    • Pod/Node distribution tracking
    • Response time and resolution time SLA tracking
  • πŸ”” Notifications

    • Email notifications for ticket events
    • Async email processing
    • Configurable notification templates

Kubernetes Features

  • βš–οΈ Horizontal Scaling: Auto-scaling based on CPU/Memory metrics
  • 🎲 Load Distribution: Demonstrates workload spread across pods
  • πŸ’š Health Checks: Liveness and readiness probes
  • πŸ“‘ Service Discovery: Pod and node tracking
  • πŸ”„ Rolling Updates: Zero-downtime deployments
  • πŸ’Ύ Persistent Storage: PostgreSQL with PVC for data persistence

πŸ—οΈ Architecture

System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Load Balancer / Ingress                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚               β”‚               β”‚
    β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”      β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”      β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”
    β”‚ Pod 1 β”‚      β”‚ Pod 2 β”‚      β”‚ Pod 3 β”‚
    β”‚Agent Aβ”‚      β”‚Agent Bβ”‚      β”‚Agent Cβ”‚
    β””β”€β”€β”€β”¬β”€β”€β”€β”˜      β””β”€β”€β”€β”¬β”€β”€β”€β”˜      β””β”€β”€β”€β”¬β”€β”€β”€β”˜
        β”‚               β”‚               β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                    β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”
                    β”‚PostgreSQLβ”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Application Components

srvc-tckt/
β”œβ”€β”€ controllers/       # HTTP request handlers
β”œβ”€β”€ services/         # Business logic layer
β”œβ”€β”€ repositories/     # Data access layer
β”œβ”€β”€ entities/         # JPA entities
β”œβ”€β”€ dto/             # Data transfer objects
β”œβ”€β”€ config/          # Spring configuration
└── templates/       # Thymeleaf HTML views

Ticket State Flow

NEW β†’ ASSIGNED β†’ IN_PROGRESS β†’ RESOLVED β†’ CLOSED β†’ ARCHIVED
         ↓             ↓
         └─────────────┴────→ WAITING_CUSTOMER ──→ IN_PROGRESS

πŸ› οΈ Technology Stack

Backend

  • Java 21 - Modern Java LTS release
  • Spring Boot 4.0.0 - Application framework
  • Spring MVC - Web framework
  • Spring Data JPA - Data persistence
  • Spring Security - Authentication & authorization
  • Hibernate - ORM
  • Flyway - Database migrations

Database

  • H2 - In-memory database (development)
  • PostgreSQL 16 - Production database

Frontend

  • Thymeleaf - Server-side templating
  • HTML5/CSS3 - Modern web standards
  • JavaScript (ES6+) - Client-side interactivity

DevOps & Infrastructure

  • Docker - Containerization
  • Kubernetes - Orchestration
  • Maven - Build automation
  • Spring Boot Actuator - Monitoring & metrics

Additional Tools

  • Lombok - Boilerplate reduction
  • Spring Boot DevTools - Development utilities
  • JavaMail - Email notifications

πŸš€ Quick Start

Prerequisites

  • Java 21 or higher
  • Maven 3.9+
  • Docker (optional, for containerization)
  • kubectl & k3s (optional, for Kubernetes deployment)

Local Development

  1. Clone the repository

    git clone https://github.com/your-org/srvc-tckt.git
    cd srvc-tckt
  2. Run with H2 (in-memory database)

    ./mvnw spring-boot:run
  3. Access the application

    URL: http://localhost:8888
    
  4. Login with default credentials

    • agent1 / password
    • agent2 / password
    • admin / admin

Run with PostgreSQL

  1. Start PostgreSQL

    docker run -d \
      --name postgres \
      -e POSTGRES_DB=srvc_tckt_db \
      -e POSTGRES_USER=postgres \
      -e POSTGRES_PASSWORD=postgres \
      -p 5432:5432 \
      postgres:16-alpine
  2. Run application with prod profile

    ./mvnw spring-boot:run -Dspring-boot.run.profiles=prod

🐳 Docker

Build Docker Image

# Build the image
docker build -t srvc-tckt:latest .

# Verify the image
docker images | grep srvc-tckt

Run with Docker Compose

Create a docker-compose.yml:

version: '3.8'

services:
  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: srvc_tckt_db
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    ports:
      - "5432:5432"
    volumes:
      - postgres-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 10s
      timeout: 5s
      retries: 5

  srvc-tckt:
    image: srvc-tckt:latest
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      SPRING_PROFILES_ACTIVE: prod
      DB_HOST: postgres
      DB_PORT: 5432
      DB_NAME: srvc_tckt_db
      DB_USERNAME: postgres
      DB_PASSWORD: postgres
    ports:
      - "8888:8888"
    healthcheck:
      test: ["CMD", "wget", "--spider", "http://localhost:8888/actuator/health"]
      interval: 30s
      timeout: 10s
      retries: 3

volumes:
  postgres-data:

Run with:

docker-compose up -d

☸️ Kubernetes Deployment

Prerequisites

  • k3s or any Kubernetes cluster
  • kubectl configured
  • Docker image built and available

Quick Deploy to k3s

  1. Build and load image into k3s

    # Build the image
    docker build -t srvc-tckt:latest .
    
    # Import into k3s
    docker save srvc-tckt:latest | sudo k3s ctr images import -
  2. Deploy to Kubernetes

    kubectl apply -f deployment.yaml
  3. Check deployment status

    # Check pods
    kubectl get pods -n srvc-tckt
    
    # Check services
    kubectl get svc -n srvc-tckt
    
    # Watch pod distribution
    kubectl get pods -n srvc-tckt -o wide
  4. Access the application

    # Get the LoadBalancer IP
    kubectl get svc srvc-tckt-service -n srvc-tckt
    
    # Access at: http://<EXTERNAL-IP>

Scaling

# Manual scaling
kubectl scale deployment srvc-tckt -n srvc-tckt --replicas=5

# Check HPA status
kubectl get hpa -n srvc-tckt

# Watch auto-scaling in action
kubectl get hpa -n srvc-tckt --watch

Monitoring Pods

# View logs from all pods
kubectl logs -n srvc-tckt -l app=srvc-tckt --tail=100

# Follow logs from a specific pod
kubectl logs -n srvc-tckt <pod-name> -f

# Execute commands in a pod
kubectl exec -n srvc-tckt <pod-name> -it -- /bin/sh

βš™οΈ Configuration

Environment Variables

Variable Description Default Required
SPRING_PROFILES_ACTIVE Active Spring profile local No
SERVER_PORT Application port 8888 No
DB_HOST Database hostname localhost Yes (prod)
DB_PORT Database port 5432 Yes (prod)
DB_NAME Database name srvc_tckt_db Yes (prod)
DB_USERNAME Database username postgres Yes (prod)
DB_PASSWORD Database password - Yes (prod)
HOSTNAME Pod name (auto-set by K8s) local-dev No
NODE_NAME Node name (set in deployment) local-node No
MAIL_HOST SMTP host localhost No
MAIL_PORT SMTP port 1025 No

Application Profiles

  • local - H2 in-memory database, development features enabled
  • prod - PostgreSQL database, production optimizations

Spring Boot Actuator Endpoints

Available at /actuator:

  • /health - Health check
  • /info - Application info
  • /metrics - Application metrics
  • /prometheus - Prometheus metrics

πŸ’‘ Usage

Creating a Ticket

  1. Navigate to Dashboard
  2. Click Create New Ticket
  3. Fill in the form:
    • Subject
    • Description
    • Priority (Urgent/High/Medium/Low)
    • Category (Technical/Billing/Account/General)
    • Customer Name & Email
  4. Click Submit Ticket

Agent Workflow

  1. Login as an agent (agent1/password)
  2. View Ticket Queue - See all unassigned tickets
  3. Click Assign to Me on a ticket
  4. Work through the ticket lifecycle:
    • Start Progress - Begin working
    • Request Info - Ask customer for more details
    • Resolve - Mark as resolved
    • Close - Final closure

Monitoring Workload Distribution

  1. Go to Statistics page
  2. View By Pod section
  3. See how tickets are distributed across pods
  4. Compare performance metrics per pod/node

Keyboard Shortcuts

  • Alt + H - Dashboard
  • Alt + Q - Ticket Queue
  • Alt + M - My Tickets
  • Alt + A - All Tickets
  • Alt + N - New Ticket

πŸ“š API Reference

REST Endpoints

Tickets

GET    /tickets              # List all tickets
GET    /tickets/{id}         # Get ticket details
POST   /tickets/new          # Create ticket
POST   /tickets/{id}/assign  # Assign to current agent
POST   /tickets/{id}/start   # Start progress
POST   /tickets/{id}/resolve # Resolve ticket
POST   /tickets/{id}/close   # Close ticket

Statistics

GET    /tickets/stats        # System statistics

Health & Monitoring

GET    /actuator/health      # Health check
GET    /actuator/metrics     # Metrics
GET    /actuator/info        # Application info

πŸ”§ Development

Building from Source

# Clean and build
./mvnw clean install

# Skip tests for faster builds
./mvnw clean install -DskipTests

# Run tests only
./mvnw test

# Package as JAR
./mvnw clean package

Project Structure

srvc-tckt/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main/
β”‚   β”‚   β”œβ”€β”€ java/
β”‚   β”‚   β”‚   └── com/helpdesk/srvc_tckt/
β”‚   β”‚   β”‚       β”œβ”€β”€ config/          # Configuration
β”‚   β”‚   β”‚       β”œβ”€β”€ controller/      # Controllers
β”‚   β”‚   β”‚       β”œβ”€β”€ dto/            # DTOs
β”‚   β”‚   β”‚       β”œβ”€β”€ entity/         # Entities
β”‚   β”‚   β”‚       β”œβ”€β”€ repository/     # Repositories
β”‚   β”‚   β”‚       └── service/        # Services
β”‚   β”‚   └── resources/
β”‚   β”‚       β”œβ”€β”€ db/migration/       # Flyway migrations
β”‚   β”‚       β”œβ”€β”€ static/             # CSS, JS
β”‚   β”‚       β”œβ”€β”€ templates/          # Thymeleaf templates
β”‚   β”‚       └── application.properties
β”‚   └── test/                       # Tests
β”œβ”€β”€ Dockerfile                      # Docker image definition
β”œβ”€β”€ deployment.yaml                 # Kubernetes manifests
β”œβ”€β”€ pom.xml                        # Maven configuration
└── README.md                      # This file

Code Style

  • Follow Java naming conventions
  • Use Lombok to reduce boilerplate
  • Document public APIs with Javadoc
  • Write unit tests for service layer
  • Keep controllers thin, business logic in services

πŸ§ͺ Testing

Run All Tests

./mvnw test

Run Specific Test Class

./mvnw test -Dtest=TicketServiceTest

Test Coverage

./mvnw clean test jacoco:report

View coverage report: target/site/jacoco/index.html


πŸ“Š Monitoring

Prometheus Metrics

Scrape metrics from:

http://localhost:8888/actuator/prometheus

Grafana Dashboard

Import the provided dashboard:

  • CPU/Memory usage per pod
  • Request rate and response times
  • Ticket processing metrics
  • Database connection pool stats

Logging

Logs are output to stdout/stderr and can be collected by:

  • Kubernetes logs: kubectl logs
  • Log aggregation: Elasticsearch/Fluentd/Kibana (EFK)
  • Cloud logging: CloudWatch, Stackdriver, etc.

πŸ› Troubleshooting

Application won't start

Check Java version:

java -version  # Should be 21 or higher

Check port availability:

lsof -i :8888  # Port should be free

Database connection issues

PostgreSQL not running:

docker ps | grep postgres

Wrong credentials: Check application-prod.properties and environment variables

Pods not starting in Kubernetes

Check pod logs:

kubectl logs -n srvc-tckt <pod-name>

Check events:

kubectl describe pod -n srvc-tckt <pod-name>

Check resources:

kubectl top pods -n srvc-tckt

Common Issues

Issue Solution
503 Service Unavailable Database not ready - check init container logs
CrashLoopBackOff Check logs with kubectl logs
ImagePullBackOff Ensure image is in k3s: docker save | k3s ctr images import
No LoadBalancer IP k3s uses Traefik - check ingress instead

🀝 Contributing

Contributions are welcome! Please follow these steps:

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

Coding Guidelines

  • Write clear commit messages
  • Add tests for new features
  • Update documentation
  • Follow existing code style
  • Ensure CI passes

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Spring Boot team for the excellent framework
  • Kubernetes community for orchestration tools
  • Open source contributors

πŸ“ž Support


Built with ❀️ for demonstrating distributed workload management in Kubernetes

⭐ Star this repo if you find it useful!

About

Help desk/support ticket system designed to demonstrate workload management across Kubernetes pods.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published