Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/yocxy2/2a/llms.txt

Use this file to discover all available pages before exploring further.

The AI Ticket Support System uses PostgreSQL as its primary data store, managed through Prisma ORM. The database holds support tickets, knowledge base articles, extracted entities, entity relationships, and user accounts. It also serves as the vector store for hybrid RAG retrieval — semantic similarity search is performed directly in Postgres using the pgvector extension, which eliminates the need for a separate vector database.

Requirements

PostgreSQL 16 or later is required, along with the pgvector extension. The easiest way to satisfy both requirements is to use the official pgvector/pgvector:pg16 Docker image, which ships with the extension pre-installed and ready to enable.
The vector(1536) column type used for knowledge base articles and entities requires the pgvector extension. On startup the backend automatically runs CREATE EXTENSION IF NOT EXISTS vector via Prisma’s $executeRawUnsafe to ensure the extension is active. Cosine distance (<=>) is used for all similarity searches.

Starting the database

Option A — standalone Docker container

If you are running the backend locally without Docker Compose, start a pgvector-enabled Postgres container with:
docker run -d -p 5432:5432 \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=postgres \
  -e POSTGRES_DB=ticket_system \
  pgvector/pgvector:pg16
The included docker-compose.yml file declares a postgres service using the same image. Running docker compose up starts Postgres alongside Redis and the backend in one command — no manual container management required.

Running migrations

After the database is reachable, run Prisma’s code-generation and migration steps from inside the backend/ directory:
cd backend
npx prisma generate
npx prisma migrate dev
prisma generate regenerates the type-safe Prisma Client from schema.prisma. prisma migrate dev applies any pending SQL migrations to the database, creating all tables and indexes. Prisma tracks applied migrations in the _prisma_migrations table so subsequent runs are safe to re-run — only new migrations are applied.

Data schema

The schema is defined in backend/prisma/schema.prisma. The generator and datasource blocks are:
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}
The five application models are described below.

Ticket

The central table for every support request submitted through the system. The AI pipeline populates category, ai_suggested_response, and confidence_score automatically during ticket creation.
FieldTypeNotes
idIntAuto-incrementing primary key
user_descriptionStringRaw text submitted by the user
categoryString?AI-predicted ticket category
ai_suggested_responseString?GPT-4o-mini generated response (@db.Text)
confidence_scoreDecimal?Model confidence between 0 and 1
statusStringWorkflow state; defaults to pending_agent
created_atDateTimeSet automatically on insert
updated_atDateTimeUpdated automatically on every write
Maps to the tickets table.

KnowledgeBase

Stores the curated articles that are retrieved during hybrid RAG to ground AI responses in authoritative content. The embedding column holds a 1 536-dimension vector generated by text-embedding-3-small and is used for semantic nearest-neighbour search.
FieldTypeNotes
idIntAuto-incrementing primary key
titleStringArticle title
contentStringFull article body (@db.Text)
categoryString?Optional category tag
embeddingvector(1536)?OpenAI embedding for cosine similarity search
importanceFloatRetrieval weight multiplier; defaults to 1.0
created_atDateTimeSet automatically on insert
Maps to the knowledge_base table.

Entity

Named entities extracted from ticket text by the GraphRAG pipeline (e.g. product names, people, concepts). Each entity carries its own embedding so it can be retrieved by semantic similarity as well as by graph traversal.
FieldTypeNotes
idIntAuto-incrementing primary key
nameStringCanonical entity name
typeStringEntity class (e.g. Person, Place, Concept)
embeddingvector(1536)?OpenAI embedding for semantic entity search
created_atDateTimeSet automatically on insert
Maps to the entities table.

EntityRelation

Directed edges in the knowledge graph connecting two Entity records. The strength field encodes the confidence or frequency of the relationship and can be used to weight graph traversal during retrieval.
FieldTypeNotes
idIntAuto-incrementing primary key
fromIdIntFK → entities.id (source node)
toIdIntFK → entities.id (target node)
relationTypeStringHuman-readable relationship label
strengthFloatRelationship weight; defaults to 1.0
Maps to the entity_relations table.

User

Stores agent and admin accounts for the support platform.
FieldTypeNotes
idIntAuto-incrementing primary key
nameStringDisplay name
emailStringUnique email address
roleStringAccess level; defaults to user
created_atDateTimeSet automatically on insert
Maps to the users table.

Data migration

If you have an existing knowledge base without embeddings, run the data migration script to backfill vectors:
cd backend
npm run migrate:data
This script iterates over every KnowledgeBase record that has a null embedding, calls the OpenAI text-embedding-3-small endpoint, and writes the resulting vector back to the database. Existing records with embeddings are left untouched, so the command is safe to re-run after adding new articles.

Build docs developers (and LLMs) love