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
Option B — Docker Compose (recommended)
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.
| Field | Type | Notes |
|---|
id | Int | Auto-incrementing primary key |
user_description | String | Raw text submitted by the user |
category | String? | AI-predicted ticket category |
ai_suggested_response | String? | GPT-4o-mini generated response (@db.Text) |
confidence_score | Decimal? | Model confidence between 0 and 1 |
status | String | Workflow state; defaults to pending_agent |
created_at | DateTime | Set automatically on insert |
updated_at | DateTime | Updated 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.
| Field | Type | Notes |
|---|
id | Int | Auto-incrementing primary key |
title | String | Article title |
content | String | Full article body (@db.Text) |
category | String? | Optional category tag |
embedding | vector(1536)? | OpenAI embedding for cosine similarity search |
importance | Float | Retrieval weight multiplier; defaults to 1.0 |
created_at | DateTime | Set 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.
| Field | Type | Notes |
|---|
id | Int | Auto-incrementing primary key |
name | String | Canonical entity name |
type | String | Entity class (e.g. Person, Place, Concept) |
embedding | vector(1536)? | OpenAI embedding for semantic entity search |
created_at | DateTime | Set 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.
| Field | Type | Notes |
|---|
id | Int | Auto-incrementing primary key |
fromId | Int | FK → entities.id (source node) |
toId | Int | FK → entities.id (target node) |
relationType | String | Human-readable relationship label |
strength | Float | Relationship weight; defaults to 1.0 |
Maps to the entity_relations table.
User
Stores agent and admin accounts for the support platform.
| Field | Type | Notes |
|---|
id | Int | Auto-incrementing primary key |
name | String | Display name |
email | String | Unique email address |
role | String | Access level; defaults to user |
created_at | DateTime | Set 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.