Backend for the app LuxAI Chat. Right now, it only stores reported conversations sent by the users.
- Node.js / Express.js
- TypeScript
- Prisma (ORM)
- SQLite (default DB, can be changed)
- Yarn for package management
-
Clone the repo:
Clone the repo and navigate to the cloned folder.
-
Install dependencies:
yarn install
-
Create a MYSQL database:
Create a MYSQL database that will be connected to the app.
-
Set up environment: Create a
.envfile, replacing the placeholders in uppercase with your database information:DATABASE_URL="mysql://USER:PASSWORD@HOST:PORT/DATABASE"
-
Initialize Prisma & DB:
npx prisma migrate dev npx prisma generate
-
Run the server:
yarn dev
-
(Optional) Deploy for production using pm2 If you want to run the application using
pm2there's a bash script calleddeploy_pm2.shthat does just that.
Description: Health check of the server
Response:
{
"status": "OK",
"timestamp": "2025-07-01T12:00:00.000Z",
"uptime": 42.345
}Description: Fetch all reports (most recent first)
Response:
{
"success": true,
"data": [
{
"id": 1,
"content": "Some report text",
"createdAt": "2025-07-01T12:34:56.000Z"
}
],
"count": 1
}Description: Create a new report
Body:
{
"content": "This is a report string"
}Success Response:
{
"success": true,
"data": {
"id": 2,
"content": "This is a report string",
"createdAt": "2025-07-01T13:00:00.000Z"
},
"message": "Report created successfully"
}Error Response:
{
"success": false,
"error": "Content is required and must be a string"
}You can run this project in production using Docker.
-
Start the MySQL database container:
docker compose up db
You can configure the container using environment variables in the
.envfile:DOCKER_MYSQL_ROOT_PASSWORD: Password for the root user (default:root)DOCKER_MYSQL_USER: Database user (default:user)DOCKER_DB_VOLUME_PATH: Path for the database volume (default: named volumeranking_db_data)DOCKER_DB_BACKUP_FILE_TO_CONSUME: Path to a backup file to initialize the database with, if any. When provided, the database will start with the backup data.ENABLE_BACKUP: If the database container should do backup in the BACKUP_PATHDOCKER_DB_BACKUP_PATH: Path to store the backup if ENABLE_BACKUP is true (default:./backup)`BACKUP_INTERVAL: Interval to do the backup (default: 86400 seconds, or one day)
-
Start the API container:
docker compose up app
Environment variables you can set in
.env:DOCKER_BACK_PORT_EXPOSED: Port on the host machine to access the API (default:3030)PORT: Port where the API will run inside the container (and outside, if run without Docker) (default:3030)