Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/geeky-hamster/Quizmaster/llms.txt

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

Quizmaster stores all quiz data, user accounts, and results in a MySQL database. This page walks you through creating the database, connecting the application, and understanding how the schema and initial admin user are managed automatically on startup.

Prerequisites

You need a running MySQL instance version 5.7 or 8.x. Quizmaster uses Sequelize with the mysql2 driver, so either version works. Confirm your MySQL version with:
mysql --version

Setup

1

Create the database

You can create the database manually or use the provided script.Option A — use the npm script:
npm run db:create
This runs ts-node scripts/create-mysql-db.ts, which connects using your DB_* environment variables and creates the database if it does not already exist.Option B — create manually in MySQL:
CREATE DATABASE quizmaster CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
2

Configure environment variables

Create a .env file in the backend directory. You can provide individual connection parameters or a single connection string.
.env (individual parameters)
DB_HOST=localhost
DB_PORT=3306
DB_NAME=quizmaster
DB_USER=root
DB_PASSWORD=your-password
JWT_SECRET=your-jwt-secret
PORT=5000
See Environment variables for the full variable reference.
3

Start the server

npm run dev
On startup, Quizmaster automatically syncs the database schema and seeds the admin user if one does not already exist. No manual migration commands are needed.

Schema auto-sync

Quizmaster calls sequelize.sync({ alter: true }) every time the server starts. This creates any missing tables and adds or modifies columns to match the current model definitions. Existing rows are preserved. You do not need to run migrations manually during development or after upgrades.
The alter: true strategy is suitable for development and straightforward deployments. For production databases with strict change-control requirements, consider replacing it with explicit Sequelize migrations before going live.

Admin user seeding

After the schema sync completes, Quizmaster checks whether any admin account exists. If none is found, it creates a default admin automatically:
FieldValue
Usernameadmin@quizmaster.com
Passwordadmin123
Roleadmin
The password is stored as a bcrypt hash. Change it immediately after your first login.

Connection pool settings

When using individual DB_* variables (not a connection string), Sequelize is configured with the following pool:
SettingValueDescription
max5Maximum concurrent connections in the pool.
min0Connections kept open when the pool is idle.
acquire30000Milliseconds to wait before throwing a timeout.
idle10000Milliseconds before an idle connection closes.
Connection attempts are retried up to 3 times before the server reports a failure.

Using a connection string

Cloud database providers (PlanetScale, Railway, Render, AWS RDS) often supply a single connection URL. Set MYSQL_URL to that value instead of configuring individual DB_* variables. Quizmaster will detect the connection string and use it directly, bypassing the pool configuration above.
.env (connection string)
MYSQL_URL=mysql://root:your-password@your-mysql-host:3306/quizmaster
DATABASE_URL is accepted as an alias for MYSQL_URL.

Build docs developers (and LLMs) love